标签:lin ali order fallback 调用 tput audio cms color
错误的代码:
//1.创建引擎
SLEngineItf eng = CreateSL();
//2.创建输出设备
SLObjectItf mix = NULL;
(*eng)->CreateOutputMix(eng , &mix ,0 ,0 ,0);
//实例化mix
(*mix)->Realize(mix , SL_BOOLEAN_FALSE);
//配置输出设备
SLDataLocator_OutputMix outMix = {SL_DATALOCATOR_OUTPUTMIX , mix};
SLDataSink audioSink = {&outMix , 0};
//配置PCM格式信息
//缓冲格式
SLDataLocator_AndroidSimpleBufferQueue queue = {SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE
, 10};
//音频格式
SLDataFormat_PCM pcm = {
SL_DATAFORMAT_PCM,
2,
SL_SAMPLINGRATE_44_1,
SL_PCMSAMPLEFORMAT_FIXED_16,
SL_PCMSAMPLEFORMAT_FIXED_16,
SL_SPEAKER_BACK_LEFT | SL_SPEAKER_BACK_RIGHT, //SL_SPEAKER_BACK_RIGHT,
SL_BYTEORDER_LITTLEENDIAN //字节序,小断------还有大段
};
SLDataSource ds = {&queue , &pcm};
//创建播放器
SLObjectItf player = NULL;
SLPlayItf iplayer = NULL ;
const SLInterfaceID ids[] = {SL_IID_BUFFERQUEUE};
const SLboolean req[] = {SL_BOOLEAN_TRUE};
(*eng)->CreateAudioPlayer(eng,&player,&ds,&audioSink,sizeof(ids)/sizeof(SLInterfaceID),ids,req); //如果只用player接口就不用传其他
//实例化播放器 //参数,因为调用到内部类的接口,
(*player)->Realize(player ,SL_BOOLEAN_FALSE); //所以必须传入其他参数
//获取接口
(*player)->GetInterface(player, SL_IID_PLAY, &iplayer);
//获取队列的接口
SLAndroidSimpleBufferQueueItf pcmQue = NULL;
(*player)->GetInterface(player, SL_IID_BUFFERQUEUE, &pcmQue);
//设置回调函数
(*pcmQue)->RegisterCallback(pcmQue, PcmCall, 0);
//设置播放状态
(*iplayer)->SetPlayState(iplayer , SL_PLAYSTATE_PLAYING);
//启动队列回调
(*pcmQue)->Enqueue(pcmQue , " ",1);
标签:lin ali order fallback 调用 tput audio cms color
原文地址:https://www.cnblogs.com/liunx1109/p/9283337.html