Revision a0e0d6ff chunker_player/player_core.c
chunker_player/player_core.c | ||
---|---|---|
246 | 246 |
printf("using audio Codecid: %d ",aCodecCtx->codec_id); |
247 | 247 |
printf("samplerate: %d ",aCodecCtx->sample_rate); |
248 | 248 |
printf("channels: %d\n",aCodecCtx->channels); |
249 |
wanted_spec.freq = aCodecCtx->sample_rate; |
|
249 |
CurrentAudioFreq = wanted_spec.freq = aCodecCtx->sample_rate;
|
|
250 | 250 |
wanted_spec.format = AUDIO_S16SYS; |
251 | 251 |
wanted_spec.channels = aCodecCtx->channels; |
252 | 252 |
wanted_spec.silence = 0; |
253 |
wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE; |
|
253 |
CurrentAudioSamples = wanted_spec.samples = SDL_AUDIO_BUFFER_SIZE;
|
|
254 | 254 |
wanted_spec.callback = AudioCallback; |
255 | 255 |
wanted_spec.userdata = aCodecCtx; |
256 | 256 |
if(SDL_OpenAudio(&wanted_spec,&AudioSpecification)<0) |
257 | 257 |
{ |
258 |
fprintf(stderr,"SDL_OpenAudio: %s\n",SDL_GetError()); |
|
258 |
fprintf(stderr,"SDL_OpenAudio: %s\n", SDL_GetError());
|
|
259 | 259 |
return -1; |
260 | 260 |
} |
261 | 261 |
dimAudioQ = AudioSpecification.size; |
... | ... | |
1294 | 1294 |
|
1295 | 1295 |
// Stop audio&video playback |
1296 | 1296 |
SDL_WaitThread(video_thread, NULL); |
1297 |
SDL_PauseAudio(1); |
|
1297 |
SDL_PauseAudio(1);
|
|
1298 | 1298 |
SDL_CloseAudio(); |
1299 | 1299 |
|
1300 | 1300 |
if(YUVOverlay != NULL) |
... | ... | |
1311 | 1311 |
free(VideoPkt.data); |
1312 | 1312 |
free(outbuf_audio); |
1313 | 1313 |
free(InitRect); |
1314 |
|
|
1315 |
/* |
|
1316 |
* Sleep two buffers' worth of audio before closing, in order |
|
1317 |
* to allow the playback to finish. This isn't always enough; |
|
1318 |
* perhaps SDL needs a way to explicitly wait for device drain? |
|
1319 |
*/ |
|
1320 |
int delay = 2 * 1000 * CurrentAudioSamples / CurrentAudioFreq; |
|
1321 |
printf("SDL_Delay(%d)\n", delay); |
|
1322 |
SDL_Delay(delay); |
|
1314 | 1323 |
} |
1315 | 1324 |
|
1316 | 1325 |
int ChunkerPlayerCore_AudioEnded() |
Also available in: Unified diff