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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 // Uses |callback| to get source data and report errors, if any. | 45 // Uses |callback| to get source data and report errors, if any. |
46 // Does *not* take ownership of this callback. | 46 // Does *not* take ownership of this callback. |
47 // Returns true if started successfully, false otherwise. | 47 // Returns true if started successfully, false otherwise. |
48 virtual bool StartStream(AudioOutputStream::AudioSourceCallback* callback, | 48 virtual bool StartStream(AudioOutputStream::AudioSourceCallback* callback, |
49 AudioOutputProxy* stream_proxy) = 0; | 49 AudioOutputProxy* stream_proxy) = 0; |
50 | 50 |
51 // Called by AudioOutputProxy when the stream is stopped. | 51 // Called by AudioOutputProxy when the stream is stopped. |
52 // Ownership of the |stream_proxy| is passed to the dispatcher. | 52 // Ownership of the |stream_proxy| is passed to the dispatcher. |
53 virtual void StopStream(AudioOutputProxy* stream_proxy) = 0; | 53 virtual void StopStream(AudioOutputProxy* stream_proxy) = 0; |
54 | 54 |
55 | |
56 // Called by AudioOutputProxy when the volume is set. | 55 // Called by AudioOutputProxy when the volume is set. |
57 virtual void StreamVolumeSet(AudioOutputProxy* stream_proxy, | 56 virtual void StreamVolumeSet(AudioOutputProxy* stream_proxy, |
58 double volume) = 0; | 57 double volume) = 0; |
59 | 58 |
60 // Called by AudioOutputProxy when the stream is closed. | 59 // Called by AudioOutputProxy when the stream is closed. |
61 virtual void CloseStream(AudioOutputProxy* stream_proxy) = 0; | 60 virtual void CloseStream(AudioOutputProxy* stream_proxy) = 0; |
62 | 61 |
63 // Called on the audio thread when the AudioManager is shutting down. | 62 // Called on the audio thread when the AudioManager is shutting down. |
64 virtual void Shutdown() = 0; | 63 virtual void Shutdown() = 0; |
65 | 64 |
66 protected: | 65 protected: |
67 friend class base::RefCountedThreadSafe<AudioOutputDispatcher>; | 66 friend class base::RefCountedThreadSafe<AudioOutputDispatcher>; |
| 67 friend class AudioOutputProxyTest; |
| 68 |
68 virtual ~AudioOutputDispatcher(); | 69 virtual ~AudioOutputDispatcher(); |
69 | 70 |
70 // A no-reference-held pointer (we don't want circular references) back to the | 71 // A no-reference-held pointer (we don't want circular references) back to the |
71 // AudioManager that owns this object. | 72 // AudioManager that owns this object. |
72 AudioManager* audio_manager_; | 73 AudioManager* audio_manager_; |
73 MessageLoop* message_loop_; | 74 MessageLoop* message_loop_; |
74 AudioParameters params_; | 75 AudioParameters params_; |
75 | 76 |
76 private: | 77 private: |
77 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); | 78 DISALLOW_COPY_AND_ASSIGN(AudioOutputDispatcher); |
78 }; | 79 }; |
79 | 80 |
80 } // namespace media | 81 } // namespace media |
81 | 82 |
82 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ | 83 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_DISPATCHER_H_ |
OLD | NEW |