annotate mp_msg.c @ 5151:610d399f50c3

- cleanup pass 1. more to come soon... - fixed order of libcss and dumpstream stuff - fixed some comments, added more to get source easier searchable - removed some nonsense goto, use if() instead - removed some obsoleted, #if 0'd code - rewritten text subtitle init calls - removed useless 'max benchmark' code (it shows 480% cpu when playing vcd on p4...) TODO: fix order or ao/vo init, and migrate video codec selection to libmpcodecs
author arpi
date Sun, 17 Mar 2002 00:47:15 +0000
parents 17f97ed8259e
children 4afbe13150e6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
1
2caba2f48026 new message printing system
arpi
parents:
diff changeset
2 #include <stdio.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
3 #include <stdlib.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
4 #include <stdarg.h>
2caba2f48026 new message printing system
arpi
parents:
diff changeset
5
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
6 #include "config.h"
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
7
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
8 #ifdef HAVE_NEW_GUI
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
9 #include "Gui/mplayer/widgets.h"
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
10 extern void gtkMessageBox( int type,char * str );
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
11 extern int use_gui;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
12 #endif
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
13 #include "mp_msg.h"
2caba2f48026 new message printing system
arpi
parents:
diff changeset
14
2caba2f48026 new message printing system
arpi
parents:
diff changeset
15 static int mp_msg_levels[MSGT_MAX]; // verbose level of this module
2caba2f48026 new message printing system
arpi
parents:
diff changeset
16
2caba2f48026 new message printing system
arpi
parents:
diff changeset
17 #if 1
2caba2f48026 new message printing system
arpi
parents:
diff changeset
18
2caba2f48026 new message printing system
arpi
parents:
diff changeset
19 void mp_msg_init(int verbose){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
20 int i;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
21 for(i=0;i<MSGT_MAX;i++){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
22 mp_msg_levels[i]=verbose;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
23 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
24 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
25
2caba2f48026 new message printing system
arpi
parents:
diff changeset
26 void mp_msg_c( int x, const char *format, ... ){
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
27 #if 1
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
28 va_list va;
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
29 char tmp[2048];
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
30
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
31 if((x&255)>mp_msg_levels[x>>8]) return; // do not display
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
32 va_start(va, mp_gettext(format));
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
33 vsnprintf(tmp, 2048, mp_gettext(format), va);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
34 tmp[2047] = 0;
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
35
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
36 #if defined(HAVE_NEW_GUI) && !defined(HAVE_MENCODER)
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
37 if(use_gui)
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
38 {
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
39 switch(x & 255)
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
40 {
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
41 case MSGL_FATAL:
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
42 gtkMessageBox(GTK_MB_FATAL|GTK_MB_SIMPLE, tmp);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
43 break;
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
44 case MSGL_ERR:
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
45 gtkMessageBox(GTK_MB_ERROR|GTK_MB_SIMPLE, tmp);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
46 break;
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
47 case MSGL_WARN:
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
48 gtkMessageBox(GTK_MB_WARNING|GTK_MB_SIMPLE, tmp);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
49 break;
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
50 }
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
51 }
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
52 #endif
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
53
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
54 fprintf(stderr, "%s", tmp);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
55 if ((x & 255) <= MSGL_ERR)
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
56 fflush(stderr);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
57 else
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
58 fflush(stdout);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
59
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
60 va_end(va);
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
61 #else
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
62 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
63 if((x&255)>mp_msg_levels[x>>8]) return; // do not display
2caba2f48026 new message printing system
arpi
parents:
diff changeset
64 va_start(va, format);
4176
116abdd0aed1 small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents: 3780
diff changeset
65 #if defined( HAVE_NEW_GUI ) && !defined( HAVE_MENCODER )
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
66 if(use_gui){
3293
fc74fe43eb89 msg limit increased
arpi
parents: 1971
diff changeset
67 char tmp[16*80];
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
68 vsnprintf( tmp,8*80,format,va ); tmp[8*80-1]=0;
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
69 switch( x&255 ) {
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
70 case MSGL_FATAL:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
71 fprintf( stderr,"%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
72 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
73 gtkMessageBox( GTK_MB_FATAL|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
74 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
75 case MSGL_ERR:
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
76 fprintf( stderr,"%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
77 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
78 gtkMessageBox( GTK_MB_ERROR|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
79 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
80 case MSGL_WARN:
4888
cb2adf32c356 Use stdout as default mencoder's output if no filename specified
nick
parents: 4176
diff changeset
81 fprintf( stderr, "%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
82 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
83 gtkMessageBox( GTK_MB_WARNING|GTK_MB_SIMPLE,tmp );
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
84 break;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1566
diff changeset
85 default:
4888
cb2adf32c356 Use stdout as default mencoder's output if no filename specified
nick
parents: 4176
diff changeset
86 fprintf(stderr, "%s",tmp );
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
87 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
88 }
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
89 } else
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
90 #endif
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
91 if((x&255)<=MSGL_ERR){
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
92 // fprintf(stderr,"%%%%%% ");
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
93 vfprintf(stderr,format, va);
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
94 fflush(stderr);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
95 } else {
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
96 // printf("%%%%%% ");
4888
cb2adf32c356 Use stdout as default mencoder's output if no filename specified
nick
parents: 4176
diff changeset
97 vfprintf(stderr,format, va);
3780
9eb4aa623ab6 fflush disappeared? .so?
arpi
parents: 3293
diff changeset
98 fflush(stdout);
1971
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
99 }
7d6116e415a3 cleanup
arpi
parents: 1934
diff changeset
100 va_end(va);
5102
17f97ed8259e added i18n support
alex
parents: 4888
diff changeset
101 #endif
1562
2caba2f48026 new message printing system
arpi
parents:
diff changeset
102 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
103
2caba2f48026 new message printing system
arpi
parents:
diff changeset
104 #else
2caba2f48026 new message printing system
arpi
parents:
diff changeset
105
2caba2f48026 new message printing system
arpi
parents:
diff changeset
106 FILE *mp_msg_file[MSGT_MAX]; // print message to this file (can be stdout/err)
2caba2f48026 new message printing system
arpi
parents:
diff changeset
107 static FILE* mp_msg_last_file=NULL;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
108
2caba2f48026 new message printing system
arpi
parents:
diff changeset
109 // how to handle errors->stderr messages->stdout ?
2caba2f48026 new message printing system
arpi
parents:
diff changeset
110 void mp_msg( int x, const char *format, ... ){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
111 if((x&255)>mp_msg_levels[x>>8] || !mp_msg_file[x>>8]) return; // do not display
2caba2f48026 new message printing system
arpi
parents:
diff changeset
112 va_list va;
2caba2f48026 new message printing system
arpi
parents:
diff changeset
113 va_start(va, format);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
114 vfprintf(mp_msg_file[x>>8],format, va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
115 if(mp_msg_last_file!=mp_msg_file[x>>8]){
2caba2f48026 new message printing system
arpi
parents:
diff changeset
116 fflush(mp_msg_file[x>>8]);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
117 mp_msg_last_file=mp_msg_file[x>>8];
2caba2f48026 new message printing system
arpi
parents:
diff changeset
118 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
119 va_end(va);
2caba2f48026 new message printing system
arpi
parents:
diff changeset
120 }
2caba2f48026 new message printing system
arpi
parents:
diff changeset
121
2caba2f48026 new message printing system
arpi
parents:
diff changeset
122 #endif