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