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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // THREAD SAFETY 5 // THREAD SAFETY
6 // 6 //
7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used 7 // AlsaPcmOutputStream object is *not* thread-safe and should only be used
8 // from the audio thread. We DCHECK on this assumption whenever we can. 8 // from the audio thread. We DCHECK on this assumption whenever we can.
9 // 9 //
10 // SEMANTICS OF Close() 10 // SEMANTICS OF Close()
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 alsa_buffer_frames_ = buffer_size; 288 alsa_buffer_frames_ = buffer_size;
289 } 289 }
290 } 290 }
291 291
292 return true; 292 return true;
293 } 293 }
294 294
295 void AlsaPcmOutputStream::Close() { 295 void AlsaPcmOutputStream::Close() {
296 DCHECK(IsOnAudioThread()); 296 DCHECK(IsOnAudioThread());
297 297
298 // Sanity check that the transition occurs correctly. It is safe to 298 if (state() != kIsClosed)
299 // continue anyways because all operations for closing are idempotent. 299 TransitionTo(kIsClosed);
300 if (TransitionTo(kIsClosed) != kIsClosed) { 300
301 NOTREACHED() << "Unable to transition Closed."; 301 // Shutdown the audio device.
302 } else { 302 if (playback_handle_) {
303 // Shutdown the audio device. 303 if (alsa_util::CloseDevice(wrapper_, playback_handle_) < 0) {
304 if (playback_handle_ &&
305 alsa_util::CloseDevice(wrapper_, playback_handle_) < 0) {
306 LOG(WARNING) << "Unable to close audio device. Leaking handle."; 304 LOG(WARNING) << "Unable to close audio device. Leaking handle.";
307 } 305 }
308 playback_handle_ = NULL; 306 playback_handle_ = NULL;
309 307
310 // Release the buffer. 308 // Release the buffer.
311 buffer_.reset(); 309 buffer_.reset();
312 310
313 // Signal anything that might already be scheduled to stop. 311 // Signal anything that might already be scheduled to stop.
314 stop_stream_ = true; // Not necessary in production, but unit tests 312 stop_stream_ = true; // Not necessary in production, but unit tests
315 // uses the flag to verify that stream was closed. 313 // uses the flag to verify that stream was closed.
316 weak_factory_.InvalidateWeakPtrs(); 314 }
317 315
318 // Signal to the manager that we're closed and can be removed. 316 weak_factory_.InvalidateWeakPtrs();
319 // Should be last call in the method as it deletes "this". 317
320 manager_->ReleaseOutputStream(this); 318 // Signal to the manager that we're closed and can be removed.
321 } 319 // Should be last call in the method as it deletes "this".
320 manager_->ReleaseOutputStream(this);
322 } 321 }
323 322
324 void AlsaPcmOutputStream::Start(AudioSourceCallback* callback) { 323 void AlsaPcmOutputStream::Start(AudioSourceCallback* callback) {
325 DCHECK(IsOnAudioThread()); 324 DCHECK(IsOnAudioThread());
326 325
327 CHECK(callback); 326 CHECK(callback);
328 327
329 if (stop_stream_) 328 if (stop_stream_)
330 return; 329 return;
331 330
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
845 if (source_callback_) 844 if (source_callback_)
846 source_callback_->OnError(this, code); 845 source_callback_->OnError(this, code);
847 } 846 }
848 847
849 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to 848 // Changes the AudioSourceCallback to proxy calls to. Pass in NULL to
850 // release ownership of the currently registered callback. 849 // release ownership of the currently registered callback.
851 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) { 850 void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) {
852 DCHECK(IsOnAudioThread()); 851 DCHECK(IsOnAudioThread());
853 source_callback_ = callback; 852 source_callback_ = callback;
854 } 853 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698