Skip to content

Conversation

@dariopellegrino00
Copy link
Collaborator

Summary

  • Update README
  • Fix some relevant compiler warnings

Signed-off-by: Dario Pellegrino <dario.pellegrino@voismart.it>
Signed-off-by: Dario Pellegrino <dario.pellegrino@voismart.it>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes compiler warnings in the OpenAI audio streaming module and updates documentation. The changes improve code safety by adding proper type casting, bounds checking, and string buffer handling.

  • Resolved compiler warnings related to type conversions and unused variables
  • Added bounds checking and explicit casts for audio resampling operations
  • Updated README with important notes about OpenAI Realtime API requirements

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
openai_audio_streamer_glue.cpp Fixed compiler warnings with type casts, bounds checking, string handling, and removed unused variables
mod_openai_audio_stream.c Removed unused variable and simplified error message formatting
README.md Added documentation about OpenAI model specification and audio format requirements

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

size_t in_samples = input_raw.size() / 2;
size_t out_samples = static_cast<size_t>(in_samples * out_sample_rate / static_cast<float>(in_sample_rate)) + 1;

double scaled = static_cast<double>(in_samples) * out_sample_rate / in_sample_rate;
Copy link

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The calculation uses double precision floating point which may be overkill for sample rate conversion. Consider using float precision to improve performance, especially since audio sample rates are typically integers and don't require double precision accuracy.

Suggested change
double scaled = static_cast<double>(in_samples) * out_sample_rate / in_sample_rate;
float scaled = static_cast<float>(in_samples) * out_sample_rate / in_sample_rate;

Copilot uses AI. Check for mistakes.
strncpy(tech_pvt->sessionId, switch_core_session_get_uuid(session), MAX_SESSION_ID - 1);
tech_pvt->sessionId[MAX_SESSION_ID - 1] = '\0';
strncpy(tech_pvt->ws_uri, wsUri, MAX_WS_URI - 1);
tech_pvt->ws_uri[MAX_WS_URI - 1] = '\0';
Copy link

Copilot AI Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While the null termination fix is good, consider using safer string copy functions like strlcpy or snprintf instead of strncpy to avoid potential buffer overflow issues and ensure proper null termination in all cases.

Suggested change
tech_pvt->ws_uri[MAX_WS_URI - 1] = '\0';
snprintf(tech_pvt->sessionId, MAX_SESSION_ID, "%s", switch_core_session_get_uuid(session));
snprintf(tech_pvt->ws_uri, MAX_WS_URI, "%s", wsUri);

Copilot uses AI. Check for mistakes.
@dariopellegrino00 dariopellegrino00 merged commit 07a4c3c into VoiSmart:develop Aug 20, 2025
@dariopellegrino00 dariopellegrino00 deleted the warning-fix branch August 20, 2025 13:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant