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

Unified Diff: media/audio/audio_output_device.cc

Issue 2038053002: Change audio render thread checking to use new AudioRendererSink::BelongsToRendererThread() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review (tommi@). Created 4 years, 6 months 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698