| 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 // Audio rendering unit utilizing an AudioRendererSink to output data. | 5 // Audio rendering unit utilizing an AudioRendererSink to output data. |
| 6 // | 6 // |
| 7 // This class lives inside three threads during it's lifetime, namely: | 7 // This class lives inside three threads during it's lifetime, namely: |
| 8 // 1. Render thread | 8 // 1. Render thread |
| 9 // Where the object is created. | 9 // Where the object is created. |
| 10 // 2. Media thread (provided via constructor) | 10 // 2. Media thread (provided via constructor) |
| 11 // All AudioDecoder methods are called on this thread. | 11 // All AudioDecoder methods are called on this thread. |
| 12 // 3. Audio thread created by the AudioRendererSink. | 12 // 3. Audio thread created by the AudioRendererSink. |
| 13 // Render() is called here where audio data is decoded into raw PCM data. | 13 // Render() is called here where audio data is decoded into raw PCM data. |
| 14 // | 14 // |
| 15 // AudioRendererImpl talks to an AudioRendererAlgorithm that takes care of | 15 // AudioRendererImpl talks to an AudioRendererAlgorithm that takes care of |
| 16 // queueing audio data and stretching/shrinking audio data when playback rate != | 16 // queueing audio data and stretching/shrinking audio data when playback rate != |
| 17 // 1.0 or 0.0. | 17 // 1.0 or 0.0. |
| 18 | 18 |
| 19 #ifndef MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ | 19 #ifndef MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ |
| 20 #define MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ | 20 #define MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ |
| 21 | 21 |
| 22 #include <deque> | 22 #include <deque> |
| 23 #include <string> |
| 23 | 24 |
| 24 #include "base/gtest_prod_util.h" | 25 #include "base/gtest_prod_util.h" |
| 25 #include "base/memory/scoped_ptr.h" | 26 #include "base/memory/scoped_ptr.h" |
| 26 #include "base/memory/weak_ptr.h" | 27 #include "base/memory/weak_ptr.h" |
| 27 #include "base/synchronization/lock.h" | 28 #include "base/synchronization/lock.h" |
| 28 #include "media/base/audio_decoder.h" | 29 #include "media/base/audio_decoder.h" |
| 29 #include "media/base/audio_renderer.h" | 30 #include "media/base/audio_renderer.h" |
| 30 #include "media/base/audio_renderer_sink.h" | 31 #include "media/base/audio_renderer_sink.h" |
| 31 #include "media/base/decryptor.h" | 32 #include "media/base/decryptor.h" |
| 32 #include "media/base/media_log.h" | 33 #include "media/base/media_log.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 const SetDecryptorReadyCB& set_decryptor_ready_cb, | 82 const SetDecryptorReadyCB& set_decryptor_ready_cb, |
| 82 const StatisticsCB& statistics_cb, | 83 const StatisticsCB& statistics_cb, |
| 83 const BufferingStateCB& buffering_state_cb, | 84 const BufferingStateCB& buffering_state_cb, |
| 84 const base::Closure& ended_cb, | 85 const base::Closure& ended_cb, |
| 85 const PipelineStatusCB& error_cb, | 86 const PipelineStatusCB& error_cb, |
| 86 const base::Closure& waiting_for_decryption_key_cb) override; | 87 const base::Closure& waiting_for_decryption_key_cb) override; |
| 87 TimeSource* GetTimeSource() override; | 88 TimeSource* GetTimeSource() override; |
| 88 void Flush(const base::Closure& callback) override; | 89 void Flush(const base::Closure& callback) override; |
| 89 void StartPlaying() override; | 90 void StartPlaying() override; |
| 90 void SetVolume(float volume) override; | 91 void SetVolume(float volume) override; |
| 92 void SwitchOutputDevice(const std::string& device_id, |
| 93 const GURL& security_origin, |
| 94 const base::Callback<void(int)>& callback) override; |
| 91 | 95 |
| 92 private: | 96 private: |
| 93 friend class AudioRendererImplTest; | 97 friend class AudioRendererImplTest; |
| 94 | 98 |
| 95 // Important detail: being in kPlaying doesn't imply that audio is being | 99 // Important detail: being in kPlaying doesn't imply that audio is being |
| 96 // rendered. Rather, it means that the renderer is ready to go. The actual | 100 // rendered. Rather, it means that the renderer is ready to go. The actual |
| 97 // rendering of audio is controlled via Start/StopRendering(). | 101 // rendering of audio is controlled via Start/StopRendering(). |
| 98 // | 102 // |
| 99 // kUninitialized | 103 // kUninitialized |
| 100 // | Initialize() | 104 // | Initialize() |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 | 268 |
| 265 // NOTE: Weak pointers must be invalidated before all other member variables. | 269 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 266 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; | 270 base::WeakPtrFactory<AudioRendererImpl> weak_factory_; |
| 267 | 271 |
| 268 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); | 272 DISALLOW_COPY_AND_ASSIGN(AudioRendererImpl); |
| 269 }; | 273 }; |
| 270 | 274 |
| 271 } // namespace media | 275 } // namespace media |
| 272 | 276 |
| 273 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ | 277 #endif // MEDIA_RENDERERS_AUDIO_RENDERER_IMPL_H_ |
| OLD | NEW |