| OLD | NEW |
| 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 #include "media/audio/audio_output_proxy.h" | 5 #include "media/audio/audio_output_proxy.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "media/audio/audio_manager.h" | 9 #include "media/audio/audio_manager.h" |
| 10 #include "media/audio/audio_output_dispatcher.h" | 10 #include "media/audio/audio_output_dispatcher.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 void AudioOutputProxy::Start(AudioSourceCallback* callback) { | 38 void AudioOutputProxy::Start(AudioSourceCallback* callback) { |
| 39 DCHECK(CalledOnValidThread()); | 39 DCHECK(CalledOnValidThread()); |
| 40 | 40 |
| 41 // We need to support both states since the callback may not handle OnError() | 41 // We need to support both states since the callback may not handle OnError() |
| 42 // immediately (or at all). It's also possible for subsequent StartStream() | 42 // immediately (or at all). It's also possible for subsequent StartStream() |
| 43 // calls to succeed after failing, so we allow it to be called again. | 43 // calls to succeed after failing, so we allow it to be called again. |
| 44 DCHECK(state_ == kOpened || state_ == kStartError); | 44 DCHECK(state_ == kOpened || state_ == kStartError); |
| 45 | 45 |
| 46 if (!dispatcher_->StartStream(callback, this)) { | 46 if (!dispatcher_->StartStream(callback, this)) { |
| 47 state_ = kStartError; | 47 state_ = kStartError; |
| 48 callback->OnError(this, 0); | 48 callback->OnError(this); |
| 49 return; | 49 return; |
| 50 } | 50 } |
| 51 state_ = kPlaying; | 51 state_ = kPlaying; |
| 52 } | 52 } |
| 53 | 53 |
| 54 void AudioOutputProxy::Stop() { | 54 void AudioOutputProxy::Stop() { |
| 55 DCHECK(CalledOnValidThread()); | 55 DCHECK(CalledOnValidThread()); |
| 56 if (state_ != kPlaying) | 56 if (state_ != kPlaying) |
| 57 return; | 57 return; |
| 58 | 58 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 84 state_ = kClosed; | 84 state_ = kClosed; |
| 85 | 85 |
| 86 // Delete the object now like is done in the Close() implementation of | 86 // Delete the object now like is done in the Close() implementation of |
| 87 // physical stream objects. If we delete the object via DeleteSoon, we | 87 // physical stream objects. If we delete the object via DeleteSoon, we |
| 88 // unnecessarily complicate the Shutdown procedure of the | 88 // unnecessarily complicate the Shutdown procedure of the |
| 89 // dispatcher+audio manager. | 89 // dispatcher+audio manager. |
| 90 delete this; | 90 delete this; |
| 91 } | 91 } |
| 92 | 92 |
| 93 } // namespace media | 93 } // namespace media |
| OLD | NEW |