Skip to content

Commit

Permalink
ao: use audioqueue volume control
Browse files Browse the repository at this point in the history
tested on macOS
  • Loading branch information
wang-bin committed Jul 27, 2016
1 parent 09e6e40 commit 3c2c197
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/output/audio/AudioOutputAudioToolbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class AudioOutputAudioToolbox Q_DECL_FINAL: public AudioOutputBackend
void onCallback() Q_DECL_OVERRIDE;
bool write(const QByteArray& data) Q_DECL_OVERRIDE;
bool play() Q_DECL_OVERRIDE;
bool setVolume(qreal value) override;
private:
static void outCallback(void* inUserData, AudioQueueRef inAQ, AudioQueueBufferRef inBuffer);
void tryPauseTimeline();
Expand Down Expand Up @@ -123,6 +124,7 @@ void AudioOutputAudioToolbox::outCallback(void* inUserData, AudioQueueRef inAQ,

AudioOutputAudioToolbox::AudioOutputAudioToolbox(QObject *parent)
: AudioOutputBackend(AudioOutput::DeviceFeatures()
|AudioOutput::SetVolume
, parent)
, m_queue(NULL)
, m_waiting(false)
Expand Down Expand Up @@ -224,4 +226,11 @@ bool AudioOutputAudioToolbox::play()
AT_ENSURE(AudioQueueStart(m_queue, NULL), false);
return true;
}

bool AudioOutputAudioToolbox::setVolume(qreal value)
{
// iOS document says the range is [0,1]. But >1.0 works on macOS. So no manually check range here
AT_ENSURE(AudioQueueSetParameter(m_queue, kAudioQueueParam_Volume, value), false);
return true;
}
} //namespace QtAV

0 comments on commit 3c2c197

Please sign in to comment.