6 #define _UWIN 1 /*disable Non-underscored versions of non-ANSI functions as otherwise int eof would conflict with eof()*/
12 // #include <sys/mman.h>
13 #include <sys/types.h>
15 #include <sys/ioctl.h>
18 #define SIGHUP 1 /* hangup */
19 #define SIGQUIT 3 /* quit */
20 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
21 #define SIGBUS 10 /* bus error */
22 extern int mp_input_win32_slave_cmd_func(int fd
,char* dest
,int size
);
39 #define HELP_MP_DEFINE_STATIC
45 #include "cfg-mplayer-def.h"
48 #include "subreader.h"
51 #include "libvo/video_out.h"
53 #include "libvo/font_load.h"
54 #include "libvo/sub.h"
57 #include "libvo/x11_common.h"
60 #include "libao2/audio_out.h"
61 #include "libao2/audio_plugin.h"
63 #include "codec-cfg.h"
76 #include "osdep/getch2.h"
77 #include "osdep/timer.h"
79 #include "cpudetect.h"
82 #include "Gui/interface.h"
85 #include "input/input.h"
92 #define ABS(x) (((x)>=0)?(x):(-(x)))
93 #define ROUND(x) ((int)((x)<0 ? (x)-0.5 : (x)+0.5))
96 #include <linux/rtc.h>
100 #include "libmpdemux/tv.h"
103 #ifdef HAS_DVBIN_SUPPORT
104 #include "libmpdemux/dvbin.h"
105 static int last_dvb_step
= 1;
108 //**************************************************************************//
110 //**************************************************************************//
111 #include "playtree.h"
112 #include "playtreeparser.h"
115 extern int import_playtree_playlist_into_gui(play_tree_t
* my_playtree
, m_config_t
* config
);
116 extern int import_initial_playtree_into_gui(play_tree_t
* my_playtree
, m_config_t
* config
, int enqueue
);
119 play_tree_t
* playtree
;
120 play_tree_iter_t
* playtree_iter
= NULL
;
122 #define PT_NEXT_ENTRY 1
123 #define PT_PREV_ENTRY -1
124 #define PT_NEXT_SRC 2
125 #define PT_PREV_SRC -2
127 #define PT_UP_PREV -3
129 //**************************************************************************//
131 //**************************************************************************//
135 m_config_parse_mp_command_line(m_config_t
*config
, int argc
, char **argv
);
137 m_config_parse_config_file(m_config_t
* config
, char *conffile
);
139 //**************************************************************************//
141 //**************************************************************************//
143 static int cfg_inc_verbose(m_option_t
*conf
){ ++verbose
; return 0;}
145 static int cfg_include(m_option_t
*conf
, char *filename
){
146 return m_config_parse_config_file(mconfig
, filename
);
149 #include "get_path.c"
151 //**************************************************************************//
153 //**************************************************************************//
156 void xscreensaver_heartbeat(void);
159 //**************************************************************************//
160 //**************************************************************************//
161 // Input media streaming & demultiplexer:
162 //**************************************************************************//
164 static int max_framesize
=0;
166 #include "libmpdemux/stream.h"
167 #include "libmpdemux/demuxer.h"
168 #include "libmpdemux/stheader.h"
169 //#include "parse_es.h"
171 #include "libmpdemux/matroska.h"
174 #include "libmpcodecs/dec_audio.h"
175 #include "libmpcodecs/dec_video.h"
176 #include "libmpcodecs/mp_image.h"
177 #include "libmpcodecs/vf.h"
179 extern void vf_list_plugins();
181 //**************************************************************************//
182 //**************************************************************************//
184 // Common FIFO functions, and keyboard/event FIFO code
186 int noconsolecontrols
=0;
187 //**************************************************************************//
189 vo_functions_t
*video_out
=NULL
;
190 ao_functions_t
*audio_out
=NULL
;
196 double video_time_usage
=0;
197 double vout_time_usage
=0;
198 static double audio_time_usage
=0;
199 static int total_time_usage_start
=0;
200 static int total_frame_cnt
=0;
201 static int drop_frame_cnt
=0; // total number of dropped frames
206 static int output_quality
=0;
208 float playback_speed
=1.0;
216 #define MAX_OSD_LEVEL 3
219 int osd_level_saved
=-1;
223 static char *seek_to_sec
=NULL
;
224 static off_t seek_to_byte
=0;
225 static off_t step_sec
=0;
226 static int loop_times
=-1;
227 static int loop_seek
=0;
230 int autosync
=0; // 30 might be a good default value.
232 // may be changed by GUI: (FIXME!)
233 float rel_seek_secs
=0;
237 char **audio_codec_list
=NULL
; // override audio codec
238 char **video_codec_list
=NULL
; // override video codec
239 char **audio_fm_list
=NULL
; // override audio codec family
240 char **video_fm_list
=NULL
; // override video codec family
247 char* audio_lang
=NULL
;
248 char* dvdsub_lang
=NULL
;
249 static char* spudec_ifo
=NULL
;
250 char* filename
=NULL
; //"MI2-Trailer.avi";
251 int forced_subs_only
=0;
254 int stream_cache_size
=-1;
255 #ifdef USE_STREAM_CACHE
256 extern int cache_fill_status
;
258 float stream_cache_min_percent
=20.0;
259 float stream_cache_prefill_percent
=5.0;
261 #define cache_fill_status 0
265 static char *stream_dump_name
="stream.dump";
266 int stream_dump_type
=0;
269 static float default_max_pts_correction
=-1;//0.01f;
270 static float max_pts_correction
=0;//default_max_pts_correction;
271 static float c_total
=0;
274 static int softsleep
=0;
277 static int force_srate
=0;
278 static int audio_output_format
=0;
279 int frame_dropping
=0; // option 0=no drop 1= drop vo 2= drop decode
280 static int play_n_frames
=-1;
281 static int play_n_frames_mf
=-1;
284 char** video_driver_list
=NULL
;
285 char** audio_driver_list
=NULL
;
287 extern char *vo_subdevice
;
288 extern char *ao_subdevice
;
290 // codec outfmt flags (defined in libmpcodecs/vd.c)
294 char *font_name
=NULL
;
295 #ifdef HAVE_FONTCONFIG
296 extern int font_fontconfig
;
298 float font_factor
=0.75;
299 char **sub_name
=NULL
;
303 char *vobsub_name
=NULL
;
304 /*DSP!!char *dsp=NULL;*/
306 int suboverlap_enabled
= 1;
308 sub_data
* set_of_subtitles
[MAX_SUBTITLE_FILES
];
309 int set_of_sub_size
= 0;
310 int set_of_sub_pos
= -1;
311 float sub_last_pts
= -303;
313 int global_sub_size
= 0; // this encompasses all subtitle sources
314 int global_sub_pos
= -1; // this encompasses all subtitle sources
315 #define SUB_SOURCE_SUBS 0
316 #define SUB_SOURCE_VOBSUB 1
317 #define SUB_SOURCE_DEMUX 2
318 #define SUB_SOURCES 3
319 int global_sub_indices
[SUB_SOURCES
];
320 int global_sub_quiet_osd_hack
= 0;
322 static stream_t
* stream
=NULL
;
323 static demuxer_t
*demuxer
=NULL
;
324 static sh_audio_t
*sh_audio
=NULL
;
325 static sh_video_t
*sh_video
=NULL
;
327 char* current_module
=NULL
; // for debugging
329 extern int vo_gamma_gamma
;
330 extern int vo_gamma_brightness
;
331 extern int vo_gamma_contrast
;
332 extern int vo_gamma_saturation
;
333 extern int vo_gamma_hue
;
338 #include "m_struct.h"
339 #include "libmenu/menu.h"
340 extern void vf_menu_pause_update(struct vf_instance_s
* vf
);
341 extern vf_info_t vf_info_menu
;
342 static vf_info_t
* libmenu_vfs
[] = {
346 static vf_instance_t
* vf_menu
= NULL
;
347 static int use_menu
= 0;
348 static char* menu_cfg
= NULL
;
349 static char* menu_root
= "main";
355 static char* rtc_device
;
359 edl_record_ptr edl_records
= NULL
; /// EDL entries memory area
360 edl_record_ptr next_edl_record
= NULL
; /// only for traversing edl_records
361 int edl_memory_slots
= 0; /// number of EDL entries (1 for skip + 2 for each mute)
362 int edl_operations
= 0; /// number of EDL operations, skip + mute
363 short edl_decision
= 0; /// 1 when an EDL operation has been made
364 FILE* edl_fd
= NULL
; /// fd to write to when in -edlout mode
365 int edl_mute_count
= 0; /// even number when mute and unmute has been matched
368 static unsigned int inited_flags
=0;
372 #define INITED_GETCH2 8
373 #define INITED_SPUDEC 32
374 #define INITED_STREAM 64
375 #define INITED_INPUT 128
376 #define INITED_VOBSUB 256
377 #define INITED_DEMUXER 512
378 #define INITED_ACODEC 1024
379 #define INITED_VCODEC 2048
380 #define INITED_ALL 0xFFFF
382 static void uninit_player(unsigned int mask
){
383 mask
=inited_flags
&mask
;
385 mp_msg(MSGT_CPLAYER
,MSGL_DBG2
,"\n*** uninit(0x%X)\n",mask
);
387 if(mask
&INITED_ACODEC
){
388 inited_flags
&=~INITED_ACODEC
;
389 current_module
="uninit_acodec";
390 if(sh_audio
) uninit_audio(sh_audio
);
394 if(mask
&INITED_VCODEC
){
395 inited_flags
&=~INITED_VCODEC
;
396 current_module
="uninit_vcodec";
397 if(sh_video
) uninit_video(sh_video
);
404 if(mask
&INITED_DEMUXER
){
405 inited_flags
&=~INITED_DEMUXER
;
406 current_module
="free_demuxer";
408 stream
=demuxer
->stream
;
409 free_demuxer(demuxer
);
414 // kill the cache process:
415 if(mask
&INITED_STREAM
){
416 inited_flags
&=~INITED_STREAM
;
417 current_module
="uninit_stream";
418 if(stream
) free_stream(stream
);
423 inited_flags
&=~INITED_VO
;
424 current_module
="uninit_vo";
429 // must be after libvo uninit, as few vo drivers (svgalib) has tty code
430 if(mask
&INITED_GETCH2
){
431 inited_flags
&=~INITED_GETCH2
;
432 current_module
="uninit_getch2";
433 mp_msg(MSGT_CPLAYER
,MSGL_DBG2
,"\n[[[uninit getch2]]]\n");
438 if(mask
&INITED_VOBSUB
){
439 inited_flags
&=~INITED_VOBSUB
;
440 current_module
="uninit_vobsub";
441 if(vo_vobsub
) vobsub_close(vo_vobsub
);
445 if (mask
&INITED_SPUDEC
){
446 inited_flags
&=~INITED_SPUDEC
;
447 current_module
="uninit_spudec";
448 spudec_free(vo_spudec
);
453 inited_flags
&=~INITED_AO
;
454 current_module
="uninit_ao";
455 audio_out
->uninit(eof
?0:1); audio_out
=NULL
;
460 inited_flags
&=~INITED_GUI
;
461 current_module
="uninit_gui";
466 if(mask
&INITED_INPUT
){
467 inited_flags
&=~INITED_INPUT
;
468 current_module
="uninit_input";
475 static void exit_player_with_rc(char* how
, int rc
){
477 uninit_player(INITED_ALL
);
482 vo_uninit(); // close the X11 connection (if any opened)
485 current_module
="exit_player";
488 if(edl_records
!= NULL
) free(edl_records
); // free mem allocated for EDL
490 if(how
) mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_ExitingHow
,mp_gettext(how
));
491 mp_msg(MSGT_CPLAYER
,MSGL_DBG2
,"max framesize was %d bytes\n",max_framesize
);
496 void exit_player(char* how
){
497 exit_player_with_rc(how
, 1);
501 static void child_sighandler(int x
){
503 while((pid
=waitpid(-1,NULL
,WNOHANG
)) > 0);
507 static void exit_sighandler(int x
){
508 static int sig_count
=0;
510 if(inited_flags
==0 && sig_count
>1) exit(1);
513 /* We're crashing bad and can't uninit cleanly :(
514 * by popular request, we make one last (dirty)
515 * effort to restore the user's
520 if(sig_count
==6) exit(1);
524 kill(getpid(),SIGKILL
);
527 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,"\n" MSGTR_IntBySignal
,x
,
528 current_module
?current_module
:mp_gettext("unknown")
536 break; // killed from keyboard (^C) or killed [-9]
538 #ifdef RUNTIME_CPUDETECT
539 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_Exit_SIGILL_RTCpuSel
);
541 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_Exit_SIGILL
);
545 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_Exit_SIGSEGV_SIGFPE
);
547 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_Exit_SIGCRASH
);
552 //extern void write_avi_header_1(FILE *f,int fcc,float fps,int width,int height);
554 extern void mp_input_register_options(m_config_t
* cfg
);
558 /// step size of mixer changes
561 #include "cfg-mplayer.h"
563 void parse_cfgfiles( m_config_t
* conf
)
567 if (m_config_parse_config_file(conf
, MPLAYER_CONFDIR
"/mplayer.conf") < 0)
569 if ((conffile
= get_path("")) == NULL
) {
570 mp_msg(MSGT_CPLAYER
,MSGL_WARN
,MSGTR_NoHomeDir
);
575 mkdir(conffile
, 0777);
578 if ((conffile
= get_path("config")) == NULL
) {
579 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_GetpathProblem
);
581 if ((conffile_fd
= open(conffile
, O_CREAT
| O_EXCL
| O_WRONLY
, 0666)) != -1) {
582 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_CreatingCfgFile
, conffile
);
583 write(conffile_fd
, default_config
, strlen(default_config
));
586 if (m_config_parse_config_file(conf
, conffile
) < 0)
593 void load_per_file_config (m_config_t
* conf
, const char *const file
)
596 char cfg
[strlen(file
)+10];
600 sprintf (cfg
, "%s.conf", file
);
602 if (!stat (cfg
, &st
))
604 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_LoadingConfig
, cfg
);
605 m_config_parse_config_file (conf
, cfg
);
609 if ((name
= strrchr (cfg
, '/')) == NULL
)
614 if ((confpath
= get_path (name
)) != NULL
)
616 if (!stat (confpath
, &st
))
618 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_LoadingConfig
, confpath
);
619 m_config_parse_config_file (conf
, confpath
);
626 // When libmpdemux perform a blocking operation (network connection or cache filling)
627 // if the operation fail we use this function to check if it was interrupted by the user.
628 // The function return a new value for eof.
629 static int libmpdemux_was_interrupted(int eof
) {
631 if((cmd
= mp_input_get_cmd(0,0,0)) != NULL
) {
634 exit_player_with_rc(MSGTR_Exit_quit
, (cmd
->nargs
> 0)? cmd
->args
[0].v
.i
: 0);
635 case MP_CMD_PLAY_TREE_STEP
: {
636 eof
= (cmd
->args
[0].v
.i
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
638 case MP_CMD_PLAY_TREE_UP_STEP
: {
639 eof
= (cmd
->args
[0].v
.i
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
641 case MP_CMD_PLAY_ALT_SRC_STEP
: {
642 eof
= (cmd
->args
[0].v
.i
> 0) ? PT_NEXT_SRC
: PT_PREV_SRC
;
650 #define mp_basename2(s) (strrchr(s,'/')==NULL?(char*)s:(strrchr(s,'/')+1))
651 #define mp_basename(s) (strrchr(s,'\\')==NULL?(mp_basename2(s)):(strrchr(s,'\\')+1))
653 int playtree_add_playlist(play_tree_t
* entry
)
655 play_tree_add_bpf(entry
,filename
);
660 import_playtree_playlist_into_gui(entry
, mconfig
);
661 play_tree_free_list(entry
,1);
667 entry
= playtree_iter
->tree
;
668 if(play_tree_iter_step(playtree_iter
,1,0) != PLAY_TREE_ITER_ENTRY
) {
669 return PT_NEXT_ENTRY
;
671 if(playtree_iter
->tree
== entry
) { // Loop with a single file
672 if(play_tree_iter_up_step(playtree_iter
,1,0) != PLAY_TREE_ITER_ENTRY
) {
673 return PT_NEXT_ENTRY
;
676 play_tree_remove(entry
,1,1);
679 play_tree_insert_entry(playtree_iter
->tree
,entry
);
680 play_tree_set_params_from(entry
,playtree_iter
->tree
);
681 entry
= playtree_iter
->tree
;
682 if(play_tree_iter_step(playtree_iter
,1,0) != PLAY_TREE_ITER_ENTRY
) {
683 return PT_NEXT_ENTRY
;
685 play_tree_remove(entry
,1,1);
690 static int play_tree_step
= 1;
697 for (i
= 0; i
< SUB_SOURCES
; i
++) {
698 int j
= global_sub_indices
[i
];
699 if ((j
>= 0) && (j
> top
) && (global_sub_pos
>= j
)) {
709 sub_data
* subdata
= NULL
;
711 void add_subtitles(char *filename
, float fps
, int silent
)
715 if (filename
== NULL
) {
719 subd
= sub_read_file(filename
, fps
);
721 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_CantLoadSub
, filename
);
722 if (subd
== NULL
|| set_of_sub_size
>= MAX_SUBTITLE_FILES
) return;
723 set_of_subtitles
[set_of_sub_size
] = subd
;
725 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_AddedSubtitleFile
, set_of_sub_size
, filename
);
728 // FIXME: if/when the GUI calls this, global sub numbering gets (potentially) broken.
729 void update_set_of_subtitles()
730 // subdata was changed, set_of_sub... have to be updated.
733 if (set_of_sub_size
> 0 && subdata
== NULL
) { // *subdata was deleted
734 for (i
= set_of_sub_pos
+ 1; i
< set_of_sub_size
; ++i
)
735 set_of_subtitles
[i
-1] = set_of_subtitles
[i
];
736 set_of_subtitles
[set_of_sub_size
-1] = NULL
;
738 if (set_of_sub_size
> 0) subdata
= set_of_subtitles
[set_of_sub_pos
=0];
740 else if (set_of_sub_size
> 0 && subdata
!= NULL
) { // *subdata was changed
741 set_of_subtitles
[set_of_sub_pos
] = subdata
;
743 else if (set_of_sub_size
<= 0 && subdata
!= NULL
) { // *subdata was added
744 set_of_subtitles
[set_of_sub_pos
=set_of_sub_size
] = subdata
;
751 * In Mac OS X the SDL-lib is built upon Cocoa. The easiest way to
752 * make it all work is to use the builtin SDL-bootstrap code, which
753 * will be done automatically by replacing our main() if we include SDL.h.
755 #if defined(SYS_DARWIN) && defined(HAVE_SDL)
760 * \brief build a chain of audio filters that converts the input format
761 * to the ao's format, taking into account the current playback_speed.
762 * \param sh_audio describes the requested input format of the chain.
763 * \param ao_data describes the requested output format of the chain.
765 static int build_afilter_chain(sh_audio_t
*sh_audio
, ao_data_t
*ao_data
)
767 int new_srate
= sh_audio
->samplerate
* playback_speed
;
770 if (new_srate
!= ao_data
->samplerate
) {
771 // limits are taken from libaf/af_resample.c
772 if (new_srate
< 8000)
774 if (new_srate
> 192000)
776 playback_speed
= (float)new_srate
/ (float)sh_audio
->samplerate
;
778 return init_audio_filters(sh_audio
, new_srate
,
779 sh_audio
->channels
, sh_audio
->sample_format
, sh_audio
->samplesize
,
780 ao_data
->samplerate
, ao_data
->channels
, ao_data
->format
,
781 audio_out_format_bits(ao_data
->format
) / 8, /* ao_data.bps, */
782 ao_data
->outburst
* 4, ao_data
->buffersize
);
785 int main(int argc
,char* argv
[]){
790 static demux_stream_t
*d_audio
=NULL
;
791 static demux_stream_t
*d_video
=NULL
;
792 static demux_stream_t
*d_dvdsub
=NULL
;
794 int file_format
=DEMUXER_TYPE_UNKNOWN
;
796 int delay_corrected
=1;
800 int osd_function
=OSD_PLAY
;
801 int osd_last_pts
=-303;
802 int osd_show_av_delay
= 0;
803 int osd_show_text
= 0;
804 int osd_show_speed
= 0;
805 int osd_show_sub_delay
= 0;
806 int osd_show_sub_pos
= 0;
807 int osd_show_sub_visibility
= 0;
808 int osd_show_sub_alignment
= 0;
809 int osd_show_vobsub_changed
= 0;
810 int osd_show_sub_changed
= 0;
811 int osd_show_percentage
= 0;
812 int osd_show_tv_channel
= 25;
813 int osd_show_ontop
= 0;
814 int osd_show_rootwin
= 0;
815 int osd_show_framedropping
= 0;
819 //float a_frame=0; // Audio
824 int gui_no_filename
=0;
827 srand((int) time(NULL
));
830 mp_msg_set_level(MSGL_STATUS
);
832 mp_msg(MSGT_CPLAYER
,MSGL_INFO
, "MPlayer " VERSION
" (C) 2000-2004 MPlayer Team\n\n");
833 /* Test for cpu capabilities (and corresponding OS support) for optimizing */
834 GetCpuCaps(&gCpuCaps
);
836 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"CPUflags: MMX: %d MMX2: %d 3DNow: %d 3DNow2: %d SSE: %d SSE2: %d\n",
837 gCpuCaps
.hasMMX
,gCpuCaps
.hasMMX2
,
838 gCpuCaps
.has3DNow
, gCpuCaps
.has3DNowExt
,
839 gCpuCaps
.hasSSE
, gCpuCaps
.hasSSE2
);
840 #ifdef RUNTIME_CPUDETECT
841 mp_msg(MSGT_CPLAYER
,MSGL_INFO
, MSGTR_CompiledWithRuntimeDetection
);
843 mp_msg(MSGT_CPLAYER
,MSGL_INFO
, MSGTR_CompiledWithCPUExtensions
);
845 mp_msg(MSGT_CPLAYER
,MSGL_INFO
," MMX");
848 mp_msg(MSGT_CPLAYER
,MSGL_INFO
," MMX2");
851 mp_msg(MSGT_CPLAYER
,MSGL_INFO
," 3DNow");
854 mp_msg(MSGT_CPLAYER
,MSGL_INFO
," 3DNowEx");
857 mp_msg(MSGT_CPLAYER
,MSGL_INFO
," SSE");
860 mp_msg(MSGT_CPLAYER
,MSGL_INFO
," SSE2");
862 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"\n\n");
866 #if defined(WIN32) && defined(USE_WIN32DLL)
867 { /*make our codec dirs available for LoadLibraryA()*/
868 char tmppath
[MAX_PATH
*2 + 1];
869 char win32path
[MAX_PATH
];
870 char realpath
[MAX_PATH
];
872 cygwin_conv_to_full_win32_path(WIN32_PATH
,win32path
);
873 strcpy(tmppath
,win32path
);
874 #ifdef USE_REALCODECS
875 cygwin_conv_to_full_win32_path(REALCODEC_PATH
,realpath
);
876 sprintf(tmppath
,"%s;%s",win32path
,realpath
);
877 #endif /*USE_REALCODECS*/
879 if(!strstr(WIN32_PATH
,":")){
880 GetModuleFileNameA(NULL
, win32path
, MAX_PATH
);
881 strcpy(win32path
+ strlen(win32path
) - strlen("mplayer.exe"), WIN32_PATH
);
883 else strcpy(win32path
,WIN32_PATH
);
884 strcpy(tmppath
,win32path
);
885 #ifdef USE_REALCODECS
886 if(!strstr(REALCODEC_PATH
,":")){
887 GetModuleFileNameA(NULL
, realpath
, MAX_PATH
);
888 strcpy(realpath
+ strlen(realpath
) - strlen("mplayer.exe"), REALCODEC_PATH
);
890 else strcpy(realpath
,REALCODEC_PATH
);
891 sprintf(tmppath
,"%s;%s",win32path
,realpath
);
892 #endif /*USE_REALCODECS*/
893 #endif /*__CYGWIN__*/
894 SetEnvironmentVariableA("PATH", tmppath
);
896 #endif /*WIN32 && USE_WIN32DLL*/
899 tv_param_immediate
= 1;
903 if(!strcmp(argv
[0],"gmplayer") ||
904 (strrchr(argv
[0],'/') && !strcmp(strrchr(argv
[0],'/'),"/gmplayer") ) )
907 mconfig
= m_config_new();
908 m_config_register_options(mconfig
,mplayer_opts
);
909 // TODO : add something to let modules register their options
910 mp_input_register_options(mconfig
);
911 parse_cfgfiles(mconfig
);
914 if ( use_gui
) cfg_read();
917 playtree
= m_config_parse_mp_command_line(mconfig
, argc
, argv
);
921 playtree
= play_tree_cleanup(playtree
);
923 playtree_iter
= play_tree_iter_new(playtree
,mconfig
);
925 if(play_tree_iter_step(playtree_iter
,0,0) != PLAY_TREE_ITER_ENTRY
) {
926 play_tree_iter_free(playtree_iter
);
927 playtree_iter
= NULL
;
929 filename
= play_tree_iter_get_file(playtree_iter
,1);
935 mp_msg(MSGT_CPLAYER
,MSGL_WARN
,MSGTR_NoGui
);
939 if(use_gui
&& !vo_init()){
940 mp_msg(MSGT_CPLAYER
,MSGL_WARN
,MSGTR_GuiNeedsX
);
943 if (use_gui
&& playtree_iter
){
944 char cwd
[PATH_MAX
+2];
945 // Remove Playtree and Playtree-Iter from memory as its not used by gui
946 play_tree_iter_free(playtree_iter
);
949 if (getcwd(cwd
, PATH_MAX
) != (char *)NULL
)
952 // Prefix relative paths with current working directory
953 play_tree_add_bpf(playtree
, cwd
);
955 // Import initital playtree into gui
956 import_initial_playtree_into_gui(playtree
, mconfig
, enqueue
);
960 if(video_driver_list
&& strcmp(video_driver_list
[0],"help")==0){
962 exit_player_with_rc(NULL
, 0);
965 if(audio_driver_list
&& strcmp(audio_driver_list
[0],"help")==0){
967 exit_player_with_rc(NULL
, 0);
971 if(!codecs_file
|| !parse_codec_cfg(codecs_file
)){
972 if(!parse_codec_cfg(mem_ptr
=get_path("codecs.conf"))){
973 if(!parse_codec_cfg(MPLAYER_CONFDIR
"/codecs.conf")){
974 if(!parse_codec_cfg(NULL
)){
975 mp_msg(MSGT_CPLAYER
,MSGL_HINT
,MSGTR_CopyCodecsConf
);
976 exit_player_with_rc(NULL
, 0);
978 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_BuiltinCodecsConf
);
981 free( mem_ptr
); // release the buffer created by get_path()
985 if(video_codec_list
){
987 video_codec
=video_codec_list
[0];
988 for(i
=0;video_codec_list
[i
];i
++)
989 mp_msg(MSGT_FIXME
,MSGL_FIXME
,"vc#%d: '%s'\n",i
,video_codec_list
[i
]);
992 if(audio_codec_list
&& strcmp(audio_codec_list
[0],"help")==0){
993 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_AvailableAudioCodecs
);
995 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\n");
996 exit_player_with_rc(NULL
, 0);
998 if(video_codec_list
&& strcmp(video_codec_list
[0],"help")==0){
999 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_AvailableVideoCodecs
);
1001 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\n");
1002 exit_player_with_rc(NULL
, 0);
1004 if(video_fm_list
&& strcmp(video_fm_list
[0],"help")==0){
1006 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\n");
1007 exit_player_with_rc(NULL
, 0);
1009 if(audio_fm_list
&& strcmp(audio_fm_list
[0],"help")==0){
1011 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\n");
1012 exit_player_with_rc(NULL
, 0);
1014 if(af_cfg
.list
&& strcmp(af_cfg
.list
[0],"help")==0){
1017 exit_player_with_rc(NULL
, 0);
1020 if(vo_fstype_list
&& strcmp(vo_fstype_list
[0],"help")==0){
1022 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\n");
1023 exit_player_with_rc(NULL
, 0);
1028 if (edl_check_mode() == EDL_ERROR
&& edl_filename
)
1030 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_EdlCantUseBothModes
);
1032 } else if (edl_filename
)
1034 edl_memory_slots
= edl_count_entries();
1035 if (edl_memory_slots
> 0)
1037 edl_records
= calloc(edl_memory_slots
, sizeof(struct edl_record
));
1038 if (edl_records
== NULL
)
1040 mp_msg(MSGT_CPLAYER
, MSGL_FATAL
, MSGTR_EdlOutOfMem
);
1044 if ((edl_operations
= edl_parse_file(edl_records
)) > 0)
1046 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdlRecordsNo
,
1051 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_EdlQueueEmpty
);
1056 next_edl_record
= edl_records
;
1058 } else if (edl_output_filename
)
1060 if ((edl_fd
= fopen(edl_output_filename
, "w")) == NULL
)
1062 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_EdlCantOpenForWrite
,
1063 edl_output_filename
);
1071 // no file/vcd/dvd -> show HELP:
1072 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, help_text
);
1073 exit_player_with_rc(NULL
, 0);
1074 } else gui_no_filename
=1;
1077 // Many users forget to include command line in bugreports...
1079 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_CommandLine
);
1080 for(i
=1;i
<argc
;i
++)mp_msg(MSGT_FIXME
, MSGL_FIXME
," '%s'",argv
[i
]);
1081 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\n");
1084 mp_msg_set_level(verbose
+MSGL_STATUS
);
1086 //------ load global data first ------
1090 #ifdef HAVE_FREETYPE
1093 #ifdef HAVE_FONTCONFIG
1094 if(!font_fontconfig
)
1098 vo_font
=read_font_desc(font_name
,font_factor
,verbose
>1);
1099 if(!vo_font
) mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_CantLoadFont
,font_name
);
1102 vo_font
=read_font_desc( mem_ptr
=get_path("font/font.desc"),font_factor
,verbose
>1);
1103 free(mem_ptr
); // release the buffer created by get_path()
1105 vo_font
=read_font_desc(MPLAYER_DATADIR
"/font/font.desc",font_factor
,verbose
>1);
1107 #ifdef HAVE_FONTCONFIG
1116 // seteuid(0); /* Can't hurt to try to get root here */
1117 if ((rtc_fd
= open(rtc_device
? rtc_device
: "/dev/rtc", O_RDONLY
)) < 0)
1118 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_RTCDeviceNotOpenable
,
1119 rtc_device
? rtc_device
: "/dev/rtc", strerror(errno
));
1121 unsigned long irqp
= 1024; /* 512 seemed OK. 128 is jerky. */
1123 if (ioctl(rtc_fd
, RTC_IRQP_SET
, irqp
) < 0) {
1124 mp_msg(MSGT_CPLAYER
, MSGL_WARN
, MSGTR_LinuxRTCInitErrorIrqpSet
, irqp
, strerror(errno
));
1125 mp_msg(MSGT_CPLAYER
, MSGL_HINT
, MSGTR_IncreaseRTCMaxUserFreq
, irqp
);
1128 } else if (ioctl(rtc_fd
, RTC_PIE_ON
, 0) < 0) {
1129 /* variable only by the root */
1130 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_LinuxRTCInitErrorPieOn
, strerror(errno
));
1134 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, MSGTR_UsingRTCTiming
, irqp
);
1138 // breaks DGA and SVGAlib and VESA drivers: --A'rpi
1139 // and now ? -- Pontscho
1140 if(use_gui
) setuid( getuid() ); // strongly test, please check this.
1144 mp_msg(MSGT_CPLAYER
, MSGL_INFO
, "Using %s timing\n",
1145 softsleep
?"software":timer_name
);
1148 if ( !use_gui
) load_termcap(NULL
); // load key-codes
1151 // ========== Init keyboard FIFO (connection to libvo) ============
1153 // Init input system
1154 current_module
= "init_input";
1156 #ifndef HAVE_NO_POSIX_SELECT
1157 make_pipe(&keyb_fifo_get
,&keyb_fifo_put
);
1159 if(keyb_fifo_get
> 0)
1160 mp_input_add_key_fd(keyb_fifo_get
,1,NULL
,NULL
);
1162 mp_input_add_key_fd(-1,0,mplayer_get_key
,NULL
);
1166 mp_input_add_cmd_fd(0,1,NULL
,NULL
);
1168 mp_input_add_cmd_fd(0,0,mp_input_win32_slave_cmd_func
,NULL
);
1170 else if(!noconsolecontrols
)
1171 #ifndef HAVE_NO_POSIX_SELECT
1172 mp_input_add_key_fd(0,1,NULL
,NULL
);
1174 mp_input_add_key_fd(0,0,NULL
,NULL
);
1177 inited_flags
|=INITED_INPUT
;
1178 current_module
= NULL
;
1182 if(menu_cfg
&& menu_init(menu_cfg
))
1183 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_MenuInitialized
, menu_cfg
);
1185 menu_cfg
= get_path("menu.conf");
1186 if(menu_init(menu_cfg
))
1187 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_MenuInitialized
, menu_cfg
);
1189 if(menu_init(MPLAYER_CONFDIR
"/menu.conf"))
1190 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_MenuInitialized
, MPLAYER_CONFDIR
"/menu.conf");
1192 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_MenuInitFailed
);
1202 signal(SIGCHLD
,child_sighandler
);
1205 //========= Catch terminate signals: ================
1206 // terminate requests:
1207 signal(SIGTERM
,exit_sighandler
); // kill
1208 signal(SIGHUP
,exit_sighandler
); // kill -HUP / xterm closed
1210 signal(SIGINT
,exit_sighandler
); // Interrupt from keyboard
1212 signal(SIGQUIT
,exit_sighandler
); // Quit from keyboard
1213 #ifdef ENABLE_SIGHANDLER
1215 signal(SIGBUS
,exit_sighandler
); // bus error
1216 signal(SIGSEGV
,exit_sighandler
); // segfault
1217 signal(SIGILL
,exit_sighandler
); // illegal instruction
1218 signal(SIGFPE
,exit_sighandler
); // floating point exc.
1219 signal(SIGABRT
,exit_sighandler
); // abort()
1225 inited_flags
|=INITED_GUI
;
1226 guiGetEvent( guiCEvent
,(char *)((gui_no_filename
) ? 0 : 1) );
1230 // ******************* Now, let's see the per-file stuff ********************
1234 // init global sub numbers
1235 global_sub_size
= 0;
1236 { int i
; for (i
= 0; i
< SUB_SOURCES
; i
++) global_sub_indices
[i
] = -1; }
1237 global_sub_quiet_osd_hack
= 1;
1239 if (filename
) load_per_file_config (mconfig
, filename
);
1241 // We must enable getch2 here to be able to interrupt network connection
1243 if(!noconsolecontrols
&& !slave_mode
){
1244 if(inited_flags
&INITED_GETCH2
)
1245 mp_msg(MSGT_CPLAYER
,MSGL_WARN
,MSGTR_Getch2InitializedTwice
);
1247 getch2_enable(); // prepare stdin for hotkeys...
1248 inited_flags
|=INITED_GETCH2
;
1249 mp_msg(MSGT_CPLAYER
,MSGL_DBG2
,"\n[[[init getch2]]]\n");
1252 // =================== GUI idle loop (STOP state) ===========================
1255 file_format
=DEMUXER_TYPE_UNKNOWN
;
1256 guiGetEvent( guiSetDefaults
,0 );
1257 while ( guiIntfStruct
.Playing
!= 1 )
1262 guiGetEvent( guiReDraw
,NULL
);
1263 if ( (cmd
= mp_input_get_cmd(0,0,0)) != NULL
) guiGetEvent( guiIEvent
,(char *)cmd
->id
);
1265 guiGetEvent( guiSetParameters
,NULL
);
1266 if ( guiIntfStruct
.StreamType
== STREAMTYPE_STREAM
)
1268 play_tree_t
* entry
= play_tree_new();
1269 play_tree_add_file( entry
,guiIntfStruct
.Filename
);
1270 if ( playtree
) play_tree_free_list( playtree
->child
,1 );
1271 else playtree
=play_tree_new();
1272 play_tree_set_child( playtree
,entry
);
1275 playtree_iter
= play_tree_iter_new(playtree
,mconfig
);
1278 if(play_tree_iter_step(playtree_iter
,0,0) != PLAY_TREE_ITER_ENTRY
)
1280 play_tree_iter_free(playtree_iter
);
1281 playtree_iter
= NULL
;
1283 filename
= play_tree_iter_get_file(playtree_iter
,1);
1289 //---------------------------------------------------------------------------
1291 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"\n");
1292 if(filename
) mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_Playing
, filename
);
1294 //==================== Open VOB-Sub ============================
1296 current_module
="vobsub";
1298 vo_vobsub
=vobsub_open(vobsub_name
,spudec_ifo
,1,&vo_spudec
);
1300 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_CantLoadSub
,vobsub_name
);
1301 }else if(sub_auto
&& filename
&& (strlen(filename
)>=5)){
1302 /* try to autodetect vobsub from movie filename ::atmos */
1303 char *buf
= malloc((strlen(filename
)-3) * sizeof(char));
1304 memset(buf
,0,strlen(filename
)-3); // make sure string is terminated
1305 strncpy(buf
, filename
, strlen(filename
)-4);
1306 vo_vobsub
=vobsub_open(buf
,spudec_ifo
,0,&vo_spudec
);
1310 inited_flags
|=INITED_VOBSUB
;
1311 vobsub_set_from_lang(vo_vobsub
, dvdsub_lang
);
1312 // check if vobsub requested only to display forced subtitles
1313 forced_subs_only
=vobsub_get_forced_subs_flag(vo_vobsub
);
1315 // setup global sub numbering
1316 global_sub_indices
[SUB_SOURCE_VOBSUB
] = global_sub_size
; // the global # of the first vobsub.
1317 global_sub_size
+= vobsub_get_indexes_count(vo_vobsub
);
1320 //============ Open & Sync STREAM --- fork cache2 ====================
1325 //free_demuxer_stream(d_audio);
1329 //free_demuxer_stream(d_video);
1335 current_module
="open_stream";
1336 stream
=open_stream(filename
,0,&file_format
);
1337 if(!stream
) { // error...
1338 eof
= libmpdemux_was_interrupted(PT_NEXT_ENTRY
);
1339 goto goto_next_file
;
1341 inited_flags
|=INITED_STREAM
;
1344 if ( use_gui
) guiGetEvent( guiSetStream
,(char *)stream
);
1347 if(file_format
== DEMUXER_TYPE_PLAYLIST
) {
1350 current_module
="handle_playlist";
1351 mp_msg(MSGT_CPLAYER
,MSGL_V
,"Parsing playlist %s...\n",filename
);
1352 entry
= parse_playtree(stream
,0);
1353 eof
=playtree_add_playlist(entry
);
1354 goto goto_next_file
;
1356 stream
->start_pos
+=seek_to_byte
;
1358 if(stream_dump_type
==5){
1359 unsigned char buf
[4096];
1362 current_module
="dumpstream";
1363 if(stream
->type
==STREAMTYPE_STREAM
&& stream
->fd
<0){
1364 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_DumpstreamFdUnavailable
);
1365 exit_player(MSGTR_Exit_error
);
1367 stream_reset(stream
);
1368 stream_seek(stream
,stream
->start_pos
);
1369 f
=fopen(stream_dump_name
,"wb");
1371 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_CantOpenDumpfile
);
1372 exit_player(MSGTR_Exit_error
);
1374 while(!stream
->eof
){
1375 len
=stream_read(stream
,buf
,4096);
1377 if(fwrite(buf
,len
,1,f
) != 1) {
1378 mp_msg(MSGT_MENCODER
,MSGL_FATAL
,MSGTR_ErrorWritingFile
,stream_dump_name
);
1379 exit_player(MSGTR_Exit_error
);
1384 mp_msg(MSGT_MENCODER
,MSGL_FATAL
,MSGTR_ErrorWritingFile
,stream_dump_name
);
1385 exit_player(MSGTR_Exit_error
);
1387 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_CoreDumped
);
1388 exit_player_with_rc(MSGTR_Exit_eof
, 0);
1392 if(stream
->type
==STREAMTYPE_DVD
){
1393 current_module
="dvd lang->id";
1394 if(audio_id
==-1) audio_id
=dvd_aid_from_lang(stream
,audio_lang
);
1395 if(dvdsub_lang
&& dvdsub_id
==-1) dvdsub_id
=dvd_sid_from_lang(stream
,dvdsub_lang
);
1396 // setup global sub numbering
1397 global_sub_indices
[SUB_SOURCE_DEMUX
] = global_sub_size
; // the global # of the first demux-specific sub.
1398 global_sub_size
+= dvd_number_of_subs(stream
);
1399 current_module
=NULL
;
1404 if (stream
->type
==STREAMTYPE_DVDNAV
) stream_cache_size
=0; // must disable caching...
1407 // CACHE2: initial prefill: 20% later: 5% (should be set by -cacheopts)
1408 #ifdef HAS_DVBIN_SUPPORT
1411 if(stream_cache_size
>0){
1412 current_module
="enable_cache";
1413 if(!stream_enable_cache(stream
,stream_cache_size
*1024,stream_cache_size
*1024*(stream_cache_min_percent
/ 100.0),stream_cache_size
*1024*(stream_cache_prefill_percent
/ 100.0)))
1414 if((eof
= libmpdemux_was_interrupted(PT_NEXT_ENTRY
))) goto goto_next_file
;
1417 //============ Open DEMUXERS --- DETECT file type =======================
1418 current_module
="demux_open";
1420 demuxer
=demux_open(stream
,file_format
,audio_id
,video_id
,dvdsub_id
,filename
);
1422 // HACK to get MOV Reference Files working
1424 if (demuxer
&& demuxer
->type
==DEMUXER_TYPE_PLAYLIST
)
1426 unsigned char* playlist_entry
;
1427 play_tree_t
*list
= NULL
, *entry
= NULL
;
1429 current_module
="handle_demux_playlist";
1430 while (ds_get_packet(demuxer
->video
,&playlist_entry
)>0)
1434 mp_msg(MSGT_CPLAYER
,MSGL_V
,"Adding file %s to element entry.\n",playlist_entry
);
1436 bname
=mp_basename(playlist_entry
);
1437 if ((strlen(bname
)>10) && !strncmp(bname
,"qt",2) && !strncmp(bname
+3,"gateQT",6))
1440 if (!strncmp(bname
,mp_basename(filename
),strlen(bname
))) // ignoring self-reference
1443 entry
= play_tree_new();
1445 if (filename
&& !strcmp(mp_basename(playlist_entry
),playlist_entry
)) // add reference path of current file
1447 temp
=malloc((strlen(filename
)-strlen(mp_basename(filename
))+strlen(playlist_entry
)+1)*sizeof(char));
1450 strncpy(temp
, filename
, strlen(filename
)-strlen(mp_basename(filename
)));
1451 temp
[strlen(filename
)-strlen(mp_basename(filename
))]='\0';
1452 strcat(temp
, playlist_entry
);
1453 play_tree_add_file(entry
,temp
);
1454 mp_msg(MSGT_CPLAYER
,MSGL_V
,"Resolving reference to %s.\n",temp
);
1459 play_tree_add_file(entry
,playlist_entry
);
1464 play_tree_append_entry(list
,entry
);
1466 free_demuxer(demuxer
);
1471 entry
= play_tree_new();
1472 play_tree_set_child(entry
,list
);
1473 eof
=playtree_add_playlist(entry
);
1474 goto goto_next_file
;
1483 current_module
="handle_playlist";
1484 switch(stream
->type
){
1485 case STREAMTYPE_VCD
:
1486 case STREAMTYPE_DVD
:
1487 case STREAMTYPE_DVDNAV
:
1488 case STREAMTYPE_CDDA
:
1489 case STREAMTYPE_VCDBINCUE
:
1490 // don't try to parse raw media as playlist, it's unlikely
1491 goto goto_next_file
;
1493 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_FallingBackOnPlaylist
,filename
);
1494 stream_reset(stream
);
1495 stream_seek(stream
,stream
->start_pos
);
1496 entry
= parse_playtree(stream
,0);
1498 mp_msg(MSGT_DEMUXER
,MSGL_ERR
,MSGTR_FormatNotRecognized
);
1500 eof
=playtree_add_playlist(entry
);
1502 goto goto_next_file
;
1504 inited_flags
|=INITED_DEMUXER
;
1506 #ifdef HAVE_MATROSKA
1507 if (demuxer
->type
==DEMUXER_TYPE_MATROSKA
) {
1508 // setup global sub numbering
1509 global_sub_indices
[SUB_SOURCE_DEMUX
] = global_sub_size
; // the global # of the first demux-specific sub.
1510 global_sub_size
+= demux_mkv_num_subs(demuxer
);
1513 #ifdef HAVE_OGGVORBIS
1514 if (demuxer
->type
==DEMUXER_TYPE_OGG
) {
1515 // setup global sub numbering
1516 global_sub_indices
[SUB_SOURCE_DEMUX
] = global_sub_size
; // the global # of the first demux-specific sub.
1517 global_sub_size
+= demux_ogg_num_subs(demuxer
);
1521 current_module
="demux_open2";
1523 //file_format=demuxer->file_format;
1525 d_audio
=demuxer
->audio
;
1526 d_video
=demuxer
->video
;
1527 d_dvdsub
=demuxer
->sub
;
1530 if((stream_dump_type
)&&(stream_dump_type
<4)){
1532 demux_stream_t
*ds
=NULL
;
1533 current_module
="dump";
1534 // select stream to dump
1535 switch(stream_dump_type
){
1536 case 1: ds
=d_audio
;break;
1537 case 2: ds
=d_video
;break;
1538 case 3: ds
=d_dvdsub
;break;
1541 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_DumpSelectedStreamMissing
);
1542 exit_player(MSGTR_Exit_error
);
1544 // disable other streams:
1545 if(d_audio
&& d_audio
!=ds
) {ds_free_packs(d_audio
); d_audio
->id
=-2; }
1546 if(d_video
&& d_video
!=ds
) {ds_free_packs(d_video
); d_video
->id
=-2; }
1547 if(d_dvdsub
&& d_dvdsub
!=ds
) {ds_free_packs(d_dvdsub
); d_dvdsub
->id
=-2; }
1549 f
=fopen(stream_dump_name
,"wb");
1551 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_CantOpenDumpfile
);
1552 exit_player(MSGTR_Exit_error
);
1555 unsigned char* start
;
1556 int in_size
=ds_get_packet(ds
,&start
);
1557 if( (demuxer
->file_format
==DEMUXER_TYPE_AVI
|| demuxer
->file_format
==DEMUXER_TYPE_ASF
|| demuxer
->file_format
==DEMUXER_TYPE_MOV
)
1558 && stream_dump_type
==2) fwrite(&in_size
,1,4,f
);
1559 if(in_size
>0) fwrite(start
,in_size
,1,f
);
1562 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_CoreDumped
);
1563 exit_player_with_rc(MSGTR_Exit_eof
, 0);
1566 sh_audio
=d_audio
->sh
;
1567 sh_video
=d_video
->sh
;
1571 current_module
="video_read_properties";
1572 if(!video_read_properties(sh_video
)) {
1573 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_CannotReadVideoProperties
);
1574 sh_video
=d_video
->sh
=NULL
;
1576 mp_msg(MSGT_CPLAYER
,MSGL_V
,"[V] filefmt:%d fourcc:0x%X size:%dx%d fps:%5.2f ftime:=%6.4f\n",
1577 demuxer
->file_format
,sh_video
->format
, sh_video
->disp_w
,sh_video
->disp_h
,
1578 sh_video
->fps
,sh_video
->frametime
1581 /* need to set fps here for output encoders to pick it up in their init */
1583 sh_video
->fps
=force_fps
;
1584 sh_video
->frametime
=1.0f
/sh_video
->fps
;
1586 vo_fps
= sh_video
->fps
;
1588 vo_mouse_timer_const
=(int)sh_video
->fps
;
1591 if(!sh_video
->fps
&& !force_fps
){
1592 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_FPSnotspecified
);
1593 sh_video
=d_video
->sh
=NULL
;
1601 if(!sh_video
&& !sh_audio
){
1602 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
, MSGTR_NoStreamFound
);
1603 #ifdef HAS_DVBIN_SUPPORT
1604 if((stream
->type
== STREAMTYPE_DVB
) && stream
->priv
)
1606 dvb_priv_t
*priv
= (dvb_priv_t
*) stream
->priv
;
1610 int v
= last_dvb_step
;
1612 dir
= DVB_CHANNEL_HIGHER
;
1614 dir
= DVB_CHANNEL_LOWER
;
1616 if(dvb_step_channel(priv
, dir
))
1618 uninit_player(INITED_ALL
-(INITED_STREAM
|INITED_INPUT
));
1619 cache_uninit(stream
);
1620 goto goto_enable_cache
;
1625 goto goto_next_file
; // exit_player(MSGTR_Exit_error);
1628 /* display clip info */
1629 demux_info_print(demuxer
);
1631 //================== Read SUBTITLES (DVD & TEXT) ==========================
1632 if(vo_spudec
==NULL
&& sh_video
&& (stream
->type
==STREAMTYPE_DVD
|| demuxer
->type
==DEMUXER_TYPE_MATROSKA
)){
1635 unsigned int palette
[16], width
, height
;
1636 current_module
="spudec_init_vobsub";
1637 if (vobsub_parse_ifo(NULL
,spudec_ifo
, palette
, &width
, &height
, 1, -1, NULL
) >= 0)
1638 vo_spudec
=spudec_new_scaled(palette
, width
, height
);
1642 if (vo_spudec
==NULL
&& stream
->type
==STREAMTYPE_DVDNAV
) {
1643 current_module
="spudec_init_dvdnav";
1644 vo_spudec
=spudec_new_scaled(dvdnav_stream_get_palette((dvdnav_priv_t
*)(stream
->priv
)),
1645 sh_video
->disp_w
, sh_video
->disp_h
);
1650 if (vo_spudec
==NULL
&& stream
->type
==STREAMTYPE_DVD
) {
1651 current_module
="spudec_init_dvdread";
1652 vo_spudec
=spudec_new_scaled(((dvd_priv_t
*)(stream
->priv
))->cur_pgc
->palette
,
1653 sh_video
->disp_w
, sh_video
->disp_h
);
1657 #ifdef HAVE_MATROSKA
1658 if ((vo_spudec
== NULL
) && (demuxer
->type
== DEMUXER_TYPE_MATROSKA
) &&
1659 (d_dvdsub
->sh
!= NULL
) && (((mkv_sh_sub_t
*)d_dvdsub
->sh
)->type
== 'v')) {
1660 mkv_sh_sub_t
*mkv_sh_sub
= (mkv_sh_sub_t
*)d_dvdsub
->sh
;
1661 current_module
= "spudec_init_matroska";
1663 spudec_new_scaled_vobsub(mkv_sh_sub
->palette
, mkv_sh_sub
->colors
,
1664 mkv_sh_sub
->custom_colors
, mkv_sh_sub
->width
,
1665 mkv_sh_sub
->height
);
1666 forced_subs_only
= mkv_sh_sub
->forced_subs_only
;
1670 if (vo_spudec
==NULL
) {
1671 current_module
="spudec_init_normal";
1672 vo_spudec
=spudec_new_scaled(NULL
, sh_video
->disp_w
, sh_video
->disp_h
);
1673 spudec_set_font_factor(vo_spudec
,font_factor
);
1676 if (vo_spudec
!=NULL
)
1677 inited_flags
|=INITED_SPUDEC
;
1681 // Apply current settings for forced subs
1682 if (vo_spudec
!=NULL
)
1683 spudec_set_forced_subs_only(vo_spudec
,forced_subs_only
);
1687 // after reading video params we should load subtitles because
1688 // we know fps so now we can adjust subtitles time to ~6 seconds AST
1690 current_module
="read_subtitles_file";
1692 for (i
= 0; sub_name
[i
] != NULL
; ++i
)
1693 add_subtitles (sub_name
[i
], sh_video
->fps
, 0);
1695 if(sub_auto
) { // auto load sub file ...
1696 char *psub
= get_path( "sub/" );
1697 char **tmp
= sub_filenames((psub
? psub
: ""), filename
);
1699 free(psub
); // release the buffer created by get_path() above
1701 add_subtitles (*tmp2
++, sh_video
->fps
, 0);
1703 if (set_of_sub_size
== 0)
1705 add_subtitles (mem_ptr
=get_path("default.sub"), sh_video
->fps
, 1);
1706 free(mem_ptr
); // release the buffer created by get_path()
1708 if (set_of_sub_size
> 0)
1709 add_subtitles (NULL
, sh_video
->fps
, 1);
1711 if (set_of_sub_size
> 0) {
1712 // setup global sub numbering
1713 global_sub_indices
[SUB_SOURCE_SUBS
] = global_sub_size
; // the global # of the first sub.
1714 global_sub_size
+= set_of_sub_size
;
1719 if (global_sub_size
) {
1720 // find the best sub to use
1721 if (vobsub_id
>= 0) {
1722 // if user asks for a vobsub id, use that first.
1723 global_sub_pos
= global_sub_indices
[SUB_SOURCE_VOBSUB
] + vobsub_id
;
1724 } else if (dvdsub_id
>= 0 && global_sub_indices
[SUB_SOURCE_DEMUX
] >= 0) {
1725 // if user asks for a dvd sub id, use that next.
1726 global_sub_pos
= global_sub_indices
[SUB_SOURCE_DEMUX
] + dvdsub_id
;
1727 } else if (global_sub_indices
[SUB_SOURCE_SUBS
] >= 0) {
1728 // if there are text subs to use, use those. (autosubs come last here)
1729 global_sub_pos
= global_sub_indices
[SUB_SOURCE_SUBS
];
1731 } else if (global_sub_indices[SUB_SOURCE_DEMUX] >= 0) {
1732 // if nothing else works, get subs from the demuxer.
1733 global_sub_pos = global_sub_indices[SUB_SOURCE_DEMUX];
1736 // nothing worth doing automatically.
1737 global_sub_pos
= -1;
1739 // rather than duplicate code, use the SUB_SELECT handler to init the right one.
1741 mp_input_queue_cmd(mp_input_parse_cmd("sub_select"));
1744 //================== Init AUDIO (codec) ==========================
1746 // Go through the codec.conf and find the best codec...
1747 current_module
="init_audio_codec";
1748 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"==========================================================================\n");
1749 if(!init_best_audio_codec(sh_audio
,audio_codec_list
,audio_fm_list
)){
1750 sh_audio
=d_audio
->sh
=NULL
; // failed to init :(
1752 inited_flags
|=INITED_ACODEC
;
1753 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"==========================================================================\n");
1757 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_FILENAME=%s\n", filename
);
1759 /* Assume FOURCC if all bytes >= 0x20 (' ') */
1760 if (sh_video
->format
>= 0x20202020)
1761 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_VIDEO_FORMAT=%.4s\n", &sh_video
->format
);
1763 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_VIDEO_FORMAT=0x%08X\n", sh_video
->format
);
1764 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_VIDEO_BITRATE=%d\n", sh_video
->i_bps
*8);
1765 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_VIDEO_WIDTH=%d\n", sh_video
->disp_w
);
1766 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_VIDEO_HEIGHT=%d\n", sh_video
->disp_h
);
1767 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_VIDEO_FPS=%5.3f\n", sh_video
->fps
);
1768 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_VIDEO_ASPECT=%1.4f\n", sh_video
->aspect
);
1771 if (sh_audio
->codec
)
1772 mp_msg(MSGT_GLOBAL
,MSGL_INFO
, "ID_AUDIO_CODEC=%s\n", sh_audio
->codec
->name
);
1773 /* Assume FOURCC if all bytes >= 0x20 (' ') */
1774 if (sh_audio
->format
>= 0x20202020)
1775 mp_msg(MSGT_GLOBAL
,MSGL_INFO
, "ID_AUDIO_FORMAT=%.4s\n", &sh_audio
->format
);
1777 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_AUDIO_FORMAT=%d\n", sh_audio
->format
);
1778 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_AUDIO_BITRATE=%d\n", sh_audio
->i_bps
*8);
1779 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_AUDIO_RATE=%d\n", sh_audio
->samplerate
);
1780 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_AUDIO_NCH=%d\n", sh_audio
->channels
);
1782 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,"ID_LENGTH=%ld\n", demuxer_get_time_length(demuxer
));
1785 if(!sh_video
) goto main
; // audio-only
1787 //================== Init VIDEO (codec & libvo) ==========================
1788 if(!fixed_vo
|| !(inited_flags
&INITED_VO
)){
1789 current_module
="preinit_libvo";
1792 //if((video_out->preinit(vo_subdevice))!=0){
1793 if(!(video_out
=init_best_video_out(video_driver_list
))){
1794 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_ErrorInitializingVODevice
);
1795 goto goto_next_file
; // exit_player(MSGTR_Exit_error);
1797 sh_video
->video_out
=video_out
;
1798 inited_flags
|=INITED_VO
;
1801 current_module
="init_video_filters";
1803 char* vf_arg
[] = { "_oldargs_", (char*)video_out
, NULL
};
1804 sh_video
->vfilter
=(void*)vf_open_filter(NULL
,"vo",vf_arg
);
1808 char* vf_arg
[] = { "_oldargs_", menu_root
, NULL
};
1809 vf_menu
= vf_open_plugin(libmenu_vfs
,sh_video
->vfilter
,"menu",vf_arg
);
1811 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_CantOpenLibmenuFilterWithThisRootMenu
,menu_root
);
1816 sh_video
->vfilter
=(void*)append_filters(vf_menu
);
1819 sh_video
->vfilter
=(void*)append_filters(sh_video
->vfilter
);
1821 current_module
="init_video_codec";
1823 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"==========================================================================\n");
1824 init_best_video_codec(sh_video
,video_codec_list
,video_fm_list
);
1825 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"==========================================================================\n");
1827 if(!sh_video
->inited
){
1828 if(!fixed_vo
) uninit_player(INITED_VO
);
1829 if(!sh_audio
) goto goto_next_file
;
1830 sh_video
= d_video
->sh
= NULL
;
1831 goto main
; // exit_player(MSGTR_Exit_error);
1834 inited_flags
|=INITED_VCODEC
;
1837 // Auto quality option enabled
1838 output_quality
=get_video_quality_max(sh_video
);
1839 if(auto_quality
>output_quality
) auto_quality
=output_quality
;
1840 else output_quality
=auto_quality
;
1841 mp_msg(MSGT_CPLAYER
,MSGL_V
,"AutoQ: setting quality to %d.\n",output_quality
);
1842 set_video_quality(sh_video
,output_quality
);
1845 // ========== Init display (sh_video->disp_w*sh_video->disp_h/out_fmt) ============
1847 current_module
="init_vo";
1849 if(vo_flags
& 0x08 && vo_spudec
)
1850 spudec_set_hw_spu(vo_spudec
,video_out
);
1852 #ifdef HAVE_FREETYPE
1853 force_load_font
= 1;
1856 //================== MAIN: ==========================
1858 current_module
="main";
1860 // If there is no video OSD has to be disabled.
1861 // In case of playing a playtree we have to restore the
1862 // old OSD level after playing one or more audio-only files.
1863 if(!sh_video
&& osd_level
>= 0) { // save OSD level only once
1864 osd_level_saved
= osd_level
;
1866 } else if (osd_level_saved
> -1) { // if there is a saved OSD level, restore it
1867 osd_level
= osd_level_saved
;
1868 osd_level_saved
= -1;
1876 if ( sh_audio
) guiIntfStruct
.AudioType
=sh_audio
->channels
; else guiIntfStruct
.AudioType
=0;
1877 if ( !sh_video
&& sh_audio
) guiGetEvent( guiSetAudioOnly
,(char *)1 ); else guiGetEvent( guiSetAudioOnly
,(char *)0 );
1878 guiGetEvent( guiSetFileFormat
,(char *)demuxer
->file_format
);
1879 if ( guiGetEvent( guiSetValues
,(char *)sh_video
) ) goto goto_next_file
;
1880 guiGetEvent( guiSetDemuxer
,(char *)demuxer
);
1885 //int frame_corr_num=0; //
1886 //float v_frame=0; // Video
1887 float time_frame
=0; // Timer
1888 //float num_frames=0; // number of frames played
1890 char osd_text_buffer
[64];
1891 char osd_show_text_buffer
[64];
1892 int drop_frame
=0; // current dropping status
1893 int dropped_frames
=0; // how many frames dropped since last non-dropped frame
1894 int too_slow_frame_cnt
=0;
1895 int too_fast_frame_cnt
=0;
1896 // for auto-quality:
1897 float AV_delay
=0; // average of A-V timestamp differences
1898 double vdecode_time
;
1899 unsigned int lastframeout_ts
=0;
1900 /*float time_frame_corr_avg=0;*/ /* unused */
1902 float next_frame_time
=0;
1903 int frame_time_remaining
=0; // flag
1906 osd_text_buffer
[0]=0;
1908 //================ SETUP AUDIO ==========================
1911 //const ao_info_t *info=audio_out->info;
1912 current_module
="af_preinit";
1913 ao_data
.samplerate
=force_srate
?force_srate
:sh_audio
->samplerate
*playback_speed
;
1914 ao_data
.channels
=audio_output_channels
?audio_output_channels
:sh_audio
->channels
;
1915 ao_data
.format
=audio_output_format
?audio_output_format
:sh_audio
->sample_format
;
1917 if(!preinit_audio_filters(sh_audio
,
1919 (int)(sh_audio
->samplerate
*playback_speed
),
1920 sh_audio
->channels
, sh_audio
->sample_format
, sh_audio
->samplesize
,
1922 &ao_data
.samplerate
, &ao_data
.channels
, &ao_data
.format
,
1923 audio_out_format_bits(ao_data
.format
)/8)){
1924 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_AudioFilterChainPreinitError
);
1926 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"AF_pre: %dHz %dch %s\n",
1927 ao_data
.samplerate
, ao_data
.channels
,
1928 audio_out_format_name(ao_data
.format
));
1931 current_module
="ao2_init";
1932 if(!(audio_out
=init_best_audio_out(audio_driver_list
,
1933 (ao_plugin_cfg
.plugin_list
!=NULL
), // plugin flag
1934 force_srate
?force_srate
:ao_data
.samplerate
,
1935 audio_output_channels
?audio_output_channels
:ao_data
.channels
,
1936 audio_output_format
?audio_output_format
:ao_data
.format
,0))){
1938 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_CannotInitAO
);
1939 uninit_player(INITED_ACODEC
); // close codec
1940 sh_audio
=d_audio
->sh
=NULL
; // -> nosound
1943 inited_flags
|=INITED_AO
;
1944 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"AO: [%s] %dHz %dch %s (%d bps)\n",
1945 audio_out
->info
->short_name
,
1946 ao_data
.samplerate
, ao_data
.channels
,
1947 audio_out_format_name(ao_data
.format
),
1948 audio_out_format_bits(ao_data
.format
)/8 );
1949 mp_msg(MSGT_CPLAYER
,MSGL_V
,"AO: Description: %s\nAO: Author: %s\n",
1950 audio_out
->info
->name
, audio_out
->info
->author
);
1951 if(strlen(audio_out
->info
->comment
) > 0)
1952 mp_msg(MSGT_CPLAYER
,MSGL_V
,"AO: Comment: %s\n", audio_out
->info
->comment
);
1953 // init audio filters:
1955 current_module
="af_init";
1956 if(!build_afilter_chain(sh_audio
, &ao_data
)) {
1957 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_NoMatchingFilter
);
1958 // mp_msg(MSGT_CPLAYER,MSGL_ERR,"Couldn't find matching filter / ao format! -> NOSOUND\n");
1959 // uninit_player(INITED_ACODEC|INITED_AO); // close codec & ao
1960 // sh_audio=d_audio->sh=NULL; // -> nosound
1964 mixer
.audio_out
= audio_out
;
1965 mixer
.afilter
= sh_audio
? sh_audio
->afilter
: NULL
;
1966 mixer
.volstep
= volstep
;
1969 current_module
="av_init";
1971 if(sh_video
) sh_video
->timer
=0;
1972 if(sh_audio
) sh_audio
->delay
=-audio_delay
;
1975 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_NoSound
);
1976 mp_msg(MSGT_CPLAYER
,MSGL_V
,"Freeing %d unused audio chunks.\n",d_audio
->packs
);
1977 ds_free_packs(d_audio
); // free buffered chunks
1978 d_audio
->id
=-2; // do not read audio chunks
1979 //uninit_player(INITED_AO); // close device
1982 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_Video_NoVideo
);
1983 mp_msg(MSGT_CPLAYER
,MSGL_V
,"Freeing %d unused video chunks.\n",d_video
->packs
);
1984 ds_free_packs(d_video
);
1986 //if(!fixed_vo) uninit_player(INITED_VO);
1989 if (!sh_video
&& !sh_audio
)
1990 goto goto_next_file
;
1992 //if(demuxer->file_format!=DEMUXER_TYPE_AVI) pts_from_bps=0; // it must be 0 for mpeg/asf!
1993 if(force_fps
&& sh_video
){
1994 vo_fps
= sh_video
->fps
=force_fps
;
1995 sh_video
->frametime
=1.0f
/sh_video
->fps
;
1996 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_FPSforced
,sh_video
->fps
,sh_video
->frametime
);
1999 //==================== START PLAYING =======================
2001 if(loop_times
>1) loop_times
--; else
2002 if(loop_times
==1) loop_times
= -1;
2004 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,MSGTR_StartPlaying
);fflush(stdout
);
2009 if (stream
->type
==STREAMTYPE_DVDNAV
) {
2010 dvdnav_stream_fullstart((dvdnav_priv_t
*)stream
->priv
);
2014 total_time_usage_start
=GetTimer();
2015 audio_time_usage
=0; video_time_usage
=0; vout_time_usage
=0;
2016 total_frame_cnt
=0; drop_frame_cnt
=0; // fix for multifile fps benchmark
2017 play_n_frames
=play_n_frames_mf
;
2019 if(play_n_frames
==0){
2020 eof
=PT_NEXT_ENTRY
; goto goto_next_file
;
2024 float aq_sleep_time
=0;
2026 if(play_n_frames
>=0){
2028 if(play_n_frames
<0) eof
= PT_NEXT_ENTRY
;
2031 /*========================== PLAY AUDIO ============================*/
2038 current_module
="play_audio";
2040 ao_data
.pts
=((sh_video
?sh_video
->timer
:0)+sh_audio
->delay
)*90000.0;
2041 playsize
=audio_out
->get_space();
2043 // handle audio-only case:
2044 if(!playsize
&& !sh_video
) { // buffer is full, do not block here!!!
2045 usec_sleep(10000); // Wait a tick before retry
2049 if(playsize
>MAX_OUTBURST
) playsize
=MAX_OUTBURST
; // we shouldn't exceed it!
2051 // Fill buffer if needed:
2052 current_module
="decode_audio"; // Enter AUDIO decoder module
2054 while(sh_audio
->a_out_buffer_len
<playsize
&& !d_audio
->eof
){
2055 int ret
=decode_audio(sh_audio
,&sh_audio
->a_out_buffer
[sh_audio
->a_out_buffer_len
],
2056 playsize
-sh_audio
->a_out_buffer_len
,sh_audio
->a_out_buffer_size
-sh_audio
->a_out_buffer_len
);
2057 if(ret
<=0) break; // EOF?
2058 sh_audio
->a_out_buffer_len
+=ret
;
2061 tt
= t
*0.000001f
; audio_time_usage
+=tt
;
2062 if(playsize
>sh_audio
->a_out_buffer_len
) playsize
=sh_audio
->a_out_buffer_len
;
2065 current_module
="play_audio";
2066 playsize
=audio_out
->play(sh_audio
->a_out_buffer
,playsize
,0);
2069 sh_audio
->a_out_buffer_len
-=playsize
;
2070 memmove(sh_audio
->a_out_buffer
,&sh_audio
->a_out_buffer
[playsize
],sh_audio
->a_out_buffer_len
);
2071 sh_audio
->delay
+=playback_speed
*playsize
/((float)((ao_data
.bps
&& sh_audio
->afilter
) ?
2072 ao_data
.bps
: sh_audio
->o_bps
));
2076 } // while(sh_audio)
2079 // handle audio-only case:
2082 // convert time to HH:MM:SS.F format
2084 long tenths
= 10 * (sh_audio
->delay
-audio_out
->get_delay()*playback_speed
);
2085 int hh
= (tenths
/ 36000) % 100;
2086 int mm
= (tenths
/ 600) % 60;
2087 int ss
= (tenths
/ 10) % 60;
2088 int f1
= tenths
% 10;
2089 char hhmmssf
[16]; // only really need 11, but just in case...
2090 sprintf( hhmmssf
, "%2d:%2d:%2d.%1d", hh
, mm
, ss
, f1
);
2095 // uncomment the next three lines to show leading zero ten-hours
2096 // else if (' ' == hhmmssf[0]) {
2097 // hhmmssf[0] = '0';
2099 if ((0 == hh
) && (0 == mm
)) {
2103 else if ((' ' == hhmmssf
[3]) && (' ' != hhmmssf
[2])) {
2106 if ((' ' == hhmmssf
[6]) && (' ' != hhmmssf
[5])) {
2109 mp_msg(MSGT_AVSYNC
,MSGL_STATUS
,"A: %s %4.1f%% %d%% %4.2fx \r"
2111 ,(sh_audio
->delay
>0.5)?100.0*audio_time_usage
/(double)sh_audio
->delay
:0
2115 if(d_audio
->eof
) eof
= PT_NEXT_ENTRY
;
2119 /*========================== PLAY VIDEO ============================*/
2121 float frame_time
=next_frame_time
;
2123 vo_pts
=sh_video
->timer
*90000.0;
2124 vo_fps
=sh_video
->fps
;
2126 if(!frame_time_remaining
){
2127 //-------------------- Decode a frame: -----------------------
2128 vdecode_time
=video_time_usage
;
2130 { unsigned char* start
=NULL
;
2133 current_module
="video_read_frame";
2134 in_size
=video_read_frame(sh_video
,&next_frame_time
,&start
,force_fps
);
2135 if(in_size
<0){ eof
=1; break; }
2136 if(in_size
>max_framesize
) max_framesize
=in_size
; // stats
2137 sh_video
->timer
+=frame_time
;
2138 if(sh_audio
) sh_audio
->delay
-=frame_time
;
2139 time_frame
+=frame_time
; // for nosound
2140 // check for frame-drop:
2141 current_module
="check_framedrop";
2142 if(sh_audio
&& !d_audio
->eof
){
2143 float delay
=playback_speed
*audio_out
->get_delay();
2144 float d
=delay
-sh_audio
->delay
;
2145 // we should avoid dropping to many frames in sequence unless we
2146 // are too late. and we allow 100ms A-V delay here:
2147 if(d
<-dropped_frames
*frame_time
-0.100 && osd_function
!= OSD_PAUSE
){
2148 drop_frame
=frame_dropping
;
2152 drop_frame
=dropped_frames
=0;
2157 current_module
="decode_video";
2158 // printf("Decode! %p %d \n",start,in_size);
2159 blit_frame
=decode_video(sh_video
,start
,in_size
,drop_frame
);
2162 vdecode_time
=video_time_usage
-vdecode_time
;
2163 //------------------------ frame decoded. --------------------
2165 mp_dbg(MSGT_AVSYNC
,MSGL_DBG2
,"*** ftime=%5.3f ***\n",frame_time
);
2167 if(sh_video
->vf_inited
<0){
2168 mp_msg(MSGT_CPLAYER
,MSGL_FATAL
,MSGTR_NotInitializeVOPorVO
);
2169 eof
=1; goto goto_next_file
;
2174 // ==========================================================================
2176 // current_module="draw_osd";
2177 // if(vo_config_count) video_out->draw_osd();
2180 if(use_gui
) guiEventHandling();
2183 current_module
="calc_sleep_time";
2186 { // debug frame dropping code
2187 float delay
=audio_out
->get_delay();
2188 mp_msg(MSGT_AVSYNC
,MSGL_V
,"\r[V] %5.3f [A] %5.3f => {%5.3f} (%5.3f) [%d] \n",
2189 sh_video
->timer
,sh_audio
->timer
-delay
,
2190 sh_video
->timer
-(sh_audio
->timer
-delay
),
2195 if(drop_frame
&& !frame_time_remaining
&& !autosync
){
2197 * Note: time_frame should not be forced to 0 in autosync mode.
2198 * It is used as a cumulative counter to predict and correct the
2199 * delay measurements from the audio driver. time_frame is already
2200 * < 0, so the "time to sleep" code does not actually sleep. Also,
2201 * blit_frame is already 0 because drop_frame was true when
2202 * decode_video was called (which causes it to set blit_frame to 0.)
2203 * When autosync==0, the default behavior is still completely unchanged.
2206 time_frame
=0; // don't sleep!
2207 blit_frame
=0; // don't display!
2211 // It's time to sleep...
2213 frame_time_remaining
=0;
2214 time_frame
-=GetRelativeTime(); // reset timer
2216 if(sh_audio
&& !d_audio
->eof
){
2217 float delay
=playback_speed
*audio_out
->get_delay();
2218 mp_dbg(MSGT_AVSYNC
,MSGL_DBG2
,"delay=%f\n",delay
);
2222 * Adjust this raw delay value by calculating the expected
2223 * delay for this frame and generating a new value which is
2224 * weighted between the two. The higher autosync is, the
2225 * closer to the delay value gets to that which "-nosound"
2226 * would have used, and the longer it will take for A/V
2227 * sync to settle at the right value (but it eventually will.)
2228 * This settling time is very short for values below 100.
2230 float predicted
= sh_audio
->delay
+time_frame
;
2231 float difference
= delay
- predicted
;
2232 delay
= predicted
+ difference
/ (float)autosync
;
2235 time_frame
=delay
-sh_audio
->delay
;
2237 // delay = amount of audio buffered in soundcard/driver
2238 if(delay
>0.25) delay
=0.25; else
2239 if(delay
<0.10) delay
=0.10;
2240 if(time_frame
>delay
*0.6){
2241 // sleep time too big - may cause audio drops (buffer underrun)
2242 frame_time_remaining
=1;
2243 time_frame
=delay
*0.5;
2249 if( (time_frame
<-3*frame_time
|| time_frame
>3*frame_time
) || benchmark
)
2254 // if(verbose>1)printf("sleep: %5.3f a:%6.3f v:%6.3f \n",time_frame,sh_audio->timer,sh_video->timer);
2256 aq_sleep_time
+=time_frame
;
2260 //============================== SLEEP: ===================================
2262 time_frame
/=playback_speed
;
2264 // flag 256 means: libvo driver does its timing (dvb card)
2265 if(time_frame
>0.001 && !(vo_flags
&256)){
2269 // -------- RTC -----------
2270 current_module
="sleep_rtc";
2271 while (time_frame
> 0.000) {
2272 unsigned long rtc_ts
;
2273 if (read (rtc_fd
, &rtc_ts
, sizeof(rtc_ts
)) <= 0)
2274 mp_msg(MSGT_CPLAYER
, MSGL_ERR
, MSGTR_LinuxRTCReadError
, strerror(errno
));
2275 time_frame
-=GetRelativeTime();
2280 // -------- TIMER + SOFTSLEEP -----------
2281 float min
=softsleep
?0.021:0.005;
2282 current_module
="sleep_timer";
2283 while(time_frame
>min
){
2284 if(time_frame
<=0.020)
2285 usec_sleep(0); // sleeps 1 clock tick (10ms)!
2287 usec_sleep(1000000*(time_frame
-0.020));
2288 time_frame
-=GetRelativeTime();
2291 current_module
="sleep_soft";
2292 if(time_frame
<0) mp_msg(MSGT_AVSYNC
, MSGL_WARN
, MSGTR_SoftsleepUnderflow
);
2293 while(time_frame
>0) time_frame
-=GetRelativeTime(); // burn the CPU
2299 //if(!frame_time_remaining){ // should we display the frame now?
2301 //====================== FLIP PAGE (VIDEO BLT): =========================
2303 current_module
="vo_check_events";
2304 if(vo_config_count
) video_out
->check_events();
2306 current_module
="flip_page";
2307 if (!frame_time_remaining
) {
2309 unsigned int t2
=GetTimer();
2312 #define FRAME_LAG_WARN 0.2
2313 j
= ((float)t2
- lastframeout_ts
) / 1000000;
2314 lastframeout_ts
= GetTimer();
2315 if (j
< frame_time
+ frame_time
* -FRAME_LAG_WARN
)
2316 too_fast_frame_cnt
++;
2317 /* printf ("PANIC: too fast frame (%.3f)!\n", j); */
2318 else if (j
> frame_time
+ frame_time
* FRAME_LAG_WARN
)
2319 too_slow_frame_cnt
++;
2320 /* printf ("PANIC: too slow frame (%.3f)!\n", j); */
2322 if(vo_config_count
) video_out
->flip_page();
2323 // usec_sleep(50000); // test only!
2326 vout_time_usage
+=tt
;
2329 Well, no blitting is needed, but some devices (such as yuv4mpeg) must output frame
2330 otherwise A/V desync will occur. -- Alvieboy
2332 if (vo_config_count
)
2333 video_out
->control(VOCTRL_DUPLICATE_FRAME
, NULL
);
2336 //====================== A-V TIMESTAMP CORRECTION: =========================
2338 current_module
="av_sync";
2344 // unplayed bytes in our and soundcard/dma buffer:
2345 float delay
=playback_speed
*audio_out
->get_delay()+(float)sh_audio
->a_buffer_len
/(float)sh_audio
->o_bps
;
2349 * If autosync is enabled, the value for delay must be calculated
2350 * a bit differently. It is set only to the difference between
2351 * the audio and video timers. Any attempt to include the real
2352 * or corrected delay causes the pts_correction code below to
2353 * try to correct for the changes in delay which autosync is
2354 * trying to measure. This keeps the two from competing, but still
2355 * allows the code to correct for PTS drift *only*. (Using a delay
2356 * value here, even a "corrected" one, would be incompatible with
2359 delay
=sh_audio
->delay
;
2360 delay
+=(float)sh_audio
->a_buffer_len
/(float)sh_audio
->o_bps
;
2365 // PTS = sample_no / samplerate
2366 unsigned int samples
=
2367 // (sh_audio->audio.dwSampleSize)?
2368 // ((ds_tell(d_audio)-sh_audio->a_in_buffer_len)/sh_audio->audio.dwSampleSize) :
2369 ds_tell_block(d_audio
); // <- used for VBR audio
2370 samples
+=sh_audio
->audio
.dwStart
; // offset
2371 a_pts
=samples
*(float)sh_audio
->audio
.dwScale
/(float)sh_audio
->audio
.dwRate
;
2373 a_pts
-=(sh_audio
->a_in_buffer_len
)/(float)sh_audio
->i_bps
;
2377 // PTS = (last timestamp) + (bytes after last timestamp)/(bytes per sec)
2379 if(!delay_corrected
) if(a_pts
) delay_corrected
=1;
2381 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\n#X# pts=%5.3f ds_pts=%5.3f buff=%5.3f total=%5.3f\n",
2383 ds_tell_pts(d_audio
)/(float)sh_audio
->i_bps
,
2384 -sh_audio
->a_in_buffer_len
/(float)sh_audio
->i_bps
,
2385 a_pts
+(ds_tell_pts(d_audio
)-sh_audio
->a_in_buffer_len
)/(float)sh_audio
->i_bps
);
2387 a_pts
+=(ds_tell_pts(d_audio
)-sh_audio
->a_in_buffer_len
)/(float)sh_audio
->i_bps
;
2389 v_pts
=sh_video
? sh_video
->pts
: d_video
->pts
;
2391 mp_dbg(MSGT_AVSYNC
,MSGL_DBG2
,"### A:%8.3f (%8.3f) V:%8.3f A-V:%7.4f \n",a_pts
,a_pts
-audio_delay
-delay
,v_pts
,(a_pts
-delay
-audio_delay
)-v_pts
);
2393 if(delay_corrected
){
2394 static int drop_message
=0;
2396 AV_delay
=(a_pts
-delay
-audio_delay
)-v_pts
;
2397 if(AV_delay
>0.5 && drop_frame_cnt
>50 && drop_message
==0){
2399 mp_msg(MSGT_AVSYNC
,MSGL_WARN
,MSGTR_SystemTooSlow
);
2402 if(x
<-max_pts_correction
) x
=-max_pts_correction
; else
2403 if(x
> max_pts_correction
) x
= max_pts_correction
;
2404 if(default_max_pts_correction
>=0)
2405 max_pts_correction
=default_max_pts_correction
;
2407 max_pts_correction
=sh_video
->frametime
*0.10; // +-10% of time
2408 if(!frame_time_remaining
){ sh_audio
->delay
+=x
; c_total
+=x
;} // correction
2409 if(!quiet
) mp_msg(MSGT_AVSYNC
,MSGL_STATUS
,"A:%6.1f V:%6.1f A-V:%7.3f ct:%7.3f %3d/%3d %2d%% %2d%% %4.1f%% %d %d %d%% %4.2fx\r",
2410 a_pts
-audio_delay
-delay
,v_pts
,AV_delay
,c_total
,
2411 (int)sh_video
->num_frames
,(int)sh_video
->num_frames_decoded
,
2412 (sh_video
->timer
>0.5)?(int)(100.0*video_time_usage
*playback_speed
/(double)sh_video
->timer
):0,
2413 (sh_video
->timer
>0.5)?(int)(100.0*vout_time_usage
*playback_speed
/(double)sh_video
->timer
):0,
2414 (sh_video
->timer
>0.5)?(100.0*audio_time_usage
*playback_speed
/(double)sh_video
->timer
):0
2427 mp_msg(MSGT_AVSYNC
,MSGL_STATUS
,"V:%6.1f %3d %2d%% %2d%% %4.1f%% %d %d %d%%\r",sh_video
->pts
,
2428 (int)sh_video
->num_frames
,
2429 (sh_video
->timer
>0.5)?(int)(100.0*video_time_usage
/(double)sh_video
->timer
):0,
2430 (sh_video
->timer
>0.5)?(int)(100.0*vout_time_usage
/(double)sh_video
->timer
):0,
2431 (sh_video
->timer
>0.5)?(100.0*audio_time_usage
/(double)sh_video
->timer
):0
2441 //============================ Auto QUALITY ============================
2443 /*Output quality adjustments:*/
2445 current_module
="autoq";
2446 // float total=0.000001f * (GetTimer()-aq_total_time);
2447 // if(output_quality<auto_quality && aq_sleep_time>0.05f*total)
2448 if(output_quality
<auto_quality
&& aq_sleep_time
>0)
2451 // if(output_quality>0 && aq_sleep_time<-0.05f*total)
2452 if(output_quality
>1 && aq_sleep_time
<0)
2455 if(output_quality
>0 && aq_sleep_time
<-0.050f
) // 50ms
2457 // printf("total: %8.6f sleep: %8.6f q: %d\n",(0.000001f*aq_total_time),aq_sleep_time,output_quality);
2458 set_video_quality(sh_video
,output_quality
);
2461 } // end if(sh_video)
2463 //============================ Handle PAUSE ===============================
2465 current_module
="pause";
2469 if (!--osd_visible
){
2470 vo_osd_progbar_type
=-1; // disable
2471 vo_osd_changed(OSDTYPE_PROGBAR
);
2472 if (osd_function
!= OSD_PAUSE
)
2473 osd_function
= OSD_PLAY
;
2478 if(osd_function
==OSD_PAUSE
){
2481 mp_msg(MSGT_CPLAYER
,MSGL_STATUS
,MSGTR_Paused
);
2485 if(use_gui
) guiGetEvent( guiCEvent
,(char *)guiSetPause
);
2487 if (video_out
&& sh_video
&& vo_config_count
)
2488 video_out
->control(VOCTRL_PAUSE
, NULL
);
2490 if (audio_out
&& sh_audio
)
2491 audio_out
->pause(); // pause audio, keep data if possible
2493 while( (cmd
= mp_input_get_cmd(20,1,1)) == NULL
) {
2494 if(sh_video
&& video_out
&& vo_config_count
) video_out
->check_events();
2498 guiGetEvent( guiReDraw
,NULL
);
2499 if(guiIntfStruct
.Playing
!=2 || (rel_seek_secs
|| abs_seek_pos
)) break;
2504 vf_menu_pause_update(vf_menu
);
2508 if (cmd
->id
== MP_CMD_PAUSE
) {
2509 cmd
= mp_input_get_cmd(0,1,0);
2512 osd_function
=OSD_PLAY
;
2513 if (audio_out
&& sh_audio
)
2514 audio_out
->resume(); // resume audio
2515 if (video_out
&& sh_video
&& vo_config_count
)
2516 video_out
->control(VOCTRL_RESUME
, NULL
); // resume video
2517 (void)GetRelativeTime(); // keep TF around FT in next cycle
2521 if ( guiIntfStruct
.Playing
== guiSetStop
) goto goto_next_file
;
2522 guiGetEvent( guiCEvent
,(char *)guiSetPlay
);
2529 osd_function
=OSD_FFW
;
2530 rel_seek_secs
+=step_sec
;
2534 if (stream
->type
==STREAMTYPE_DVDNAV
&& dvd_nav_still
)
2535 dvdnav_stream_sleeping((dvdnav_priv_t
*)stream
->priv
);
2538 //================= EDL =========================================
2541 if( next_edl_record
) { // Are we (still?) doing EDL?
2543 mp_msg( MSGT_CPLAYER
, MSGL_ERR
, MSGTR_EdlNOsh_video
);
2544 next_edl_record
->next
= NULL
;
2546 if( sh_video
->pts
>= next_edl_record
->start_sec
) {
2547 if( next_edl_record
->action
== EDL_SKIP
) {
2548 osd_function
= OSD_FFW
;
2550 rel_seek_secs
= next_edl_record
->length_sec
;
2552 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_EDLSKIPStartStopLength
, next_edl_record
->start_sec
, next_edl_record
->stop_sec
, next_edl_record
->length_sec
);
2555 } else if( next_edl_record
->action
== EDL_MUTE
) {
2557 edl_mute_count
++; // new EDL seek behavior needs this
2559 mp_msg(MSGT_FIXME
, MSGL_FIXME
, "\nEDL_MUTE: [%f]\n", next_edl_record
->start_sec
);
2563 next_edl_record
=next_edl_record
->next
;
2569 //================= Keyboard events, SEEKing ====================
2571 current_module
="key_events";
2576 while( !brk_cmd
&& (cmd
= mp_input_get_cmd(0,0,0)) != NULL
) {
2578 case MP_CMD_SEEK
: {
2580 osd_show_percentage
= 25;
2581 v
= cmd
->args
[0].v
.i
;
2582 abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2583 if(abs
==2) { /* Absolute seek to a specific timestamp in seconds */
2586 osd_function
= (v
> sh_video
->timer
) ? OSD_FFW
: OSD_REW
;
2589 else if(abs
) { /* Absolute seek by percentage */
2592 osd_function
= (v
> sh_video
->timer
) ? OSD_FFW
: OSD_REW
;
2593 rel_seek_secs
= v
/100.0;
2597 osd_function
= (v
> 0) ? OSD_FFW
: OSD_REW
;
2602 case MP_CMD_EDL_MARK
:
2604 float v
= sh_video
->pts
;
2605 fprintf( edl_fd
, "%f %f %d\n", v
-2, v
, 0 );
2609 case MP_CMD_SWITCH_RATIO
: {
2610 if (cmd
->nargs
== 0)
2611 movie_aspect
= (float) sh_video
->disp_w
/ sh_video
->disp_h
;
2613 movie_aspect
= cmd
->args
[0].v
.f
;
2614 mpcodecs_config_vo (sh_video
, sh_video
->disp_w
, sh_video
->disp_h
, 0);
2616 case MP_CMD_AUDIO_DELAY
: {
2617 float v
= cmd
->args
[0].v
.f
;
2619 osd_show_av_delay
= 9;
2620 if(sh_audio
) sh_audio
->delay
+= v
;
2622 case MP_CMD_SPEED_INCR
: {
2623 float v
= cmd
->args
[0].v
.f
;
2624 playback_speed
+= v
;
2625 osd_show_speed
= sh_video
->fps
;
2626 build_afilter_chain(sh_audio
, &ao_data
);
2628 case MP_CMD_SPEED_MULT
: {
2629 float v
= cmd
->args
[0].v
.f
;
2630 playback_speed
*= v
;
2631 osd_show_speed
= sh_video
->fps
;
2632 build_afilter_chain(sh_audio
, &ao_data
);
2634 case MP_CMD_SPEED_SET
: {
2635 float v
= cmd
->args
[0].v
.f
;
2637 osd_show_speed
= sh_video
->fps
;
2638 build_afilter_chain(sh_audio
, &ao_data
);
2640 case MP_CMD_FRAME_STEP
:
2641 case MP_CMD_PAUSE
: {
2642 osd_function
=OSD_PAUSE
;
2645 case MP_CMD_QUIT
: {
2646 exit_player_with_rc(MSGTR_Exit_quit
, (cmd
->nargs
> 0)? cmd
->args
[0].v
.i
: 0);
2648 case MP_CMD_GRAB_FRAMES
: {
2651 case MP_CMD_PLAY_TREE_STEP
: {
2652 int n
= cmd
->args
[0].v
.i
== 0 ? 1 : cmd
->args
[0].v
.i
;
2653 int force
= cmd
->args
[1].v
.i
;
2662 for (i
=0;i
<-1*n
;i
++)
2667 if(!force
&& playtree_iter
) {
2668 play_tree_iter_t
* i
= play_tree_iter_new_copy(playtree_iter
);
2670 if(play_tree_iter_step(i
,n
,0) == PLAY_TREE_ITER_ENTRY
)
2671 eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2672 play_tree_iter_free(i
);
2674 eof
= (n
> 0) ? PT_NEXT_ENTRY
: PT_PREV_ENTRY
;
2680 case MP_CMD_PLAY_TREE_UP_STEP
: {
2681 int n
= cmd
->args
[0].v
.i
> 0 ? 1 : -1;
2682 int force
= cmd
->args
[1].v
.i
;
2684 if(!force
&& playtree_iter
) {
2685 play_tree_iter_t
* i
= play_tree_iter_new_copy(playtree_iter
);
2686 if(play_tree_iter_up_step(i
,n
,0) == PLAY_TREE_ITER_ENTRY
)
2687 eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2688 play_tree_iter_free(i
);
2690 eof
= (n
> 0) ? PT_UP_NEXT
: PT_UP_PREV
;
2693 case MP_CMD_PLAY_ALT_SRC_STEP
: {
2694 if(playtree_iter
&& playtree_iter
->num_files
> 1) {
2695 int v
= cmd
->args
[0].v
.i
;
2696 if(v
> 0 && playtree_iter
->file
< playtree_iter
->num_files
)
2698 else if(v
< 0 && playtree_iter
->file
> 1)
2703 case MP_CMD_SUB_DELAY
: {
2706 int abs
= cmd
->args
[1].v
.i
;
2707 float v
= cmd
->args
[0].v
.f
;
2712 osd_show_sub_delay
= 9; // show the subdelay in OSD
2716 case MP_CMD_SUB_STEP
: {
2719 int movement
= cmd
->args
[0].v
.i
;
2720 step_sub(subdata
, sh_video
->pts
, movement
);
2721 osd_show_sub_delay
= 9; // show the subdelay in OSD
2728 int v
= cmd
->args
[0].v
.i
;
2730 osd_level
=(osd_level
+1)%(MAX_OSD_LEVEL
+1);
2732 osd_level
= v
> MAX_OSD_LEVEL
? MAX_OSD_LEVEL
: v
;
2736 case MP_CMD_OSD_SHOW_TEXT
: {
2738 if(osd_level
&& sh_video
){
2739 osd_show_text
=sh_video
->fps
; // 1 sec
2740 strncpy(osd_show_text_buffer
, cmd
->args
[0].v
.s
, 64);
2744 case MP_CMD_VOLUME
: {
2745 int v
= cmd
->args
[0].v
.i
;
2747 // start change for absolute volume value
2748 int abs
= (cmd
->nargs
> 1) ? cmd
->args
[1].v
.i
: 0;
2752 mixer_setvolume(&mixer
, (float)v
, (float)v
);
2755 mixer_incvolume(&mixer
);
2757 mixer_decvolume(&mixer
);
2761 if(osd_level
&& sh_video
){
2763 osd_visible
=sh_video
->fps
; // 1 sec
2764 vo_osd_progbar_type
=OSD_VOLUME
;
2765 mixer_getbothvolume(&mixer
, &vol
);
2766 vo_osd_progbar_value
=(vol
*256.0)/100.0;
2767 vo_osd_changed(OSDTYPE_PROGBAR
);
2774 case MP_CMD_LOADFILE
: {
2775 play_tree_t
* e
= play_tree_new();
2776 play_tree_add_file(e
,cmd
->args
[0].v
.s
);
2778 // Go back to the start point
2779 while(play_tree_iter_up_step(playtree_iter
,0,1) != PLAY_TREE_ITER_END
)
2781 play_tree_free_list(playtree
->child
,1);
2782 play_tree_set_child(playtree
,e
);
2783 play_tree_iter_step(playtree_iter
,0,0);
2787 case MP_CMD_LOADLIST
: {
2788 play_tree_t
* e
= parse_playlist_file(cmd
->args
[0].v
.s
);
2790 mp_msg(MSGT_CPLAYER
,MSGL_ERR
,MSGTR_PlaylistLoadUnable
,cmd
->args
[0].v
.s
);
2792 // Go back to the start point
2793 while(play_tree_iter_up_step(playtree_iter
,0,1) != PLAY_TREE_ITER_END
)
2795 play_tree_free_list(playtree
->child
,1);
2796 play_tree_set_child(playtree
,e
);
2797 play_tree_iter_step(playtree_iter
,0,0);
2802 case MP_CMD_GAMMA
: {
2803 int v
= cmd
->args
[0].v
.i
, abs
= cmd
->args
[1].v
.i
;
2808 if (vo_gamma_gamma
== 1000)
2811 get_video_colors (sh_video
, "gamma", &vo_gamma_gamma
);
2817 vo_gamma_gamma
+= v
;
2819 if (vo_gamma_gamma
> 100)
2820 vo_gamma_gamma
= 100;
2821 else if (vo_gamma_gamma
< -100)
2822 vo_gamma_gamma
= -100;
2823 set_video_colors(sh_video
, "gamma", vo_gamma_gamma
);
2826 osd_visible
=sh_video
->fps
; // 1 sec
2827 vo_osd_progbar_type
=OSD_BRIGHTNESS
;
2828 vo_osd_progbar_value
=(vo_gamma_gamma
<<7)/100 + 128;
2829 vo_osd_changed(OSDTYPE_PROGBAR
);
2833 case MP_CMD_BRIGHTNESS
: {
2834 int v
= cmd
->args
[0].v
.i
, abs
= cmd
->args
[1].v
.i
;
2839 if (vo_gamma_brightness
== 1000)
2841 vo_gamma_brightness
= 0;
2842 get_video_colors(sh_video
, "brightness", &vo_gamma_brightness
);
2846 vo_gamma_brightness
= v
;
2848 vo_gamma_brightness
+= v
;
2850 if (vo_gamma_brightness
> 100)
2851 vo_gamma_brightness
= 100;
2852 else if (vo_gamma_brightness
< -100)
2853 vo_gamma_brightness
= -100;
2854 if(set_video_colors(sh_video
, "brightness", vo_gamma_brightness
)){
2857 osd_visible
=sh_video
->fps
; // 1 sec
2858 vo_osd_progbar_type
=OSD_BRIGHTNESS
;
2859 vo_osd_progbar_value
=(vo_gamma_brightness
<<7)/100 + 128;
2860 vo_osd_changed(OSDTYPE_PROGBAR
);
2865 case MP_CMD_CONTRAST
: {
2866 int v
= cmd
->args
[0].v
.i
, abs
= cmd
->args
[1].v
.i
;
2871 if (vo_gamma_contrast
== 1000)
2873 vo_gamma_contrast
= 0;
2874 get_video_colors(sh_video
, "contrast", &vo_gamma_contrast
);
2878 vo_gamma_contrast
= v
;
2880 vo_gamma_contrast
+= v
;
2882 if (vo_gamma_contrast
> 100)
2883 vo_gamma_contrast
= 100;
2884 else if (vo_gamma_contrast
< -100)
2885 vo_gamma_contrast
= -100;
2886 if(set_video_colors(sh_video
, "contrast", vo_gamma_contrast
)){
2889 osd_visible
=sh_video
->fps
; // 1 sec
2890 vo_osd_progbar_type
=OSD_CONTRAST
;
2891 vo_osd_progbar_value
=(vo_gamma_contrast
<<7)/100 + 128;
2892 vo_osd_changed(OSDTYPE_PROGBAR
);
2897 case MP_CMD_SATURATION
: {
2898 int v
= cmd
->args
[0].v
.i
, abs
= cmd
->args
[1].v
.i
;
2903 if (vo_gamma_saturation
== 1000)
2905 vo_gamma_saturation
= 0;
2906 get_video_colors(sh_video
, "saturation", &vo_gamma_saturation
);
2910 vo_gamma_saturation
= v
;
2912 vo_gamma_saturation
+= v
;
2914 if (vo_gamma_saturation
> 100)
2915 vo_gamma_saturation
= 100;
2916 else if (vo_gamma_saturation
< -100)
2917 vo_gamma_saturation
= -100;
2918 if(set_video_colors(sh_video
, "saturation", vo_gamma_saturation
)){
2921 osd_visible
=sh_video
->fps
; // 1 sec
2922 vo_osd_progbar_type
=OSD_SATURATION
;
2923 vo_osd_progbar_value
=(vo_gamma_saturation
<<7)/100 + 128;
2924 vo_osd_changed(OSDTYPE_PROGBAR
);
2930 int v
= cmd
->args
[0].v
.i
, abs
= cmd
->args
[1].v
.i
;
2935 if (vo_gamma_hue
== 1000)
2938 get_video_colors(sh_video
, "hue", &vo_gamma_hue
);
2946 if (vo_gamma_hue
> 100)
2948 else if (vo_gamma_hue
< -100)
2949 vo_gamma_hue
= -100;
2950 if(set_video_colors(sh_video
, "hue", vo_gamma_hue
)){
2953 osd_visible
=sh_video
->fps
; // 1 sec
2954 vo_osd_progbar_type
=OSD_HUE
;
2955 vo_osd_progbar_value
=(vo_gamma_hue
<<7)/100 + 128;
2956 vo_osd_changed(OSDTYPE_PROGBAR
);
2961 case MP_CMD_FRAMEDROPPING
: {
2962 int v
= cmd
->args
[0].v
.i
;
2964 frame_dropping
= (frame_dropping
+1)%3;
2966 osd_show_framedropping
=10;
2967 vo_osd_changed(OSDTYPE_SUBTITLE
);
2971 frame_dropping
= v
> 2 ? 2 : v
;
2974 case MP_CMD_TV_SET_FREQ
: {
2975 if (file_format
== DEMUXER_TYPE_TV
)
2976 tv_set_freq((tvi_handle_t
*)(demuxer
->priv
), cmd
->args
[0].v
.f
* 16.0);
2978 case MP_CMD_TV_SET_NORM
: {
2979 if (file_format
== DEMUXER_TYPE_TV
)
2980 tv_set_norm((tvi_handle_t
*)(demuxer
->priv
), cmd
->args
[0].v
.s
);
2982 case MP_CMD_TV_SET_BRIGHTNESS
: {
2983 if (file_format
== DEMUXER_TYPE_TV
)
2984 tv_set_color_options((tvi_handle_t
*)(demuxer
->priv
), TV_COLOR_BRIGHTNESS
, cmd
->args
[0].v
.i
);
2986 case MP_CMD_TV_SET_HUE
: {
2987 if (file_format
== DEMUXER_TYPE_TV
)
2988 tv_set_color_options((tvi_handle_t
*)(demuxer
->priv
), TV_COLOR_HUE
, cmd
->args
[0].v
.i
);
2990 case MP_CMD_TV_SET_SATURATION
: {
2991 if (file_format
== DEMUXER_TYPE_TV
)
2992 tv_set_color_options((tvi_handle_t
*)(demuxer
->priv
), TV_COLOR_SATURATION
, cmd
->args
[0].v
.i
);
2994 case MP_CMD_TV_SET_CONTRAST
: {
2995 if (file_format
== DEMUXER_TYPE_TV
)
2996 tv_set_color_options((tvi_handle_t
*)(demuxer
->priv
), TV_COLOR_CONTRAST
, cmd
->args
[0].v
.i
);
2998 case MP_CMD_TV_STEP_CHANNEL
: {
2999 if (file_format
== DEMUXER_TYPE_TV
) {
3000 int v
= cmd
->args
[0].v
.i
;
3002 tv_step_channel((tvi_handle_t
*)(demuxer
->priv
), TV_CHANNEL_HIGHER
);
3004 if (tv_channel_list
) {
3005 osd_show_tv_channel
= sh_video
->fps
;
3006 vo_osd_changed(OSDTYPE_SUBTITLE
);
3010 tv_step_channel((tvi_handle_t
*)(demuxer
->priv
), TV_CHANNEL_LOWER
);
3012 if (tv_channel_list
) {
3013 osd_show_tv_channel
= sh_video
->fps
;
3014 vo_osd_changed(OSDTYPE_SUBTITLE
);
3020 #ifdef HAS_DVBIN_SUPPORT
3021 if((stream
->type
== STREAMTYPE_DVB
) && stream
->priv
)
3023 dvb_priv_t
*priv
= (dvb_priv_t
*) stream
->priv
;
3027 int v
= cmd
->args
[0].v
.i
;
3031 dir
= DVB_CHANNEL_HIGHER
;
3033 dir
= DVB_CHANNEL_LOWER
;
3036 if(dvb_step_channel(priv
, dir
))
3038 uninit_player(INITED_ALL
-(INITED_STREAM
|INITED_INPUT
));
3039 cache_uninit(stream
);
3040 goto goto_enable_cache
;
3046 case MP_CMD_TV_SET_CHANNEL
: {
3047 if (file_format
== DEMUXER_TYPE_TV
) {
3048 tv_set_channel((tvi_handle_t
*)(demuxer
->priv
), cmd
->args
[0].v
.s
);
3050 if (tv_channel_list
) {
3051 osd_show_tv_channel
= sh_video
->fps
;
3052 vo_osd_changed(OSDTYPE_SUBTITLE
);
3057 #ifdef HAS_DVBIN_SUPPORT
3058 case MP_CMD_DVB_SET_CHANNEL
:
3060 if((stream
->type
== STREAMTYPE_DVB
) && stream
->priv
)
3062 dvb_priv_t
*priv
= (dvb_priv_t
*) stream
->priv
;
3065 if(priv
->list
->current
<= cmd
->args
[0].v
.i
)
3070 if(dvb_set_channel(priv
, cmd
->args
[1].v
.i
, cmd
->args
[0].v
.i
))
3072 uninit_player(INITED_ALL
-(INITED_STREAM
|INITED_INPUT
));
3073 cache_uninit(stream
);
3074 goto goto_enable_cache
;
3080 case MP_CMD_TV_LAST_CHANNEL
: {
3081 if (file_format
== DEMUXER_TYPE_TV
) {
3082 tv_last_channel((tvi_handle_t
*)(demuxer
->priv
));
3084 if (tv_channel_list
) {
3085 osd_show_tv_channel
= sh_video
->fps
;
3086 vo_osd_changed(OSDTYPE_SUBTITLE
);
3091 case MP_CMD_TV_STEP_NORM
: {
3092 if (file_format
== DEMUXER_TYPE_TV
)
3093 tv_step_norm((tvi_handle_t
*)(demuxer
->priv
));
3095 case MP_CMD_TV_STEP_CHANNEL_LIST
: {
3096 if (file_format
== DEMUXER_TYPE_TV
)
3097 tv_step_chanlist((tvi_handle_t
*)(demuxer
->priv
));
3100 case MP_CMD_SWITCH_VSYNC
: {
3101 vo_vsync
= ( cmd
->nargs
> 0 )? cmd
->args
[0].v
.i
: !vo_vsync
;
3103 case MP_CMD_VO_FULLSCREEN
:
3106 if ( use_gui
) guiGetEvent( guiIEvent
,(char *)MP_CMD_GUI_FULLSCREEN
);
3109 if(video_out
&& vo_config_count
) video_out
->control(VOCTRL_FULLSCREEN
, 0);
3111 case MP_CMD_VO_ONTOP
:
3113 if(video_out
&& vo_config_count
) {
3114 video_out
->control(VOCTRL_ONTOP
, 0);
3117 vo_osd_changed(OSDTYPE_SUBTITLE
);
3122 case MP_CMD_VO_ROOTWIN
:
3124 if(video_out
&& vo_config_count
) {
3125 video_out
->control(VOCTRL_ROOTWIN
, 0);
3127 osd_show_rootwin
=10;
3128 vo_osd_changed(OSDTYPE_SUBTITLE
);
3133 case MP_CMD_PANSCAN
: {
3134 if ( !video_out
) break;
3135 if ( video_out
->control( VOCTRL_GET_PANSCAN
,NULL
) == VO_TRUE
)
3137 int abs
= cmd
->args
[1].v
.i
;
3138 float v
= cmd
->args
[0].v
.f
;
3141 else res
= vo_panscan
+v
;
3142 vo_panscan
= res
> 1 ? 1 : res
< 0 ? 0 : res
;
3143 video_out
->control( VOCTRL_SET_PANSCAN
,NULL
);
3145 if(osd_level
&& sh_video
){
3146 osd_visible
=sh_video
->fps
; // 1 sec
3147 vo_osd_progbar_type
=OSD_PANSCAN
;
3148 vo_osd_progbar_value
=vo_panscan
*256;
3149 vo_osd_changed(OSDTYPE_PROGBAR
);
3150 #ifdef HAVE_FREETYPE
3151 if (subtitle_autoscale
== 2 || subtitle_autoscale
== 3)
3152 // force scaling font to movie width or diagonal
3153 force_load_font
= 1;
3159 case MP_CMD_SUB_POS
:
3164 v
= cmd
->args
[0].v
.i
;
3167 if(sub_pos
>100) sub_pos
=100;
3168 if(sub_pos
<0) sub_pos
=0;
3169 vo_osd_changed(OSDTYPE_SUBTITLE
);
3170 osd_show_sub_pos
= 9;
3174 case MP_CMD_SUB_ALIGNMENT
:
3178 if (cmd
->nargs
>= 1)
3179 sub_alignment
= cmd
->args
[0].v
.i
;
3181 sub_alignment
= (sub_alignment
+1) % 3;
3182 osd_show_sub_alignment
= 9;
3183 vo_osd_changed(OSDTYPE_SUBTITLE
);
3187 case MP_CMD_SUB_VISIBILITY
:
3191 sub_visibility
=1-sub_visibility
;
3192 osd_show_sub_visibility
= 9; // show state of subtitle visibility in OSD
3193 vo_osd_changed(OSDTYPE_SUBTITLE
);
3197 case MP_CMD_GET_SUB_VISIBILITY
:
3201 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,MSGTR_AnsSubVisibility
, sub_visibility
);
3205 case MP_CMD_SUB_SELECT
:
3206 if (global_sub_size
) {
3210 if (global_sub_pos
>= global_sub_size
)
3211 global_sub_pos
= -1;
3212 if (global_sub_pos
>= 0)
3213 source
= sub_source();
3215 mp_msg(MSGT_CPLAYER
, MSGL_DBG3
, "subtitles: %d subs, (v@%d s@%d d@%d), @%d, source @%d\n",
3216 global_sub_size
, global_sub_indices
[SUB_SOURCE_VOBSUB
],
3217 global_sub_indices
[SUB_SOURCE_SUBS
], global_sub_indices
[SUB_SOURCE_DEMUX
],
3218 global_sub_pos
, source
);
3221 set_of_sub_pos
= -1;
3227 if (d_dvdsub
) d_dvdsub
->id
= -1;
3230 // if sub_changed is till on but subdata's been reset, bad things happen.
3231 osd_show_vobsub_changed
= 0;
3232 osd_show_sub_changed
= 0;
3234 if (source
== SUB_SOURCE_VOBSUB
) {
3235 vobsub_id
= global_sub_pos
- global_sub_indices
[SUB_SOURCE_VOBSUB
];
3236 if (!global_sub_quiet_osd_hack
) osd_show_vobsub_changed
= sh_video
->fps
;
3238 } else if (source
== SUB_SOURCE_SUBS
) {
3239 set_of_sub_pos
= global_sub_pos
- global_sub_indices
[SUB_SOURCE_SUBS
];
3240 subdata
= set_of_subtitles
[set_of_sub_pos
];
3241 if (!global_sub_quiet_osd_hack
) osd_show_sub_changed
= sh_video
->fps
;
3242 vo_osd_changed(OSDTYPE_SUBTITLE
);
3244 // FIXME: is this the correct place for these?
3245 if(stream_dump_type
==3) list_sub_file(subdata
);
3246 if(stream_dump_type
==4) dump_mpsub(subdata
, sh_video
->fps
);
3247 if(stream_dump_type
==6) dump_srt(subdata
, sh_video
->fps
);
3248 if(stream_dump_type
==7) dump_microdvd(subdata
, sh_video
->fps
);
3249 if(stream_dump_type
==8) dump_jacosub(subdata
, sh_video
->fps
);
3250 if(stream_dump_type
==9) dump_sami(subdata
, sh_video
->fps
);
3252 } else if (source
== SUB_SOURCE_DEMUX
) {
3253 dvdsub_id
= global_sub_pos
- global_sub_indices
[SUB_SOURCE_DEMUX
];
3256 if (vo_spudec
&& stream
->type
== STREAMTYPE_DVD
) {
3257 d_dvdsub
->id
= dvdsub_id
;
3258 spudec_reset(vo_spudec
);
3261 #ifdef HAVE_OGGVORBIS
3262 if (demuxer
->type
== DEMUXER_TYPE_OGG
)
3263 d_dvdsub
->id
= demux_ogg_sub_id(demuxer
, dvdsub_id
);
3265 #ifdef HAVE_MATROSKA
3266 if (demuxer
->type
== DEMUXER_TYPE_MATROSKA
) {
3267 d_dvdsub
->id
= demux_mkv_change_subs(demuxer
, dvdsub_id
);
3268 if (d_dvdsub
->id
>= 0 && ((mkv_sh_sub_t
*)d_dvdsub
->sh
)->type
== 'v') {
3269 mkv_sh_sub_t
*mkv_sh_sub
= (mkv_sh_sub_t
*)d_dvdsub
->sh
;
3270 if (vo_spudec
!= NULL
)
3271 spudec_free(vo_spudec
);
3273 spudec_new_scaled_vobsub(mkv_sh_sub
->palette
, mkv_sh_sub
->colors
,
3274 mkv_sh_sub
->custom_colors
,
3276 mkv_sh_sub
->height
);
3277 if (!forced_subs_only
)
3278 forced_subs_only
= mkv_sh_sub
->forced_subs_only
;
3280 spudec_set_forced_subs_only(vo_spudec
, forced_subs_only
);
3281 inited_flags
|= INITED_SPUDEC
;
3287 if (!global_sub_quiet_osd_hack
) osd_show_vobsub_changed
= sh_video
->fps
;
3289 if (!global_sub_quiet_osd_hack
) osd_show_vobsub_changed
= sh_video
->fps
;
3291 vo_osd_changed(OSDTYPE_SUBTITLE
);
3294 // it's annoying and dumb to show osd saying "off" at every subless file...
3295 global_sub_quiet_osd_hack
= 0;
3298 case MP_CMD_SUB_FORCED_ONLY
:
3300 forced_subs_only
= forced_subs_only
? 0 : ~0; // toggle state
3301 spudec_set_forced_subs_only(vo_spudec
,forced_subs_only
);
3304 case MP_CMD_SCREENSHOT
:
3305 if(vo_config_count
) video_out
->control(VOCTRL_SCREENSHOT
, NULL
);
3307 case MP_CMD_VF_CHANGE_RECTANGLE
:
3308 set_rectangle(sh_video
, cmd
->args
[0].v
.i
, cmd
->args
[1].v
.i
);
3311 case MP_CMD_GET_TIME_LENGTH
: {
3312 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,MSGTR_AnsLength
, demuxer_get_time_length(demuxer
));
3315 case MP_CMD_GET_VO_FULLSCREEN
: {
3316 if(video_out
&& vo_config_count
)
3317 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,MSGTR_AnsVoFullscreen
, vo_fs
);
3320 case MP_CMD_GET_PERCENT_POS
: {
3321 mp_msg(MSGT_GLOBAL
,MSGL_INFO
,MSGTR_AnsPercentPos
, demuxer_get_percent_pos(demuxer
));
3324 case MP_CMD_CRUN
: {
3327 execl("/bin/sh","sh","-c",cmd
->args
[0].v
.s
,NULL
);
3335 case MP_CMD_DVDNAV_EVENT
: {
3336 dvdnav_priv_t
* dvdnav_priv
= (dvdnav_priv_t
*)(stream
->priv
);
3337 dvdnav_event_t
* dvdnav_event
= (dvdnav_event_t
*)(cmd
->args
[0].v
.v
);
3339 /* ignore these events if we're not in dvd_nav mode */
3340 if (stream
->type
!= STREAMTYPE_DVDNAV
) break;
3342 if (!dvdnav_event
) {
3343 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNullEvent
);
3347 //printf("mplayer: got event: %d\n",dvdnav_event->event);
3349 switch (dvdnav_event
->event
) {
3350 case DVDNAV_BLOCK_OK
: {
3351 /* be silent about this one */
3354 case DVDNAV_HIGHLIGHT
: {
3355 dvdnav_highlight_event_t
*hevent
= (dvdnav_highlight_event_t
*)(dvdnav_event
->details
);
3357 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavHighlightEventBroken
);
3361 if (hevent
->display
&& hevent
->buttonN
>0)
3363 //dvdnav_priv->seen_root_menu=1; /* if we got a highlight, we're on a menu */
3364 sprintf( dvd_nav_text
, "Highlight button %d (%u,%u)-(%u,%u) PTS %d (now is %5.2f)",
3366 hevent
->sx
,hevent
->sy
,
3367 hevent
->ex
,hevent
->ey
,
3368 hevent
->pts
, d_video
->pts
);
3369 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavEvent
,dvd_nav_text
);
3370 //osd_show_dvd_nav_delay = 60;
3372 osd_show_dvd_nav_highlight
=1;
3373 osd_show_dvd_nav_sx
=hevent
->sx
;
3374 osd_show_dvd_nav_ex
=hevent
->ex
;
3375 osd_show_dvd_nav_sy
=hevent
->sy
;
3376 osd_show_dvd_nav_ey
=hevent
->ey
;
3379 osd_show_dvd_nav_highlight
=0;
3380 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavHighlightHide
);
3384 case DVDNAV_STILL_FRAME
: {
3385 dvdnav_still_event_t
*still_event
= (dvdnav_still_event_t
*)(dvdnav_event
->details
);
3387 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavStillFrame
, still_event
->length
);
3388 while (dvdnav_stream_sleeping(dvdnav_priv
)) {
3389 usec_sleep(1000); /* 1ms */
3391 dvdnav_stream_sleep(dvdnav_priv
,still_event
->length
);
3395 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavStop
);
3399 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavNOP
);
3402 case DVDNAV_SPU_STREAM_CHANGE
: {
3403 #if DVDNAVVERSION > 012
3404 dvdnav_spu_stream_change_event_t
*stream_change
= (dvdnav_spu_stream_change_event_t
*)(dvdnav_event
->details
);
3406 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavSpuStreamChangeVerbose
,
3407 stream_change
->physical_wide
,
3408 stream_change
->physical_letterbox
,
3409 stream_change
->physical_pan_scan
,
3410 stream_change
->logical
);
3412 if (vo_spudec
&& dvdsub_id
!=stream_change
->physical_wide
) {
3413 mp_msg(MSGT_INPUT
,MSGL_DBG2
,"d_dvdsub->id change: was %d is now %d\n",
3414 d_dvdsub
->id
,stream_change
->physical_wide
);
3415 // FIXME: need a better way to change SPU id
3416 d_dvdsub
->id
=dvdsub_id
=stream_change
->physical_wide
;
3417 if (vo_spudec
) spudec_reset(vo_spudec
);
3420 dvdnav_stream_change_event_t
*stream_change
= (dvdnav_stream_change_event_t
*)(dvdnav_event
->details
);
3422 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavSpuStreamChange
,
3423 stream_change
->physical
,
3424 stream_change
->logical
);
3426 if (vo_spudec
&& dvdsub_id
!=stream_change
->physical
) {
3427 mp_msg(MSGT_INPUT
,MSGL_DBG2
,"d_dvdsub->id change: was %d is now %d\n",
3428 d_dvdsub
->id
,stream_change
->physical
);
3429 // FIXME: need a better way to change SPU id
3430 d_dvdsub
->id
=dvdsub_id
=stream_change
->physical
;
3431 if (vo_spudec
) spudec_reset(vo_spudec
);
3436 case DVDNAV_AUDIO_STREAM_CHANGE
: {
3438 #if DVDNAVVERSION > 012
3439 dvdnav_audio_stream_change_event_t
*stream_change
= (dvdnav_audio_stream_change_event_t
*)(dvdnav_event
->details
);
3441 dvdnav_stream_change_event_t
*stream_change
= (dvdnav_stream_change_event_t
*)(dvdnav_event
->details
);
3444 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavAudioStreamChange
,
3445 stream_change
->physical
,
3446 stream_change
->logical
);
3448 aid_temp
=stream_change
->physical
;
3449 if (aid_temp
>=0) aid_temp
+=128; // FIXME: is this sane?
3450 if (d_audio
&& audio_id
!=aid_temp
) {
3451 mp_msg(MSGT_INPUT
,MSGL_DBG2
,"d_audio->id change: was %d is now %d\n",
3452 d_audio
->id
,aid_temp
);
3453 // FIXME: need a bettery way to change audio stream id
3454 d_audio
->id
=dvdsub_id
=aid_temp
;
3455 if(sh_audio
) resync_audio_stream(sh_audio
);
3460 case DVDNAV_VTS_CHANGE
: {
3461 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavVTSChange
);
3464 case DVDNAV_CELL_CHANGE
: {
3465 dvdnav_cell_change_event_t
*cell_change
= (dvdnav_cell_change_event_t
*)(dvdnav_event
->details
);
3466 cell_playback_t
* cell_playback
= cell_change
->new_cell
;
3468 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavCellChange
);
3469 osd_show_dvd_nav_highlight
=0; /* screen changed, disable menu */
3471 printf("new still time: %d\n",cell_playback->still_time);
3472 printf("new cell_cmd_nr: %d\n",cell_playback->cell_cmd_nr);
3473 printf("new playback_time: %02d:%02d:%02d.%02d\n",
3474 cell_playback->playback_time.hour,
3475 cell_playback->playback_time.minute,
3476 cell_playback->playback_time.second,
3477 cell_playback->playback_time.frame_u);
3480 //rel_seek_secs=1; // not really: we can't seek, but it'll reset the muxer
3484 case DVDNAV_NAV_PACKET
: {
3485 // printf("DVDNAV Event: Nav Packet\n");
3488 case DVDNAV_SPU_CLUT_CHANGE
: {
3489 uint32_t * new_clut
= (uint32_t *)(dvdnav_event
->details
);
3491 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavSpuClutChange
);
3492 // send new palette to SPU decoder
3493 if (vo_spudec
) spudec_update_palette(vo_spudec
,new_clut
);
3497 case DVDNAV_SEEK_DONE
: {
3498 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_DvdnavNavSeekDone
);
3503 // free the dvdnav event
3504 free(dvdnav_event
->details
);
3506 cmd
->args
[0].v
.v
=NULL
;
3508 case MP_CMD_DVDNAV
: {
3509 dvdnav_priv_t
* dvdnav_priv
=(dvdnav_priv_t
*)stream
->priv
;
3511 /* ignore these events if we're not in dvd_nav mode */
3512 if (stream
->type
!= STREAMTYPE_DVDNAV
) break;
3514 switch (cmd
->args
[0].v
.i
) {
3515 case MP_CMD_DVDNAV_UP
:
3516 dvdnav_upper_button_select(dvdnav_priv
->dvdnav
);
3518 case MP_CMD_DVDNAV_DOWN
:
3519 dvdnav_lower_button_select(dvdnav_priv
->dvdnav
);
3521 case MP_CMD_DVDNAV_LEFT
:
3522 dvdnav_left_button_select(dvdnav_priv
->dvdnav
);
3524 case MP_CMD_DVDNAV_RIGHT
:
3525 dvdnav_right_button_select(dvdnav_priv
->dvdnav
);
3527 case MP_CMD_DVDNAV_MENU
:
3528 mp_msg(MSGT_FIXME
, MSGL_FIXME
, MSGTR_MenuCall
);
3529 dvdnav_menu_call(dvdnav_priv
->dvdnav
,DVD_MENU_Root
);
3531 case MP_CMD_DVDNAV_SELECT
:
3532 dvdnav_button_activate(dvdnav_priv
->dvdnav
);
3535 mp_msg(MSGT_CPLAYER
, MSGL_V
, "Weird DVD Nav cmd %d\n",cmd
->args
[0].v
.i
);
3543 if ( ( use_gui
)&&( cmd
->id
> MP_CMD_GUI_EVENTS
) ) guiGetEvent( guiIEvent
,(char *)cmd
->id
);
3546 mp_msg(MSGT_CPLAYER
, MSGL_V
, "Received unknown cmd %s\n",cmd
->name
);
3556 if (sscanf(seek_to_sec
, "%d:%d:%f", &a
,&b
,&d
)==3)
3557 rel_seek_secs
+= 3600*a
+60*b
+d
;
3558 else if (sscanf(seek_to_sec
, "%d:%f", &a
, &d
)==2)
3559 rel_seek_secs
+= 60*a
+d
;
3560 else if (sscanf(seek_to_sec
, "%f", &d
)==1)
3567 if(eof
==1 && loop_times
>=0) {
3569 play_tree_iter_step(playtree_iter
,0,0);
3571 mp_msg(MSGT_CPLAYER
,MSGL_V
,"loop_times = %d, eof = %d\n", loop_times
,eof
);
3573 if(loop_times
>1) loop_times
--; else
3574 if(loop_times
==1) loop_times
=-1;
3575 play_n_frames
=play_n_frames_mf
;
3577 abs_seek_pos
=3; rel_seek_secs
=0; // seek to start of movie (0%)
3581 if(rel_seek_secs
|| abs_seek_pos
){
3582 current_module
="seek";
3583 if(demux_seek(demuxer
,rel_seek_secs
,abs_seek_pos
)){
3585 /* FIXME there should be real seeking for vobsub */
3586 if(sh_video
) sh_video
->pts
=d_video
->pts
;
3588 //vobsub_reset(vo_vobsub);
3589 vobsub_seek(vo_vobsub
,sh_video
->pts
);
3591 if(sh_video
&& d_video
->packs
== 0)
3592 ds_fill_buffer(d_video
);
3594 if(d_audio
->packs
== 0)
3595 ds_fill_buffer(d_audio
);
3597 float a_pts
=d_audio
->pts
;
3598 a_pts
+=(ds_tell_pts(d_audio
)-sh_audio
->a_in_buffer_len
)/(float)sh_audio
->i_bps
;
3599 mp_msg(MSGT_AVSYNC
,MSGL_V
,"SEEK: A: %5.3f V: %5.3f A-V: %5.3f \n",a_pts
,d_video
->pts
,a_pts
-d_video
->pts
);
3601 mp_msg(MSGT_AVSYNC
,MSGL_STATUS
,"A:%6.1f V:%6.1f A-V:%7.3f ct: ? \r",d_audio
->pts
,d_video
->pts
,0.0f
);
3603 mp_msg(MSGT_AVSYNC
,MSGL_STATUS
,"A: --- V:%6.1f \r",d_video
->pts
);
3609 current_module
="seek_video_reset";
3610 resync_video_stream(sh_video
);
3611 if(vo_config_count
) video_out
->control(VOCTRL_RESET
,NULL
);
3615 current_module
="seek_audio_reset";
3616 audio_out
->reset(); // stop audio, throwing away buffered data
3620 if(osd_level
&& !loop_seek
){
3622 if( !edl_decision
) {
3624 if( 1 ) { // Let the compiler optimize this out
3626 int len
=((demuxer
->movi_end
-demuxer
->movi_start
)>>8);
3627 if (len
>0 && sh_video
){
3628 osd_visible
=sh_video
->fps
; // 1 sec
3629 vo_osd_progbar_type
=0;
3630 vo_osd_progbar_value
=(demuxer
->filepos
-demuxer
->movi_start
)/len
;
3631 vo_osd_changed(OSDTYPE_PROGBAR
);
3638 max_pts_correction
=0.1;
3639 osd_visible
=sh_video
->fps
; // to rewert to PLAY pointer after 1 sec
3640 audio_time_usage
=0; video_time_usage
=0; vout_time_usage
=0;
3642 too_slow_frame_cnt
=0;
3643 too_fast_frame_cnt
=0;
3645 if(vo_spudec
) spudec_reset(vo_spudec
);
3650 * We saw a seek, have to rewind the EDL operations stack
3651 * and find the next EDL action to take care of.
3654 next_edl_record
= edl_records
;
3656 while (next_edl_record
)
3658 /* Trying to remember if we need to mute/unmute first;
3659 * prior EDL implementation lacks this.
3662 if (next_edl_record
->start_sec
>= sh_video
->pts
)
3664 if (edl_mute_count
> 0)
3666 if ((edl_mute_count
% 2) == 0 &&
3667 next_edl_record
->mute_state
== EDL_MUTE_END
)
3672 if ((edl_mute_count
% 2) != 0 &&
3673 next_edl_record
->mute_state
== EDL_MUTE_START
)
3678 } else if (next_edl_record
->mute_state
== EDL_MUTE_END
)
3686 next_edl_record
= next_edl_record
->next
;
3688 if (!next_edl_record
&& (edl_mute_count
% 2) != 0
3689 && edl_mute_count
> 0)
3698 frame_time_remaining
=0;
3699 current_module
=NULL
;
3706 if(demuxer
->file_format
==DEMUXER_TYPE_AVI
&& sh_video
&& sh_video
->video
.dwLength
>2){
3707 // get pos from frame number / total frames
3708 guiIntfStruct
.Position
=(float)d_video
->pack_no
*100.0f
/sh_video
->video
.dwLength
;
3710 off_t len
= ( demuxer
->movi_end
- demuxer
->movi_start
);
3711 off_t pos
= ( demuxer
->file_format
== DEMUXER_TYPE_AUDIO
?stream
->pos
:demuxer
->filepos
);
3712 guiIntfStruct
.Position
=(len
<= 0? 0.0f
: ( pos
- demuxer
->movi_start
) * 100.0f
/ len
);
3714 if ( sh_video
) guiIntfStruct
.TimeSec
=sh_video
->pts
;
3715 else if ( sh_audio
) guiIntfStruct
.TimeSec
=sh_audio
->delay
;
3716 guiIntfStruct
.LengthInSec
=demuxer_get_time_length(demuxer
);
3717 guiGetEvent( guiReDraw
,NULL
);
3718 guiGetEvent( guiSetVolume
,NULL
);
3719 if(guiIntfStruct
.Playing
==0) break; // STOP
3720 if(guiIntfStruct
.Playing
==2) osd_function
=OSD_PAUSE
;
3721 if ( guiIntfStruct
.DiskChanged
|| guiIntfStruct
.NewPlay
) goto goto_next_file
;
3723 if ( stream
->type
== STREAMTYPE_DVD
)
3725 dvd_priv_t
* dvdp
= stream
->priv
;
3726 guiIntfStruct
.DVD
.current_chapter
=dvd_chapter_from_cell(dvdp
,guiIntfStruct
.DVD
.current_title
-1, dvdp
->cur_cell
)+1;
3733 //================= Update OSD ====================
3735 if(osd_level
>=1 && sh_video
){
3736 int pts
=sh_video
->pts
;
3737 char osd_text_tmp
[64];
3738 if(pts
==osd_last_pts
-1) ++pts
; else osd_last_pts
=pts
;
3739 vo_osd_text
=osd_text_buffer
;
3741 if (osd_show_dvd_nav_delay
) {
3742 snprintf(osd_text_tmp
, 63, "DVDNAV: %s", dvd_nav_text
);
3743 osd_show_dvd_nav_delay
--;
3747 if (osd_show_tv_channel
&& tv_channel_list
) {
3748 snprintf(osd_text_tmp
, 63, "Channel: %s", tv_channel_current
->name
);
3749 osd_show_tv_channel
--;
3752 if (osd_show_text
) {
3753 snprintf(osd_text_tmp
, 63, "%s", osd_show_text_buffer
);
3756 if (osd_show_sub_visibility
) {
3757 snprintf(osd_text_tmp
, 63, "Subtitles: %sabled", sub_visibility
?"en":"dis");
3758 osd_show_sub_visibility
--;
3760 if (osd_show_vobsub_changed
) {
3761 if (vo_vobsub
&& vobsub_id
>= 0) {
3762 const char *language
= "none";
3763 language
= vobsub_get_id(vo_vobsub
, (unsigned int) vobsub_id
);
3764 snprintf(osd_text_tmp
, 63, "Subtitles: (%d) %s", vobsub_id
, language
? language
: "unknown");
3766 #ifdef HAVE_OGGVORBIS
3767 if (d_dvdsub
&& demuxer
->type
== DEMUXER_TYPE_OGG
) {
3769 snprintf(osd_text_tmp
, 63, "Subtitles: (off)");
3771 char *lang
= demux_ogg_sub_lang(demuxer
, dvdsub_id
);
3772 if (!lang
) lang
= "unknown";
3773 snprintf(osd_text_tmp
, 63, "Subtitles: (%d) %s", dvdsub_id
, lang
);
3778 if (vo_spudec
&& (demuxer
->type
!= DEMUXER_TYPE_MATROSKA
)) {
3779 char lang
[5] = "none";
3781 if (dvdsub_id
>= 0) code
= dvd_lang_from_sid(stream
, dvdsub_id
);
3783 lang
[0] = code
>> 8;
3787 snprintf(osd_text_tmp
, 63, "Subtitles: (%d) %s", dvdsub_id
, lang
);
3790 #ifdef HAVE_MATROSKA
3791 if (demuxer
->type
== DEMUXER_TYPE_MATROSKA
) {
3792 char lang
[10] = "unknown";
3793 if (dvdsub_id
>= 0) {
3794 demux_mkv_get_sub_lang(demuxer
, dvdsub_id
, lang
, 9);
3797 strcpy(lang
, "off");
3798 snprintf(osd_text_tmp
, 63, "Subtitles: (%d) %s", dvdsub_id
, lang
);
3801 osd_show_vobsub_changed
--;
3804 if (osd_show_sub_changed
) {
3806 tmp
= subdata
->filename
;
3807 if ((tmp2
= strrchr(tmp
, '/'))) {
3810 snprintf(osd_text_tmp
, 63, "Sub: (%d) %s%s",
3812 strlen(tmp
) < 20 ? "" : "...",
3813 strlen(tmp
) < 20 ? tmp
: tmp
+strlen(tmp
)-19);
3814 osd_show_sub_changed
--;
3817 if (osd_show_sub_delay
) {
3818 snprintf(osd_text_tmp
, 63, "Sub delay: %d ms", ROUND(sub_delay
*1000));
3819 osd_show_sub_delay
--;
3821 if (osd_show_sub_pos
) {
3822 snprintf(osd_text_tmp
, 63, "Sub position: %d/100", sub_pos
);
3825 if (osd_show_sub_alignment
) {
3826 snprintf(osd_text_tmp
, 63, "Sub alignment: %s",
3827 (sub_alignment
== 2 ? "bottom" :
3828 (sub_alignment
== 1 ? "center" : "top")));
3829 osd_show_sub_alignment
--;
3831 if (osd_show_av_delay
) {
3832 snprintf(osd_text_tmp
, 63, "A-V delay: %d ms", ROUND(audio_delay
*1000));
3833 osd_show_av_delay
--;
3834 } else if (osd_show_speed
) {
3835 snprintf(osd_text_tmp
, 63, "Speed: x %6.2f", playback_speed
);
3837 } else if (osd_show_ontop
) {
3838 snprintf(osd_text_tmp
, 63, "Stay on top: %sabled", vo_ontop
?"en":"dis");
3840 } else if (osd_show_rootwin
) {
3841 snprintf(osd_text_tmp
, 63, "Rootwin: %sabled", vo_rootwin
?"en":"dis");
3843 } else if (osd_show_framedropping
) {
3844 snprintf(osd_text_tmp
, 63, "Framedropping: %s",
3845 (frame_dropping
== 1 ? "on" :
3846 (frame_dropping
== 2 ? "hard" : "off")));
3847 osd_show_framedropping
--;
3848 } else if(osd_level
>=2) {
3849 int len
= demuxer_get_time_length(demuxer
);
3850 int percentage
= -1;
3851 char percentage_text
[10];
3852 if (osd_show_percentage
) {
3853 percentage
= demuxer_get_percent_pos(demuxer
);
3854 osd_show_percentage
--;
3856 if (percentage
>= 0)
3857 snprintf(percentage_text
, 9, " (%d%%)", percentage
);
3859 percentage_text
[0] = 0;
3861 snprintf(osd_text_tmp
, 63, "%c %02d:%02d:%02d / %02d:%02d:%02d%s",osd_function
,pts
/3600,(pts
/60)%60,pts
%60,len
/3600,(len
/60)%60,len
%60,percentage_text
);
3863 snprintf(osd_text_tmp
, 63, "%c %02d:%02d:%02d%s",osd_function
,pts
/3600,(pts
/60)%60,pts
%60,percentage_text
);
3864 } else osd_text_tmp
[0]=0;
3866 if(strcmp(vo_osd_text
, osd_text_tmp
)) {
3867 strncpy(vo_osd_text
, osd_text_tmp
, 63);
3868 vo_osd_changed(OSDTYPE_OSD
);
3873 vo_osd_changed(OSDTYPE_OSD
);
3876 // for(i=1;i<=11;i++) osd_text_buffer[10+i]=i;osd_text_buffer[10+i]=0;
3877 // vo_osd_text=osd_text_buffer;
3882 if(subdata
&& sh_video
->pts
>0){
3883 float pts
=sh_video
->pts
;
3884 if(sub_fps
==0) sub_fps
=sh_video
->fps
;
3885 current_module
="find_sub";
3886 if (pts
> sub_last_pts
|| pts
< sub_last_pts
-1.0 ) {
3887 find_sub(subdata
, (pts
+sub_delay
) *
3888 (subdata
->sub_uses_time
? 100. : sub_fps
));
3889 // FIXME! frame counter...
3892 current_module
=NULL
;
3897 if (stop_xscreensaver
&& sh_video
) {
3898 current_module
="stop_xscreensaver";
3899 xscreensaver_heartbeat();
3900 current_module
=NULL
;
3905 if(vo_config_count
&& vo_spudec
) {
3906 unsigned char* packet
=NULL
;
3908 current_module
="spudec";
3909 spudec_heartbeat(vo_spudec
,90000*sh_video
->timer
);
3910 // Get a sub packet from the dvd or a vobsub and make a timestamp relative to sh_video->timer
3915 if(sh_video
->pts
+sub_delay
>=0) {
3916 // The + next_frame_time is there because we'll display the sub at the next frame
3917 len
= vobsub_get_packet(vo_vobsub
,sh_video
->pts
+sub_delay
+next_frame_time
,(void**)&packet
,×tamp
);
3919 timestamp
-= (sh_video
->pts
+ sub_delay
- sh_video
->timer
)*90000;
3920 mp_dbg(MSGT_CPLAYER
,MSGL_V
,"\rVOB sub: len=%d v_pts=%5.3f v_timer=%5.3f sub=%5.3f ts=%d \n",len
,sh_video
->pts
,sh_video
->timer
,timestamp
/ 90000.0,timestamp
);
3925 len
= ds_get_packet_sub(d_dvdsub
,(unsigned char**)&packet
);
3927 float x
= d_dvdsub
->pts
- sh_video
->pts
;
3928 if (x
< -10 || x
> 10) // prevent missing subs on pts reset
3929 timestamp
= 90000*(sh_video
->timer
+ d_dvdsub
->pts
+ sub_delay
- sh_video
->pts
);
3930 else timestamp
= 90000*(sh_video
->timer
+ sub_delay
);
3931 mp_dbg(MSGT_CPLAYER
,MSGL_V
,"\rDVD sub: len=%d v_pts=%5.3f s_pts=%5.3f ts=%d \n",len
,sh_video
->pts
,d_dvdsub
->pts
,timestamp
);
3934 if(len
<=0 || !packet
) break;
3935 if(timestamp
< 0) timestamp
= 0;
3936 else spudec_assemble(vo_spudec
,packet
,len
,timestamp
);
3939 /* detect wether the sub has changed or not */
3940 if(spudec_changed(vo_spudec
))
3941 vo_osd_changed(OSDTYPE_SPU
);
3942 current_module
=NULL
;
3947 mp_msg(MSGT_GLOBAL
,MSGL_V
,"EOF code: %d \n",eof
);
3951 goto_next_file
: // don't jump here after ao/vo/getch initialization!
3953 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"\n");
3956 double tot
=video_time_usage
+vout_time_usage
+audio_time_usage
;
3957 double total_time_usage
;
3958 total_time_usage_start
=GetTimer()-total_time_usage_start
;
3959 total_time_usage
= (float)total_time_usage_start
*0.000001;
3960 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"\nBENCHMARKs: VC:%8.3fs VO:%8.3fs A:%8.3fs Sys:%8.3fs = %8.3fs\n",
3961 video_time_usage
,vout_time_usage
,audio_time_usage
,
3962 total_time_usage
-tot
,total_time_usage
);
3963 if(total_time_usage
>0.0)
3964 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"BENCHMARK%%: VC:%8.4f%% VO:%8.4f%% A:%8.4f%% Sys:%8.4f%% = %8.4f%%\n",
3965 100.0*video_time_usage
/total_time_usage
,
3966 100.0*vout_time_usage
/total_time_usage
,
3967 100.0*audio_time_usage
/total_time_usage
,
3968 100.0*(total_time_usage
-tot
)/total_time_usage
,
3970 if(total_frame_cnt
&& frame_dropping
)
3971 mp_msg(MSGT_CPLAYER
,MSGL_INFO
,"BENCHMARKn: disp: %d (%3.2f fps) drop: %d (%d%%) total: %d (%3.2f fps)\n",
3972 total_frame_cnt
-drop_frame_cnt
,
3973 (total_time_usage
>0.5)?((total_frame_cnt
-drop_frame_cnt
)/total_time_usage
):0,
3975 100*drop_frame_cnt
/total_frame_cnt
,
3977 (total_time_usage
>0.5)?(total_frame_cnt
/total_time_usage
):0);
3981 // time to uninit all, except global stuff:
3982 uninit_player(INITED_ALL
-(INITED_GUI
+INITED_INPUT
+(fixed_vo
?INITED_VO
:0)));
3985 if ( set_of_sub_size
> 0 )
3987 current_module
="sub_free";
3988 for (i
= 0; i
< set_of_sub_size
; ++i
)
3989 sub_free( set_of_subtitles
[i
] );
3990 set_of_sub_size
= 0;
3996 if(eof
== PT_NEXT_ENTRY
|| eof
== PT_PREV_ENTRY
) {
3997 eof
= eof
== PT_NEXT_ENTRY
? 1 : -1;
3998 if(play_tree_iter_step(playtree_iter
,play_tree_step
,0) == PLAY_TREE_ITER_ENTRY
) {
4001 play_tree_iter_free(playtree_iter
);
4002 playtree_iter
= NULL
;
4005 } else if (eof
== PT_UP_NEXT
|| eof
== PT_UP_PREV
) {
4006 eof
= eof
== PT_UP_NEXT
? 1 : -1;
4007 if ( playtree_iter
) {
4008 if(play_tree_iter_up_step(playtree_iter
,eof
,0) == PLAY_TREE_ITER_ENTRY
) {
4011 play_tree_iter_free(playtree_iter
);
4012 playtree_iter
= NULL
;
4015 } else { // NEXT PREV SRC
4016 eof
= eof
== PT_PREV_SRC
? -1 : 1;
4019 if(eof
== 0) eof
= 1;
4021 while(playtree_iter
!= NULL
) {
4022 filename
= play_tree_iter_get_file(playtree_iter
,eof
);
4023 if(filename
== NULL
) {
4024 if( play_tree_iter_step(playtree_iter
,eof
,0) != PLAY_TREE_ITER_ENTRY
) {
4025 play_tree_iter_free(playtree_iter
);
4026 playtree_iter
= NULL
;
4033 if( use_gui
&& !playtree_iter
)
4036 if ( !guiIntfStruct
.DiskChanged
)
4042 if(use_gui
|| playtree_iter
!= NULL
){
4045 goto play_next_file
;
4048 #ifdef HAVE_FREETYPE
4049 current_module
="uninit_font";
4050 if (vo_font
) free_font_desc(vo_font
);
4055 exit_player_with_rc(MSGTR_Exit_eof
, 0);