Skip to content

Commit

Permalink
ao: remove useless backend preferedSampleFormat/ChannelLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Jul 27, 2016
1 parent b61894f commit 7109347
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
11 changes: 0 additions & 11 deletions src/QtAV/private/AudioOutputBackend.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,6 @@ class Q_AV_PRIVATE_EXPORT AudioOutputBackend : public QObject
virtual bool isSupported(AudioFormat::SampleFormat f) const { return !AudioFormat::isPlanar(f);}
// 5, 6, 7 channels may not play
virtual bool isSupported(AudioFormat::ChannelLayout cl) const { return int(cl) < int(AudioFormat::ChannelLayout_Unsupported);}
/*!
* \brief preferredSampleFormat
* \return the preferred sample format. default is signed16 packed
* If the specified format is not supported, resample to preffered format
*/
virtual AudioFormat::SampleFormat preferredSampleFormat() const { return AudioFormat::SampleFormat_Signed16;}
/*!
* \brief preferredChannelLayout
* \return the preferred channel layout. default is stereo
*/
virtual AudioFormat::ChannelLayout preferredChannelLayout() const { return AudioFormat::ChannelLayout_Stereo;}
/*!
* \brief The BufferControl enum
* Used to adapt to different audio playback backend. Usually you don't need this in application level development.
Expand Down
22 changes: 5 additions & 17 deletions src/output/audio/AudioOutputOpenAL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class AudioOutputOpenAL Q_DECL_FINAL: public AudioOutputBackend
bool isSupported(const AudioFormat& format) const Q_DECL_FINAL;
bool isSupported(AudioFormat::SampleFormat sampleFormat) const Q_DECL_FINAL;
bool isSupported(AudioFormat::ChannelLayout channelLayout) const Q_DECL_FINAL;
AudioFormat::SampleFormat preferredSampleFormat() const Q_DECL_FINAL;
AudioFormat::ChannelLayout preferredChannelLayout() const Q_DECL_FINAL;
protected:
BufferControl bufferControl() const Q_DECL_FINAL;
bool write(const QByteArray& data) Q_DECL_FINAL;
Expand Down Expand Up @@ -101,7 +99,7 @@ typedef AudioOutputOpenAL AudioOutputBackendOpenAL;
static const AudioOutputBackendId AudioOutputBackendId_OpenAL = mkid::id32base36_6<'O', 'p', 'e', 'n', 'A', 'L'>::value;
FACTORY_REGISTER(AudioOutputBackend, OpenAL, kName)

#define AL_ENSURE_OK(expr, ...) \
#define AL_ENSURE(expr, ...) \
do { \
expr; \
const ALenum err = alGetError(); \
Expand Down Expand Up @@ -365,16 +363,6 @@ bool AudioOutputOpenAL::isSupported(AudioFormat::ChannelLayout channelLayout) co
return channelLayout == AudioFormat::ChannelLayout_Mono || channelLayout == AudioFormat::ChannelLayout_Stereo;
}

AudioFormat::SampleFormat AudioOutputOpenAL::preferredSampleFormat() const
{
return AudioFormat::SampleFormat_Signed16;
}

AudioFormat::ChannelLayout AudioOutputOpenAL::preferredChannelLayout() const
{
return AudioFormat::ChannelLayout_Stereo;
}

QString AudioOutputOpenAL::deviceName() const
{
if (!device)
Expand All @@ -399,10 +387,10 @@ bool AudioOutputOpenAL::write(const QByteArray& data)
buf = buffer[(-state)%buffer_count];
--state;
} else {
AL_ENSURE_OK(alSourceUnqueueBuffers(source, 1, &buf), false);
AL_ENSURE(alSourceUnqueueBuffers(source, 1, &buf), false);
}
AL_ENSURE_OK(alBufferData(buf, format_al, data.constData(), data.size(), format.sampleRate()), false);
AL_ENSURE_OK(alSourceQueueBuffers(source, 1, &buf), false);
AL_ENSURE(alBufferData(buf, format_al, data.constData(), data.size(), format.sampleRate()), false);
AL_ENSURE(alSourceQueueBuffers(source, 1, &buf), false);
return true;
}

Expand All @@ -428,7 +416,7 @@ int AudioOutputOpenAL::getPlayedCount()
bool AudioOutputOpenAL::setVolume(qreal value)
{
SCOPE_LOCK_CONTEXT();
AL_ENSURE_OK(alListenerf(AL_GAIN, value), false);
AL_ENSURE(alListenerf(AL_GAIN, value), false);
return true;
}

Expand Down

0 comments on commit 7109347

Please sign in to comment.