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

Side by Side Diff: media/audio/clockless_audio_sink.cc

Issue 292363005: Prevent media::ClocklessAudioSink from stopping already stopped threads. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
« no previous file with comments | « no previous file | 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/audio/clockless_audio_sink.h" 5 #include "media/audio/clockless_audio_sink.h"
6 6
7 #include "base/threading/simple_thread.h" 7 #include "base/threading/simple_thread.h"
8 #include "base/time/time.h" 8 #include "base/time/time.h"
9 #include "media/base/audio_renderer_sink.h" 9 #include "media/base/audio_renderer_sink.h"
10 10
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 ClocklessAudioSink::~ClocklessAudioSink() {} 66 ClocklessAudioSink::~ClocklessAudioSink() {}
67 67
68 void ClocklessAudioSink::Initialize(const AudioParameters& params, 68 void ClocklessAudioSink::Initialize(const AudioParameters& params,
69 RenderCallback* callback) { 69 RenderCallback* callback) {
70 DCHECK(!initialized_); 70 DCHECK(!initialized_);
71 thread_.reset(new ClocklessAudioSinkThread(params, callback)); 71 thread_.reset(new ClocklessAudioSinkThread(params, callback));
72 initialized_ = true; 72 initialized_ = true;
73 } 73 }
74 74
75 void ClocklessAudioSink::Start() { 75 void ClocklessAudioSink::Start() {
76 DCHECK(initialized_);
76 DCHECK(!playing_); 77 DCHECK(!playing_);
77 } 78 }
78 79
79 void ClocklessAudioSink::Stop() { 80 void ClocklessAudioSink::Stop() {
80 DCHECK(initialized_); 81 Pause();
81
82 if (!playing_)
83 return;
84
85 playback_time_ = thread_->Stop();
86 } 82 }
87 83
88 void ClocklessAudioSink::Play() { 84 void ClocklessAudioSink::Play() {
89 DCHECK(initialized_); 85 DCHECK(initialized_);
90 86
91 if (playing_) 87 if (playing_)
92 return; 88 return;
93 89
94 playing_ = true; 90 playing_ = true;
95 thread_->Start(); 91 thread_->Start();
96 } 92 }
97 93
98 void ClocklessAudioSink::Pause() { 94 void ClocklessAudioSink::Pause() {
99 Stop(); 95 DCHECK(initialized_);
96
97 if (!playing_)
98 return;
99
100 playing_ = false;
101 playback_time_ = thread_->Stop();
100 } 102 }
101 103
102 bool ClocklessAudioSink::SetVolume(double volume) { 104 bool ClocklessAudioSink::SetVolume(double volume) {
103 // Audio is always muted. 105 // Audio is always muted.
104 return volume == 0.0; 106 return volume == 0.0;
105 } 107 }
106 108
107 } // namespace media 109 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698