| 2271 | } |
| 2272 | |
| 2273 | static void stream_component_close(VideoState *is, int stream_index) |
| 2274 | { |
| 2275 | AVFormatContext *ic = is->ic; |
| 2276 | AVCodecContext *avctx; |
| 2277 | |
| 2278 | if (stream_index < 0 || stream_index >= ic->nb_streams) |
| 2279 | return; |
| 2280 | avctx = ic->streams[stream_index]->codec; |
| 2281 | |
| 2282 | switch(avctx->codec_type) { |
| 2283 | case AVMEDIA_TYPE_AUDIO: |
| 2284 | packet_queue_abort(&is->audioq); |
| 2285 | |
| 2286 | SDL_CloseAudio(); |
| 2287 | |
| 2288 | packet_queue_end(&is->audioq); |
| 2289 | if (is->reformat_ctx) |
| 2290 | av_audio_convert_free(is->reformat_ctx); |
| 2291 | is->reformat_ctx = NULL; |
| 2292 | break; |
| 2293 | case AVMEDIA_TYPE_VIDEO: |
| 2294 | packet_queue_abort(&is->videoq); |
| 2295 | |
| 2296 | /* note: we also signal this mutex to make sure we deblock the |
| 2297 | video thread in all cases */ |
| 2298 | SDL_LockMutex(is->pictq_mutex); |
| 2299 | SDL_CondSignal(is->pictq_cond); |
| 2300 | SDL_UnlockMutex(is->pictq_mutex); |
| 2301 | |
| 2302 | SDL_WaitThread(is->video_tid, NULL); |
| 2303 | |
| 2304 | packet_queue_end(&is->videoq); |
| 2305 | break; |
| 2306 | case AVMEDIA_TYPE_SUBTITLE: |
| 2307 | packet_queue_abort(&is->subtitleq); |
| 2308 | |
| 2309 | /* note: we also signal this mutex to make sure we deblock the |
| 2310 | video thread in all cases */ |
| 2311 | SDL_LockMutex(is->subpq_mutex); |
| 2312 | is->subtitle_stream_changed = 1; |
| 2313 | |
| 2314 | SDL_CondSignal(is->subpq_cond); |
| 2315 | SDL_UnlockMutex(is->subpq_mutex); |
| 2316 | |
| 2317 | SDL_WaitThread(is->subtitle_tid, NULL); |
| 2318 | |
| 2319 | packet_queue_end(&is->subtitleq); |
| 2320 | break; |
| 2321 | default: |
| 2322 | break; |
| 2323 | } |
| 2324 | |
| 2325 | ic->streams[stream_index]->discard = AVDISCARD_ALL; |
| 2326 | avcodec_close(avctx); |
| 2327 | switch(avctx->codec_type) { |
| 2328 | case AVMEDIA_TYPE_AUDIO: |
| 2329 | is->audio_st = NULL; |
| 2330 | is->audio_stream = -1; |
no test coverage detected