Chromium Code Reviews| Index: webrtc/audio/audio_receive_stream.cc |
| diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc |
| index 12b8b3f7ad568582c1fb45b912c328b7b74b2deb..ab06537562745e16c7dcc917ad5dd81fe6cf7018 100644 |
| --- a/webrtc/audio/audio_receive_stream.cc |
| +++ b/webrtc/audio/audio_receive_stream.cc |
| @@ -154,16 +154,42 @@ AudioReceiveStream::~AudioReceiveStream() { |
| } |
| void AudioReceiveStream::Start() { |
| - RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| + RTC_DCHECK_RUN_ON(&thread_checker_); |
|
the sun
2016/10/27 10:06:45
This is nice, but should all thread checking in th
aleloi
2016/11/01 15:17:34
I added an ACCESS_ON annotation on playout_. Now e
|
| + if (playing_) { |
|
ossu
2016/10/25 14:13:33
Is this fine or does it indicate a usage error?
I.
the sun
2016/10/27 10:06:45
Since this is going to be part of the public API I
aleloi
2016/11/01 15:17:34
webrtcvoiceengine runs Stop on everything in SetPl
|
| + return; |
| + } |
| + |
| ScopedVoEInterface<VoEBase> base(voice_engine()); |
| int error = base->StartPlayout(config_.voe_channel_id); |
| if (error != 0) { |
| LOG(LS_ERROR) << "AudioReceiveStream::Start failed with error: " << error; |
| + return; |
| + } |
| + |
| + playing_ = true; |
| + |
| + auto* const audio_state = |
|
the sun
2016/10/27 10:06:45
Make a class private method internal::AudioState*
aleloi
2016/11/01 15:17:34
That's a design tip from Scott Meyers! I read that
|
| + static_cast<internal::AudioState*>(audio_state_.get()); |
|
ossu
2016/10/25 14:13:33
I wonder about the cast here. I see it's being don
the sun
2016/10/27 10:06:45
AudioState is intended as (for clients of the Call
|
| + |
| + if (!audio_state->mixer()->AddSource(this)) { |
| + LOG(LS_ERROR) << "Failed to add source to mixer."; |
|
the sun
2016/10/27 10:06:45
Does that mean we're not actually playing and we s
aleloi
2016/11/01 15:17:35
Thanks! It's an error that is never supposed to ha
|
| } |
| } |
| void AudioReceiveStream::Stop() { |
| - RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| + RTC_DCHECK_RUN_ON(&thread_checker_); |
| + |
| + if (!playing_) { |
| + return; |
| + } |
| + playing_ = false; |
| + |
| + auto* const audio_state = |
| + static_cast<internal::AudioState*>(audio_state_.get()); |
| + if (!audio_state->mixer()->RemoveSource(this)) { |
|
the sun
2016/10/27 10:06:45
Uhm, sorry, I missed there was a return code for R
aleloi
2016/11/01 15:17:35
It's not too late to change! But why? Isn't it the
|
| + LOG(LS_ERROR) << "Failed to remove stream from mixer."; |
| + } |
| + |
| ScopedVoEInterface<VoEBase> base(voice_engine()); |
| base->StopPlayout(config_.voe_channel_id); |
| } |