-
Notifications
You must be signed in to change notification settings - Fork 910
Race condition during AEC settings modification when sound device is running #4665
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
Conversation
pjmedia/src/pjmedia/sound_port.c
Outdated
|
|
||
| PJ_LOG(4,(THIS_FILE, "AEC settings modified, tail length=%d ms, " | ||
| "options=%d", tail_ms, options)); | ||
| return status; |
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.
- What if it returns PJ_EPENDING?
- Mention the pending settings in the log as well?
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.
won't this be considered API change? i.e. it will affect apps that only check for PJ_SUCCESS.
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.
Yes, it introduces a behavioral change, but I think it makes sense (perhaps even necessary?) since the settings are no longer applied immediately?
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.
It's not behavioral change, rather incorrect implementation.
First, are you proposing changing pjmedia only or also pjsua?
For pjsua, it's clear, the doc already specifies the behavior, which is that the settings will be applied for future use if sound device is opened (If software AEC is being used, this function will change the software EC settings. In all cases, the setting will be saved for future opening of the sound device.). So apps have always expected this behavior, and now it's corrected to match the spec. From apps perspective, the behavior stays the same.
For pjmedia however, it's not as clear from the doc. If software AEC is being used, this function will change the software EC settings (no mention when). But it also says not all sound device implementation supports changing the EC setting once the device has been opened. So apps should already know that changing the EC setting may not be immediate. But yes, it's not as explicitly stated as pjsua.
So if you want to change pjmedia only, perhaps it's still acceptable, except that it will introduce a difference between the pjsua and pjmedia APIs.
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.
As I understand it, in pjsua, the intention is to apply the settings immediately whenever possible (for EC & other settings, see also pjsua_snd_set_setting() docs). The "future use" is an additional feature that preserves the settings.
Btw, the sound port API does not seem to have start/stop functions, only create & destroy, so what does "future use"/keeping-settings mean/purpose?
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.
Very good point.
I try a different approach in the last commit, by stopping the audio stream first.
When sound device is running, modifying AEC settings may potentially cause race condition and crash such as: