| OLD | NEW |
| 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 "media/filters/audio_renderer_impl.h" | 5 #include "media/filters/audio_renderer_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "media/base/filter_host.h" | 10 #include "media/base/filter_host.h" |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 void AudioRendererImpl::OnClose(AudioOutputStream* stream) { | 65 void AudioRendererImpl::OnClose(AudioOutputStream* stream) { |
| 66 // TODO(scherkus): implement OnClose. | 66 // TODO(scherkus): implement OnClose. |
| 67 NOTIMPLEMENTED(); | 67 NOTIMPLEMENTED(); |
| 68 } | 68 } |
| 69 | 69 |
| 70 void AudioRendererImpl::OnError(AudioOutputStream* stream, int code) { | 70 void AudioRendererImpl::OnError(AudioOutputStream* stream, int code) { |
| 71 // TODO(scherkus): implement OnError. | 71 // TODO(scherkus): implement OnError. |
| 72 NOTIMPLEMENTED(); | 72 NOTIMPLEMENTED(); |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool AudioRendererImpl::OnInitialize(const AudioDecoderConfig& config) { | 75 bool AudioRendererImpl::OnInitialize(int bits_per_channel, |
| 76 AudioParameters params(config); | 76 ChannelLayout channel_layout, |
| 77 params.samples_per_packet = kSamplesPerBuffer; | 77 int sample_rate) { |
| 78 AudioParameters params(AudioParameters::AUDIO_PCM_LINEAR, channel_layout, |
| 79 sample_rate, bits_per_channel, kSamplesPerBuffer); |
| 78 | 80 |
| 79 bytes_per_second_ = params.GetBytesPerSecond(); | 81 bytes_per_second_ = params.GetBytesPerSecond(); |
| 80 | 82 |
| 81 // Create our audio stream. | 83 // Create our audio stream. |
| 82 stream_ = AudioManager::GetAudioManager()->MakeAudioOutputStream(params); | 84 stream_ = AudioManager::GetAudioManager()->MakeAudioOutputStream(params); |
| 83 if (!stream_) | 85 if (!stream_) |
| 84 return false; | 86 return false; |
| 85 | 87 |
| 86 if (!stream_->Open()) { | 88 if (!stream_->Open()) { |
| 87 stream_->Close(); | 89 stream_->Close(); |
| 88 stream_ = NULL; | 90 stream_ = NULL; |
| 89 } | 91 } |
| 90 return true; | 92 return true; |
| 91 } | 93 } |
| 92 | 94 |
| 93 void AudioRendererImpl::OnStop() { | 95 void AudioRendererImpl::OnStop() { |
| 94 if (stream_) | 96 if (stream_) |
| 95 stream_->Stop(); | 97 stream_->Stop(); |
| 96 } | 98 } |
| 97 | 99 |
| 98 } // namespace media | 100 } // namespace media |
| OLD | NEW |