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

Side by Side Diff: components/copresence/mediums/audio/audio_player_impl.cc

Issue 704923002: Add polling and audio check to copresence. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/copresence/mediums/audio/audio_player_impl.h" 5 #include "components/copresence/mediums/audio/audio_player_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 { 103 {
104 base::AutoLock al(state_lock_); 104 base::AutoLock al(state_lock_);
105 105
106 samples_ = samples; 106 samples_ = samples;
107 frame_index_ = 0; 107 frame_index_ = 0;
108 108
109 if (is_playing_) 109 if (is_playing_)
110 return; 110 return;
111 } 111 }
112 112
113 VLOG(3) << "Starting playback.";
113 is_playing_ = true; 114 is_playing_ = true;
114 stream_->Start(this); 115 stream_->Start(this);
115 } 116 }
116 117
117 void AudioPlayerImpl::StopOnAudioThread() { 118 void AudioPlayerImpl::StopOnAudioThread() {
118 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); 119 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
119 if (!stream_) 120 if (!stream_)
120 return; 121 return;
121 122
123 VLOG(3) << "Stopping playback.";
122 stream_->Stop(); 124 stream_->Stop();
123 is_playing_ = false; 125 is_playing_ = false;
124 } 126 }
125 127
126 void AudioPlayerImpl::StopAndCloseOnAudioThread() { 128 void AudioPlayerImpl::StopAndCloseOnAudioThread() {
127 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread()); 129 DCHECK(media::AudioManager::Get()->GetTaskRunner()->BelongsToCurrentThread());
128 if (!stream_) 130 if (!stream_)
129 return; 131 return;
130 132
131 if (is_playing_) 133 if (is_playing_)
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 base::RunLoop rl; 181 base::RunLoop rl;
180 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply( 182 media::AudioManager::Get()->GetTaskRunner()->PostTaskAndReply(
181 FROM_HERE, 183 FROM_HERE,
182 base::Bind(base::IgnoreResult(&AudioPlayerImpl::FlushAudioLoopForTesting), 184 base::Bind(base::IgnoreResult(&AudioPlayerImpl::FlushAudioLoopForTesting),
183 base::Unretained(this)), 185 base::Unretained(this)),
184 rl.QuitClosure()); 186 rl.QuitClosure());
185 rl.Run(); 187 rl.Run();
186 } 188 }
187 189
188 } // namespace copresence 190 } // namespace copresence
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698