Chromium Code Reviews| Index: media/cast/audio_receiver/audio_decoder.cc |
| diff --git a/media/cast/audio_receiver/audio_decoder.cc b/media/cast/audio_receiver/audio_decoder.cc |
| index b140788fe04887c406a6b05095420f516dac56c1..6e674861da29bb0e8d4a9415fe2b268271bde292 100644 |
| --- a/media/cast/audio_receiver/audio_decoder.cc |
| +++ b/media/cast/audio_receiver/audio_decoder.cc |
| @@ -52,7 +52,12 @@ bool AudioDecoder::GetRawAudioFrame(int number_of_10ms_blocks, |
| int desired_frequency, |
| PcmAudioFrame* audio_frame, |
| uint32* rtp_timestamp) { |
| - if (!have_received_packets_) return false; |
| + // Get a local copy under lock. |
|
Alpha Left Google
2013/11/22 20:03:53
Do you expect to have a race condition using the l
pwestin
2013/11/22 21:16:36
We don't care about the race where a thread ask fo
|
| + lock_.Acquire(); |
| + bool have_received_packets = have_received_packets_; |
| + lock_.Release(); |
| + |
| + if (!have_received_packets) return false; |
| audio_frame->samples.clear(); |
| @@ -92,7 +97,10 @@ void AudioDecoder::IncomingParsedRtpPacket(const uint8* payload_data, |
| DCHECK_LE(payload_size, kIpPacketSize); |
| audio_decoder_->IncomingPacket(payload_data, static_cast<int32>(payload_size), |
| rtp_header.webrtc); |
| + |
| + lock_.Acquire(); |
| have_received_packets_ = true; |
| + lock_.Release(); |
| } |
| } // namespace cast |