annotate gui/mplayer/gui_common.c @ 32709:f1b29f413940

Correct translation of filenames and prevent out-of-bounds array access
author ib
date Tue, 18 Jan 2011 11:39:49 +0000
parents fbe5c829c69b
children f49e1b37281a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * main window
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
17 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
19 */
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
20
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
21 #include <stdlib.h>
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
22 #include <stdio.h>
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
23 #include <inttypes.h>
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
24 #include <sys/stat.h>
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
25 #include <unistd.h>
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
26 #include <string.h>
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
27
26365
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 25603
diff changeset
28 #include "gui/app.h"
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 25603
diff changeset
29 #include "gui/skin/font.h"
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 25603
diff changeset
30 #include "gui/skin/skin.h"
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 25603
diff changeset
31 #include "gui/wm/ws.h"
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
32
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
33 #include "config.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
34 #include "help_mp.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
35 #include "libvo/x11_common.h"
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
36
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
37 #include "stream/stream.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
38 #include "mixer.h"
32467
fbe5c829c69b Move libvo/sub.[ch] from libvo to sub.
cigaes
parents: 30529
diff changeset
39 #include "sub/sub.h"
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
40
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
41 #include "libmpdemux/demuxer.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
42 #include "libmpdemux/stheader.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
43 #include "codec-cfg.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
44 #include "access_mpcontext.h"
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
45 #include "libavutil/avstring.h"
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
46
30529
6ef41a766a74 GUI: #include associated .h files in .c files.
diego
parents: 29263
diff changeset
47 #include "gui_common.h"
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
48 #include "play.h"
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
49 #include "widgets.h"
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
50
28051
9e739bdb049c Get rid of pointless 'extern' keywords.
diego
parents: 27370
diff changeset
51 unsigned int GetTimerMS( void );
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
52
27207
e1c5299a4114 Mark function not used outside of the file as static.
diego
parents: 26458
diff changeset
53 static inline void TranslateFilename( int c,char * tmp,size_t tmplen )
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
54 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
55 int i;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
56 char * p;
32709
f1b29f413940 Correct translation of filenames and prevent out-of-bounds array access
ib
parents: 32467
diff changeset
57 size_t len;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
58
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
59 switch ( guiIntfStruct.StreamType )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
60 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
61 case STREAMTYPE_STREAM:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
62 av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
63 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
64 case STREAMTYPE_FILE:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
65 if ( ( guiIntfStruct.Filename )&&( guiIntfStruct.Filename[0] ) )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
66 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
67 if ( (p = strrchr(guiIntfStruct.Filename, '/')) )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
68 av_strlcpy(tmp, p + 1, tmplen);
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
69 else
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
70 av_strlcpy(tmp, guiIntfStruct.Filename, tmplen);
32709
f1b29f413940 Correct translation of filenames and prevent out-of-bounds array access
ib
parents: 32467
diff changeset
71 len=strlen( tmp );
f1b29f413940 Correct translation of filenames and prevent out-of-bounds array access
ib
parents: 32467
diff changeset
72 if ( ( len > 3 )&&( tmp[len - 3] == '.' ) ) tmp[len - 3]=0;
f1b29f413940 Correct translation of filenames and prevent out-of-bounds array access
ib
parents: 32467
diff changeset
73 else if ( ( len > 4 )&&( tmp[len - 4] == '.' ) ) tmp[len - 4]=0;
f1b29f413940 Correct translation of filenames and prevent out-of-bounds array access
ib
parents: 32467
diff changeset
74 else if ( ( len > 5 )&&( tmp[len - 5] == '.' ) ) tmp[len - 5]=0;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
75 } else av_strlcpy( tmp,MSGTR_NoFileLoaded,tmplen );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
76 break;
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 27207
diff changeset
77 #ifdef CONFIG_DVDREAD
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
78 case STREAMTYPE_DVD:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
79 if ( guiIntfStruct.DVD.current_chapter ) snprintf(tmp,tmplen,MSGTR_Chapter,guiIntfStruct.DVD.current_chapter );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
80 else av_strlcat( tmp,MSGTR_NoChapter,tmplen );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
81 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
82 #endif
27370
14c5017f40d2 Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents: 27341
diff changeset
83 #ifdef CONFIG_VCD
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
84 case STREAMTYPE_VCD:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
85 snprintf( tmp,tmplen,MSGTR_VCDTrack,guiIntfStruct.Track );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
86 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
87 #endif
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
88 default: av_strlcpy( tmp,MSGTR_NoMediaOpened,tmplen );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
89 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
90 if ( c )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
91 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
92 for ( i=0;i < (int)strlen( tmp );i++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
93 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
94 int t=0;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
95 if ( c == 1 ) { if ( ( tmp[i] >= 'A' )&&( tmp[i] <= 'Z' ) ) t=32; }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
96 if ( c == 2 ) { if ( ( tmp[i] >= 'a' )&&( tmp[i] <= 'z' ) ) t=-32; }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
97 tmp[i]=(char)( tmp[i] + t );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
98 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
99 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
100 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
101
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
102 /* Unsafe! Pass only null-terminated strings as (char *)str. */
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
103 char * Translate( char * str )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
104 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
105 mixer_t *mixer = mpctx_get_mixer(guiIntfStruct.mpcontext);
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
106 static char trbuf[512];
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
107 char tmp[512];
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
108 int i,c;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
109 int t;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
110 int strsize = 0;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
111 memset( trbuf,0,512 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
112 memset( tmp,0,128 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
113 strsize = strlen(str);
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
114 for ( c=0,i=0;i < strsize;i++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
115 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
116 if ( str[i] != '$' ) { trbuf[c++]=str[i]; trbuf[c]=0; }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
117 else
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
118 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
119 switch ( str[++i] )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
120 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
121 case 't': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.Track );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
122 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
123 case 'o': TranslateFilename( 0,tmp,sizeof( tmp ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
124 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
125 case 'f': TranslateFilename( 1,tmp,sizeof( tmp ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
126 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
127 case 'F': TranslateFilename( 2,tmp,sizeof( tmp ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
128 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
129 case '6': t=guiIntfStruct.LengthInSec; goto calclengthhhmmss;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
130 case '1': t=guiIntfStruct.TimeSec;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
131 calclengthhhmmss:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
132 snprintf( tmp,sizeof( tmp ),"%02d:%02d:%02d",t/3600,t/60%60,t%60 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
133 av_strlcat( trbuf,tmp,sizeof( trbuf ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
134 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
135 case '7': t=guiIntfStruct.LengthInSec; goto calclengthmmmmss;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
136 case '2': t=guiIntfStruct.TimeSec;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
137 calclengthmmmmss:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
138 snprintf( tmp,sizeof( tmp ),"%04d:%02d",t/60,t%60 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
139 av_strlcat( trbuf,tmp,sizeof( trbuf ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
140 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
141 case '3': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec / 3600 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
142 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
143 case '4': snprintf( tmp,sizeof( tmp ),"%02d",( ( guiIntfStruct.TimeSec / 60 ) % 60 ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
144 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
145 case '5': snprintf( tmp,sizeof( tmp ),"%02d",guiIntfStruct.TimeSec % 60 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
146 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
147 case '8': snprintf( tmp,sizeof( tmp ),"%01d:%02d:%02d",guiIntfStruct.TimeSec / 3600,( guiIntfStruct.TimeSec / 60 ) % 60,guiIntfStruct.TimeSec % 60 ); av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
148 case 'v': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Volume );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
149 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
150 case 'V': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Volume );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
151 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
152 case 'b': snprintf( tmp,sizeof( tmp ),"%3.2f%%",guiIntfStruct.Balance );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
153 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
154 case 'B': snprintf( tmp,sizeof( tmp ),"%3.1f",guiIntfStruct.Balance );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
155 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
156 case 'd': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.FrameDrop );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
157 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
158 case 'x': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieWidth );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
159 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
160 case 'y': snprintf( tmp,sizeof( tmp ),"%d",guiIntfStruct.MovieHeight );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
161 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
162 case 'C': snprintf( tmp,sizeof( tmp ),"%s", guiIntfStruct.sh_video? ((sh_video_t *)guiIntfStruct.sh_video)->codec->name : "");
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
163 av_strlcat( trbuf,tmp,sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
164 case 's': if ( guiIntfStruct.Playing == 0 ) av_strlcat( trbuf,"s",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
165 case 'l': if ( guiIntfStruct.Playing == 1 ) av_strlcat( trbuf,"p",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
166 case 'e': if ( guiIntfStruct.Playing == 2 ) av_strlcat( trbuf,"e",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
167 case 'a':
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
168 if ( mixer->muted ) { av_strlcat( trbuf,"n",sizeof( trbuf ) ); break; }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
169 switch ( guiIntfStruct.AudioType )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
170 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
171 case 0: av_strlcat( trbuf,"n",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
172 case 1: av_strlcat( trbuf,"m",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
173 case 2: av_strlcat( trbuf,"t",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
174 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
175 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
176 case 'T':
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
177 switch ( guiIntfStruct.StreamType )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
178 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
179 case STREAMTYPE_FILE: av_strlcat( trbuf,"f",sizeof( trbuf ) ); break;
27370
14c5017f40d2 Change a bunch of video/audio-output-specific preprocessor directives from
diego
parents: 27341
diff changeset
180 #ifdef CONFIG_VCD
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
181 case STREAMTYPE_VCD: av_strlcat( trbuf,"v",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
182 #endif
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
183 case STREAMTYPE_STREAM: av_strlcat( trbuf,"u",sizeof( trbuf ) ); break;
27341
e7c989f7a7c9 Start unifying names of internal preprocessor directives.
diego
parents: 27207
diff changeset
184 #ifdef CONFIG_DVDREAD
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
185 case STREAMTYPE_DVD: av_strlcat( trbuf,"d",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
186 #endif
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
187 default: av_strlcat( trbuf," ",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
188 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
189 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
190 case '$': av_strlcat( trbuf,"$",sizeof( trbuf ) ); break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
191 default: continue;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
192 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
193 c=strlen( trbuf );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
194 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
195 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
196 return trbuf;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
197 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
198
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
199 static char * image_buffer = NULL;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
200 static int image_width = 0;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
201
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
202 void PutImage( txSample * bf,int x,int y,int max,int ofs )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
203 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
204 int i=0,ix,iy;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
205 uint32_t * buf = NULL;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
206 uint32_t * drw = NULL;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
207 register uint32_t tmp;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
208 /* register uint32_t yc; */
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
209
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
210 if ( ( !bf )||( bf->Image == NULL ) ) return;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
211
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
212 i=( bf->Width * ( bf->Height / max ) ) * ofs;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
213 buf=(uint32_t *)image_buffer;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
214 drw=(uint32_t *)bf->Image;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
215
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
216 #if 1
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
217 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
218 for ( ix=x;ix < (int)(x+bf->Width);ix++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
219 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
220 tmp=drw[i++];
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
221 if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
222 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
223 #else
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
224 yc=y * image_width;
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
225 for ( iy=y;iy < (int)(y+bf->Height / max);iy++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
226 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
227 for ( ix=x;ix < (int)(x+bf->Width);ix++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
228 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
229 tmp=drw[i++];
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
230 if ( tmp != 0x00ff00ff ) buf[yc + ix]=tmp;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
231 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
232 yc+=image_width;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
233 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
234 #endif
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
235 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
236
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
237 void SimplePotmeterPutImage( txSample * bf,int x,int y,float frac )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
238 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
239 int i=0,w,r,ix,iy;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
240 uint32_t * buf = NULL;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
241 uint32_t * drw = NULL;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
242 register uint32_t tmp;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
243
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
244 if ( ( !bf )||( bf->Image == NULL ) ) return;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
245
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
246 buf=(uint32_t *)image_buffer;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
247 drw=(uint32_t *)bf->Image;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
248 w=bf->Width*frac;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
249 r=bf->Width-w;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
250 for ( iy=y;iy < (int)(y+bf->Height);iy++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
251 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
252 for ( ix=x;ix < (int)(x+w);ix++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
253 {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28051
diff changeset
254 tmp=drw[i++];
25603
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
255 if ( tmp != 0x00ff00ff ) buf[iy * image_width + ix]=tmp;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
256 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
257 i+=r;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
258 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
259 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
260
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
261 void Render( wsTWindow * window,wItem * Items,int nrItems,char * db,int size )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
262 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
263 wItem * item;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
264 txSample * image = NULL;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
265 int i;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
266
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
267 image_buffer=db;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
268 image_width=window->Width;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
269
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
270 for( i=0;i < nrItems + 1;i++ )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
271 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
272 item=&Items[i];
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
273 switch( item->type )
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
274 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
275 case itButton:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
276 PutImage( &item->Bitmap,item->x,item->y,3,item->pressed );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
277 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
278 case itPotmeter:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
279 if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
280 else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
281 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
282 case itHPotmeter:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
283 if (item->phases == 1)SimplePotmeterPutImage( &item->Bitmap,item->x,item->y, item->value / 100.0f );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
284 else PutImage( &item->Bitmap,item->x,item->y,item->phases,( item->phases - 1 ) * ( item->value / 100.0f ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
285 PutImage( &item->Mask,item->x + (int)( ( item->width - item->psx ) * item->value / 100.0f ),item->y,3,item->pressed );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
286 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
287 case itVPotmeter:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
288 PutImage( &item->Bitmap,
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
289 item->x,item->y,
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
290 item->phases,
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
291 item->phases * ( 1. - item->value / 100.0f ) );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
292 PutImage( &item->Mask,
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
293 item->x,item->y + (int)( ( item->height - item->psy ) * ( 1. - item->value / 100.0f ) ),
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
294 3,item->pressed );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
295 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
296 case itSLabel:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
297 image=fntRender( item,0,"%s",item->label );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
298 if ( image ) PutImage( image,item->x,item->y,1,0 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
299 case itDLabel:
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
300 {
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
301 char * t = Translate( item->label );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
302 int l = fntTextWidth( item->fontid,t );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
303 l=(l?l:item->width);
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
304 image=fntRender( item,l-(GetTimerMS() / 20)%l,"%s",t );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
305 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
306 if ( image ) PutImage( image,item->x,item->y,1,0 );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
307 break;
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
308 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
309 }
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
310 wsConvert( window,db,size );
01754b23193e Rename common.[ch], there are too many files by that name.
diego
parents:
diff changeset
311 }