| 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_RENDERER_WEBAUDIODEVICE_IMPL_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ |
| 6 #define CONTENT_RENDERER_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ | 6 #define CONTENT_RENDERER_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
| 13 #include "base/threading/thread_checker.h" | 13 #include "base/threading/thread_checker.h" |
| 14 #include "media/audio/audio_parameters.h" | 14 #include "media/audio/audio_parameters.h" |
| 15 #include "media/base/audio_renderer_sink.h" | 15 #include "media/base/audio_renderer_sink.h" |
| 16 #include "third_party/WebKit/public/platform/WebAudioDevice.h" | 16 #include "third_party/WebKit/public/platform/WebAudioDevice.h" |
| 17 #include "third_party/WebKit/public/platform/WebVector.h" | 17 #include "third_party/WebKit/public/platform/WebVector.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class SingleThreadTaskRunner; | 20 class SingleThreadTaskRunner; |
| 21 } | 21 } |
| 22 | 22 |
| 23 namespace media { | 23 namespace media { |
| 24 class AudioOutputDevice; | 24 class RestartableAudioOutputDevice; |
| 25 class NullAudioSink; | 25 class NullAudioSink; |
| 26 } | 26 } |
| 27 | 27 |
| 28 namespace content { | 28 namespace content { |
| 29 | 29 |
| 30 class RendererWebAudioDeviceImpl | 30 class RendererWebAudioDeviceImpl |
| 31 : public blink::WebAudioDevice, | 31 : public blink::WebAudioDevice, |
| 32 public media::AudioRendererSink::RenderCallback { | 32 public media::AudioRendererSink::RenderCallback { |
| 33 public: | 33 public: |
| 34 RendererWebAudioDeviceImpl(const media::AudioParameters& params, | 34 RendererWebAudioDeviceImpl(const media::AudioParameters& params, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 52 const media::AudioParameters params_; | 52 const media::AudioParameters params_; |
| 53 | 53 |
| 54 // Weak reference to the callback into WebKit code. | 54 // Weak reference to the callback into WebKit code. |
| 55 blink::WebAudioDevice::RenderCallback* const client_callback_; | 55 blink::WebAudioDevice::RenderCallback* const client_callback_; |
| 56 | 56 |
| 57 // To avoid the need for locking, ensure the control methods of the | 57 // To avoid the need for locking, ensure the control methods of the |
| 58 // blink::WebAudioDevice implementation are called on the same thread. | 58 // blink::WebAudioDevice implementation are called on the same thread. |
| 59 base::ThreadChecker thread_checker_; | 59 base::ThreadChecker thread_checker_; |
| 60 | 60 |
| 61 // When non-NULL, we are started. When NULL, we are stopped. | 61 // When non-NULL, we are started. When NULL, we are stopped. |
| 62 scoped_refptr<media::AudioOutputDevice> output_device_; | 62 scoped_refptr<media::RestartableAudioOutputDevice> output_device_; |
| 63 | 63 |
| 64 // ID to allow browser to select the correct input device for unified IO. | 64 // ID to allow browser to select the correct input device for unified IO. |
| 65 int session_id_; | 65 int session_id_; |
| 66 | 66 |
| 67 // Timeticks when the silence starts. | 67 // Timeticks when the silence starts. |
| 68 base::TimeTicks first_silence_time_ ; | 68 base::TimeTicks first_silence_time_ ; |
| 69 | 69 |
| 70 // TaskRunner to post callbacks to the render thread. | 70 // TaskRunner to post callbacks to the render thread. |
| 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; | 71 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; |
| 72 | 72 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 87 // A cancelable task that is posted to start the |null_audio_sink_| after a | 87 // A cancelable task that is posted to start the |null_audio_sink_| after a |
| 88 // period of silence. We do this on android to save battery consumption. | 88 // period of silence. We do this on android to save battery consumption. |
| 89 base::CancelableClosure start_null_audio_sink_callback_; | 89 base::CancelableClosure start_null_audio_sink_callback_; |
| 90 | 90 |
| 91 DISALLOW_COPY_AND_ASSIGN(RendererWebAudioDeviceImpl); | 91 DISALLOW_COPY_AND_ASSIGN(RendererWebAudioDeviceImpl); |
| 92 }; | 92 }; |
| 93 | 93 |
| 94 } // namespace content | 94 } // namespace content |
| 95 | 95 |
| 96 #endif // CONTENT_RENDERER_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ | 96 #endif // CONTENT_RENDERER_MEDIA_RENDERER_WEBAUDIODEVICE_IMPL_H_ |
| OLD | NEW |