Mercurial > mplayer.hg
comparison mplayer.c @ 4587:886bf5274992
Audio only support. Include a fix in the asf demuxer opening.
Plus : stop displaying PAUSE when -quiet is used.
author | albeu |
---|---|
date | Fri, 08 Feb 2002 16:00:14 +0000 |
parents | 46ccfbb41f9c |
children | 3769ccb8da8b |
comparison
equal
deleted
inserted
replaced
4586:ee28f294cc48 | 4587:886bf5274992 |
---|---|
198 float rel_seek_secs=0; | 198 float rel_seek_secs=0; |
199 int abs_seek_pos=0; | 199 int abs_seek_pos=0; |
200 | 200 |
201 // codecs: | 201 // codecs: |
202 int has_audio=1; | 202 int has_audio=1; |
203 int has_video=1; | |
203 char *audio_codec=NULL; // override audio codec | 204 char *audio_codec=NULL; // override audio codec |
204 char *video_codec=NULL; // override video codec | 205 char *video_codec=NULL; // override video codec |
205 int audio_family=-1; // override audio codec family | 206 int audio_family=-1; // override audio codec family |
206 int video_family=-1; // override video codec family | 207 int video_family=-1; // override video codec family |
207 | 208 |
1053 | 1054 |
1054 current_module="video_read_properties"; | 1055 current_module="video_read_properties"; |
1055 | 1056 |
1056 if(sh_video){ | 1057 if(sh_video){ |
1057 | 1058 |
1058 if(!video_read_properties(sh_video)) goto goto_next_file; // exit_player(MSGTR_Exit_error); // couldn't read header? | 1059 if(!video_read_properties(sh_video)) { |
1059 | 1060 mp_msg(MSGT_CPLAYER,MSGL_ERR,"Video: can't read properties\n"); |
1060 mp_msg(MSGT_CPLAYER,MSGL_INFO,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", | 1061 sh_video=d_video->sh=NULL; |
1061 demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h, | 1062 } else { |
1062 sh_video->fps,sh_video->frametime | 1063 mp_msg(MSGT_CPLAYER,MSGL_INFO,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n", |
1063 ); | 1064 demuxer->file_format,sh_video->format, sh_video->disp_w,sh_video->disp_h, |
1064 | 1065 sh_video->fps,sh_video->frametime |
1065 if(!sh_video->fps && !force_fps){ | 1066 ); |
1066 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_FPSnotspecified); | 1067 |
1067 goto goto_next_file; // exit_player(MSGTR_Exit_error); | 1068 if(!sh_video->fps && !force_fps){ |
1069 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_FPSnotspecified); | |
1070 sh_video=d_video->sh=NULL; | |
1071 } | |
1068 } | 1072 } |
1069 | 1073 |
1070 } | 1074 } |
1071 | 1075 |
1072 fflush(stdout); | 1076 fflush(stdout); |
1073 | 1077 |
1074 if(!sh_video){ | 1078 if(!sh_video && !sh_audio){ |
1075 mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_NoVideoStream); | 1079 mp_msg(MSGT_CPLAYER,MSGL_FATAL,"No stream found\n"); |
1076 goto goto_next_file; // exit_player(MSGTR_Exit_error); | 1080 goto goto_next_file; // exit_player(MSGTR_Exit_error); |
1077 } | 1081 } |
1082 | |
1083 if(!sh_video) goto init_audio; | |
1078 | 1084 |
1079 #ifdef USE_DVDREAD | 1085 #ifdef USE_DVDREAD |
1080 current_module="spudec"; | 1086 current_module="spudec"; |
1081 vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL, | 1087 vo_spudec=spudec_new_scaled(stream->type==STREAMTYPE_DVD?((dvd_priv_t *)(stream->priv))->cur_pgc->palette:NULL, |
1082 sh_video->disp_w, sh_video->disp_h); | 1088 sh_video->disp_w, sh_video->disp_h); |
1117 | 1123 |
1118 /* display clip info */ | 1124 /* display clip info */ |
1119 demux_info_print(demuxer); | 1125 demux_info_print(demuxer); |
1120 | 1126 |
1121 //================== Init AUDIO (codec) ========================== | 1127 //================== Init AUDIO (codec) ========================== |
1122 | 1128 init_audio: |
1123 current_module="init_audio_codec"; | 1129 current_module="init_audio_codec"; |
1124 | 1130 |
1125 if(sh_audio){ | 1131 if(sh_audio){ |
1126 // Go through the codec.conf and find the best codec... | 1132 // Go through the codec.conf and find the best codec... |
1127 sh_audio->codec=NULL; | 1133 sh_audio->codec=NULL; |
1163 #endif | 1169 #endif |
1164 } | 1170 } |
1165 } | 1171 } |
1166 | 1172 |
1167 //================== Init VIDEO (codec & libvo) ========================== | 1173 //================== Init VIDEO (codec & libvo) ========================== |
1168 | 1174 if(!sh_video) |
1175 goto main; | |
1169 current_module="init_video_codec"; | 1176 current_module="init_video_codec"; |
1170 | 1177 |
1171 // Go through the codec.conf and find the best codec... | 1178 // Go through the codec.conf and find the best codec... |
1172 sh_video->codec=NULL; | 1179 sh_video->codec=NULL; |
1173 if(video_family!=-1) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_TryForceVideoFmt,video_family); | 1180 if(video_family!=-1) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_TryForceVideoFmt,video_family); |
1185 continue; | 1192 continue; |
1186 } | 1193 } |
1187 if(bestprio==-1 || !video_codec) { | 1194 if(bestprio==-1 || !video_codec) { |
1188 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format); | 1195 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CantFindVideoCodec,sh_video->format); |
1189 mp_msg(MSGT_CPLAYER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf")); | 1196 mp_msg(MSGT_CPLAYER,MSGL_HINT, MSGTR_TryUpgradeCodecsConfOrRTFM,get_path("codecs.conf")); |
1190 goto goto_next_file; // exit_player(MSGTR_Exit_error); | 1197 sh_video = d_video->sh = NULL; |
1198 goto main; // exit_player(MSGTR_Exit_error); | |
1191 } | 1199 } |
1192 } else { | 1200 } else { |
1193 // is next line needed anymore? - atmos :: | 1201 // is next line needed anymore? - atmos :: |
1194 if(!allow_dshow && sh_video->codec->driver==VFM_DSHOW) continue; // skip DShow | 1202 if(!allow_dshow && sh_video->codec->driver==VFM_DSHOW) continue; // skip DShow |
1195 else if(video_codec && strcmp(sh_video->codec->name,video_codec)) continue; | 1203 else if(video_codec && strcmp(sh_video->codec->name,video_codec)) continue; |
1382 } | 1390 } |
1383 init_video_vaa(); | 1391 init_video_vaa(); |
1384 fflush(stdout); | 1392 fflush(stdout); |
1385 | 1393 |
1386 //================== MAIN: ========================== | 1394 //================== MAIN: ========================== |
1395 main: | |
1396 if(!sh_video) osd_level = 0; | |
1387 { | 1397 { |
1388 | 1398 |
1389 //int frame_corr_num=0; // | 1399 //int frame_corr_num=0; // |
1390 //float v_frame=0; // Video | 1400 //float v_frame=0; // Video |
1391 float time_frame=0; // Timer | 1401 float time_frame=0; // Timer |
1425 mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Comment: %s\n", info->comment); | 1435 mp_msg(MSGT_CPLAYER,MSGL_V,"AO: Comment: %s\n", info->comment); |
1426 if(!audio_out->init(force_srate?force_srate:sh_audio->samplerate, | 1436 if(!audio_out->init(force_srate?force_srate:sh_audio->samplerate, |
1427 sh_audio->channels,sh_audio->sample_format,0)){ | 1437 sh_audio->channels,sh_audio->sample_format,0)){ |
1428 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); | 1438 mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO); |
1429 sh_audio=d_audio->sh=NULL; | 1439 sh_audio=d_audio->sh=NULL; |
1440 if(sh_video == NULL) | |
1441 goto goto_next_file; | |
1430 } else { | 1442 } else { |
1431 inited_flags|=INITED_AO; | 1443 inited_flags|=INITED_AO; |
1432 } | 1444 } |
1433 | 1445 |
1434 // printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay); | 1446 // printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay); |
1440 // } | 1452 // } |
1441 | 1453 |
1442 // sh_audio->timer=-(audio_buffer_delay); | 1454 // sh_audio->timer=-(audio_buffer_delay); |
1443 } | 1455 } |
1444 | 1456 |
1445 sh_video->timer=0; | 1457 if(sh_video) sh_video->timer=0; |
1446 if(sh_audio) sh_audio->timer=-audio_delay; | 1458 if(sh_audio) sh_audio->timer=-audio_delay; |
1447 | 1459 |
1448 if(!sh_audio){ | 1460 if(!sh_audio){ |
1449 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound); | 1461 mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_NoSound); |
1450 if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks\n",d_audio->packs); | 1462 if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks\n",d_audio->packs); |
1451 ds_free_packs(d_audio); // free buffered chunks | 1463 ds_free_packs(d_audio); // free buffered chunks |
1452 d_audio->id=-2; // do not read audio chunks | 1464 d_audio->id=-2; // do not read audio chunks |
1453 if(audio_out) uninit_player(INITED_AO); // close device | 1465 if(audio_out) uninit_player(INITED_AO); // close device |
1454 } | 1466 } |
1455 | 1467 if(!sh_video){ |
1468 mp_msg(MSGT_CPLAYER,MSGL_INFO,"Video: no video!!!\n"); | |
1469 if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused video chunks\n",d_video->packs); | |
1470 ds_free_packs(d_video); | |
1471 d_video->id=-2; | |
1472 if(video_out) uninit_player(INITED_VO); | |
1473 } | |
1456 current_module=NULL; | 1474 current_module=NULL; |
1457 | 1475 |
1458 if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf! | 1476 if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf! |
1459 if(force_fps){ | 1477 if(force_fps){ |
1460 sh_video->fps=force_fps; | 1478 sh_video->fps=force_fps; |
1482 | 1500 |
1483 if(play_n_frames>=0){ | 1501 if(play_n_frames>=0){ |
1484 --play_n_frames; | 1502 --play_n_frames; |
1485 if(play_n_frames<0) eof = PT_NEXT_ENTRY; | 1503 if(play_n_frames<0) eof = PT_NEXT_ENTRY; |
1486 } | 1504 } |
1487 | |
1488 vo_pts=sh_video->timer*90000.0; | |
1489 vo_fps=sh_video->fps; | |
1490 | 1505 |
1491 /*========================== PLAY AUDIO ============================*/ | 1506 /*========================== PLAY AUDIO ============================*/ |
1492 while(sh_audio){ | 1507 while(sh_audio){ |
1493 unsigned int t; | 1508 unsigned int t; |
1494 int playsize; | 1509 int playsize; |
1505 current_module="decode_audio"; // Enter AUDIO decoder module | 1520 current_module="decode_audio"; // Enter AUDIO decoder module |
1506 t=GetTimer(); | 1521 t=GetTimer(); |
1507 while(sh_audio->a_buffer_len<playsize && !d_audio->eof){ | 1522 while(sh_audio->a_buffer_len<playsize && !d_audio->eof){ |
1508 int ret=decode_audio(sh_audio,&sh_audio->a_buffer[sh_audio->a_buffer_len], | 1523 int ret=decode_audio(sh_audio,&sh_audio->a_buffer[sh_audio->a_buffer_len], |
1509 playsize-sh_audio->a_buffer_len,sh_audio->a_buffer_size-sh_audio->a_buffer_len); | 1524 playsize-sh_audio->a_buffer_len,sh_audio->a_buffer_size-sh_audio->a_buffer_len); |
1510 if(ret>0) sh_audio->a_buffer_len+=ret; else break; | 1525 if(ret>0) sh_audio->a_buffer_len+=ret; |
1526 else { | |
1527 if(!sh_video) | |
1528 eof = PT_NEXT_ENTRY; | |
1529 break; | |
1530 } | |
1511 } | 1531 } |
1512 current_module=NULL; // Leave AUDIO decoder module | 1532 current_module=NULL; // Leave AUDIO decoder module |
1513 t=GetTimer()-t;audio_time_usage+=t*0.000001; | 1533 t=GetTimer()-t;audio_time_usage+=t*0.000001; |
1514 | 1534 |
1515 if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len; | 1535 if(playsize>sh_audio->a_buffer_len) playsize=sh_audio->a_buffer_len; |
1543 } | 1563 } |
1544 } | 1564 } |
1545 } | 1565 } |
1546 #endif | 1566 #endif |
1547 | 1567 |
1568 if(!sh_video) { | |
1569 if(!quiet) mp_msg(MSGT_AVSYNC,MSGL_STATUS,"A:%6.1f %4.1f%% %d%% \r" | |
1570 ,sh_audio->timer-audio_out->get_delay() | |
1571 ,(sh_audio->timer>0.5)?100.0*audio_time_usage/(double)sh_audio->timer:0 | |
1572 ,cache_fill_status | |
1573 ); | |
1574 usec_sleep(sh_audio->a_buffer_len/sh_audio->o_bps/1000); | |
1575 goto read_input; | |
1576 } | |
1577 | |
1548 /*========================== PLAY VIDEO ============================*/ | 1578 /*========================== PLAY VIDEO ============================*/ |
1579 | |
1580 vo_pts=sh_video->timer*90000.0; | |
1581 vo_fps=sh_video->fps; | |
1549 | 1582 |
1550 cvideo_base_vframe=sh_video->timer; | 1583 cvideo_base_vframe=sh_video->timer; |
1551 cvideo_base_vtime=video_time_usage; | 1584 cvideo_base_vtime=video_time_usage; |
1552 | 1585 |
1553 if(1) | 1586 if(1) |
1885 // printf("total: %8.6f sleep: %8.6f q: %d\n",(0.000001f*aq_total_time),aq_sleep_time,output_quality); | 1918 // printf("total: %8.6f sleep: %8.6f q: %d\n",(0.000001f*aq_total_time),aq_sleep_time,output_quality); |
1886 set_video_quality(sh_video,output_quality); | 1919 set_video_quality(sh_video,output_quality); |
1887 #endif | 1920 #endif |
1888 } | 1921 } |
1889 | 1922 |
1923 read_input: | |
1924 | |
1890 #ifdef USE_OSD | 1925 #ifdef USE_OSD |
1891 if(osd_visible){ | 1926 if(osd_visible){ |
1892 if (!--osd_visible){ vo_osd_progbar_type=-1; // disable | 1927 if (!--osd_visible){ vo_osd_progbar_type=-1; // disable |
1893 if (osd_function != OSD_PAUSE) | 1928 if (osd_function != OSD_PAUSE) |
1894 osd_function = OSD_PLAY; | 1929 osd_function = OSD_PLAY; |
1901 mp_cmd_t* cmd; | 1936 mp_cmd_t* cmd; |
1902 #endif | 1937 #endif |
1903 #ifdef HAVE_NEW_GUI | 1938 #ifdef HAVE_NEW_GUI |
1904 int gui_pause_flag=0; // gany! | 1939 int gui_pause_flag=0; // gany! |
1905 #endif | 1940 #endif |
1906 mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\n------ PAUSED -------\r");fflush(stdout); | 1941 if(!quiet) { |
1942 mp_msg(MSGT_CPLAYER,MSGL_STATUS,"\n------ PAUSED -------\r"); | |
1943 fflush(stdout); | |
1944 } | |
1907 #ifdef HAVE_NEW_GUI | 1945 #ifdef HAVE_NEW_GUI |
1908 if(use_gui) mplShMem->Playing=2; | 1946 if(use_gui) mplShMem->Playing=2; |
1909 #endif | 1947 #endif |
1910 if (audio_out && sh_audio) | 1948 if (audio_out && sh_audio) |
1911 audio_out->pause(); // pause audio, keep data if possible | 1949 audio_out->pause(); // pause audio, keep data if possible |
1933 lirc_mp_getinput()<=0 && | 1971 lirc_mp_getinput()<=0 && |
1934 #endif | 1972 #endif |
1935 (use_stdin || getch2(20)<=0) && mplayer_get_key()<=0){ | 1973 (use_stdin || getch2(20)<=0) && mplayer_get_key()<=0){ |
1936 #endif | 1974 #endif |
1937 #ifndef USE_LIBVO2 | 1975 #ifndef USE_LIBVO2 |
1938 video_out->check_events(); | 1976 if(sh_video && video_out) video_out->check_events(); |
1939 #endif /* HAVE_NEW_INPUT */ | 1977 #endif /* HAVE_NEW_INPUT */ |
1940 #ifdef HAVE_NEW_GUI | 1978 #ifdef HAVE_NEW_GUI |
1941 if(use_gui){ | 1979 if(use_gui){ |
1942 EventHandling(); | 1980 EventHandling(); |
1943 if(mplShMem->Playing!=2 || (rel_seek_secs || abs_seek_pos)) | 1981 if(mplShMem->Playing!=2 || (rel_seek_secs || abs_seek_pos)) |
2096 case KEY_DEL: | 2134 case KEY_DEL: |
2097 if(playtree_iter->num_files > 1 && playtree_iter->file > 1) | 2135 if(playtree_iter->num_files > 1 && playtree_iter->file > 1) |
2098 eof = PT_PREV_SRC; | 2136 eof = PT_PREV_SRC; |
2099 break; | 2137 break; |
2100 case 'o': // toggle OSD | 2138 case 'o': // toggle OSD |
2101 osd_level=(osd_level+1)%3; | 2139 if(sh_video) |
2140 osd_level=(osd_level+1)%3; | |
2102 break; | 2141 break; |
2103 case 'z': | 2142 case 'z': |
2104 sub_delay -= 0.1; | 2143 sub_delay -= 0.1; |
2105 osd_show_sub_delay = 9; // show the subdelay in OSD | 2144 osd_show_sub_delay = 9; // show the subdelay in OSD |
2106 break; | 2145 break; |
2350 sub_delay = v; | 2389 sub_delay = v; |
2351 else | 2390 else |
2352 sub_delay += v; | 2391 sub_delay += v; |
2353 osd_show_sub_delay = 9; // show the subdelay in OSD | 2392 osd_show_sub_delay = 9; // show the subdelay in OSD |
2354 } break; | 2393 } break; |
2355 case MP_CMD_OSD : { | 2394 case MP_CMD_OSD : |
2356 int v = cmd->args[0].v.i; | 2395 if(sh_video) { |
2357 if(v < 0) | 2396 int v = cmd->args[0].v.i; |
2358 osd_level=(osd_level+1)%3; | 2397 if(v < 0) |
2359 else | 2398 osd_level=(osd_level+1)%3; |
2360 osd_level= v > 2 ? 2 : v; | 2399 else |
2361 } break; | 2400 osd_level= v > 2 ? 2 : v; |
2401 } break; | |
2362 case MP_CMD_VOLUME : { | 2402 case MP_CMD_VOLUME : { |
2363 int v = cmd->args[0].v.i; | 2403 int v = cmd->args[0].v.i; |
2364 if(v > 0) | 2404 if(v > 0) |
2365 mixer_incvolume(); | 2405 mixer_incvolume(); |
2366 else | 2406 else |
2554 vo_osd_progbar_type=0; | 2594 vo_osd_progbar_type=0; |
2555 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; | 2595 vo_osd_progbar_value=(demuxer->filepos-demuxer->movi_start)/len; |
2556 } | 2596 } |
2557 } | 2597 } |
2558 #endif | 2598 #endif |
2559 | 2599 if(sh_video) { |
2560 c_total=0; | 2600 c_total=0; |
2561 max_pts_correction=0.1; | 2601 max_pts_correction=0.1; |
2562 osd_visible=sh_video->fps; // to rewert to PLAY pointer after 1 sec | 2602 osd_visible=sh_video->fps; // to rewert to PLAY pointer after 1 sec |
2563 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; | 2603 audio_time_usage=0; video_time_usage=0; vout_time_usage=0; |
2564 drop_frame_cnt=0; | 2604 drop_frame_cnt=0; |
2565 too_slow_frame_cnt=0; | 2605 too_slow_frame_cnt=0; |
2566 too_fast_frame_cnt=0; | 2606 too_fast_frame_cnt=0; |
2567 | 2607 |
2568 #ifdef USE_DVDREAD | 2608 #ifdef USE_DVDREAD |
2569 if(vo_spudec) spudec_reset(vo_spudec); | 2609 if(vo_spudec) spudec_reset(vo_spudec); |
2570 #endif | 2610 #endif |
2611 } | |
2571 } | 2612 } |
2572 rel_seek_secs=0; | 2613 rel_seek_secs=0; |
2573 abs_seek_pos=0; | 2614 abs_seek_pos=0; |
2574 current_module=NULL; | 2615 current_module=NULL; |
2575 } | 2616 } |