Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(734)

Side by Side Diff: media/filters/null_audio_renderer.cc

Issue 7796033: Replace AudioDecoderConfig with simple accessors on AudioDecoder. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: rebase Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/filters/null_audio_renderer.h ('k') | media/media.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> 5 #include <algorithm>
6 #include <cmath> 6 #include <cmath>
7 7
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/threading/platform_thread.h" 9 #include "base/threading/platform_thread.h"
10 #include "media/base/filter_host.h" 10 #include "media/base/filter_host.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 // If paused, sleep for 10 milliseconds before polling again. 53 // If paused, sleep for 10 milliseconds before polling again.
54 sleep_in_milliseconds = 10.0f; 54 sleep_in_milliseconds = 10.0f;
55 } 55 }
56 56
57 // Sleep for at least one millisecond so we don't spin the CPU. 57 // Sleep for at least one millisecond so we don't spin the CPU.
58 base::PlatformThread::Sleep( 58 base::PlatformThread::Sleep(
59 std::max(1, static_cast<int>(sleep_in_milliseconds))); 59 std::max(1, static_cast<int>(sleep_in_milliseconds)));
60 } 60 }
61 } 61 }
62 62
63 bool NullAudioRenderer::OnInitialize(const AudioDecoderConfig& config) { 63 bool NullAudioRenderer::OnInitialize(int bits_per_channel,
64 ChannelLayout channel_layout,
65 int sample_rate) {
64 // Calculate our bytes per millisecond value and allocate our buffer. 66 // Calculate our bytes per millisecond value and allocate our buffer.
65 bytes_per_millisecond_ = 67 bytes_per_millisecond_ =
66 (ChannelLayoutToChannelCount(config.channel_layout) * config.sample_rate * 68 (ChannelLayoutToChannelCount(channel_layout) * sample_rate *
67 config.bits_per_channel / 8) / base::Time::kMillisecondsPerSecond; 69 bits_per_channel / 8) / base::Time::kMillisecondsPerSecond;
68 buffer_size_ = bytes_per_millisecond_ * kBufferSizeInMilliseconds; 70 buffer_size_ = bytes_per_millisecond_ * kBufferSizeInMilliseconds;
69 buffer_.reset(new uint8[buffer_size_]); 71 buffer_.reset(new uint8[buffer_size_]);
70 DCHECK(buffer_.get()); 72 DCHECK(buffer_.get());
71 73
72 // It's safe to start the thread now because it simply sleeps when playback 74 // It's safe to start the thread now because it simply sleeps when playback
73 // rate is 0.0f. 75 // rate is 0.0f.
74 return base::PlatformThread::Create(0, this, &thread_); 76 return base::PlatformThread::Create(0, this, &thread_);
75 } 77 }
76 78
77 void NullAudioRenderer::OnStop() { 79 void NullAudioRenderer::OnStop() {
78 shutdown_ = true; 80 shutdown_ = true;
79 if (thread_) { 81 if (thread_) {
80 base::PlatformThread::Join(thread_); 82 base::PlatformThread::Join(thread_);
81 thread_ = base::kNullThreadHandle; 83 thread_ = base::kNullThreadHandle;
82 } 84 }
83 } 85 }
84 86
85 } // namespace media 87 } // namespace media
OLDNEW
« no previous file with comments | « media/filters/null_audio_renderer.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698