| 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 CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include "base/memory/ref_counted.h" | 8 #include "base/memory/ref_counted.h" |
| 9 #include "base/threading/thread_checker.h" |
| 10 #include "media/audio/audio_parameters.h" |
| 9 #include "media/base/audio_renderer_sink.h" | 11 #include "media/base/audio_renderer_sink.h" |
| 10 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebAudioDevi
ce.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebAudioDevi
ce.h" |
| 11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" | 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebVector.h" |
| 12 | 14 |
| 13 namespace content { | 15 namespace content { |
| 14 | 16 |
| 17 class RendererAudioOutputDevice; |
| 18 |
| 15 class RendererWebAudioDeviceImpl | 19 class RendererWebAudioDeviceImpl |
| 16 : public WebKit::WebAudioDevice, | 20 : public WebKit::WebAudioDevice, |
| 17 public media::AudioRendererSink::RenderCallback { | 21 public media::AudioRendererSink::RenderCallback { |
| 18 public: | 22 public: |
| 19 RendererWebAudioDeviceImpl(const media::AudioParameters& params, | 23 RendererWebAudioDeviceImpl(const media::AudioParameters& params, |
| 20 WebKit::WebAudioDevice::RenderCallback* callback); | 24 WebKit::WebAudioDevice::RenderCallback* callback); |
| 21 virtual ~RendererWebAudioDeviceImpl(); | 25 virtual ~RendererWebAudioDeviceImpl(); |
| 22 | 26 |
| 23 // WebKit::WebAudioDevice implementation. | 27 // WebKit::WebAudioDevice implementation. |
| 24 virtual void start(); | 28 virtual void start(); |
| 25 virtual void stop(); | 29 virtual void stop(); |
| 26 virtual double sampleRate(); | 30 virtual double sampleRate(); |
| 27 | 31 |
| 28 // AudioRendererSink::RenderCallback implementation. | 32 // AudioRendererSink::RenderCallback implementation. |
| 29 virtual int Render(media::AudioBus* dest, | 33 virtual int Render(media::AudioBus* dest, |
| 30 int audio_delay_milliseconds) OVERRIDE; | 34 int audio_delay_milliseconds) OVERRIDE; |
| 31 | 35 |
| 32 virtual void RenderIO(media::AudioBus* source, | 36 virtual void RenderIO(media::AudioBus* source, |
| 33 media::AudioBus* dest, | 37 media::AudioBus* dest, |
| 34 int audio_delay_milliseconds) OVERRIDE; | 38 int audio_delay_milliseconds) OVERRIDE; |
| 35 | 39 |
| 36 virtual void OnRenderError() OVERRIDE; | 40 virtual void OnRenderError() OVERRIDE; |
| 37 | 41 |
| 38 private: | 42 private: |
| 39 scoped_refptr<media::AudioRendererSink> audio_device_; | 43 const media::AudioParameters params_; |
| 40 bool is_running_; | |
| 41 | 44 |
| 42 // Weak reference to the callback into WebKit code. | 45 // Weak reference to the callback into WebKit code. |
| 43 WebKit::WebAudioDevice::RenderCallback* client_callback_; | 46 WebKit::WebAudioDevice::RenderCallback* const client_callback_; |
| 47 |
| 48 // To avoid the need locking, ensure methods of the WebKit::WebAudioDevice |
| 49 // implementation are called on the same thread. |
| 50 base::ThreadChecker thread_checker_; |
| 51 |
| 52 // When non-NULL, we are started. When NULL, we are stopped. |
| 53 scoped_refptr<RendererAudioOutputDevice> output_device_; |
| 44 | 54 |
| 45 DISALLOW_COPY_AND_ASSIGN(RendererWebAudioDeviceImpl); | 55 DISALLOW_COPY_AND_ASSIGN(RendererWebAudioDeviceImpl); |
| 46 }; | 56 }; |
| 47 | 57 |
| 48 } // namespace content | 58 } // namespace content |
| 49 | 59 |
| 50 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ | 60 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ |
| OLD | NEW |