Mercurial > mplayer.hg
annotate Gui/interface.c @ 6619:f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
author | pontscho |
---|---|
date | Tue, 02 Jul 2002 13:35:04 +0000 |
parents | cf2c2b92d1a7 |
children | 7bc4c6ba9485 |
rev | line source |
---|---|
6280 | 1 |
4845 | 2 #include <inttypes.h> |
3 #include <stdlib.h> | |
4 #include <stdio.h> | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
5 #include <string.h> |
4798 | 6 |
7 #include "ws.h" | |
8 #include "mplayer/play.h" | |
9 #include "interface.h" | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
10 #include "skin/skin.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
11 |
4798 | 12 #include "../mplayer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
13 #include "mplayer/widgets.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
14 #include "mplayer/mplayer.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
15 #include "app.h" |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
16 #include "../libvo/x11_common.h" |
5789 | 17 #include "../libvo/video_out.h" |
4858 | 18 #include "../input/input.h" |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
19 #include "../libao2/audio_out.h" |
5789 | 20 |
6280 | 21 #include <inttypes.h> |
22 #include <sys/types.h> | |
23 | |
5665 | 24 #include "../libmpdemux/stream.h" |
5789 | 25 #include "../libmpdemux/demuxer.h" |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
26 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
27 guiInterface_t guiIntfStruct; |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
28 |
6218 | 29 void guiInit( void ) |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
30 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
31 memset( &guiIntfStruct,0,sizeof( guiIntfStruct ) ); |
6218 | 32 appInit( (void*)mDisplay ); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
33 } |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
34 |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
35 void guiDone( void ) |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
36 { |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
37 mp_msg( MSGT_GPLAYER,MSGL_V,"[mplayer] exit.\n" ); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
38 mplStop(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
39 gtkDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
40 wsXDone(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
41 } |
4798 | 42 |
4858 | 43 int guiCMDArray[] = |
44 { | |
45 evLoad, | |
46 evLoadSubtitle, | |
47 evAbout, | |
48 evPlay, | |
49 evStop, | |
50 evPlayList, | |
51 evPreferences, | |
52 evFullScreen, | |
53 evSkinBrowser | |
54 }; | |
55 | |
5789 | 56 typedef struct |
57 { | |
58 demux_stream_t *ds; | |
59 unsigned int format; | |
60 struct codecs_st *codec; | |
61 int inited; | |
62 // output format: | |
63 float timer; | |
64 float fps; | |
65 float frametime; | |
66 int i_bps; | |
67 int disp_w,disp_h; | |
68 } tmp_sh_video_t; | |
69 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
70 extern ao_functions_t * audio_out; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
71 |
4798 | 72 void guiGetEvent( int type,char * arg ) |
73 { | |
6280 | 74 stream_t * stream = (stream_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
75 #ifdef USE_DVDREAD |
5665 | 76 dvd_priv_t * dvdp = (dvd_priv_t *) arg; |
5672
1f8b34f1e7c0
ifdef reading dvd args, without it non-dvd compilation fails.
eyck
parents:
5665
diff
changeset
|
77 #endif |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
78 |
4798 | 79 switch ( type ) |
80 { | |
81 case guiXEvent: | |
82 wsEvents( wsDisplay,(XEvent *)arg,NULL ); | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
83 gtkEventHandling(); |
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
84 break; |
4798 | 85 case guiCEvent: |
4963 | 86 switch ( (int)arg ) |
87 { | |
88 case guiSetPlay: guiIntfStruct.Playing=1; mplState(); break; | |
89 case guiSetStop: guiIntfStruct.Playing=0; mplState(); break; | |
90 case guiSetPause: guiIntfStruct.Playing=2; mplState(); break; | |
91 } | |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
92 break; |
5665 | 93 case guiSetState: |
94 mplState(); | |
95 break; | |
96 case guiSetFileName: | |
97 if ( arg ) guiSetFilename( guiIntfStruct.Filename,arg ); | |
98 break; | |
5789 | 99 case guiSetAudioOnly: |
100 guiIntfStruct.AudioOnly=(int)arg; | |
101 if ( (int)arg ) wsVisibleWindow( &appMPlayer.subWindow,wsHideWindow ); | |
102 else wsVisibleWindow( &appMPlayer.subWindow,wsShowWindow ); | |
103 break; | |
104 case guiReDrawSubWindow: | |
105 wsPostRedisplay( &appMPlayer.subWindow ); | |
5956 | 106 if ( guiIntfStruct.Playing == 1 ) wsSetBackgroundRGB( &appMPlayer.subWindow,0,0,0 ); |
5789 | 107 break; |
108 case guiSetShVideo: | |
109 { | |
5986 | 110 if ( !appMPlayer.subWindow.isFullScreen ) |
111 { | |
112 wsResizeWindow( &appMPlayer.subWindow,vo_dwidth,vo_dheight ); | |
113 wsMoveWindow( &appMPlayer.subWindow,True,appMPlayer.sub.x,appMPlayer.sub.y ); | |
114 } | |
5955
caac20b1ca79
fix xmga fs, resize to movie size and mouse auto hide + dga
pontscho
parents:
5945
diff
changeset
|
115 guiIntfStruct.MovieWidth=vo_dwidth; |
5997
b5fb9a927bf3
add WM detection, and wm specific fullscreen code. (???)
pontscho
parents:
5986
diff
changeset
|
116 guiIntfStruct.MovieHeight=vo_dheight; |
5789 | 117 } |
118 break; | |
5665 | 119 #ifdef USE_DVDREAD |
120 case guiSetDVD: | |
121 guiIntfStruct.DVD.titles=dvdp->vmg_file->tt_srpt->nr_of_srpts; | |
122 guiIntfStruct.DVD.chapters=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_ptts; | |
123 guiIntfStruct.DVD.angles=dvdp->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; | |
124 guiIntfStruct.DVD.nr_of_audio_channels=dvdp->nr_of_channels; | |
125 memcpy( guiIntfStruct.DVD.audio_streams,dvdp->audio_streams,sizeof( dvdp->audio_streams ) ); | |
126 guiIntfStruct.DVD.nr_of_subtitles=dvdp->nr_of_subtitles; | |
127 memcpy( guiIntfStruct.DVD.subtitles,dvdp->subtitles,sizeof( dvdp->subtitles ) ); | |
128 guiIntfStruct.DVD.current_title=dvd_title + 1; | |
129 guiIntfStruct.DVD.current_chapter=dvd_chapter + 1; | |
130 guiIntfStruct.DVD.current_angle=dvd_angle + 1; | |
131 guiIntfStruct.Track=dvd_title + 1; | |
132 break; | |
133 #endif | |
6280 | 134 case guiSetStream: |
135 guiIntfStruct.StreamType=stream->type; | |
136 switch( stream->type ) | |
137 { | |
138 case STREAMTYPE_DVD: | |
139 guiGetEvent( guiSetDVD,(char *)stream->priv ); | |
140 break; | |
141 #ifdef HAVE_VCD | |
142 case STREAMTYPE_VCD: | |
143 { | |
144 int i; | |
145 for ( i=1;i < 100;i++ ) | |
146 if ( vcd_seek_to_track( stream->fd,i ) < 0 ) break; | |
147 vcd_seek_to_track( stream->fd,vcd_track ); | |
148 guiIntfStruct.VCDTracks=--i; | |
149 mp_msg( MSGT_GPLAYER,MSGL_INFO,"[interface] vcd tracks: %d\n",guiIntfStruct.VCDTracks ); | |
150 guiIntfStruct.Track=vcd_track; | |
151 break; | |
152 } | |
153 #endif | |
154 } | |
155 break; | |
5120 | 156 #ifdef HAVE_NEW_INPUT |
4858 | 157 case guiIEvent: |
158 printf( "cmd: %d\n",(int)arg ); | |
159 switch( (int)arg ) | |
160 { | |
161 case MP_CMD_QUIT: | |
162 mplEventHandling( evExit,0 ); | |
163 break; | |
164 case MP_CMD_VO_FULLSCREEN: | |
165 mplEventHandling( evFullScreen,0 ); | |
166 break; | |
167 default: | |
168 mplEventHandling( guiCMDArray[ (int)arg - MP_CMD_GUI_EVENTS - 1 ],0 ); | |
169 } | |
170 break; | |
5120 | 171 #endif |
6280 | 172 case guiClearStruct: |
173 #ifdef USE_DVDREAD | |
174 if ( (unsigned int)arg & guiDVD ) memset( &guiIntfStruct.DVD,0,sizeof( guiDVDStruct ) ); | |
175 #endif | |
176 #ifdef HAVE_VCD | |
177 if ( (unsigned int)arg & guiVCD ) guiIntfStruct.VCDTracks=0; | |
178 #endif | |
179 break; | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
180 case guiReDraw: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
181 // if ( audio_out ) |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
182 // { |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
183 // float l,r; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
184 // mixer_getvolume( &l,&r ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
185 // guiIntfStruct.Volume=(r>l?r:l); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
186 // printf( "!!! guiIntfStruct.Volume: %.2f \n",guiIntfStruct.Volume ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
187 // } |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
188 mplEventHandling( evRedraw,0 ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
189 break; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
190 case guiSetVolume: |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
191 if ( audio_out ) |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
192 { |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
193 float l,r; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
194 mixer_getvolume( &l,&r ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
195 guiIntfStruct.Volume=(r>l?r:l); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
196 if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
197 else guiIntfStruct.Balance=0.0f; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
198 btnModify( evSetVolume,guiIntfStruct.Volume ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
199 btnModify( evSetBalance,guiIntfStruct.Balance ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
200 } |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
201 break; |
4798 | 202 } |
203 } | |
204 | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
205 extern unsigned int GetTimerMS( void ); |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
206 extern int mplTimer; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
207 |
4798 | 208 void guiEventHandling( void ) |
209 { | |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
210 if ( !guiIntfStruct.Playing || guiIntfStruct.AudioOnly ) wsHandleEvents(); |
4818
3473ca9ef158
new gui interface, and gtk moved into mplayer process. fork ... bleh :)
pontscho
parents:
4798
diff
changeset
|
211 gtkEventHandling(); |
6619
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
212 mplTimer=GetTimerMS() / 20; |
f554e7271587
fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix
pontscho
parents:
6280
diff
changeset
|
213 // if ( !( GetTimerMS()%2 ) ) |
4798 | 214 } |