summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authortommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 21:07:25 +0000
committertommi@chromium.org <tommi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-15 21:07:25 +0000
commit94ad15f3b66c2f05747bf987ca1e4475f4a4ea3e (patch)
tree3704c6bb0ec24aae4e1a6187367f54353603506f /media
parentdbc54d55d144471b4cbac05d0b45f9bf9e19415c (diff)
downloadchromium_src-94ad15f3b66c2f05747bf987ca1e4475f4a4ea3e.zip
chromium_src-94ad15f3b66c2f05747bf987ca1e4475f4a4ea3e.tar.gz
chromium_src-94ad15f3b66c2f05747bf987ca1e4475f4a4ea3e.tar.bz2
Update DCHECKs in AlsaPcmOutputStream to account for NULL message loop.
TBR=xians Review URL: https://chromiumcodereview.appspot.com/9403027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@122146 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/linux/alsa_output.cc33
-rw-r--r--media/audio/linux/alsa_output.h4
2 files changed, 23 insertions, 14 deletions
diff --git a/media/audio/linux/alsa_output.cc b/media/audio/linux/alsa_output.cc
index 0cc5280..0cd2d0c 100644
--- a/media/audio/linux/alsa_output.cc
+++ b/media/audio/linux/alsa_output.cc
@@ -204,7 +204,7 @@ AlsaPcmOutputStream::AlsaPcmOutputStream(const std::string& device_name,
state_(kCreated),
volume_(1.0f),
source_callback_(NULL) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
// Sanity check input values.
if ((params.sample_rate > kAlsaMaxSampleRate) || (params.sample_rate <= 0)) {
@@ -233,7 +233,7 @@ AlsaPcmOutputStream::~AlsaPcmOutputStream() {
}
bool AlsaPcmOutputStream::Open() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
if (state() == kInError)
return false;
@@ -293,7 +293,7 @@ bool AlsaPcmOutputStream::Open() {
}
void AlsaPcmOutputStream::Close() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
// Sanity check that the transition occurs correctly. It is safe to
// continue anyways because all operations for closing are idempotent.
@@ -322,7 +322,7 @@ void AlsaPcmOutputStream::Close() {
}
void AlsaPcmOutputStream::Start(AudioSourceCallback* callback) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
CHECK(callback);
@@ -361,7 +361,7 @@ void AlsaPcmOutputStream::Start(AudioSourceCallback* callback) {
}
void AlsaPcmOutputStream::Stop() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
// Reset the callback, so that it is not called anymore.
set_source_callback(NULL);
@@ -370,19 +370,19 @@ void AlsaPcmOutputStream::Stop() {
}
void AlsaPcmOutputStream::SetVolume(double volume) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
volume_ = static_cast<float>(volume);
}
void AlsaPcmOutputStream::GetVolume(double* volume) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
*volume = volume_;
}
void AlsaPcmOutputStream::BufferPacket(bool* source_exhausted) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
// If stopped, simulate a 0-length packet.
if (stop_stream_) {
@@ -473,7 +473,7 @@ void AlsaPcmOutputStream::BufferPacket(bool* source_exhausted) {
}
void AlsaPcmOutputStream::WritePacket() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
// If the device is in error, just eat the bytes.
if (stop_stream_) {
@@ -537,7 +537,7 @@ void AlsaPcmOutputStream::WritePacket() {
}
void AlsaPcmOutputStream::WriteTask() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
if (stop_stream_)
return;
@@ -553,7 +553,7 @@ void AlsaPcmOutputStream::WriteTask() {
}
void AlsaPcmOutputStream::ScheduleNextWrite(bool source_exhausted) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
if (stop_stream_)
return;
@@ -695,7 +695,7 @@ snd_pcm_sframes_t AlsaPcmOutputStream::GetCurrentDelay() {
}
snd_pcm_sframes_t AlsaPcmOutputStream::GetAvailableFrames() {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
if (stop_stream_)
return 0;
@@ -809,7 +809,7 @@ bool AlsaPcmOutputStream::CanTransitionTo(InternalState to) {
AlsaPcmOutputStream::InternalState
AlsaPcmOutputStream::TransitionTo(InternalState to) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
if (!CanTransitionTo(to)) {
NOTREACHED() << "Cannot transition from: " << state_ << " to: " << to;
@@ -824,6 +824,11 @@ AlsaPcmOutputStream::InternalState AlsaPcmOutputStream::state() {
return state_;
}
+bool AlsaPcmOutputStream::IsOnAudioThread() const {
+ return !manager_->GetMessageLoop() ||
+ manager_->GetMessageLoop()->BelongsToCurrentThread();
+}
+
uint32 AlsaPcmOutputStream::RunDataCallback(uint8* dest,
uint32 max_size,
AudioBuffersState buffers_state) {
@@ -843,6 +848,6 @@ void AlsaPcmOutputStream::RunErrorCallback(int code) {
// Changes the AudioSourceCallback to proxy calls to. Pass in NULL to
// release ownership of the currently registered callback.
void AlsaPcmOutputStream::set_source_callback(AudioSourceCallback* callback) {
- DCHECK(manager_->GetMessageLoop()->BelongsToCurrentThread());
+ DCHECK(IsOnAudioThread());
source_callback_ = callback;
}
diff --git a/media/audio/linux/alsa_output.h b/media/audio/linux/alsa_output.h
index 54d38a0..ee257eb 100644
--- a/media/audio/linux/alsa_output.h
+++ b/media/audio/linux/alsa_output.h
@@ -139,6 +139,10 @@ class MEDIA_EXPORT AlsaPcmOutputStream : public AudioOutputStream {
InternalState TransitionTo(InternalState to);
InternalState state();
+ // Returns true when we're on the audio thread or if the audio thread's
+ // message loop is NULL (which will happen during shutdown).
+ bool IsOnAudioThread() const;
+
// API for Proxying calls to the AudioSourceCallback provided during
// Start().
//