这段代码大概就是 先执行main函数,开启分线程audio_callback()不断读取音频流,然后用audio_decode_frame()解码,解码的数据从packet_queue_get()中取出来, 继续回到main函数packet_queue_put()负责把音频帧放到队列中去,以便于packet_queue_get()从队列中获取。 c文件下载 http://download.csdn.net/detail/wenwei...
// 音频参数设置SDL_AudioSpecspec.freq=44100;// 采样频率spec.format=AUDIO_S16SYS;// 采样点格式spec.channels=2;// 2通道spec.silence=0;spec.samples=1024;// 23.2ms -> 46.4ms 每次读取的采样数量,多久产生一次回调spec.callback=fill_audio_pcm;// 回调函数spec.userdata=NULL; 1. 2. 3. 4. 5...
void SDL_AudioCallback(void* userdata, Uint8* stream, int len) 1. 2. 3. where its parameters are: Once the callback returns, the buffer will no longer be valid. Stereo samples are stored in a LRLRLR ordering. The callbackmustcompletely initialize the buffer; as of SDL 2.0, this buff...
循环读取音频流包的信息。 voidaudio_callback(void*userdata, Uint8 *stream,intlen) {//获得编解码器的上下文信息AVCodecContext *aCodecCtx = (AVCodecContext *) userdata;intlen1, audio_size;staticuint8_t audio_buf[(AVCODEC_MAX_AUDIO_FRAME_SIZE *3) /2];staticunsignedintaudio_buf_size =0;static...
由独立的线程执行音频部分,并提供用户回调(callback)机制。 设计上考虑到了客户定制的软混音器, 但实际上在例程中就包含了一个完整的音频/音乐输出库。 ·CD音频 完整的CD音频控制API ·线程 简单的线程创建API 用于同步的简单的二进制信号量(semaphores) ...
#include<SDL.h>#include<stdio.h>voidaudio_callback(void*userdata,Uint8*stream,intlen){// 在回调中填充音频数据}intmain(){SDL_Init(SDL_INIT_AUDIO);SDL_AudioSpec desiredSpec;SDL_AudioSpec obtainedSpec;desiredSpec.freq=44100;// 采样率desiredSpec.format=AUDIO_F32;// 音频格式desiredSpec.channels...
SDL_AudioSpec wavSpec;wavSpec.freq=0;// 频率可以设置为 0wavSpec.format=AUDIO_S16SYS;// 音频格式设置为 16 位系统格式wavSpec.channels=2;// 设置为立体声音频wavSpec.samples=4096;// 音频缓冲区大小wavSpec.callback=NULL;// 不需要回调函数 ...