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
This commit is contained in:
pontscho
2002-07-02 13:35:04 +00:00
parent 2677cc6ae2
commit 90dabd0261
9 changed files with 79 additions and 70 deletions
+33 -2
View File
@@ -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 ) )
}
+2 -3
View File
@@ -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
-7
View File
@@ -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;
-1
View File
@@ -14,6 +14,5 @@ extern int mplMiddleMenu;
extern void mplInit( void * disp );
extern void mplEventHandling( int msg,float param );
extern void mplTimerHandler( void );
#endif
+34 -30
View File
@@ -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;
-1
View File
@@ -18,7 +18,6 @@ void mplSubDraw( wsParamDisplay )
if ( mplSubRender )
{
if ( appMPlayer.sub.Bitmap.Image ) wsPutImage( &appMPlayer.subWindow );
// XFlush( wsDisplay );
}
appMPlayer.subWindow.State=0;
}
-3
View File
@@ -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)
}
+7 -23
View File
@@ -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);
+3
View File
@@ -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