Skip to content

Commit

Permalink
When closing input streams on Mac iterate throug base input streams.
Browse files Browse the repository at this point in the history
AudioManagerBase input streams may contain fake streams, which are not
closed properly on Mac now. Fixing it.

Bug: 810321
Cq-Include-Trybots: luci.chromium.try:android_optional_gpu_tests_rel;luci.chromium.try:linux_optional_gpu_tests_rel;luci.chromium.try:mac_optional_gpu_tests_rel;luci.chromium.try:win_optional_gpu_tests_rel
Change-Id: I117da2df47c99f43c2d122be8af4ca43da87531d
Reviewed-on: https://chromium-review.googlesource.com/1065679
Reviewed-by: Max Morin <maxmorin@chromium.org>
Commit-Queue: Olga Sharonova <olka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560250}
  • Loading branch information
Olga Sharonova authored and Commit Bot committed May 21, 2018
1 parent eba861a commit 93e6107
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
10 changes: 10 additions & 0 deletions media/audio/audio_manager_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ std::string AudioManagerBase::GetGroupIDInput(
return GetGroupIDOutput(output_device_id);
}

void AudioManagerBase::CloseAllInputStreams() {
for (auto iter = input_streams_.begin(); iter != input_streams_.end();) {
// Note: Closing the stream will invalidate the iterator.
// Increment the iterator before closing the stream.
AudioInputStream* stream = *iter++;
stream->Close();
}
CHECK(input_streams_.empty());
}

std::string AudioManagerBase::GetDefaultInputDeviceID() {
return std::string();
}
Expand Down
3 changes: 3 additions & 0 deletions media/audio/audio_manager_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,9 @@ class MEDIA_EXPORT AudioManagerBase : public AudioManager {
virtual std::string GetGroupIDOutput(const std::string& output_device_id);
virtual std::string GetGroupIDInput(const std::string& input_device_id);

// Closes all currently open input streams.
void CloseAllInputStreams();

private:
FRIEND_TEST_ALL_PREFIXES(AudioManagerTest, AudioDebugRecording);

Expand Down
15 changes: 1 addition & 14 deletions media/audio/mac/audio_manager_mac.cc
Original file line number Diff line number Diff line change
Expand Up @@ -525,20 +525,7 @@ void AudioManagerMac::ShutdownOnAudioThread() {
// Even if tasks to close the streams are enqueued, they would not run
// leading to CHECKs getting hit in the destructor about open streams. Close
// them explicitly here. crbug.com/608049.
for (auto iter = basic_input_streams_.begin();
iter != basic_input_streams_.end();) {
// Note: Closing the stream will invalidate the iterator.
// Increment the iterator before closing the stream.
AudioInputStream* stream = *iter++;
stream->Close();
}
for (auto iter = low_latency_input_streams_.begin();
iter != low_latency_input_streams_.end();) {
// Note: Closing the stream will invalidate the iterator.
// Increment the iterator before closing the stream.
AudioInputStream* stream = *iter++;
stream->Close();
}
CloseAllInputStreams();
CHECK(basic_input_streams_.empty());
CHECK(low_latency_input_streams_.empty());

Expand Down

0 comments on commit 93e6107

Please sign in to comment.