Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, | 5 // TODO(scherkus): clean up PipelineImpl... too many crazy function names, |
| 6 // potential deadlocks, etc... | 6 // potential deadlocks, etc... |
| 7 | 7 |
| 8 #include "media/base/pipeline_impl.h" | 8 #include "media/base/pipeline_impl.h" |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 } | 231 } |
| 232 } | 232 } |
| 233 | 233 |
| 234 base::TimeDelta PipelineImpl::GetCurrentTime() const { | 234 base::TimeDelta PipelineImpl::GetCurrentTime() const { |
| 235 base::AutoLock auto_lock(lock_); | 235 base::AutoLock auto_lock(lock_); |
| 236 return GetCurrentTime_Locked(); | 236 return GetCurrentTime_Locked(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 base::TimeDelta PipelineImpl::GetCurrentTime_Locked() const { | 239 base::TimeDelta PipelineImpl::GetCurrentTime_Locked() const { |
| 240 lock_.AssertAcquired(); | 240 lock_.AssertAcquired(); |
| 241 base::TimeDelta elapsed = clock_->Elapsed(); | 241 return clock_->Elapsed(); |
| 242 if (elapsed > duration_) | |
| 243 return duration_; | |
| 244 | |
| 245 return elapsed; | |
| 246 } | 242 } |
| 247 | 243 |
| 248 base::TimeDelta PipelineImpl::GetBufferedTime() { | 244 base::TimeDelta PipelineImpl::GetBufferedTime() { |
| 249 base::AutoLock auto_lock(lock_); | 245 base::AutoLock auto_lock(lock_); |
| 250 | 246 |
| 251 // If media is fully loaded, then return duration. | 247 // If media is fully loaded, then return duration. |
| 252 if (local_source_ || total_bytes_ == buffered_bytes_) { | 248 if (local_source_ || total_bytes_ == buffered_bytes_) { |
| 253 max_buffered_time_ = duration_; | 249 max_buffered_time_ = clock_->media_duration(); |
| 254 return duration_; | 250 return max_buffered_time_; |
| 255 } | 251 } |
| 256 | 252 |
| 257 base::TimeDelta current_time = GetCurrentTime_Locked(); | 253 base::TimeDelta current_time = GetCurrentTime_Locked(); |
| 258 | 254 |
| 259 // If buffered time was set, we report that value directly. | 255 // If buffered time was set, we report that value directly. |
| 260 if (buffered_time_.ToInternalValue() > 0) | 256 if (buffered_time_.ToInternalValue() > 0) |
| 261 return std::max(buffered_time_, current_time); | 257 return std::max(buffered_time_, current_time); |
| 262 | 258 |
| 263 if (total_bytes_ == 0) | 259 if (total_bytes_ == 0) |
| 264 return base::TimeDelta(); | 260 return base::TimeDelta(); |
| 265 | 261 |
| 266 // If buffered time was not set, we use current time, current bytes, and | 262 // If buffered time was not set, we use current time, current bytes, and |
| 267 // buffered bytes to estimate the buffered time. | 263 // buffered bytes to estimate the buffered time. |
| 268 double estimated_rate = duration_.InMillisecondsF() / total_bytes_; | 264 double estimated_rate = |
| 265 clock_->media_duration().InMillisecondsF() / total_bytes_; | |
| 269 double estimated_current_time = estimated_rate * current_bytes_; | 266 double estimated_current_time = estimated_rate * current_bytes_; |
| 270 DCHECK_GE(buffered_bytes_, current_bytes_); | 267 DCHECK_GE(buffered_bytes_, current_bytes_); |
| 271 base::TimeDelta buffered_time = base::TimeDelta::FromMilliseconds( | 268 base::TimeDelta buffered_time = base::TimeDelta::FromMilliseconds( |
| 272 static_cast<int64>(estimated_rate * (buffered_bytes_ - current_bytes_) + | 269 static_cast<int64>(estimated_rate * (buffered_bytes_ - current_bytes_) + |
| 273 estimated_current_time)); | 270 estimated_current_time)); |
| 274 | 271 |
| 275 // Cap approximated buffered time at the length of the video. | 272 // Cap approximated buffered time at the length of the video. |
| 276 buffered_time = std::min(buffered_time, duration_); | 273 buffered_time = std::min(buffered_time, clock_->media_duration()); |
| 277 | 274 |
| 278 // Make sure buffered_time is at least the current time | 275 // Make sure buffered_time is at least the current time |
| 279 buffered_time = std::max(buffered_time, current_time); | 276 buffered_time = std::max(buffered_time, current_time); |
| 280 | 277 |
| 281 // Only print the max buffered time for smooth buffering. | 278 // Only print the max buffered time for smooth buffering. |
| 282 max_buffered_time_ = std::max(buffered_time, max_buffered_time_); | 279 max_buffered_time_ = std::max(buffered_time, max_buffered_time_); |
| 283 | 280 |
| 284 return max_buffered_time_; | 281 return max_buffered_time_; |
| 285 } | 282 } |
| 286 | 283 |
| 287 base::TimeDelta PipelineImpl::GetMediaDuration() const { | 284 base::TimeDelta PipelineImpl::GetMediaDuration() const { |
| 288 base::AutoLock auto_lock(lock_); | 285 base::AutoLock auto_lock(lock_); |
| 289 return duration_; | 286 return clock_->media_duration(); |
| 290 } | 287 } |
| 291 | 288 |
| 292 int64 PipelineImpl::GetBufferedBytes() const { | 289 int64 PipelineImpl::GetBufferedBytes() const { |
| 293 base::AutoLock auto_lock(lock_); | 290 base::AutoLock auto_lock(lock_); |
| 294 return buffered_bytes_; | 291 return buffered_bytes_; |
| 295 } | 292 } |
| 296 | 293 |
| 297 int64 PipelineImpl::GetTotalBytes() const { | 294 int64 PipelineImpl::GetTotalBytes() const { |
| 298 base::AutoLock auto_lock(lock_); | 295 base::AutoLock auto_lock(lock_); |
| 299 return total_bytes_; | 296 return total_bytes_; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 | 337 |
| 341 void PipelineImpl::ResetState() { | 338 void PipelineImpl::ResetState() { |
| 342 base::AutoLock auto_lock(lock_); | 339 base::AutoLock auto_lock(lock_); |
| 343 const base::TimeDelta kZero; | 340 const base::TimeDelta kZero; |
| 344 running_ = false; | 341 running_ = false; |
| 345 stop_pending_ = false; | 342 stop_pending_ = false; |
| 346 seek_pending_ = false; | 343 seek_pending_ = false; |
| 347 tearing_down_ = false; | 344 tearing_down_ = false; |
| 348 error_caused_teardown_ = false; | 345 error_caused_teardown_ = false; |
| 349 playback_rate_change_pending_ = false; | 346 playback_rate_change_pending_ = false; |
| 350 duration_ = kZero; | 347 clock_->set_media_duration(kZero); |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
Replace this and the call below with a clock_->Res
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
| |
| 351 buffered_time_ = kZero; | 348 buffered_time_ = kZero; |
| 352 buffered_bytes_ = 0; | 349 buffered_bytes_ = 0; |
| 353 streaming_ = false; | 350 streaming_ = false; |
| 354 local_source_ = false; | 351 local_source_ = false; |
| 355 total_bytes_ = 0; | 352 total_bytes_ = 0; |
| 356 natural_size_.SetSize(0, 0); | 353 natural_size_.SetSize(0, 0); |
| 357 volume_ = 1.0f; | 354 volume_ = 1.0f; |
| 358 preload_ = AUTO; | 355 preload_ = AUTO; |
| 359 playback_rate_ = 0.0f; | 356 playback_rate_ = 0.0f; |
| 360 pending_playback_rate_ = 0.0f; | 357 pending_playback_rate_ = 0.0f; |
| 361 status_ = PIPELINE_OK; | 358 status_ = PIPELINE_OK; |
| 362 has_audio_ = false; | 359 has_audio_ = false; |
| 363 has_video_ = false; | 360 has_video_ = false; |
| 364 waiting_for_clock_update_ = false; | 361 waiting_for_clock_update_ = false; |
| 365 audio_disabled_ = false; | 362 audio_disabled_ = false; |
| 366 clock_->SetTime(kZero); | 363 clock_->SetTime(kZero, kZero); |
| 367 download_rate_monitor_.Reset(); | 364 download_rate_monitor_.Reset(); |
| 368 } | 365 } |
| 369 | 366 |
| 370 void PipelineImpl::SetState(State next_state) { | 367 void PipelineImpl::SetState(State next_state) { |
| 371 if (state_ != kStarted && next_state == kStarted && | 368 if (state_ != kStarted && next_state == kStarted && |
| 372 !creation_time_.is_null()) { | 369 !creation_time_.is_null()) { |
| 373 UMA_HISTOGRAM_TIMES( | 370 UMA_HISTOGRAM_TIMES( |
| 374 "Media.TimeToPipelineStarted", base::Time::Now() - creation_time_); | 371 "Media.TimeToPipelineStarted", base::Time::Now() - creation_time_); |
| 375 creation_time_ = base::Time(); | 372 creation_time_ = base::Time(); |
| 376 } | 373 } |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 468 base::TimeDelta PipelineImpl::GetTime() const { | 465 base::TimeDelta PipelineImpl::GetTime() const { |
| 469 DCHECK(IsRunning()); | 466 DCHECK(IsRunning()); |
| 470 return GetCurrentTime(); | 467 return GetCurrentTime(); |
| 471 } | 468 } |
| 472 | 469 |
| 473 base::TimeDelta PipelineImpl::GetDuration() const { | 470 base::TimeDelta PipelineImpl::GetDuration() const { |
| 474 DCHECK(IsRunning()); | 471 DCHECK(IsRunning()); |
| 475 return GetMediaDuration(); | 472 return GetMediaDuration(); |
| 476 } | 473 } |
| 477 | 474 |
| 478 void PipelineImpl::SetTime(base::TimeDelta time) { | 475 void PipelineImpl::OnAudioTimeUpdate(base::TimeDelta time, |
| 476 base::TimeDelta max_time) { | |
| 477 DCHECK(time <= max_time); | |
| 479 DCHECK(IsRunning()); | 478 DCHECK(IsRunning()); |
| 480 base::AutoLock auto_lock(lock_); | 479 base::AutoLock auto_lock(lock_); |
| 481 | 480 |
| 482 // If we were waiting for a valid timestamp and such timestamp arrives, we | 481 if (!has_audio_) |
| 483 // need to clear the flag for waiting and start the clock. | |
| 484 if (waiting_for_clock_update_) { | |
| 485 if (time < clock_->Elapsed()) | |
| 486 return; | |
| 487 clock_->SetTime(time); | |
| 488 StartClockIfWaitingForTimeUpdate_Locked(); | |
| 489 return; | 482 return; |
| 490 } | 483 if (waiting_for_clock_update_ && time < clock_->Elapsed()) |
| 491 clock_->SetTime(time); | 484 return; |
| 485 | |
| 486 clock_->SetTime(time, max_time); | |
| 487 StartClockIfWaitingForTimeUpdate_Locked(); | |
| 488 } | |
| 489 | |
| 490 void PipelineImpl::OnVideoTimeUpdate(base::TimeDelta max_time) { | |
| 491 DCHECK(IsRunning()); | |
| 492 base::AutoLock auto_lock(lock_); | |
| 493 | |
| 494 if (has_audio_) | |
| 495 return; | |
| 496 | |
| 497 DCHECK(!waiting_for_clock_update_); | |
| 498 DCHECK(clock_->Elapsed() >= max_time); | |
| 499 clock_->set_max_time(max_time); | |
| 492 } | 500 } |
| 493 | 501 |
| 494 void PipelineImpl::SetDuration(base::TimeDelta duration) { | 502 void PipelineImpl::SetDuration(base::TimeDelta duration) { |
| 495 DCHECK(IsRunning()); | 503 DCHECK(IsRunning()); |
| 496 media_log_->AddEvent( | 504 media_log_->AddEvent( |
| 497 media_log_->CreateTimeEvent( | 505 media_log_->CreateTimeEvent( |
| 498 MediaLogEvent::DURATION_SET, "duration", duration)); | 506 MediaLogEvent::DURATION_SET, "duration", duration)); |
| 499 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration); | 507 UMA_HISTOGRAM_LONG_TIMES("Media.Duration", duration); |
| 500 | 508 |
| 501 base::AutoLock auto_lock(lock_); | 509 base::AutoLock auto_lock(lock_); |
| 502 duration_ = duration; | 510 clock_->set_media_duration(duration); |
| 503 } | 511 } |
| 504 | 512 |
| 505 void PipelineImpl::SetBufferedTime(base::TimeDelta buffered_time) { | 513 void PipelineImpl::SetBufferedTime(base::TimeDelta buffered_time) { |
| 506 DCHECK(IsRunning()); | 514 DCHECK(IsRunning()); |
| 507 base::AutoLock auto_lock(lock_); | 515 base::AutoLock auto_lock(lock_); |
| 508 buffered_time_ = buffered_time; | 516 buffered_time_ = buffered_time; |
| 509 } | 517 } |
| 510 | 518 |
| 511 void PipelineImpl::SetTotalBytes(int64 total_bytes) { | 519 void PipelineImpl::SetTotalBytes(int64 total_bytes) { |
| 512 DCHECK(IsRunning()); | 520 DCHECK(IsRunning()); |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 885 // We'll need to pause every filter before seeking. The state transition | 893 // We'll need to pause every filter before seeking. The state transition |
| 886 // is as follows: | 894 // is as follows: |
| 887 // kStarted/kEnded | 895 // kStarted/kEnded |
| 888 // kPausing (for each filter) | 896 // kPausing (for each filter) |
| 889 // kSeeking (for each filter) | 897 // kSeeking (for each filter) |
| 890 // kStarting (for each filter) | 898 // kStarting (for each filter) |
| 891 // kStarted | 899 // kStarted |
| 892 SetState(kPausing); | 900 SetState(kPausing); |
| 893 seek_timestamp_ = time; | 901 seek_timestamp_ = time; |
| 894 seek_callback_ = seek_callback; | 902 seek_callback_ = seek_callback; |
| 903 clock_->set_max_time(seek_timestamp_); | |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
I'm pretty sure this needs to be inside the locked
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
I believe the reason why I did this was to prevent
| |
| 895 | 904 |
| 896 // Kick off seeking! | 905 // Kick off seeking! |
| 897 { | 906 { |
| 898 base::AutoLock auto_lock(lock_); | 907 base::AutoLock auto_lock(lock_); |
| 899 if (clock_->IsPlaying()) | 908 if (clock_->IsPlaying()) |
| 900 clock_->Pause(); | 909 clock_->Pause(); |
| 901 } | 910 } |
| 902 pipeline_filter_->Pause( | 911 pipeline_filter_->Pause( |
| 903 base::Bind(&PipelineImpl::OnFilterStateTransition, this)); | 912 base::Bind(&PipelineImpl::OnFilterStateTransition, this)); |
| 904 } | 913 } |
| (...skipping 22 matching lines...) Expand all Loading... | |
| 927 | 936 |
| 928 if (video_renderer_ && !video_renderer_->HasEnded()) { | 937 if (video_renderer_ && !video_renderer_->HasEnded()) { |
| 929 return; | 938 return; |
| 930 } | 939 } |
| 931 | 940 |
| 932 // Transition to ended, executing the callback if present. | 941 // Transition to ended, executing the callback if present. |
| 933 SetState(kEnded); | 942 SetState(kEnded); |
| 934 { | 943 { |
| 935 base::AutoLock auto_lock(lock_); | 944 base::AutoLock auto_lock(lock_); |
| 936 clock_->Pause(); | 945 clock_->Pause(); |
| 937 clock_->SetTime(duration_); | 946 clock_->SetTime(clock_->media_duration(), clock_->media_duration()); |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
How about clock_->EndOfStream() or something simil
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
| |
| 938 } | 947 } |
| 939 | 948 |
| 940 if (!ended_callback_.is_null()) { | 949 if (!ended_callback_.is_null()) { |
| 941 ended_callback_.Run(status_); | 950 ended_callback_.Run(status_); |
| 942 } | 951 } |
| 943 } | 952 } |
| 944 | 953 |
| 945 void PipelineImpl::NotifyNetworkEventTask(NetworkEvent type) { | 954 void PipelineImpl::NotifyNetworkEventTask(NetworkEvent type) { |
| 946 DCHECK_EQ(MessageLoop::current(), message_loop_); | 955 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 947 if (!network_callback_.is_null()) | 956 if (!network_callback_.is_null()) |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 987 NOTREACHED() << "Invalid current state: " << state_; | 996 NOTREACHED() << "Invalid current state: " << state_; |
| 988 SetError(PIPELINE_ERROR_ABORT); | 997 SetError(PIPELINE_ERROR_ABORT); |
| 989 return; | 998 return; |
| 990 } | 999 } |
| 991 | 1000 |
| 992 // Decrement the number of remaining transitions, making sure to transition | 1001 // Decrement the number of remaining transitions, making sure to transition |
| 993 // to the next state if needed. | 1002 // to the next state if needed. |
| 994 SetState(FindNextState(state_)); | 1003 SetState(FindNextState(state_)); |
| 995 if (state_ == kSeeking) { | 1004 if (state_ == kSeeking) { |
| 996 base::AutoLock auto_lock(lock_); | 1005 base::AutoLock auto_lock(lock_); |
| 997 clock_->SetTime(seek_timestamp_); | 1006 clock_->SetTime(seek_timestamp_, seek_timestamp_); |
| 998 } | 1007 } |
| 999 | 1008 |
| 1000 // Carry out the action for the current state. | 1009 // Carry out the action for the current state. |
| 1001 if (TransientState(state_)) { | 1010 if (TransientState(state_)) { |
| 1002 if (state_ == kPausing) { | 1011 if (state_ == kPausing) { |
| 1003 pipeline_filter_->Pause( | 1012 pipeline_filter_->Pause( |
| 1004 base::Bind(&PipelineImpl::OnFilterStateTransition, this)); | 1013 base::Bind(&PipelineImpl::OnFilterStateTransition, this)); |
| 1005 } else if (state_ == kFlushing) { | 1014 } else if (state_ == kFlushing) { |
| 1006 pipeline_filter_->Flush( | 1015 pipeline_filter_->Flush( |
| 1007 base::Bind(&PipelineImpl::OnFilterStateTransition, this)); | 1016 base::Bind(&PipelineImpl::OnFilterStateTransition, this)); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1026 // the seek has compelted. | 1035 // the seek has compelted. |
| 1027 if (playback_rate_change_pending_) { | 1036 if (playback_rate_change_pending_) { |
| 1028 playback_rate_change_pending_ = false; | 1037 playback_rate_change_pending_ = false; |
| 1029 PlaybackRateChangedTask(pending_playback_rate_); | 1038 PlaybackRateChangedTask(pending_playback_rate_); |
| 1030 } | 1039 } |
| 1031 | 1040 |
| 1032 base::AutoLock auto_lock(lock_); | 1041 base::AutoLock auto_lock(lock_); |
| 1033 // We use audio stream to update the clock. So if there is such a stream, | 1042 // We use audio stream to update the clock. So if there is such a stream, |
| 1034 // we pause the clock until we receive a valid timestamp. | 1043 // we pause the clock until we receive a valid timestamp. |
| 1035 waiting_for_clock_update_ = true; | 1044 waiting_for_clock_update_ = true; |
| 1036 if (!has_audio_) | 1045 if (!has_audio_) { |
| 1046 clock_->set_max_time(clock_->media_duration()); | |
| 1037 StartClockIfWaitingForTimeUpdate_Locked(); | 1047 StartClockIfWaitingForTimeUpdate_Locked(); |
| 1048 } | |
| 1038 | 1049 |
| 1039 // Start monitoring rate of downloading. | 1050 // Start monitoring rate of downloading. |
| 1040 int bitrate = 0; | 1051 int bitrate = 0; |
| 1041 if (demuxer_.get()) { | 1052 if (demuxer_.get()) { |
| 1042 bitrate = demuxer_->GetBitrate(); | 1053 bitrate = demuxer_->GetBitrate(); |
| 1043 local_source_ = demuxer_->IsLocalSource(); | 1054 local_source_ = demuxer_->IsLocalSource(); |
| 1044 streaming_ = !demuxer_->IsSeekable(); | 1055 streaming_ = !demuxer_->IsSeekable(); |
| 1045 } | 1056 } |
| 1046 // Needs to be locked because most other calls to |download_rate_monitor_| | 1057 // Needs to be locked because most other calls to |download_rate_monitor_| |
| 1047 // occur on the renderer thread. | 1058 // occur on the renderer thread. |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1158 return; | 1169 return; |
| 1159 } | 1170 } |
| 1160 | 1171 |
| 1161 demuxer_ = demuxer; | 1172 demuxer_ = demuxer; |
| 1162 demuxer_->set_host(this); | 1173 demuxer_->set_host(this); |
| 1163 | 1174 |
| 1164 { | 1175 { |
| 1165 base::AutoLock auto_lock(lock_); | 1176 base::AutoLock auto_lock(lock_); |
| 1166 // We do not want to start the clock running. We only want to set the base | 1177 // We do not want to start the clock running. We only want to set the base |
| 1167 // media time so our timestamp calculations will be correct. | 1178 // media time so our timestamp calculations will be correct. |
| 1168 clock_->SetTime(demuxer_->GetStartTime()); | 1179 clock_->SetTime(demuxer_->GetStartTime(), clock_->media_duration()); |
|
acolwell GONE FROM CHROMIUM
2012/01/13 22:51:21
I think we might want to use demuxer_->GetStartTim
vrk (LEFT CHROMIUM)
2012/01/21 00:54:14
Done.
| |
| 1169 } | 1180 } |
| 1170 | 1181 |
| 1171 OnFilterInitialize(PIPELINE_OK); | 1182 OnFilterInitialize(PIPELINE_OK); |
| 1172 } | 1183 } |
| 1173 | 1184 |
| 1174 bool PipelineImpl::InitializeAudioDecoder( | 1185 bool PipelineImpl::InitializeAudioDecoder( |
| 1175 const scoped_refptr<Demuxer>& demuxer) { | 1186 const scoped_refptr<Demuxer>& demuxer) { |
| 1176 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1187 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 1177 DCHECK(IsPipelineOk()); | 1188 DCHECK(IsPipelineOk()); |
| 1178 | 1189 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1247 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); | 1258 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); |
| 1248 return false; | 1259 return false; |
| 1249 } | 1260 } |
| 1250 | 1261 |
| 1251 if (!PrepareFilter(audio_renderer_)) | 1262 if (!PrepareFilter(audio_renderer_)) |
| 1252 return false; | 1263 return false; |
| 1253 | 1264 |
| 1254 audio_renderer_->Initialize( | 1265 audio_renderer_->Initialize( |
| 1255 decoder, | 1266 decoder, |
| 1256 base::Bind(&PipelineImpl::OnFilterInitialize, this, PIPELINE_OK), | 1267 base::Bind(&PipelineImpl::OnFilterInitialize, this, PIPELINE_OK), |
| 1257 base::Bind(&PipelineImpl::OnAudioUnderflow, this)); | 1268 base::Bind(&PipelineImpl::OnAudioUnderflow, this), |
| 1269 base::Bind(&PipelineImpl::OnAudioTimeUpdate, this)); | |
| 1270 | |
| 1258 return true; | 1271 return true; |
| 1259 } | 1272 } |
| 1260 | 1273 |
| 1261 bool PipelineImpl::InitializeVideoRenderer( | 1274 bool PipelineImpl::InitializeVideoRenderer( |
| 1262 const scoped_refptr<VideoDecoder>& decoder) { | 1275 const scoped_refptr<VideoDecoder>& decoder) { |
| 1263 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1276 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 1264 DCHECK(IsPipelineOk()); | 1277 DCHECK(IsPipelineOk()); |
| 1265 | 1278 |
| 1266 if (!decoder) | 1279 if (!decoder) |
| 1267 return false; | 1280 return false; |
| 1268 | 1281 |
| 1269 filter_collection_->SelectVideoRenderer(&video_renderer_); | 1282 filter_collection_->SelectVideoRenderer(&video_renderer_); |
| 1270 if (!video_renderer_) { | 1283 if (!video_renderer_) { |
| 1271 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); | 1284 SetError(PIPELINE_ERROR_REQUIRED_FILTER_MISSING); |
| 1272 return false; | 1285 return false; |
| 1273 } | 1286 } |
| 1274 | 1287 |
| 1275 if (!PrepareFilter(video_renderer_)) | 1288 if (!PrepareFilter(video_renderer_)) |
| 1276 return false; | 1289 return false; |
| 1277 | 1290 |
| 1278 video_renderer_->Initialize( | 1291 video_renderer_->Initialize( |
| 1279 decoder, | 1292 decoder, |
| 1280 base::Bind(&PipelineImpl::OnFilterInitialize, this, PIPELINE_OK), | 1293 base::Bind(&PipelineImpl::OnFilterInitialize, this, PIPELINE_OK), |
| 1281 base::Bind(&PipelineImpl::OnUpdateStatistics, this)); | 1294 base::Bind(&PipelineImpl::OnUpdateStatistics, this), |
| 1295 base::Bind(&PipelineImpl::OnVideoTimeUpdate, this)); | |
| 1282 return true; | 1296 return true; |
| 1283 } | 1297 } |
| 1284 | 1298 |
| 1285 void PipelineImpl::TearDownPipeline() { | 1299 void PipelineImpl::TearDownPipeline() { |
| 1286 DCHECK_EQ(MessageLoop::current(), message_loop_); | 1300 DCHECK_EQ(MessageLoop::current(), message_loop_); |
| 1287 DCHECK_NE(kStopped, state_); | 1301 DCHECK_NE(kStopped, state_); |
| 1288 | 1302 |
| 1289 DCHECK(!tearing_down_ || // Teardown on Stop(). | 1303 DCHECK(!tearing_down_ || // Teardown on Stop(). |
| 1290 (tearing_down_ && error_caused_teardown_) || // Teardown on error. | 1304 (tearing_down_ && error_caused_teardown_) || // Teardown on error. |
| 1291 (tearing_down_ && stop_pending_)); // Stop during teardown by error. | 1305 (tearing_down_ && stop_pending_)); // Stop during teardown by error. |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1436 void PipelineImpl::StartClockIfWaitingForTimeUpdate_Locked() { | 1450 void PipelineImpl::StartClockIfWaitingForTimeUpdate_Locked() { |
| 1437 lock_.AssertAcquired(); | 1451 lock_.AssertAcquired(); |
| 1438 if (!waiting_for_clock_update_) | 1452 if (!waiting_for_clock_update_) |
| 1439 return; | 1453 return; |
| 1440 | 1454 |
| 1441 waiting_for_clock_update_ = false; | 1455 waiting_for_clock_update_ = false; |
| 1442 clock_->Play(); | 1456 clock_->Play(); |
| 1443 } | 1457 } |
| 1444 | 1458 |
| 1445 } // namespace media | 1459 } // namespace media |
| OLD | NEW |