FMOD playSound抛出有关无效参数的错误

时间:2012-03-07 18:27:22

标签: c++ audio fmod

我尝试在openAL无法在某些机器上交付之后构建某种音频管理器,所以我发现了fmod。但是,经过几个小时的代码更改后,没有什么可行的。我的playSound电话似乎在窃听。

将无效参数传递给此函数。

这正是错误检查输出给我的。

代码......让我们从头开始:

typedef std::map<std::string, FMOD::Sound*> SoundPool; 
SoundPool m_sounds;
FMOD::Channel* m_soundChannels[MAX_SOUNDS];
FMOD::System* m_soundSystem;

然后:

FMOD::System_Create(&m_soundSystem);
m_soundSystem->init(32, FMOD_INIT_NORMAL, NULL);
for(int i = 0; i < MAX_SOUNDS; i++)
    m_soundChannels[i] = 0;

以后:

void CResourceManager::PlaySound(std::string filename, float volume)
{
    for(int i = 0; i < MAX_SOUNDS; i++)
    {
        if(m_soundChannels[i] == 0)
        {
            if(volume > 1.0f) volume = 1.0f;
            FMOD_RESULT result = m_soundSystem->playSound(FMOD_CHANNEL_FREE,
                                 m_sounds[filename], false, &m_soundChannels[i]);
            if(result != FMOD_OK)
            {
                std::cout << FMOD_ErrorString(result); //// here's the error 
            }
            m_soundChannels[i]->setVolume(volume);
            break;
       }
   }
}

void CResourceManager::Update()
{
    m_soundSystem->update();

    for(int i = 0; i < MAX_SOUNDS; i++)
    {
        if(m_soundChannels[i] != 0)
        {
            bool playing;
            m_soundChannels[i]->isPlaying(&playing);

            if(!playing)
                m_soundChannels[i] = 0;
        }
    }
}

bool CResourceManager::AddSound( std::string filename )
{
    FMOD_RESULT result = m_soundSystem->createSound(filename.c_str(),
                            FMOD_LOOP_NORMAL, NULL, &m_sounds[filename]);

    if(result == FMOD_OK)
        return true;

    return false;
}

0 个答案:

没有答案
相关问题