Index: media/audio/linux/alsa_output.cc |
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc |
index a57c2763511e955667d542a6798c7ce3275527ee..8394c564380c14baff9c212e8a52f25dd1fc9622 100644 |
--- a/media/audio/linux/alsa_output.cc |
+++ b/media/audio/linux/alsa_output.cc |
@@ -295,14 +295,12 @@ bool AlsaPcmOutputStream::Open() { |
void AlsaPcmOutputStream::Close() { |
DCHECK(IsOnAudioThread()); |
- // Sanity check that the transition occurs correctly. It is safe to |
- // continue anyways because all operations for closing are idempotent. |
- if (TransitionTo(kIsClosed) != kIsClosed) { |
- NOTREACHED() << "Unable to transition Closed."; |
- } else { |
- // Shutdown the audio device. |
- if (playback_handle_ && |
- alsa_util::CloseDevice(wrapper_, playback_handle_) < 0) { |
+ if (state() != kIsClosed) |
+ TransitionTo(kIsClosed); |
+ |
+ // Shutdown the audio device. |
+ if (playback_handle_) { |
+ if (alsa_util::CloseDevice(wrapper_, playback_handle_) < 0) { |
LOG(WARNING) << "Unable to close audio device. Leaking handle."; |
} |
playback_handle_ = NULL; |
@@ -313,12 +311,13 @@ void AlsaPcmOutputStream::Close() { |
// Signal anything that might already be scheduled to stop. |
stop_stream_ = true; // Not necessary in production, but unit tests |
// uses the flag to verify that stream was closed. |
- weak_factory_.InvalidateWeakPtrs(); |
- |
- // Signal to the manager that we're closed and can be removed. |
- // Should be last call in the method as it deletes "this". |
- manager_->ReleaseOutputStream(this); |
} |
+ |
+ weak_factory_.InvalidateWeakPtrs(); |
+ |
+ // Signal to the manager that we're closed and can be removed. |
+ // Should be last call in the method as it deletes "this". |
+ manager_->ReleaseOutputStream(this); |
} |
void AlsaPcmOutputStream::Start(AudioSourceCallback* callback) { |