summaryrefslogtreecommitdiffstats
path: root/chromeos/audio
diff options
context:
space:
mode:
authorrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 01:19:15 +0000
committerrkc@chromium.org <rkc@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-07 01:19:15 +0000
commite2171994b0d0539274d7ad694c7d8b16faca180c (patch)
tree1b5c932631b9da755271c74ac73383120a2d1386 /chromeos/audio
parentb0e932251a432faa7eebbb2f3e08cb10a0921b98 (diff)
downloadchromium_src-e2171994b0d0539274d7ad694c7d8b16faca180c.zip
chromium_src-e2171994b0d0539274d7ad694c7d8b16faca180c.tar.gz
chromium_src-e2171994b0d0539274d7ad694c7d8b16faca180c.tar.bz2
Fix for AudioSwitchHandler crashing on VM's.
On VM's since we have no audio devices, the input/ouput device priority queue's top() methods crash; fix this by first checking to see if we have any devices on the priority queues before we try to access the top. R=hshi@chromium.org BUG=None. TEST=Turning on Chrome side audio switching on a VM does not crash it. Review URL: https://codereview.chromium.org/14722015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198587 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chromeos/audio')
-rw-r--r--chromeos/audio/cras_audio_switch_handler.cc10
1 files changed, 4 insertions, 6 deletions
diff --git a/chromeos/audio/cras_audio_switch_handler.cc b/chromeos/audio/cras_audio_switch_handler.cc
index 2255cc4..efda61e 100644
--- a/chromeos/audio/cras_audio_switch_handler.cc
+++ b/chromeos/audio/cras_audio_switch_handler.cc
@@ -141,15 +141,13 @@ void CrasAudioSwitchHandler::UpdateDevicesAndSwitch(
// .) the top input/output device is already active, or,
// .) an input/output device was removed but not the active device,
// then we don't need to switch the device, otherwise we do need to switch.
- if (!(input_devices_.top().active ||
- (input_device_removed && have_active_input_device))) {
+ if (!input_devices_.empty() && (!(input_devices_.top().active ||
+ (input_device_removed && have_active_input_device))))
SwitchToDevice(input_devices_.top());
- }
- if (!(output_devices_.top().active ||
- (output_device_removed && have_active_output_device))) {
+ if (!output_devices_.empty() && (!(output_devices_.top().active ||
+ (output_device_removed && have_active_output_device))))
SwitchToDevice(output_devices_.top());
- }
}
void CrasAudioSwitchHandler::HandleGetNodes(