ubuntu – Openal – alGetError()始终返回AL_INVALID_OPERATION

我在pendrive上运行ubuntu 12.04.我安装了openAL和alut
我的主要是:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <al.h> 
#include <alc.h>

// Buffers hold sound data.
ALuint Buffer;
using namespace std;
string ErrorCheck(ALenum error)
{
    if(error == AL_INVALID_NAME)
    {
        return "Invalid name";
    }
    else if(error == AL_INVALID_ENUM)
    {
        return " Invalid enum ";
    }
    else if(error == AL_INVALID_VALUE)
    {
        return " Invalid value ";
    }
    else if(error == AL_INVALID_OPERATION)
    {
        return " Invalid operation ";
    }
    else if(error == AL_OUT_OF_MEMORY)
    {
        return " Out of memory like! ";
    }

    return " Don't kNow ";


}

int main(int argc,char **argv)

{
    ALenum error;   

    error = alGetError();
    cout << "\n\tinitial error at start of program - " << ErrorCheck(error);

    error = alGetError();
    cout << "\n\tError persists - " << ErrorCheck(error);

    cout << "\n\tGenerating buffer...";
    alGenBuffers(1,&Buffer);

    error = alGetError();
    if(error != AL_NO_ERROR)
    {
        cout << "\n\tError generating buffer - "<< ErrorCheck(error) << "\n\n";
        return 0;
    }


    return 0;
}

使用该行编译时没有错误

g++ main.cpp -I/usr/include/AL -lopenal -lalut

但是当程序运行时,每次调用alGetError()都会返回AL_INVALID_OPERATION
我认为调用alGetError()意味着重置错误标志,所以我在开始时调用它两次,第二个应该至少不返回错误.
我真的卡住了!

解决方法

这个问题的答案仍然适用于您的问题.我没有在代码中看到任何OpenAL上下文的创建.

http://opensource.creative.com/pipermail/openal/2008-May/011130.html

相关文章

ubuntu退出redis的示例:指定配置文件方式启动源码redis:roo...
ubuntu中mysql改密码忘了的解决方法:1.在终端中切换到root权...
ubuntu安装mysql失败的解决方法原因:可能是原有的MySQL还有...
使用centos和ubuntu建站的区别有以下几点1.CentOS是Linux发行...
ubuntu图形界面和字符界面切换的方法:可以通过快捷键CTRL+A...
ubuntu中重启mysql失败的解决方法1.首先,在ubuntu命令行中,...