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

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

Issue 1094783002: Switch to double for time calculations using playback rate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Making changes at chromecast side to fix trybots Created 5 years, 8 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.h ('k') | media/base/pipeline_unittest.cc » ('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) 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 19 matching lines...) Expand all
30 namespace media { 30 namespace media {
31 31
32 Pipeline::Pipeline( 32 Pipeline::Pipeline(
33 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner, 33 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner,
34 MediaLog* media_log) 34 MediaLog* media_log)
35 : task_runner_(task_runner), 35 : task_runner_(task_runner),
36 media_log_(media_log), 36 media_log_(media_log),
37 running_(false), 37 running_(false),
38 did_loading_progress_(false), 38 did_loading_progress_(false),
39 volume_(1.0f), 39 volume_(1.0f),
40 playback_rate_(0.0f), 40 playback_rate_(0.0),
41 status_(PIPELINE_OK), 41 status_(PIPELINE_OK),
42 state_(kCreated), 42 state_(kCreated),
43 renderer_ended_(false), 43 renderer_ended_(false),
44 text_renderer_ended_(false), 44 text_renderer_ended_(false),
45 demuxer_(NULL), 45 demuxer_(NULL),
46 pending_cdm_context_(nullptr), 46 pending_cdm_context_(nullptr),
47 weak_factory_(this) { 47 weak_factory_(this) {
48 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated)); 48 media_log_->AddEvent(media_log_->CreatePipelineStateChangedEvent(kCreated));
49 media_log_->AddEvent( 49 media_log_->AddEvent(
50 media_log_->CreateEvent(MediaLogEvent::PIPELINE_CREATED)); 50 media_log_->CreateEvent(MediaLogEvent::PIPELINE_CREATED));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 FROM_HERE, 117 FROM_HERE,
118 base::Bind( 118 base::Bind(
119 &Pipeline::SeekTask, weak_factory_.GetWeakPtr(), time, seek_cb)); 119 &Pipeline::SeekTask, weak_factory_.GetWeakPtr(), time, seek_cb));
120 } 120 }
121 121
122 bool Pipeline::IsRunning() const { 122 bool Pipeline::IsRunning() const {
123 base::AutoLock auto_lock(lock_); 123 base::AutoLock auto_lock(lock_);
124 return running_; 124 return running_;
125 } 125 }
126 126
127 float Pipeline::GetPlaybackRate() const { 127 double Pipeline::GetPlaybackRate() const {
128 base::AutoLock auto_lock(lock_); 128 base::AutoLock auto_lock(lock_);
129 return playback_rate_; 129 return playback_rate_;
130 } 130 }
131 131
132 void Pipeline::SetPlaybackRate(float playback_rate) { 132 void Pipeline::SetPlaybackRate(double playback_rate) {
133 if (playback_rate < 0.0f) 133 if (playback_rate < 0.0)
134 return; 134 return;
135 135
136 base::AutoLock auto_lock(lock_); 136 base::AutoLock auto_lock(lock_);
137 playback_rate_ = playback_rate; 137 playback_rate_ = playback_rate;
138 if (running_) { 138 if (running_) {
139 task_runner_->PostTask(FROM_HERE, 139 task_runner_->PostTask(FROM_HERE,
140 base::Bind(&Pipeline::PlaybackRateChangedTask, 140 base::Bind(&Pipeline::PlaybackRateChangedTask,
141 weak_factory_.GetWeakPtr(), 141 weak_factory_.GetWeakPtr(),
142 playback_rate)); 142 playback_rate));
143 } 143 }
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 if (state_ == kStopping || state_ == kStopped) 548 if (state_ == kStopping || state_ == kStopped)
549 return; 549 return;
550 550
551 SetState(kStopping); 551 SetState(kStopping);
552 pending_callbacks_.reset(); 552 pending_callbacks_.reset();
553 status_ = error; 553 status_ = error;
554 554
555 DoStop(base::Bind(&Pipeline::OnStopCompleted, weak_factory_.GetWeakPtr())); 555 DoStop(base::Bind(&Pipeline::OnStopCompleted, weak_factory_.GetWeakPtr()));
556 } 556 }
557 557
558 void Pipeline::PlaybackRateChangedTask(float playback_rate) { 558 void Pipeline::PlaybackRateChangedTask(double playback_rate) {
559 DCHECK(task_runner_->BelongsToCurrentThread()); 559 DCHECK(task_runner_->BelongsToCurrentThread());
560 560
561 // Playback rate changes are only carried out while playing. 561 // Playback rate changes are only carried out while playing.
562 if (state_ != kPlaying) 562 if (state_ != kPlaying)
563 return; 563 return;
564 564
565 renderer_->SetPlaybackRate(playback_rate); 565 renderer_->SetPlaybackRate(playback_rate);
566 } 566 }
567 567
568 void Pipeline::VolumeChangedTask(float volume) { 568 void Pipeline::VolumeChangedTask(float volume) {
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 metadata_cb_.Run(metadata); 736 metadata_cb_.Run(metadata);
737 } 737 }
738 738
739 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) { 739 void Pipeline::BufferingStateChanged(BufferingState new_buffering_state) {
740 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") "; 740 DVLOG(1) << __FUNCTION__ << "(" << new_buffering_state << ") ";
741 DCHECK(task_runner_->BelongsToCurrentThread()); 741 DCHECK(task_runner_->BelongsToCurrentThread());
742 buffering_state_cb_.Run(new_buffering_state); 742 buffering_state_cb_.Run(new_buffering_state);
743 } 743 }
744 744
745 } // namespace media 745 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline.h ('k') | media/base/pipeline_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698