| 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 // AudioOutputDispatcher is a single-threaded base class that dispatches | 5 // AudioOutputDispatcher is a single-threaded base class that dispatches |
| 6 // creation and deletion of audio output streams. AudioOutputProxy objects use | 6 // creation and deletion of audio output streams. AudioOutputProxy objects use |
| 7 // this class to allocate and recycle actual audio output streams. When playback | 7 // this class to allocate and recycle actual audio output streams. When playback |
| 8 // is started, the proxy calls StartStream() to get an output stream that it | 8 // is started, the proxy calls StartStream() to get an output stream that it |
| 9 // uses to play audio. When playback is stopped, the proxy returns the stream | 9 // uses to play audio. When playback is stopped, the proxy returns the stream |
| 10 // back to the dispatcher by calling StopStream(). | 10 // back to the dispatcher by calling StopStream(). |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 } | 30 } |
| 31 | 31 |
| 32 namespace media { | 32 namespace media { |
| 33 | 33 |
| 34 class AudioOutputProxy; | 34 class AudioOutputProxy; |
| 35 | 35 |
| 36 class MEDIA_EXPORT AudioOutputDispatcher | 36 class MEDIA_EXPORT AudioOutputDispatcher |
| 37 : public base::RefCountedThreadSafe<AudioOutputDispatcher> { | 37 : public base::RefCountedThreadSafe<AudioOutputDispatcher> { |
| 38 public: | 38 public: |
| 39 AudioOutputDispatcher(AudioManager* audio_manager, | 39 AudioOutputDispatcher(AudioManager* audio_manager, |
| 40 const AudioParameters& params); | 40 const AudioParameters& params, |
| 41 const std::string& input_device_id); |
| 41 | 42 |
| 42 // Called by AudioOutputProxy to open the stream. | 43 // Called by AudioOutputProxy to open the stream. |
| 43 // Returns false, if it fails to open it. | 44 // Returns false, if it fails to open it. |
| 44 virtual bool OpenStream() = 0; | 45 virtual bool OpenStream() = 0; |
| 45 | 46 |
| 46 // Called by AudioOutputProxy when the stream is started. | 47 // Called by AudioOutputProxy when the stream is started. |
| 47 // Uses |callback| to get source data and report errors, if any. | 48 // Uses |callback| to get source data and report errors, if any. |
| 48 // Does *not* take ownership of this callback. | 49 // Does *not* take ownership of this callback. |
| 49 // Returns true if started successfully, false otherwise. | 50 // Returns true if started successfully, false otherwise. |
| 50 virtual bool StartStream(AudioOutputStream::AudioSourceCallback* callback, | 51 virtual bool StartStream(AudioOutputStream::AudioSourceCallback* callback, |
| 51 AudioOutputProxy* stream_proxy) = 0; | 52 AudioOutputProxy* stream_proxy) = 0; |
| 52 | 53 |
| 53 // Called by AudioOutputProxy when the stream is stopped. | 54 // Called by AudioOutputProxy when the stream is stopped. |
| 54 // Ownership of the |stream_proxy| is passed to the dispatcher. | 55 // Ownership of the |stream_proxy| is passed to the dispatcher. |
| 55 virtual void StopStream(AudioOutputProxy* stream_proxy) = 0; | 56 virtual void StopStream(AudioOutputProxy* stream_proxy) = 0; |
| 56 | 57 |
| 57 // Called by AudioOutputProxy when the volume is set. | 58 // Called by AudioOutputProxy when the volume is set. |
| 58 virtual void StreamVolumeSet(AudioOutputProxy* stream_proxy, | 59 virtual void StreamVolumeSet(AudioOutputProxy* stream_proxy, |
| 59 double volume) = 0; | 60 double volume) = 0; |
| 60 | 61 |
| 61 // Called by AudioOutputProxy when the stream is closed. | 62 // Called by AudioOutputProxy when the stream is closed. |
| 62 virtual void CloseStream(AudioOutputProxy* stream_proxy) = 0; | 63 virtual void CloseStream(AudioOutputProxy* stream_proxy) = 0; |
| 63 | 64 |
| 64 // Called on the audio thread when the AudioManager is shutting down. | 65 // Called on the audio thread when the AudioManager is shutting down. |
| 65 virtual void Shutdown() = 0; | 66 virtual void Shutdown() = 0; |
| 66 | 67 |
| 68 // Accessor to the input device id used by unified IO. |
| 69 const std::string& input_device_id() const { return input_device_id_; } |
| 70 |
| 67 protected: | 71 protected: |
| 68 friend class base::RefCountedThreadSafe<AudioOutputDispatcher>; | 72 friend class base::RefCountedThreadSafe<AudioOutputDispatcher>; |
| 69 friend class AudioOutputProxyTest; | 73 friend class AudioOutputProxyTest; |
| 70 | 74 |
| 71 virtual ~AudioOutputDispatcher(); | 75 virtual ~AudioOutputDispatcher(); |
| 72 | 76 |
| 73 // A no-reference-held pointer (we don't want circular references) back to the | 77 // A no-reference-held pointer (we don't want circular references) back to the |
| 74 // AudioManager that owns this object. | 78 // AudioManager that owns this object. |
| 75 AudioManager* audio_manager_; | 79 AudioManager* audio_manager_; |
| 76 base::MessageLoop* message_loop_; | 80 base::MessageLoop* message_loop_; |
| 77 AudioParameters params_; | 81 AudioParameters params_; |
| 82 const std::string input_device_id_; |
| 78 | 83 |
| 79 private: | 84 private: |
| 80 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); | 85 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); |
| 81 }; | 86 }; |
| 82 | 87 |
| 83 } // namespace media | 88 } // namespace media |
| 84 | 89 |
| 85 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 90 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
| OLD | NEW |