summaryrefslogtreecommitdiffstats
path: root/media/audio/mac
diff options
context:
space:
mode:
Diffstat (limited to 'media/audio/mac')
-rw-r--r--media/audio/mac/audio_input_mac.cc14
-rw-r--r--media/audio/mac/audio_input_mac.h2
2 files changed, 12 insertions, 4 deletions
diff --git a/media/audio/mac/audio_input_mac.cc b/media/audio/mac/audio_input_mac.cc
index 3f73c2e..eb6f167 100644
--- a/media/audio/mac/audio_input_mac.cc
+++ b/media/audio/mac/audio_input_mac.cc
@@ -21,7 +21,8 @@ PCMQueueInAudioInputStream::PCMQueueInAudioInputStream(
: manager_(manager),
callback_(NULL),
audio_queue_(NULL),
- buffer_size_bytes_(0) {
+ buffer_size_bytes_(0),
+ started_(false) {
// We must have a manager.
DCHECK(manager_);
// A frame is one sample across all channels. In interleaved audio the per
@@ -68,15 +69,18 @@ void PCMQueueInAudioInputStream::Start(AudioInputCallback* callback) {
return;
callback_ = callback;
OSStatus err = AudioQueueStart(audio_queue_, NULL);
- if (err != noErr)
+ if (err != noErr) {
HandleError(err);
- else
+ } else {
+ started_ = true;
manager_->IncreaseActiveInputStreamCount();
+ }
}
void PCMQueueInAudioInputStream::Stop() {
- if (!audio_queue_)
+ if (!audio_queue_ || !started_)
return;
+
// Stop is always called before Close. In case of error, this will be
// also called when closing the input controller.
manager_->DecreaseActiveInputStreamCount();
@@ -86,6 +90,8 @@ void PCMQueueInAudioInputStream::Stop() {
OSStatus err = AudioQueueStop(audio_queue_, true);
if (err != noErr)
HandleError(err);
+
+ started_ = false;
}
void PCMQueueInAudioInputStream::Close() {
diff --git a/media/audio/mac/audio_input_mac.h b/media/audio/mac/audio_input_mac.h
index 7569c36..26be177 100644
--- a/media/audio/mac/audio_input_mac.h
+++ b/media/audio/mac/audio_input_mac.h
@@ -67,6 +67,8 @@ class PCMQueueInAudioInputStream : public AudioInputStream {
AudioQueueRef audio_queue_;
// Size of each of the buffers in |audio_buffers_|
uint32 buffer_size_bytes_;
+ // True iff Start() has been called successfully.
+ bool started_;
DISALLOW_COPY_AND_ASSIGN(PCMQueueInAudioInputStream);
};