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 "media/base/filter_host.h" | 5 #include "media/base/filter_host.h" |
6 #include "media/filters/audio_renderer_impl.h" | 6 #include "media/filters/audio_renderer_impl.h" |
7 | 7 |
8 namespace media { | 8 namespace media { |
9 | 9 |
10 // We'll try to fill 4096 samples per buffer, which is roughly ~92ms of audio | 10 // We'll try to fill 4096 samples per buffer, which is roughly ~92ms of audio |
11 // data for a 44.1kHz audio source. | 11 // data for a 44.1kHz audio source. |
12 static const size_t kSamplesPerBuffer = 4096; | 12 static const size_t kSamplesPerBuffer = 4096; |
13 | 13 |
14 AudioRendererImpl::AudioRendererImpl() | 14 AudioRendererImpl::AudioRendererImpl() |
15 : AudioRendererBase(kDefaultMaxQueueSize), | 15 : AudioRendererBase(kDefaultMaxQueueSize), |
16 stream_(NULL) { | 16 stream_(NULL) { |
17 } | 17 } |
18 | 18 |
19 AudioRendererImpl::~AudioRendererImpl() { | 19 AudioRendererImpl::~AudioRendererImpl() { |
20 // Close down the audio device. | 20 // Close down the audio device. |
21 if (stream_) { | 21 if (stream_) { |
22 stream_->Stop(); | 22 stream_->Stop(); |
23 stream_->Close(); | 23 stream_->Close(); |
24 } | 24 } |
25 } | 25 } |
26 | 26 |
27 bool AudioRendererImpl::IsMediaFormatSupported( | 27 bool AudioRendererImpl::IsMediaFormatSupported( |
28 const MediaFormat* media_format) { | 28 const MediaFormat& media_format) { |
29 int channels; | 29 int channels; |
30 int sample_rate; | 30 int sample_rate; |
31 int sample_bits; | 31 int sample_bits; |
32 return ParseMediaFormat(media_format, &channels, &sample_rate, &sample_bits); | 32 return ParseMediaFormat(media_format, &channels, &sample_rate, &sample_bits); |
33 } | 33 } |
34 | 34 |
35 void AudioRendererImpl::SetPlaybackRate(float playback_rate) { | 35 void AudioRendererImpl::SetPlaybackRate(float playback_rate) { |
36 DCHECK(stream_); | 36 DCHECK(stream_); |
37 // TODO(scherkus): handle playback rates not equal to 1.0. | 37 // TODO(scherkus): handle playback rates not equal to 1.0. |
38 if (playback_rate == 1.0f) { | 38 if (playback_rate == 1.0f) { |
(...skipping 19 matching lines...) Expand all Loading... |
58 void AudioRendererImpl::OnClose(AudioOutputStream* stream) { | 58 void AudioRendererImpl::OnClose(AudioOutputStream* stream) { |
59 // TODO(scherkus): implement OnClose. | 59 // TODO(scherkus): implement OnClose. |
60 NOTIMPLEMENTED(); | 60 NOTIMPLEMENTED(); |
61 } | 61 } |
62 | 62 |
63 void AudioRendererImpl::OnError(AudioOutputStream* stream, int code) { | 63 void AudioRendererImpl::OnError(AudioOutputStream* stream, int code) { |
64 // TODO(scherkus): implement OnError. | 64 // TODO(scherkus): implement OnError. |
65 NOTIMPLEMENTED(); | 65 NOTIMPLEMENTED(); |
66 } | 66 } |
67 | 67 |
68 bool AudioRendererImpl::OnInitialize(const MediaFormat* media_format) { | 68 bool AudioRendererImpl::OnInitialize(const MediaFormat& media_format) { |
69 // Parse out audio parameters. | 69 // Parse out audio parameters. |
70 int channels; | 70 int channels; |
71 int sample_rate; | 71 int sample_rate; |
72 int sample_bits; | 72 int sample_bits; |
73 if (!ParseMediaFormat(media_format, &channels, &sample_rate, &sample_bits)) { | 73 if (!ParseMediaFormat(media_format, &channels, &sample_rate, &sample_bits)) { |
74 return false; | 74 return false; |
75 } | 75 } |
76 | 76 |
77 // Create our audio stream. | 77 // Create our audio stream. |
78 stream_ = AudioManager::GetAudioManager()->MakeAudioStream( | 78 stream_ = AudioManager::GetAudioManager()->MakeAudioStream( |
(...skipping 11 matching lines...) Expand all Loading... |
90 } | 90 } |
91 return true; | 91 return true; |
92 } | 92 } |
93 | 93 |
94 void AudioRendererImpl::OnStop() { | 94 void AudioRendererImpl::OnStop() { |
95 DCHECK(stream_); | 95 DCHECK(stream_); |
96 stream_->Stop(); | 96 stream_->Stop(); |
97 } | 97 } |
98 | 98 |
99 } // namespace media | 99 } // namespace media |
OLD | NEW |