diff options
| author | skidau <skidau@gmail.com> | 2015-01-23 12:30:48 +1100 |
|---|---|---|
| committer | skidau <skidau@gmail.com> | 2015-01-23 12:30:48 +1100 |
| commit | 6e99accf064bad70f8a0fd12a980ab5c732258de (patch) | |
| tree | d5e0993b5e1bde18b6e0e7f250810fc257f29e60 /Source/Core/AudioCommon/PulseAudioStream.cpp | |
| parent | e49408bdf05d6a2fe90cb16fa305fae585cf8d28 (diff) | |
| parent | 05d2bf6060e26d3507bbb6f285c452a328101780 (diff) | |
Merge pull request #1917 from adamdmoss/no-lfe
Remove explicit subwoofer/LFE channel from Pulseaudio and OpenAL
Diffstat (limited to 'Source/Core/AudioCommon/PulseAudioStream.cpp')
| -rw-r--r-- | Source/Core/AudioCommon/PulseAudioStream.cpp | 27 |
1 files changed, 19 insertions, 8 deletions
diff --git a/Source/Core/AudioCommon/PulseAudioStream.cpp b/Source/Core/AudioCommon/PulseAudioStream.cpp index e474fdf14d..8f36286403 100644 --- a/Source/Core/AudioCommon/PulseAudioStream.cpp +++ b/Source/Core/AudioCommon/PulseAudioStream.cpp @@ -23,7 +23,7 @@ PulseAudio::PulseAudio(CMixer *mixer) bool PulseAudio::Start() { m_stereo = !SConfig::GetInstance().m_LocalCoreStartupParameter.bDPL2Decoder; - m_channels = m_stereo ? 2 : 6; // will tell PA we use a Stereo or 5.1 channel setup + m_channels = m_stereo ? 2 : 5; // will tell PA we use a Stereo or 5.0 channel setup NOTICE_LOG(AUDIO, "PulseAudio backend using %d channels", m_channels); @@ -103,15 +103,13 @@ bool PulseAudio::PulseInit() ss.format = PA_SAMPLE_FLOAT32NE; m_bytespersample = sizeof(float); - // DPL2Decode output: LEFTFRONT, RIGHTFRONT, CENTREFRONT, (sub), LEFTREAR, RIGHTREAR channel_map_p = &channel_map; // explicit channel map: - channel_map.channels = 6; + channel_map.channels = 5; channel_map.map[0] = PA_CHANNEL_POSITION_FRONT_LEFT; channel_map.map[1] = PA_CHANNEL_POSITION_FRONT_RIGHT; channel_map.map[2] = PA_CHANNEL_POSITION_FRONT_CENTER; - channel_map.map[3] = PA_CHANNEL_POSITION_LFE; - channel_map.map[4] = PA_CHANNEL_POSITION_REAR_LEFT; - channel_map.map[5] = PA_CHANNEL_POSITION_REAR_RIGHT; + channel_map.map[3] = PA_CHANNEL_POSITION_REAR_LEFT; + channel_map.map[4] = PA_CHANNEL_POSITION_REAR_RIGHT; } ss.channels = m_channels; ss.rate = m_mixer->GetSampleRate(); @@ -202,9 +200,22 @@ void PulseAudio::WriteCallback(pa_stream* s, size_t length) floatbuffer_stereo[i] = s16buffer_stereo[i] / float(1 << 15); } - if (m_channels == 6) // Extract dpl2/5.1 Surround + if (m_channels == 5) // Extract dpl2/5.0 Surround { - DPL2Decode(floatbuffer_stereo, frames, (float*)buffer); + float floatbuffer_6chan[frames * 6]; + // DPL2Decode output: LEFTFRONT, RIGHTFRONT, CENTREFRONT, (sub), LEFTREAR, RIGHTREAR + DPL2Decode(floatbuffer_stereo, frames, floatbuffer_6chan); + + // Discard the subwoofer channel - DPL2Decode generates a pretty + // good 5.0 but not a good 5.1 output. + const int dpl2_to_5chan[] = {0,1,2,4,5}; + for (int i=0; i < frames; ++i) + { + for (int j=0; j < m_channels; ++j) + { + ((float*)buffer)[m_channels * i + j] = floatbuffer_6chan[6 * i + dpl2_to_5chan[j]]; + } + } } else { |
