New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid channels' count not detected on OS X Lion #201

Closed
Ceylo opened this Issue Apr 8, 2012 · 1 comment

Comments

Projects
None yet
2 participants
@Ceylo
Contributor

Ceylo commented Apr 8, 2012

Running the following code :

#include <OpenAL/al.h>
#include <iostream>

int main()
{
    std::cout << alGetEnumValue("AL_FORMAT_51CHN16") << std::endl;
    return 0;
}

outputs -1 on Mac OS X 10.7.3 with integrated Intel audio chipset.

alGetEnum() is used in AudioDevice.cpp here :

////////////////////////////////////////////////////////////
int AudioDevice::getFormatFromChannelCount(unsigned int channelCount)
{
    ensureALInit();

    // Find the good format according to the number of channels
    switch (channelCount)
    {
        case 1  : return AL_FORMAT_MONO16;
        case 2  : return AL_FORMAT_STEREO16;
        case 4  : return alGetEnumValue("AL_FORMAT_QUAD16");
        case 6  : return alGetEnumValue("AL_FORMAT_51CHN16");
        case 7  : return alGetEnumValue("AL_FORMAT_61CHN16");
        case 8  : return alGetEnumValue("AL_FORMAT_71CHN16");
        default : return 0;
    }
}

which results in incorrect error handling in SoundStream.cpp :

////////////////////////////////////////////////////////////
void SoundStream::initialize(unsigned int channelCount, unsigned int sampleRate)
{
    m_channelCount = channelCount;
    m_sampleRate   = sampleRate;

    // Deduce the format from the number of channels
    m_format = priv::AudioDevice::getFormatFromChannelCount(channelCount);

    // Check if the format is valid
    if (m_format == 0)
    {
        m_channelCount = 0;
        m_sampleRate   = 0;
        err() << "Unsupported number of channels (" << m_channelCount << ")" << std::endl;
    }
}

Audio then of course doesn't get played, but without any error message.

@ghost ghost assigned LaurentGomila Apr 8, 2012

@LaurentGomila

This comment has been minimized.

Show comment
Hide comment
@LaurentGomila

LaurentGomila Apr 8, 2012

Member

One more bug in the OS X implementation.

Fortunately, the workaround is easy.

Member

LaurentGomila commented Apr 8, 2012

One more bug in the OS X implementation.

Fortunately, the workaround is easy.

LaurentGomila added a commit that referenced this issue Jul 10, 2013

Added a workaround for a bug in the OS X implementation of OpenAL (un…
…supported channel count no properly detected) (#201)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment