Revert "Fix surround sound channel mapping on ALSA" since it can be handled inside PortAudio

This commit is contained in:
Cameron Gutman 2018-10-02 01:09:13 -07:00
parent 8dddcd04d5
commit a614a693e5
6 changed files with 7 additions and 58 deletions

View file

@ -77,27 +77,23 @@ int Session::arInit(int /* audioConfiguration */,
SDL_memcpy(&s_ActiveSession->m_AudioConfig, opusConfig, sizeof(*opusConfig));
s_ActiveSession->m_AudioRenderer = s_ActiveSession->createAudioRenderer();
if (s_ActiveSession->m_AudioRenderer == nullptr) {
return -1;
}
// Allow the audio renderer to adjust the channel mapping to fit its
// preferred channel order
s_ActiveSession->m_AudioRenderer->adjustOpusChannelMapping(&s_ActiveSession->m_AudioConfig);
s_ActiveSession->m_OpusDecoder =
opus_multistream_decoder_create(opusConfig->sampleRate,
opusConfig->channelCount,
opusConfig->streams,
opusConfig->coupledStreams,
s_ActiveSession->m_AudioConfig.mapping,
opusConfig->mapping,
&error);
if (s_ActiveSession->m_OpusDecoder == NULL) {
delete s_ActiveSession->m_AudioRenderer;
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Failed to create decoder: %d",
error);
return -1;
}
s_ActiveSession->m_AudioRenderer = s_ActiveSession->createAudioRenderer();
if (s_ActiveSession->m_AudioRenderer == nullptr) {
opus_multistream_decoder_destroy(s_ActiveSession->m_OpusDecoder);
return -2;
}

View file

@ -131,42 +131,6 @@ int PortAudioRenderer::detectAudioConfiguration() const
}
}
void PortAudioRenderer::adjustOpusChannelMapping(OPUS_MULTISTREAM_CONFIGURATION* opusConfig) const
{
const OPUS_MULTISTREAM_CONFIGURATION origConfig = *opusConfig;
const PaDeviceInfo* deviceInfo = Pa_GetDeviceInfo(Pa_GetDefaultOutputDevice());
if (deviceInfo == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Pa_GetDeviceInfo() failed");
return;
}
const PaHostApiInfo* hostApiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi);
if (hostApiInfo == nullptr) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION,
"Pa_GetHostApiInfo() failed");
return;
}
SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION,
"PortAudio host API: %s",
hostApiInfo->name);
if (hostApiInfo->type == paALSA) {
// The default mapping array has is: FL-FR-C-LFE-RL-RR
// ALSA expects: FL-FR-RL-RR-C-LFE
opusConfig->mapping[0] = origConfig.mapping[0];
opusConfig->mapping[1] = origConfig.mapping[1];
if (opusConfig->channelCount == 6) {
opusConfig->mapping[2] = origConfig.mapping[4];
opusConfig->mapping[3] = origConfig.mapping[5];
opusConfig->mapping[4] = origConfig.mapping[2];
opusConfig->mapping[5] = origConfig.mapping[3];
}
}
}
int PortAudioRenderer::paStreamCallback(const void*, void* output, unsigned long frameCount, const PaStreamCallbackTimeInfo*, PaStreamCallbackFlags, void* userData)
{
auto me = reinterpret_cast<PortAudioRenderer*>(userData);

View file

@ -22,8 +22,6 @@ public:
virtual int detectAudioConfiguration() const;
virtual void adjustOpusChannelMapping(OPUS_MULTISTREAM_CONFIGURATION* opusConfig) const;
static int paStreamCallback(const void *input,
void *output,
unsigned long frameCount,

View file

@ -10,8 +10,6 @@ class IAudioRenderer
public:
virtual ~IAudioRenderer() {}
virtual void adjustOpusChannelMapping(OPUS_MULTISTREAM_CONFIGURATION* opusConfig) const = 0;
virtual bool prepareForPlayback(const OPUS_MULTISTREAM_CONFIGURATION* opusConfig) = 0;
virtual void submitAudio(short* audioBuffer, int audioSize) = 0;

View file

@ -21,8 +21,6 @@ public:
virtual int detectAudioConfiguration() const;
virtual void adjustOpusChannelMapping(OPUS_MULTISTREAM_CONFIGURATION* opusConfig) const;
private:
SDL_AudioDeviceID m_AudioDevice;
Uint32 m_ChannelCount;

View file

@ -51,11 +51,6 @@ int SdlAudioRenderer::detectAudioConfiguration() const
}
}
void SdlAudioRenderer::adjustOpusChannelMapping(OPUS_MULTISTREAM_CONFIGURATION*) const
{
// The default mapping is fine for SDL
}
SdlAudioRenderer::SdlAudioRenderer()
: m_AudioDevice(0),
m_ChannelCount(0),