From 90dabd0261ce580efb8bfe078eb3717673cea8ea Mon Sep 17 00:00:00 2001 From: pontscho Date: Tue, 2 Jul 2002 13:35:04 +0000 Subject: fix volume handling ( step 2 ) -- add balance support and some code cleanup and fix git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@6620 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Gui/interface.c | 35 ++++++++++++++++++++++++++-- Gui/interface.h | 5 ++-- Gui/mplayer/mplayer.c | 7 ------ Gui/mplayer/mplayer.h | 1 - Gui/mplayer/mw.h | 64 +++++++++++++++++++++++++++------------------------ Gui/mplayer/sw.h | 1 - Gui/wm/ws.c | 3 --- 7 files changed, 69 insertions(+), 47 deletions(-) (limited to 'Gui') diff --git a/Gui/interface.c b/Gui/interface.c index 84f6967f38..7e473a59c9 100644 --- a/Gui/interface.c +++ b/Gui/interface.c @@ -7,6 +7,7 @@ #include "ws.h" #include "mplayer/play.h" #include "interface.h" +#include "skin/skin.h" #include "../mplayer.h" #include "mplayer/widgets.h" @@ -15,6 +16,7 @@ #include "../libvo/x11_common.h" #include "../libvo/video_out.h" #include "../input/input.h" +#include "../libao2/audio_out.h" #include #include @@ -65,12 +67,15 @@ typedef struct int disp_w,disp_h; } tmp_sh_video_t; +extern ao_functions_t * audio_out; + void guiGetEvent( int type,char * arg ) { stream_t * stream = (stream_t *) arg; #ifdef USE_DVDREAD dvd_priv_t * dvdp = (dvd_priv_t *) arg; #endif + switch ( type ) { case guiXEvent: @@ -172,12 +177,38 @@ void guiGetEvent( int type,char * arg ) if ( (unsigned int)arg & guiVCD ) guiIntfStruct.VCDTracks=0; #endif break; + case guiReDraw: +// if ( audio_out ) +// { +// float l,r; + // mixer_getvolume( &l,&r ); +// guiIntfStruct.Volume=(r>l?r:l); +// printf( "!!! guiIntfStruct.Volume: %.2f \n",guiIntfStruct.Volume ); +// } + mplEventHandling( evRedraw,0 ); + break; + case guiSetVolume: + if ( audio_out ) + { + float l,r; + mixer_getvolume( &l,&r ); + guiIntfStruct.Volume=(r>l?r:l); + if ( r != l ) guiIntfStruct.Balance=( ( r - l ) + 100 ) * 0.5f; + else guiIntfStruct.Balance=0.0f; + btnModify( evSetVolume,guiIntfStruct.Volume ); + btnModify( evSetBalance,guiIntfStruct.Balance ); + } + break; } } +extern unsigned int GetTimerMS( void ); +extern int mplTimer; + void guiEventHandling( void ) { - if ( ( use_gui && !guiIntfStruct.Playing )||( guiIntfStruct.AudioOnly ) ) wsHandleEvents(); + if ( !guiIntfStruct.Playing || guiIntfStruct.AudioOnly ) wsHandleEvents(); gtkEventHandling(); - mplTimerHandler(); // handle GUI timer events + mplTimer=GetTimerMS() / 20; +// if ( !( GetTimerMS()%2 ) ) } diff --git a/Gui/interface.h b/Gui/interface.h index 4a1eb6d61c..82748fa5b2 100644 --- a/Gui/interface.h +++ b/Gui/interface.h @@ -10,7 +10,6 @@ #include "../libmpdemux/stream.h" #endif - typedef struct { int x; @@ -74,9 +73,7 @@ typedef struct int MovieHeight; float Volume; - int VolumeChanged; float Balance; - int Mute; int Track; int AudioType; @@ -111,6 +108,8 @@ extern guiInterface_t guiIntfStruct; #define guiSetShVideo 8 #define guiSetStream 9 #define guiClearStruct 10 +#define guiReDraw 11 +#define guiSetVolume 12 #define guiSetStop 0 #define guiSetPlay 1 diff --git a/Gui/mplayer/mplayer.c b/Gui/mplayer/mplayer.c index 4286841780..544d8f8a7a 100644 --- a/Gui/mplayer/mplayer.c +++ b/Gui/mplayer/mplayer.c @@ -35,13 +35,6 @@ void mplEventHandling( int msg,float param ); #include "sw.h" #include "widgets.h" -void mplTimerHandler( void ) -{ - mplTimer++; - mplRedrawTimer--; - if ( mplRedrawTimer == 0 ) mplEventHandling( evRedraw,0 ); -} - void mplInit( void * disp ) { int i; diff --git a/Gui/mplayer/mplayer.h b/Gui/mplayer/mplayer.h index 23465bd24a..662eacb334 100644 --- a/Gui/mplayer/mplayer.h +++ b/Gui/mplayer/mplayer.h @@ -14,6 +14,5 @@ extern int mplMiddleMenu; extern void mplInit( void * disp ); extern void mplEventHandling( int msg,float param ); -extern void mplTimerHandler( void ); #endif diff --git a/Gui/mplayer/mw.h b/Gui/mplayer/mw.h index 6871bab518..56f1bfc214 100644 --- a/Gui/mplayer/mw.h +++ b/Gui/mplayer/mw.h @@ -3,6 +3,8 @@ #include "../../libmpdemux/stream.h" #include "../../mixer.h" +#include "../../libvo/sub.h" +#include "../../mplayer.h" unsigned char * mplDrawBuffer = NULL; int mplMainRender = 1; @@ -100,7 +102,7 @@ calclengthmmmmss: case 'l': if ( guiIntfStruct.Playing == 1 ) strcat( trbuf,"p" ); break; case 'e': if ( guiIntfStruct.Playing == 2 ) strcat( trbuf,"e" ); break; case 'a': -// if ( guiIntfStruct.Mute ) { strcat( trbuf,"n" ); break; } + if ( muted ) { strcat( trbuf,"n" ); break; } switch ( guiIntfStruct.AudioType ) { case 0: strcat( trbuf,"n" ); break; @@ -214,6 +216,7 @@ extern int dvdsub_id; extern char * dvd_device; extern int vcd_track; extern char * cdrom_device; +extern int osd_visible; void mplEventHandling( int msg,float param ) { @@ -261,11 +264,11 @@ play: { case STREAMTYPE_STREAM: case STREAMTYPE_FILE: - guiGetEvent( guiClearStruct,guiALL ); + guiGetEvent( guiClearStruct,(char *)guiALL ); break; #ifdef HAVE_VCD case STREAMTYPE_VCD: - guiGetEvent( guiClearStruct,guiALL - guiVCD ); + guiGetEvent( guiClearStruct,(char *)(guiALL - guiVCD ) ); if ( !cdrom_device ) { cdrom_device=DEFAULT_CDROM_DEVICE; @@ -285,7 +288,7 @@ play: #endif #ifdef USE_DVDREAD case STREAMTYPE_DVD: - guiGetEvent( guiClearStruct,guiALL - guiDVD ); + guiGetEvent( guiClearStruct,(char *)(guiALL - guiDVD ) ); if ( !dvd_device ) { dvd_device=DEFAULT_DVD_DEVICE; @@ -375,9 +378,32 @@ NoPause: case evIncVolume: vo_x11_putkey( wsGrayMul ); break; case evDecVolume: vo_x11_putkey( wsGrayDiv ); break; - case evMute: mixer_mute(); guiIntfStruct.Mute=muted; break; + case evMute: mixer_mute(); break; + case evSetVolume: - case evSetBalance: guiIntfStruct.VolumeChanged=1; break; + guiIntfStruct.Volume=param; + goto set_volume; + case evSetBalance: + guiIntfStruct.Balance=param; +set_volume: + { + float l = guiIntfStruct.Volume * ( ( 100.0 - guiIntfStruct.Balance ) / 50.0 ); + float r = guiIntfStruct.Volume * ( ( guiIntfStruct.Balance ) / 50.0 ); + if ( l > guiIntfStruct.Volume ) l=guiIntfStruct.Volume; + if ( r > guiIntfStruct.Volume ) r=guiIntfStruct.Volume; +// printf( "!!! v: %.2f b: %.2f -> %.2f x %.2f\n",guiIntfStruct.Volume,guiIntfStruct.Balance,l,r ); + mixer_setvolume( l,r ); + } +#ifdef USE_OSD + if ( osd_level ) + { + osd_visible=vo_mouse_timer_const; + vo_osd_progbar_type=OSD_VOLUME; + vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0; + vo_osd_changed( OSDTYPE_PROGBAR ); + } +#endif + break; case evIconify: @@ -426,7 +452,6 @@ NoPause: case evRedraw: mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow ); - XFlush( wsDisplay ); mplRedrawTimer=mplRedrawTimerConst; break; // --- system events @@ -499,13 +524,7 @@ void mplMainMouseHandle( int Button,int X,int Y,int RX,int RY ) case itPotmeter: case itHPotmeter: btnModify( item->msg,(float)( X - item->x ) / item->width * 100.0f ); - switch ( item->msg ) - { - case evSetVolume: - guiIntfStruct.VolumeChanged=1; - guiIntfStruct.Volume=item->value; - break; - } + mplEventHandling( item->msg,item->value ); value=item->value; break; } @@ -527,13 +546,6 @@ rollerhandled: { item->value+=value; btnModify( item->msg,item->value ); - switch ( item->msg ) - { - case evSetVolume: - guiIntfStruct.VolumeChanged=1; - guiIntfStruct.Volume=item->value; - break; - } mplEventHandling( item->msg,item->value ); mplMainRender=1; } @@ -559,20 +571,12 @@ rollerhandled: potihandled: if ( item->value > 100.0f ) item->value=100.0f; if ( item->value < 0.0f ) item->value=0.0f; - switch ( item->msg ) - { - case evSetVolume: - guiIntfStruct.VolumeChanged=1; - guiIntfStruct.Volume=item->value; - break; - } mplEventHandling( item->msg,item->value ); - mplMainRender=1; wsPostRedisplay( &appMPlayer.mainWindow ); break; } break; } - if ( Button != wsMoveMouse ) wsPostRedisplay( &appMPlayer.mainWindow ); +// if ( Button != wsMoveMouse ) wsPostRedisplay( &appMPlayer.mainWindow ); } int keyPressed = 0; diff --git a/Gui/mplayer/sw.h b/Gui/mplayer/sw.h index 9a8f39d575..88cf6ec235 100644 --- a/Gui/mplayer/sw.h +++ b/Gui/mplayer/sw.h @@ -18,7 +18,6 @@ void mplSubDraw( wsParamDisplay ) if ( mplSubRender ) { if ( appMPlayer.sub.Bitmap.Image ) wsPutImage( &appMPlayer.subWindow ); -// XFlush( wsDisplay ); } appMPlayer.subWindow.State=0; } diff --git a/Gui/wm/ws.c b/Gui/wm/ws.c index 6bcb468565..d3fabf00e3 100644 --- a/Gui/wm/ws.c +++ b/Gui/wm/ws.c @@ -699,8 +699,6 @@ void wsHandleEvents( void ){ } } -extern void mplTimerHandler( void ); - void wsMainLoop( void ) { int delay=20; @@ -718,7 +716,6 @@ while(wsTrue){ wsEvents( wsDisplay,&wsEvent,NULL ); delay=0; } - mplTimerHandler(); // handle timer event usleep(delay*1000); // FIXME! if(delay<10*20) delay+=20; // pump up delay up to 0.2 sec (low activity) } -- cgit v1.2.3