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
3 // found in the LICENSE file.
5 #ifndef CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_
6 #define CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/threading/thread_checker.h"
10 #include "media/audio/audio_parameters.h"
11 #include "media/base/audio_renderer_sink.h"
12 #include "third_party/WebKit/Source/Platform/chromium/public/WebAudioDevice.h"
13 #include "third_party/WebKit/Source/Platform/chromium/public/WebVector.h"
17 class RendererAudioOutputDevice
;
19 class RendererWebAudioDeviceImpl
20 : public WebKit::WebAudioDevice
,
21 public media::AudioRendererSink::RenderCallback
{
23 RendererWebAudioDeviceImpl(const media::AudioParameters
& params
,
24 WebKit::WebAudioDevice::RenderCallback
* callback
);
25 virtual ~RendererWebAudioDeviceImpl();
27 // WebKit::WebAudioDevice implementation.
30 virtual double sampleRate();
32 // AudioRendererSink::RenderCallback implementation.
33 virtual int Render(media::AudioBus
* dest
,
34 int audio_delay_milliseconds
) OVERRIDE
;
36 virtual void RenderIO(media::AudioBus
* source
,
37 media::AudioBus
* dest
,
38 int audio_delay_milliseconds
) OVERRIDE
;
40 virtual void OnRenderError() OVERRIDE
;
43 const media::AudioParameters params_
;
45 // Weak reference to the callback into WebKit code.
46 WebKit::WebAudioDevice::RenderCallback
* const client_callback_
;
48 // To avoid the need for locking, ensure the control methods of the
49 // WebKit::WebAudioDevice implementation are called on the same thread.
50 base::ThreadChecker thread_checker_
;
52 // When non-NULL, we are started. When NULL, we are stopped.
53 scoped_refptr
<RendererAudioOutputDevice
> output_device_
;
55 DISALLOW_COPY_AND_ASSIGN(RendererWebAudioDeviceImpl
);
58 } // namespace content
60 #endif // CONTENT_RENDERER_MEDIA_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_