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

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: Build fix. Rebase. 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 12d102c4ad196911c9ddfb7430e60da7ca99093b..e618b3b5242f41ee4838137099788cf36ec1ad4c 100644
--- a/media/audio/audio_output_device.cc
+++ b/media/audio/audio_output_device.cc
@@ -41,6 +41,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_;
@@ -154,6 +158,13 @@ OutputDeviceInfo AudioOutputDevice::GetOutputDeviceInfo() {
device_status_, output_params_);
}
+bool AudioOutputDevice::CurrentThreadIsRenderingThread() {
+ // Since this function is supposed to be called on the rendering thread,
+ // 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);
@@ -477,4 +488,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