Index: media/audio/audio_output_device.cc |
diff --git a/media/audio/audio_output_device.cc b/media/audio/audio_output_device.cc |
index a3effebfb43af118500197a6eed9a48093563f7d..b8b0da6477146f65b46fa25ad37dc151c6b1e75a 100644 |
--- a/media/audio/audio_output_device.cc |
+++ b/media/audio/audio_output_device.cc |
@@ -39,6 +39,10 @@ class AudioOutputDevice::AudioThreadCallback |
// Called whenever we receive notifications about pending data. |
void Process(uint32_t pending_data) override; |
+ // Returns whether the current thread is the audio device thread or not. |
+ // Will always return true if DCHECKs are not enabled. |
+ bool CurrentThreadIsAudioDeviceThread(); |
+ |
private: |
AudioRendererSink::RenderCallback* render_callback_; |
std::unique_ptr<AudioBus> output_bus_; |
@@ -150,6 +154,13 @@ OutputDeviceInfo AudioOutputDevice::GetOutputDeviceInfo() { |
device_status_, output_params_); |
} |
+bool AudioOutputDevice::CurrentThreadIsRenderingThread() { |
+ // Since this function is supposed to be called on the rendering thread, |
DaleCurtis
2016/06/14 17:07:49
Hmm, seems like this should have a DCHECK(CurrentT
Henrik Grunell
2016/06/14 19:33:41
Yes, a failure could be confusing if that happens.
DaleCurtis
2016/06/14 20:07:16
I'd just add some text to the DCHECK() on the audi
Henrik Grunell
2016/06/15 07:17:54
Done.
|
+ // it's safe to access |audio_callback_| here. It will always be valid when |
+ // the rendering thread is running. |
+ return audio_callback_->CurrentThreadIsAudioDeviceThread(); |
+} |
+ |
void AudioOutputDevice::RequestDeviceAuthorizationOnIOThread() { |
DCHECK(task_runner()->BelongsToCurrentThread()); |
DCHECK_EQ(state_, IDLE); |
@@ -450,4 +461,9 @@ void AudioOutputDevice::AudioThreadCallback::Process(uint32_t pending_data) { |
frames_skipped); |
} |
+bool AudioOutputDevice::AudioThreadCallback:: |
+ CurrentThreadIsAudioDeviceThread() { |
+ return thread_checker_.CalledOnValidThread(); |
+} |
+ |
} // namespace media |