aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-07-02 13:35:04 +0000
committerGravatar pontscho <pontscho@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-07-02 13:35:04 +0000
commit90dabd0261ce580efb8bfe078eb3717673cea8ea (patch)
treebac8807b73f59c8a5ab12c7efffc9d018f58b96b
parent2677cc6ae2f2d5dda311a1ed5afd17f3f195cd4b (diff)
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
-rw-r--r--Gui/interface.c35
-rw-r--r--Gui/interface.h5
-rw-r--r--Gui/mplayer/mplayer.c7
-rw-r--r--Gui/mplayer/mplayer.h1
-rw-r--r--Gui/mplayer/mw.h64
-rw-r--r--Gui/mplayer/sw.h1
-rw-r--r--Gui/wm/ws.c3
-rw-r--r--mplayer.c30
-rw-r--r--mplayer.h3
9 files changed, 79 insertions, 70 deletions
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 <inttypes.h>
#include <sys/types.h>
@@ -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)
}
diff --git a/mplayer.c b/mplayer.c
index 17e0c0920d..ebfbd2c0bb 100644
--- a/mplayer.c
+++ b/mplayer.c
@@ -172,6 +172,7 @@ static int output_quality=0;
int use_gui=0;
int osd_level=2;
+int osd_visible=100;
// seek:
char *seek_to_sec=NULL;
@@ -501,7 +502,6 @@ int delay_corrected=1;
int out_fmt=0;
int eof=0;
-int osd_visible=100;
int osd_function=OSD_PLAY;
int osd_last_pts=-303;
int osd_show_av_delay = 0;
@@ -807,8 +807,9 @@ if(!use_stdin && !slave_mode){
#ifdef HAVE_NEW_INPUT
mp_cmd_t* cmd;
#endif
- usleep(40000);
+ usleep(20000);
guiEventHandling();
+ guiGetEvent( guiReDraw,NULL );
#ifdef HAVE_NEW_INPUT
if ( (cmd = mp_input_get_cmd(0,0)) != NULL) guiGetEvent( guiIEvent,(char *)cmd->id );
#endif
@@ -1392,6 +1393,7 @@ fflush(stdout);
guiGetEvent( guiSetStream,(char *)stream );
if ( sh_audio ) guiIntfStruct.AudioType=sh_audio->channels; else guiIntfStruct.AudioType=0;
if ( !sh_video && sh_audio ) guiGetEvent( guiSetAudioOnly,1 ); else guiGetEvent( guiSetAudioOnly,0 );
+ guiGetEvent( guiSetVolume,NULL );
}
#endif
@@ -1953,6 +1955,7 @@ if(auto_quality>0){
#ifdef HAVE_NEW_GUI
if(use_gui){
guiEventHandling();
+ guiGetEvent( guiReDraw,NULL );
if(guiIntfStruct.Playing!=2 || (rel_seek_secs || abs_seek_pos)) break;
}
#endif
@@ -2905,23 +2908,9 @@ if(rel_seek_secs || abs_seek_pos){
}
if ( sh_video ) guiIntfStruct.TimeSec=d_video->pts;
else if ( sh_audio ) guiIntfStruct.TimeSec=sh_audio->timer;
+ guiGetEvent( guiReDraw,NULL );
if(guiIntfStruct.Playing==0) break; // STOP
if(guiIntfStruct.Playing==2) osd_function=OSD_PAUSE;
- if ( guiIntfStruct.VolumeChanged )
- {
- mixer_setvolume( guiIntfStruct.Volume,guiIntfStruct.Volume );
- guiIntfStruct.VolumeChanged=0;
-#ifdef USE_OSD
- if ( osd_level )
- {
- osd_visible=sh_video->fps; // 1 sec
- vo_osd_progbar_type=OSD_VOLUME;
- vo_osd_progbar_value=( ( guiIntfStruct.Volume ) * 256.0 ) / 100.0;
- vo_osd_changed(OSDTYPE_PROGBAR);
- }
-#endif
- }
- guiIntfStruct.Volume=(float)mixer_getbothvolume();
if ( guiIntfStruct.DiskChanged ) goto goto_next_file;
#ifdef USE_DVDREAD
if ( stream->type == STREAMTYPE_DVD )
@@ -3108,12 +3097,7 @@ while(playtree_iter != NULL) {
}
#endif
-if(use_gui || playtree_iter != NULL
-// once use_gui is set, this won't be reached -> useless: --A'rpi
-//#if defined( HAVE_NEW_GUI ) && defined( USE_DVDREAD )
-// || ( guiIntfStruct.DVDChanged && use_gui )
-//#endif
-){
+if(use_gui || playtree_iter != NULL){
current_module="uninit_acodec";
if(sh_audio) uninit_audio(sh_audio);
diff --git a/mplayer.h b/mplayer.h
index e9641ffd8b..4cac5ecc52 100644
--- a/mplayer.h
+++ b/mplayer.h
@@ -7,6 +7,9 @@ extern char* current_module;
extern int fullscreen;
extern int vcd_track;
+extern int osd_level;
+extern int osd_visible;
+
extern void exit_player(char* how);
#endif