| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_ | 5 #ifndef MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_ |
| 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_ | 6 #define MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_ |
| 7 | 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback.h" |
| 8 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
| 9 #include "base/single_thread_task_runner.h" | 12 #include "base/single_thread_task_runner.h" |
| 10 #include "base/synchronization/lock.h" | 13 #include "base/synchronization/lock.h" |
| 11 #include "media/audio/audio_io.h" | 14 #include "media/audio/audio_io.h" |
| 12 #include "media/base/audio_renderer_sink.h" | 15 #include "media/base/audio_renderer_sink.h" |
| 13 #include "media/base/media_export.h" | 16 #include "media/base/media_export.h" |
| 17 #include "url/gurl.h" |
| 14 | 18 |
| 15 namespace media { | 19 namespace media { |
| 16 | 20 |
| 17 // Wrapper which exposes the browser side audio interface (AudioOutputStream) as | 21 // Wrapper which exposes the browser side audio interface (AudioOutputStream) as |
| 18 // if it were a renderer side audio interface (AudioRendererSink). Note: This | 22 // if it were a renderer side audio interface (AudioRendererSink). Note: This |
| 19 // will not work for sandboxed renderers. | 23 // will not work for sandboxed renderers. |
| 20 // | 24 // |
| 21 // TODO(dalecurtis): Delete this class once we have a proper mojo audio service; | 25 // TODO(dalecurtis): Delete this class once we have a proper mojo audio service; |
| 22 // tracked by http://crbug.com/425368 | 26 // tracked by http://crbug.com/425368 |
| 23 class MEDIA_EXPORT AudioOutputStreamSink | 27 class MEDIA_EXPORT AudioOutputStreamSink |
| 24 : NON_EXPORTED_BASE(public AudioRendererSink), | 28 : NON_EXPORTED_BASE(public AudioRendererSink), |
| 25 public AudioOutputStream::AudioSourceCallback { | 29 public AudioOutputStream::AudioSourceCallback { |
| 26 public: | 30 public: |
| 27 AudioOutputStreamSink(); | 31 AudioOutputStreamSink(); |
| 28 | 32 |
| 29 // AudioRendererSink implementation. | 33 // AudioRendererSink implementation. |
| 30 void Initialize(const AudioParameters& params, | 34 void Initialize(const AudioParameters& params, |
| 31 RenderCallback* callback) override; | 35 RenderCallback* callback) override; |
| 32 void Start() override; | 36 void Start() override; |
| 33 void Stop() override; | 37 void Stop() override; |
| 34 void Pause() override; | 38 void Pause() override; |
| 35 void Play() override; | 39 void Play() override; |
| 36 bool SetVolume(double volume) override; | 40 bool SetVolume(double volume) override; |
| 41 void SwitchOutputDevice(const std::string& device_id, |
| 42 const GURL& security_origin, |
| 43 const base::Callback<void(int)>& callback) override; |
| 37 | 44 |
| 38 // AudioSourceCallback implementation. | 45 // AudioSourceCallback implementation. |
| 39 int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) override; | 46 int OnMoreData(AudioBus* dest, uint32 total_bytes_delay) override; |
| 40 void OnError(AudioOutputStream* stream) override; | 47 void OnError(AudioOutputStream* stream) override; |
| 41 | 48 |
| 42 private: | 49 private: |
| 43 ~AudioOutputStreamSink() override; | 50 ~AudioOutputStreamSink() override; |
| 44 | 51 |
| 45 // Helper methods for running AudioManager methods on the audio thread. | 52 // Helper methods for running AudioManager methods on the audio thread. |
| 46 void DoStart(); | 53 void DoStart(); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 71 // Lock and callback for forwarding OnMoreData() calls into Render() calls. | 78 // Lock and callback for forwarding OnMoreData() calls into Render() calls. |
| 72 base::Lock callback_lock_; | 79 base::Lock callback_lock_; |
| 73 RenderCallback* active_render_callback_; | 80 RenderCallback* active_render_callback_; |
| 74 | 81 |
| 75 DISALLOW_COPY_AND_ASSIGN(AudioOutputStreamSink); | 82 DISALLOW_COPY_AND_ASSIGN(AudioOutputStreamSink); |
| 76 }; | 83 }; |
| 77 | 84 |
| 78 } // namepace media | 85 } // namepace media |
| 79 | 86 |
| 80 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_ | 87 #endif // MEDIA_AUDIO_AUDIO_OUTPUT_STREAM_SINK_H_ |
| OLD | NEW |