第一篇总体提了一下SDL,完全没有提到FFMPEG。我的思路是,在说解码之前,你起码要知道怎么使用解码后的文件。
相信大家如果看了网上的一些教程,应该已经能够播放出PCM文件。今天我来谈谈如何播放多个PCM文件。
这回先上代码
#define MAX_MUSIC_DATA 10
#define PCM_BUFFER_SIZE 4096
struct AudioData
{
Uint8 *audio_chunk;
Uint32 audio_len;
Uint8 *audio_pos;
SDL_Thread *thread;
AudioState state;
FILE *file;
char *pcm_buffer;
char *filename;
float skipSecond;
float HzPercent;
int originalFreq;
int volume;
}m_data[MAX_MUSIC_DATA], *pData;
/* Audio Callback
* The audio function callback takes the following parameters:
* stream: A pointer to the audio buffer to be filled
* len: The length (in bytes) of the audio buffer
*
*/
void fill_audio(void