webrtc: Add Sound volume and mute controls support#2213
webrtc: Add Sound volume and mute controls support#2213thjnk wants to merge 1 commit intogoogle:mainfrom
Conversation
3400ea9 to
74ccc5d
Compare
|
The three bullet points in the PR description sound like they should be different commits. That would make the PR much easier to review. |
| {SampleRate::Audio_SampleRate_RATE_64000, 64000}, | ||
| }; | ||
|
|
||
| static const auto parse_stream_settings = |
There was a problem hiding this comment.
Looks like this could be a regular function in an anonymous namespace instead of a lambda. Any reason to make it a lambda?
There was a problem hiding this comment.
- I use static variables (
kChannelLayoutMap) inside the lambda which is defined in theSetupAudiofunction. - It is only invoked from within
SetupAudio. I prefer to have definition near by usage in such cases.
However I am not strongly against moving it (and static variables) to a anonymous namespace. what do you think ?
| if (is_muted_by_control) { | ||
| memset(rx_buffer, 0, bytes_read); | ||
| } else if (volume < 1.){ | ||
| static const auto apply_volume = [](auto* data, size_t size, float volume) { |
There was a problem hiding this comment.
This could be a template function instead of a lambda, and you could avoid some repetition by accepting the size in bytes as parameter and dividing by the size of the template parameter. Something like this:
template<typename T>
void apply_volume(T* data, size_bytes, float volume) {
for (T& val: std::span(data, size_bytes / sizeof(T))) {
val *= volume;
}
}
There was a problem hiding this comment.
Again, I'd prefer to have the function be right next to where it is invoked, esp. since it is only few lines of code. And it acts exectly as a template function.
This change implements volume and mute controls for the WebRTC audio backend in Cuttlefish. These controls allow the guest to dynamically adjust playback and capture audio levels via Virtio Sound control messages. - AudioMixer: Apply playback volume scaling during audio stream resampling by modifying the channel mix map. - Implement read/write logic for Virtio audio volume/mute control commands. - Guest Config: Allow enabling of Virtio Sound controls per stream.
This change implements volume and mute controls for the WebRTC audio backend in Cuttlefish. These controls allow the guest to dynamically adjust playback and capture audio levels via Virtio Sound control messages.