我们有一段 SDL 代码如下。
SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
atexit(SDL_Quit);
g_pDisplaySurface =
SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,0,SDL_ANYFORMAT);
g_SpecDesired=new SDL_AudioSpec;
g_SpecObtained=new SDL_AudioSpec;
g_SpecDesired->freq=22050;
g_SpecDesired->format=AUDIO_U8;
g_SpecDesired->channels=1;
g_SpecDesired->samples=8192;
g_SpecDesired->callback=FOSDLAudioCallback;
g_SpecDesired->userdata=NULL;
回调函数是
void FOSDLAudioCallback(void* userdata,Uint8* buffer,int len)
{
int index;
printf("LEn is :%d",&len);
for(index=0;index<len;index++)
{
buffer[index]=rand()%256;
}
}
这里的问题即使我们将通道更改为 1 或 2 它仍然在两个立体声通道上播放?为什么它会以这种方式运行?