[Mplayer-cvslog] CVS: main mplayer.c,1.273,1.274
Arpi of Ize
arpi at mplayer.dev.hu
Wed Sep 5 12:49:16 CEST 2001
Update of /cvsroot/mplayer/main
In directory mplayer:/var/tmp.root/cvs-serv21090
Modified Files:
mplayer.c
Log Message:
uninit fixed
Index: mplayer.c
===================================================================
RCS file: /cvsroot/mplayer/main/mplayer.c,v
retrieving revision 1.273
retrieving revision 1.274
diff -u -r1.273 -r1.274
--- mplayer.c 4 Sep 2001 15:20:48 -0000 1.273
+++ mplayer.c 5 Sep 2001 10:49:04 -0000 1.274
@@ -276,29 +276,73 @@
extern char *vo_subdevice;
extern char *ao_subdevice;
-void exit_player(char* how){
- total_time_usage_start=GetTimer()-total_time_usage_start;
-
- // restore terminal:
- getch2_disable();
+static char* current_module=NULL; // for debugging
+static unsigned int inited_flags=0;
+#define INITED_VO 1
+#define INITED_AO 2
+#define INITED_GUI 4
+#define INITED_GETCH2 8
+#define INITED_LIRC 16
+#define INITED_ENCODE 32
+#define INITED_ALL 0xFFFF
+
+void uninit_player(unsigned int mask){
+ mask=inited_flags&mask;
+ if(mask&INITED_VO){
+ inited_flags&=~INITED_VO;
+ current_module="uninit_vo";
#ifdef USE_LIBVO2
- if(video_out) vo2_close(video_out);
+ vo2_close(video_out);
#else
- if(video_out) video_out->uninit();
+ video_out->uninit();
#endif
+ }
+
+ if(mask&INITED_AO){
+ inited_flags&=~INITED_AO;
+ current_module="uninit_ao";
+ audio_out->uninit();
+ }
+
+ if(mask&INITED_GETCH2){
+ inited_flags&=~INITED_GETCH2;
+ current_module="uninit_getch2";
+ // restore terminal:
+ getch2_disable();
+ }
#ifdef HAVE_NEW_GUI
- if(use_gui) mplDone();
+ if(mask&INITED_GUI){
+ inited_flags&=~INITED_GUI;
+ current_module="uninit_gui";
+ mplDone();
+ }
#endif
- if(audio_out) audio_out->uninit();
+ if(mask&INITED_ENCODE){
+ inited_flags&=~INITED_ENCODE;
+ current_module="uninit_encode";
+ avi_fixate();
+ }
- if(encode_name) avi_fixate();
#ifdef HAVE_LIRC
- lirc_mp_cleanup();
+ if(mask&INITED_LIRC){
+ inited_flags&=~INITED_LIRC;
+ current_module="uninit_lirc";
+ lirc_mp_cleanup();
+ }
#endif
+}
+
+void exit_player(char* how){
+ total_time_usage_start=GetTimer()-total_time_usage_start;
+
+ uninit_player(INITED_ALL);
+
+ current_module="exit_player";
+
if(how) mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_Exiting,how);
mp_msg(MSGT_CPLAYER,MSGL_V,"max framesize was %d bytes\n",max_framesize);
if(benchmark){
@@ -319,8 +363,6 @@
exit(1);
}
-static char* current_module=NULL; // for debugging
-
void exit_sighandler(int x){
static int sig_count=0;
++sig_count;
@@ -543,12 +585,14 @@
#ifdef HAVE_NEW_GUI
if(use_gui){
appInit( argc,argv,envp,(void*)mDisplay );
+ inited_flags|=INITED_GUI;
mplShMem->Playing= (gui_no_filename) ? 0 : 1;
}
#endif
#ifdef HAVE_LIRC
lirc_mp_setup();
+ inited_flags|=INITED_LIRC;
#endif
#ifdef USE_TERMCAP
@@ -920,7 +964,8 @@
if((encode_file=fopen(encode_index_name,"wb")))
fclose(encode_file);
else encode_index_name=NULL;
- sh_audio=d_audio->sh=NULL;
+ sh_audio=d_audio->sh=NULL; // force nosound
+ inited_flags|=INITED_ENCODE;
}
// ========== Init display (sh_video->disp_w*sh_video->disp_h/out_fmt) ============
@@ -998,6 +1043,7 @@
mp_msg(MSGT_CPLAYER,MSGL_FATAL,MSGTR_CannotInitVO);
goto goto_next_file; // exit_player(MSGTR_Exit_error);
}
+ inited_flags|=INITED_VO;
mp_msg(MSGT_CPLAYER,MSGL_V,"INFO: Video OUT driver init OK!\n");
fflush(stdout);
@@ -1044,6 +1090,8 @@
sh_audio->channels,sh_audio->sample_format,0)){
mp_msg(MSGT_CPLAYER,MSGL_ERR,MSGTR_CannotInitAO);
sh_audio=d_audio->sh=NULL;
+ } else {
+ inited_flags|=INITED_AO;
}
// printf("Audio buffer size: %d bytes, delay: %5.3fs\n",audio_buffer_size,audio_buffer_delay);
@@ -1065,7 +1113,7 @@
if(verbose) mp_msg(MSGT_CPLAYER,MSGL_V,"Freeing %d unused audio chunks\n",d_audio->packs);
ds_free_packs(d_audio); // free buffered chunks
d_audio->id=-2; // do not read audio chunks
- if(audio_out){ audio_out->uninit(); audio_out=NULL;} // close device
+ if(audio_out) uninit_player(INITED_AO); // close device
}
current_module=NULL;
@@ -1081,7 +1129,10 @@
mp_msg(MSGT_CPLAYER,MSGL_INFO,MSGTR_StartPlaying);fflush(stdout);
-if(!use_stdin) getch2_enable(); // prepare stdin for hotkeys...
+if(!use_stdin){
+ getch2_enable(); // prepare stdin for hotkeys...
+ inited_flags|=INITED_GETCH2;
+}
InitTimer();
@@ -1857,20 +1908,8 @@
if(curr_filename+1<num_filenames || use_gui){
// partial uninit:
- // restore terminal:
- getch2_disable();
-
- current_module="uninit_vo";
-
-#ifdef USE_LIBVO2
- if(video_out) vo2_close(video_out);
-#else
- if(video_out) video_out->uninit();
-#endif
+ uninit_player(INITED_ALL-INITED_GUI);
- current_module="uninit_ao";
- if(audio_out) audio_out->uninit();
-// if(encode_name) avi_fixate();
}
goto_next_file: // don't jump here after ao/vo/getch initialization!
More information about the MPlayer-cvslog
mailing list