| 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 #ifndef MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 5 #ifndef MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
| 6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 6 #define MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
| 7 | 7 |
| 8 #include <string> |
| 8 #include <vector> | 9 #include <vector> |
| 10 |
| 9 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 10 #include "base/logging.h" | 12 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
| 14 #include "media/audio/audio_output_ipc.h" |
| 12 #include "media/audio/audio_parameters.h" | 15 #include "media/audio/audio_parameters.h" |
| 13 #include "media/base/audio_bus.h" | 16 #include "media/base/audio_bus.h" |
| 14 #include "media/base/media_export.h" | 17 #include "media/base/media_export.h" |
| 18 #include "url/gurl.h" |
| 19 |
| 20 namespace base { |
| 21 class SingleThreadTaskRunner; |
| 22 } |
| 15 | 23 |
| 16 namespace media { | 24 namespace media { |
| 17 | 25 |
| 18 // AudioRendererSink is an interface representing the end-point for | 26 // AudioRendererSink is an interface representing the end-point for |
| 19 // rendered audio. An implementation is expected to | 27 // rendered audio. An implementation is expected to |
| 20 // periodically call Render() on a callback object. | 28 // periodically call Render() on a callback object. |
| 21 | 29 |
| 22 class AudioRendererSink | 30 class AudioRendererSink |
| 23 : public base::RefCountedThreadSafe<media::AudioRendererSink> { | 31 : public base::RefCountedThreadSafe<media::AudioRendererSink> { |
| 24 public: | 32 public: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 49 // Pauses playback. | 57 // Pauses playback. |
| 50 virtual void Pause() = 0; | 58 virtual void Pause() = 0; |
| 51 | 59 |
| 52 // Resumes playback after calling Pause(). | 60 // Resumes playback after calling Pause(). |
| 53 virtual void Play() = 0; | 61 virtual void Play() = 0; |
| 54 | 62 |
| 55 // Sets the playback volume, with range [0.0, 1.0] inclusive. | 63 // Sets the playback volume, with range [0.0, 1.0] inclusive. |
| 56 // Returns |true| on success. | 64 // Returns |true| on success. |
| 57 virtual bool SetVolume(double volume) = 0; | 65 virtual bool SetVolume(double volume) = 0; |
| 58 | 66 |
| 67 // Attempts to switch the audio output device. |
| 68 // Once the attempt is finished, |callback| is invoked with the |
| 69 // result of the operation passed as a parameter. The result is a value from |
| 70 // the media::SwitchOutputDeviceResult enum. |
| 71 // There is no guarantee about the thread where |callback| will |
| 72 // be invoked, so users are advised to use media::BindToCurrentLoop() to |
| 73 // ensure that |callback| runs on the correct thread. |
| 74 // Note also that copy constructors and destructors for arguments bound to |
| 75 // |callback| may run on arbitrary threads as |callback| is moved across |
| 76 // threads. It is advisable to bind arguments such that they are released by |
| 77 // |callback| when it runs in order to avoid surprises. |
| 78 virtual void SwitchOutputDevice(const std::string& device_id, |
| 79 const GURL& security_origin, |
| 80 const SwitchOutputDeviceCB& callback) = 0; |
| 81 |
| 59 protected: | 82 protected: |
| 60 friend class base::RefCountedThreadSafe<AudioRendererSink>; | 83 friend class base::RefCountedThreadSafe<AudioRendererSink>; |
| 61 virtual ~AudioRendererSink() {} | 84 virtual ~AudioRendererSink() {} |
| 62 }; | 85 }; |
| 63 | 86 |
| 64 } // namespace media | 87 } // namespace media |
| 65 | 88 |
| 66 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ | 89 #endif // MEDIA_BASE_AUDIO_RENDERER_SINK_H_ |
| OLD | NEW |