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

Side by Side Diff: media/base/pipeline.cc

Issue 9325044: Remove AudioDecoder from the Filter heirarchy. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Moved audio_decoder_ out of Pipeline; AudioRendererBase is in charge of it now. Created 8 years, 10 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/pipeline.h" 5 #include "media/base/pipeline.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback.h" 10 #include "base/callback.h"
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 while (!notified_) 47 while (!notified_)
48 cv_.Wait(); 48 cv_.Wait();
49 } 49 }
50 50
51 media::PipelineStatus PipelineStatusNotification::status() { 51 media::PipelineStatus PipelineStatusNotification::status() {
52 base::AutoLock auto_lock(lock_); 52 base::AutoLock auto_lock(lock_);
53 DCHECK(notified_); 53 DCHECK(notified_);
54 return status_; 54 return status_;
55 } 55 }
56 56
57 class Pipeline::PipelineInitState { 57 struct Pipeline::PipelineInitState {
58 public:
59 scoped_refptr<AudioDecoder> audio_decoder_; 58 scoped_refptr<AudioDecoder> audio_decoder_;
scherkus (not reviewing) 2012/02/06 21:04:04 nit: drop trailing _ for structs
Ami GONE FROM CHROMIUM 2012/02/06 21:38:48 Done.
60 scoped_refptr<VideoDecoder> video_decoder_; 59 scoped_refptr<VideoDecoder> video_decoder_;
61 scoped_refptr<CompositeFilter> composite_; 60 scoped_refptr<CompositeFilter> composite_;
62 }; 61 };
63 62
64 Pipeline::Pipeline(MessageLoop* message_loop, MediaLog* media_log) 63 Pipeline::Pipeline(MessageLoop* message_loop, MediaLog* media_log)
65 : message_loop_(message_loop), 64 : message_loop_(message_loop),
66 media_log_(media_log), 65 media_log_(media_log),
67 clock_(new Clock(&base::Time::Now)), 66 clock_(new Clock(&base::Time::Now)),
68 waiting_for_clock_update_(false), 67 waiting_for_clock_update_(false),
69 state_(kCreated), 68 state_(kCreated),
(...skipping 952 matching lines...) Expand 10 before | Expand all | Expand 10 after
1022 // We use audio stream to update the clock. So if there is such a stream, 1021 // We use audio stream to update the clock. So if there is such a stream,
1023 // we pause the clock until we receive a valid timestamp. 1022 // we pause the clock until we receive a valid timestamp.
1024 waiting_for_clock_update_ = true; 1023 waiting_for_clock_update_ = true;
1025 if (!has_audio_) { 1024 if (!has_audio_) {
1026 clock_->SetMaxTime(clock_->Duration()); 1025 clock_->SetMaxTime(clock_->Duration());
1027 StartClockIfWaitingForTimeUpdate_Locked(); 1026 StartClockIfWaitingForTimeUpdate_Locked();
1028 } 1027 }
1029 1028
1030 // Start monitoring rate of downloading. 1029 // Start monitoring rate of downloading.
1031 int bitrate = 0; 1030 int bitrate = 0;
1032 if (demuxer_.get()) { 1031 if (demuxer_) {
1033 bitrate = demuxer_->GetBitrate(); 1032 bitrate = demuxer_->GetBitrate();
1034 local_source_ = demuxer_->IsLocalSource(); 1033 local_source_ = demuxer_->IsLocalSource();
1035 streaming_ = !demuxer_->IsSeekable(); 1034 streaming_ = !demuxer_->IsSeekable();
1036 } 1035 }
1037 // Needs to be locked because most other calls to |download_rate_monitor_| 1036 // Needs to be locked because most other calls to |download_rate_monitor_|
1038 // occur on the renderer thread. 1037 // occur on the renderer thread.
1039 download_rate_monitor_.Start( 1038 download_rate_monitor_.Start(
1040 base::Bind(&Pipeline::OnCanPlayThrough, this), 1039 base::Bind(&Pipeline::OnCanPlayThrough, this),
1041 bitrate, streaming_, local_source_); 1040 bitrate, streaming_, local_source_);
1042 download_rate_monitor_.SetBufferedBytes(buffered_bytes_, base::Time::Now()); 1041 download_rate_monitor_.SetBufferedBytes(buffered_bytes_, base::Time::Now());
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1164 const scoped_refptr<Demuxer>& demuxer) { 1163 const scoped_refptr<Demuxer>& demuxer) {
1165 DCHECK_EQ(MessageLoop::current(), message_loop_); 1164 DCHECK_EQ(MessageLoop::current(), message_loop_);
1166 DCHECK(IsPipelineOk()); 1165 DCHECK(IsPipelineOk());
1167 1166
1168 scoped_refptr<DemuxerStream> stream = 1167 scoped_refptr<DemuxerStream> stream =
1169 demuxer->GetStream(DemuxerStream::AUDIO); 1168 demuxer->GetStream(DemuxerStream::AUDIO);
1170 1169
1171 if (!stream) 1170 if (!stream)
1172 return false; 1171 return false;
1173 1172
1174 scoped_refptr<AudioDecoder> audio_decoder; 1173 filter_collection_->SelectAudioDecoder(&pipeline_init_state_->audio_decoder_);
1175 filter_collection_->SelectAudioDecoder(&audio_decoder);
1176 1174
1177 if (!audio_decoder) { 1175 if (!pipeline_init_state_->audio_decoder_) {
1178 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); 1176 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING);
1179 return false; 1177 return false;
1180 } 1178 }
1181 1179
1182 if (!PrepareFilter(audio_decoder)) 1180 pipeline_init_state_->audio_decoder_->Initialize(
1183 return false;
1184
1185 pipeline_init_state_->audio_decoder_ = audio_decoder;
1186 audio_decoder->Initialize(
1187 stream, 1181 stream,
1188 base::Bind(&Pipeline::OnFilterInitialize, this), 1182 base::Bind(&Pipeline::OnFilterInitialize, this),
1189 base::Bind(&Pipeline::OnUpdateStatistics, this)); 1183 base::Bind(&Pipeline::OnUpdateStatistics, this));
1190 return true; 1184 return true;
1191 } 1185 }
1192 1186
1193 bool Pipeline::InitializeVideoDecoder( 1187 bool Pipeline::InitializeVideoDecoder(
1194 const scoped_refptr<Demuxer>& demuxer) { 1188 const scoped_refptr<Demuxer>& demuxer) {
1195 DCHECK_EQ(MessageLoop::current(), message_loop_); 1189 DCHECK_EQ(MessageLoop::current(), message_loop_);
1196 DCHECK(IsPipelineOk()); 1190 DCHECK(IsPipelineOk());
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1425 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() { 1419 void Pipeline::StartClockIfWaitingForTimeUpdate_Locked() {
1426 lock_.AssertAcquired(); 1420 lock_.AssertAcquired();
1427 if (!waiting_for_clock_update_) 1421 if (!waiting_for_clock_update_)
1428 return; 1422 return;
1429 1423
1430 waiting_for_clock_update_ = false; 1424 waiting_for_clock_update_ = false;
1431 clock_->Play(); 1425 clock_->Play();
1432 } 1426 }
1433 1427
1434 } // namespace media 1428 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698