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

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

Issue 4661001: Simplified AudioOutputStream interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 10 years, 1 month 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/base/limits.h ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "media/base/filter_host.h" 9 #include "media/base/filter_host.h"
10 #include "media/audio/audio_manager.h" 10 #include "media/audio/audio_manager.h"
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 bool AudioRendererImpl::OnInitialize(const MediaFormat& media_format) { 74 bool AudioRendererImpl::OnInitialize(const MediaFormat& media_format) {
75 // Parse out audio parameters. 75 // Parse out audio parameters.
76 AudioParameters params; 76 AudioParameters params;
77 if (!ParseMediaFormat(media_format, &params.channels, 77 if (!ParseMediaFormat(media_format, &params.channels,
78 &params.sample_rate, &params.bits_per_sample)) { 78 &params.sample_rate, &params.bits_per_sample)) {
79 return false; 79 return false;
80 } 80 }
81 81
82 // Set packet size.
83 params.samples_per_packet = kSamplesPerBuffer;
84
82 bytes_per_second_ = params.sample_rate * params.channels * 85 bytes_per_second_ = params.sample_rate * params.channels *
83 params.bits_per_sample / 8; 86 params.bits_per_sample / 8;
84 87
85 // Create our audio stream. 88 // Create our audio stream.
86 stream_ = AudioManager::GetAudioManager()->MakeAudioOutputStream(params); 89 stream_ = AudioManager::GetAudioManager()->MakeAudioOutputStream(params);
87 if (!stream_) 90 if (!stream_)
88 return false; 91 return false;
89 92
90 // Calculate buffer size and open the stream. 93 if (!stream_->Open()) {
91 size_t size = kSamplesPerBuffer * params.channels *
92 params.bits_per_sample / 8;
93 if (!stream_->Open(size)) {
94 stream_->Close(); 94 stream_->Close();
95 stream_ = NULL; 95 stream_ = NULL;
96 } 96 }
97 return true; 97 return true;
98 } 98 }
99 99
100 void AudioRendererImpl::OnStop() { 100 void AudioRendererImpl::OnStop() {
101 if (stream_) 101 if (stream_)
102 stream_->Stop(); 102 stream_->Stop();
103 } 103 }
104 104
105 } // namespace media 105 } // namespace media
OLDNEW
« no previous file with comments | « media/base/limits.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698