| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |