-
Notifications
You must be signed in to change notification settings - Fork 2
Fix Warning #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Warning #5
Conversation
Signed-off-by: Dario Pellegrino <dario.pellegrino@voismart.it>
Signed-off-by: Dario Pellegrino <dario.pellegrino@voismart.it>
There was a problem hiding this 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; |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
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.
| 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; |
| 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'; |
Copilot
AI
Aug 20, 2025
There was a problem hiding this comment.
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.
| 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); |
Summary