Skip to content

Commit

Permalink
Fix T71322: Crash in Audaspace with some video file
Browse files Browse the repository at this point in the history
Getting upstream audaspace fixes for audio files with more than 8
channels.
  • Loading branch information
neXyon committed Nov 17, 2019
1 parent e385bdb commit fb1cbba
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion extern/audaspace/plugins/openal/OpenALDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,8 @@ OpenALDevice::OpenALDevice(DeviceSpecs specs, int buffersize, std::string name)

if((!m_useMC && specs.channels > CHANNELS_STEREO) ||
specs.channels == CHANNELS_STEREO_LFE ||
specs.channels == CHANNELS_SURROUND5)
specs.channels == CHANNELS_SURROUND5 ||
specs.channels > CHANNELS_SURROUND71)
specs.channels = CHANNELS_STEREO;

alGetError();
Expand Down
19 changes: 11 additions & 8 deletions extern/audaspace/src/respec/ChannelMapperReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,15 @@ void ChannelMapperReader::calculateMapping()
for(int i = 0; i < m_source_channels * m_target_channels; i++)
m_mapping[i] = 0;

const Channel* source_channels = CHANNEL_MAPS[m_source_channels - 1];
const Channel* target_channels = CHANNEL_MAPS[m_target_channels - 1];
const Channels source_channel_count = std::min(m_source_channels, CHANNELS_SURROUND71);
const Channels target_channel_count = std::min(m_target_channels, CHANNELS_SURROUND71);

const Channel* source_channels = CHANNEL_MAPS[source_channel_count - 1];
const Channel* target_channels = CHANNEL_MAPS[target_channel_count - 1];

int lfe = -1;

for(int i = 0; i < m_target_channels; i++)
for(int i = 0; i < target_channel_count; i++)
{
if(target_channels[i] == CHANNEL_LFE)
{
Expand All @@ -111,16 +114,16 @@ void ChannelMapperReader::calculateMapping()
}
}

const float* source_angles = CHANNEL_ANGLES[m_source_channels - 1];
const float* target_angles = CHANNEL_ANGLES[m_target_channels - 1];
const float* source_angles = CHANNEL_ANGLES[source_channel_count - 1];
const float* target_angles = CHANNEL_ANGLES[target_channel_count - 1];

if(m_source_channels == CHANNELS_MONO)
if(source_channel_count == CHANNELS_MONO)
source_angles = &m_mono_angle;

int channel_left, channel_right;
float angle_left, angle_right, angle;

for(int i = 0; i < m_source_channels; i++)
for(int i = 0; i < source_channel_count; i++)
{
if(source_channels[i] == CHANNEL_LFE)
{
Expand All @@ -134,7 +137,7 @@ void ChannelMapperReader::calculateMapping()
angle_left = -2 * M_PI;
angle_right = 2 * M_PI;

for(int j = 0; j < m_target_channels; j++)
for(int j = 0; j < target_channel_count; j++)
{
if(j == lfe)
continue;
Expand Down

0 comments on commit fb1cbba

Please sign in to comment.