Index: content/browser/renderer_host/media/audio_renderer_host.cc |
diff --git a/content/browser/renderer_host/media/audio_renderer_host.cc b/content/browser/renderer_host/media/audio_renderer_host.cc |
index 29c9d7f81866734f5ed6580c90facbee4464fb2c..84ebe5b60b9e45c246a8775c6562544066949921 100644 |
--- a/content/browser/renderer_host/media/audio_renderer_host.cc |
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc |
@@ -70,9 +70,10 @@ void NotifyResourceDispatcherOfAudioStateChange(int render_process_id, |
} |
media::AudioParameters DummyParams() { |
- return media::AudioParameters(media::AudioParameters::AUDIO_PCM_LINEAR, |
- media::CHANNEL_LAYOUT_STEREO, |
- media::limits::kMinSampleRate, 1, 1); |
+ return media::AudioParameters( |
+ media::AudioParameters::AUDIO_FAKE, media::CHANNEL_LAYOUT_STEREO, |
+ media::AudioParameters::kAudioCDSampleRate, 16, |
+ media::AudioParameters::kAudioCDSampleRate / 10); |
} |
std::pair<int, std::pair<bool, std::string>> MakeAuthorizationData( |
@@ -133,6 +134,24 @@ void NotifyRenderProcessHostThatAudioStateChanged(int render_process_id) { |
render_process_host->AudioStateChanged(); |
} |
+void MaybeFixAudioParameters(media::AudioParameters* params) { |
+ // If the number of output channels is greater than the maximum, change |
+ // to the maximum allowed value. Hardware channels are ignored upstream, |
+ // so it is better to report status OK if the only problem is that the number |
+ // of hardware channels is too large. |
+ if (!params->IsValid() && |
DaleCurtis
2016/01/07 19:14:51
Seems these first two conditions aren't necessary?
Guido Urdaneta
2016/01/08 11:20:34
Done.
|
+ params->channel_layout() == media::CHANNEL_LAYOUT_DISCRETE && |
+ params->channels() > media::limits::kMaxChannels) { |
+ params->set_channels_for_discrete(media::limits::kMaxChannels); |
+ } |
+ |
+ // If hardware parameters are still invalid, use dummy parameters with |
+ // fake audio path. |
+ if (!params->IsValid()) { |
+ *params = DummyParams(); |
+ } |
+} |
+ |
} // namespace |
class AudioRendererHost::AudioEntry |
@@ -457,6 +476,7 @@ void AudioRendererHost::OnRequestDeviceAuthorization( |
output_params.set_effects(info->device.matched_output.effects); |
authorizations_.insert(MakeAuthorizationData( |
stream_id, true, info->device.matched_output_device_id)); |
+ MaybeFixAudioParameters(&output_params); |
Send(new AudioMsg_NotifyDeviceAuthorized( |
stream_id, media::OUTPUT_DEVICE_STATUS_OK, output_params)); |
return; |
@@ -532,8 +552,11 @@ void AudioRendererHost::OnDeviceIDTranslated( |
auth_data->second.first = true; |
auth_data->second.second = device_info.unique_id; |
+ |
+ media::AudioParameters output_params = device_info.output_params; |
+ MaybeFixAudioParameters(&output_params); |
Send(new AudioMsg_NotifyDeviceAuthorized( |
- stream_id, media::OUTPUT_DEVICE_STATUS_OK, device_info.output_params)); |
+ stream_id, media::OUTPUT_DEVICE_STATUS_OK, output_params)); |
} |
void AudioRendererHost::OnCreateStream(int stream_id, |