| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "media/base/filter_host.h" | 7 #include "media/base/filter_host.h" |
| 8 #include "media/filters/null_audio_renderer.h" | 8 #include "media/filters/null_audio_renderer.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| 11 | 11 |
| 12 // How "long" our buffer should be in terms of milliseconds. In OnInitialize | 12 // How "long" our buffer should be in terms of milliseconds. In OnInitialize |
| 13 // we calculate the size of one second of audio data and use this number to | 13 // we calculate the size of one second of audio data and use this number to |
| 14 // allocate a buffer to pass to FillBuffer. | 14 // allocate a buffer to pass to FillBuffer. |
| 15 static const size_t kBufferSizeInMilliseconds = 100; | 15 static const size_t kBufferSizeInMilliseconds = 100; |
| 16 | 16 |
| 17 NullAudioRenderer::NullAudioRenderer() | 17 NullAudioRenderer::NullAudioRenderer() |
| 18 : AudioRendererBase(), | 18 : AudioRendererBase(), |
| 19 bytes_per_millisecond_(0), | 19 bytes_per_millisecond_(0), |
| 20 buffer_size_(0), | 20 buffer_size_(0), |
| 21 thread_(0), | 21 thread_(NULL), |
| 22 shutdown_(false) { | 22 shutdown_(false) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 NullAudioRenderer::~NullAudioRenderer() { | 25 NullAudioRenderer::~NullAudioRenderer() { |
| 26 Stop(); | 26 Stop(); |
| 27 } | 27 } |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 bool NullAudioRenderer::IsMediaFormatSupported( | 30 bool NullAudioRenderer::IsMediaFormatSupported( |
| 31 const MediaFormat& media_format) { | 31 const MediaFormat& media_format) { |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 | 82 |
| 83 // It's safe to start the thread now because it simply sleeps when playback | 83 // It's safe to start the thread now because it simply sleeps when playback |
| 84 // rate is 0.0f. | 84 // rate is 0.0f. |
| 85 return PlatformThread::Create(0, this, &thread_); | 85 return PlatformThread::Create(0, this, &thread_); |
| 86 } | 86 } |
| 87 | 87 |
| 88 void NullAudioRenderer::OnStop() { | 88 void NullAudioRenderer::OnStop() { |
| 89 shutdown_ = true; | 89 shutdown_ = true; |
| 90 if (thread_) { | 90 if (thread_) { |
| 91 PlatformThread::Join(thread_); | 91 PlatformThread::Join(thread_); |
| 92 thread_ = 0; | 92 thread_ = NULL; |
| 93 } | 93 } |
| 94 } | 94 } |
| 95 | 95 |
| 96 } // namespace media | 96 } // namespace media |
| OLD | NEW |