直接播放pcm格式练习
pcm直接使用 sdl播放,主要理解的是操作流程,就是将从文件读取出来的数据通过回调函数 copy到音频队列中,主线程和读取函数也就是回调函数是不在同一个线程中的,每次通过fread*读取到全局变量audio_chunk中,在回调函数中复制到音频设备。
#include <QCoreApplication>
#include <pthread.h>
#include <condition_variable>
extern "C" {
#include <SDL2/SDL.h>
#include <libavcodec/avcodec.h>
#include <libavutil/avutil.h>
#include <libavformat/avformat.h>
#include <libavformat/version.h>
}
static SDL_Window *window = nullptr;
static SDL_Renderer *renderer = nullptr;
static SDL_RendererInfo renderenInfo;
static SDL_Texture *texture = nullptr;
static SDL_Surface *surface = nullptr;
#ifdef __MINGW32__
#undef main
#endif
const size_t default_wid