Fix T71322: Crash in Audaspace with some video file
authorJörg Müller <nexyon@gmail.com>
Sun, 17 Nov 2019 08:02:18 +0000 (09:02 +0100)
committerJörg Müller <nexyon@gmail.com>
Sun, 17 Nov 2019 08:02:18 +0000 (09:02 +0100)
Getting upstream audaspace fixes for audio files with more than 8
channels.

extern/audaspace/plugins/openal/OpenALDevice.cpp
extern/audaspace/src/respec/ChannelMapperReader.cpp

index 6ad87c183aa2cf8a28c86003aa7a5edcf5079c7c..f41e9c6bef898be0cbf04f631cd8a5086c20800a 100644 (file)
@@ -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();
index 1af5e70bfc87d8dc4066c3a7de9b434ac0fa37a7..e0063d5c4a2c03c3191088d2cfb4d10092355164 100644 (file)
@@ -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)
                {
@@ -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)
                {
@@ -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;