Skip to content

Commit

Permalink
Bug fixes for files with more than 8 channels.
Browse files Browse the repository at this point in the history
  • Loading branch information
neXyon committed Nov 17, 2019
1 parent 94dc527 commit 20a7a28
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
10 changes: 10 additions & 0 deletions demos/audaplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@ int main(int argc, char* argv[])

device->lock();
auto handle = device->play(reader);

if(!handle)
{
device->unlock();

std::cout << "Device could not play the file." << std::endl;

return 1;
}

handle->setStopCallback(release, &condition);
device->unlock();

Expand Down
3 changes: 2 additions & 1 deletion 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 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 20a7a28

Please sign in to comment.