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

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

Issue 155230: Made MediaFilter::host_ and MediaFilter::message_loop_ private. (Closed)
Patch Set: Merge with ToT Created 11 years, 5 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
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/filters/decoder_base.h » ('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) 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_base.h" 6 #include "media/filters/audio_renderer_base.h"
7 7
8 namespace media { 8 namespace media {
9 9
10 // The maximum size of the queue, which also acts as the number of initial reads 10 // The maximum size of the queue, which also acts as the number of initial reads
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // the target queue size or the stream has ended. 82 // the target queue size or the stream has ended.
83 if (queue_.size() == max_queue_size_ || buffer_in->IsEndOfStream()) 83 if (queue_.size() == max_queue_size_ || buffer_in->IsEndOfStream())
84 initialization_complete = true; 84 initialization_complete = true;
85 } 85 }
86 } 86 }
87 87
88 if (initialization_complete) { 88 if (initialization_complete) {
89 if (queue_.empty()) { 89 if (queue_.empty()) {
90 // If we say we have initialized but buffer queue is empty, raise an 90 // If we say we have initialized but buffer queue is empty, raise an
91 // error. 91 // error.
92 host_->Error(PIPELINE_ERROR_NO_DATA); 92 host()->Error(PIPELINE_ERROR_NO_DATA);
93 } else { 93 } else {
94 initialized_ = true; 94 initialized_ = true;
95 host_->InitializationComplete(); 95 host()->InitializationComplete();
96 } 96 }
97 } 97 }
98 } 98 }
99 99
100 // TODO(scherkus): clean up FillBuffer().. it's overly complex!! 100 // TODO(scherkus): clean up FillBuffer().. it's overly complex!!
101 size_t AudioRendererBase::FillBuffer(uint8* dest, 101 size_t AudioRendererBase::FillBuffer(uint8* dest,
102 size_t dest_len, 102 size_t dest_len,
103 float rate, 103 float rate,
104 const base::TimeDelta& playback_delay) { 104 const base::TimeDelta& playback_delay) {
105 size_t buffers_released = 0; 105 size_t buffers_released = 0;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 // Update the pipeline's time if it was set last time. 203 // Update the pipeline's time if it was set last time.
204 if (last_fill_buffer_time.InMicroseconds() > 0) { 204 if (last_fill_buffer_time.InMicroseconds() > 0) {
205 // Adjust the |last_fill_buffer_time| with the playback delay. 205 // Adjust the |last_fill_buffer_time| with the playback delay.
206 // TODO(hclam): If there is a playback delay, the pipeline would not be 206 // TODO(hclam): If there is a playback delay, the pipeline would not be
207 // updated with a correct timestamp when the stream is played at the very 207 // updated with a correct timestamp when the stream is played at the very
208 // end since we use decoded packets to trigger time updates. A better 208 // end since we use decoded packets to trigger time updates. A better
209 // solution is to start a timer when an audio packet is decoded to allow 209 // solution is to start a timer when an audio packet is decoded to allow
210 // finer time update events. 210 // finer time update events.
211 if (playback_delay < last_fill_buffer_time) 211 if (playback_delay < last_fill_buffer_time)
212 last_fill_buffer_time -= playback_delay; 212 last_fill_buffer_time -= playback_delay;
213 host_->SetTime(last_fill_buffer_time); 213 host()->SetTime(last_fill_buffer_time);
214 } 214 }
215 215
216 return dest_written; 216 return dest_written;
217 } 217 }
218 218
219 void AudioRendererBase::ScheduleRead() { 219 void AudioRendererBase::ScheduleRead() {
220 decoder_->Read(NewCallback(this, &AudioRendererBase::OnReadComplete)); 220 decoder_->Read(NewCallback(this, &AudioRendererBase::OnReadComplete));
221 } 221 }
222 222
223 // static 223 // static
224 bool AudioRendererBase::ParseMediaFormat(const MediaFormat& media_format, 224 bool AudioRendererBase::ParseMediaFormat(const MediaFormat& media_format,
225 int* channels_out, 225 int* channels_out,
226 int* sample_rate_out, 226 int* sample_rate_out,
227 int* sample_bits_out) { 227 int* sample_bits_out) {
228 // TODO(scherkus): might be handy to support NULL parameters. 228 // TODO(scherkus): might be handy to support NULL parameters.
229 std::string mime_type; 229 std::string mime_type;
230 return media_format.GetAsString(MediaFormat::kMimeType, &mime_type) && 230 return media_format.GetAsString(MediaFormat::kMimeType, &mime_type) &&
231 media_format.GetAsInteger(MediaFormat::kChannels, channels_out) && 231 media_format.GetAsInteger(MediaFormat::kChannels, channels_out) &&
232 media_format.GetAsInteger(MediaFormat::kSampleRate, sample_rate_out) && 232 media_format.GetAsInteger(MediaFormat::kSampleRate, sample_rate_out) &&
233 media_format.GetAsInteger(MediaFormat::kSampleBits, sample_bits_out) && 233 media_format.GetAsInteger(MediaFormat::kSampleBits, sample_bits_out) &&
234 mime_type.compare(mime_type::kUncompressedAudio) == 0; 234 mime_type.compare(mime_type::kUncompressedAudio) == 0;
235 } 235 }
236 236
237 } // namespace media 237 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline_impl.cc ('k') | media/filters/decoder_base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698