Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3225)

Unified Diff: media/audio/linux/alsa_output.cc

Issue 9570014: Move some generic functions to AudioManagerBase to be inherited by platform-specific AudioManager*** (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: changed the GetMaxOutputStreamsAllowed Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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) {

Powered by Google App Engine
This is Rietveld 408576698