2001-04-15 18:37:07 +00:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <sys/ioctl.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <stdio.h>
|
2001-04-23 23:46:24 +00:00
|
|
|
#include <unistd.h>
|
2001-04-15 18:37:07 +00:00
|
|
|
|
2001-06-05 18:40:44 +00:00
|
|
|
#include "config.h"
|
2001-06-08 23:36:58 +00:00
|
|
|
#include "mixer.h"
|
2002-02-21 16:02:26 +00:00
|
|
|
#include "libao2/audio_out.h"
|
2001-04-15 18:37:07 +00:00
|
|
|
|
2002-02-21 16:02:26 +00:00
|
|
|
extern ao_functions_t *audio_out;
|
2001-06-05 18:40:44 +00:00
|
|
|
|
2002-02-21 16:02:26 +00:00
|
|
|
char * mixer_device=NULL;
|
2001-06-05 18:40:44 +00:00
|
|
|
|
2002-06-06 07:13:57 +00:00
|
|
|
int muted = 0;
|
|
|
|
float mute_l = 0.0f;
|
|
|
|
float mute_r = 0.0f;
|
|
|
|
|
2001-06-05 18:40:44 +00:00
|
|
|
void mixer_getvolume( float *l,float *r )
|
|
|
|
{
|
2002-02-21 16:02:26 +00:00
|
|
|
ao_control_vol_t vol;
|
|
|
|
*l=0; *r=0;
|
|
|
|
if(audio_out){
|
|
|
|
if(CONTROL_OK != audio_out->control(AOCONTROL_GET_VOLUME,(int)&vol))
|
|
|
|
return;
|
|
|
|
*r=vol.right;
|
|
|
|
*l=vol.left;
|
2001-06-05 18:40:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void mixer_setvolume( float l,float r )
|
|
|
|
{
|
2002-02-21 16:02:26 +00:00
|
|
|
ao_control_vol_t vol;
|
|
|
|
vol.right=r; vol.left=l;
|
|
|
|
if(audio_out){
|
|
|
|
if(CONTROL_OK != audio_out->control(AOCONTROL_SET_VOLUME,(int)&vol))
|
|
|
|
return;
|
2001-06-05 18:40:44 +00:00
|
|
|
}
|
2002-06-06 07:13:57 +00:00
|
|
|
muted=0;
|
2001-06-05 18:40:44 +00:00
|
|
|
}
|
2001-06-08 23:36:58 +00:00
|
|
|
|
2001-09-11 16:26:41 +00:00
|
|
|
#define MIXER_CHANGE 3
|
2001-04-15 18:37:07 +00:00
|
|
|
|
|
|
|
void mixer_incvolume( void )
|
|
|
|
{
|
2001-06-05 18:40:44 +00:00
|
|
|
float mixer_l, mixer_r;
|
2001-04-15 18:37:07 +00:00
|
|
|
mixer_getvolume( &mixer_l,&mixer_r );
|
2001-09-11 16:26:41 +00:00
|
|
|
mixer_l += MIXER_CHANGE;
|
2001-06-05 18:40:44 +00:00
|
|
|
if ( mixer_l > 100 ) mixer_l = 100;
|
2001-09-11 16:26:41 +00:00
|
|
|
mixer_r += MIXER_CHANGE;
|
2001-06-05 18:40:44 +00:00
|
|
|
if ( mixer_r > 100 ) mixer_r = 100;
|
2001-04-15 18:37:07 +00:00
|
|
|
mixer_setvolume( mixer_l,mixer_r );
|
|
|
|
}
|
|
|
|
|
|
|
|
void mixer_decvolume( void )
|
|
|
|
{
|
2001-06-05 18:40:44 +00:00
|
|
|
float mixer_l, mixer_r;
|
2001-04-15 18:37:07 +00:00
|
|
|
mixer_getvolume( &mixer_l,&mixer_r );
|
2001-09-11 16:26:41 +00:00
|
|
|
mixer_l -= MIXER_CHANGE;
|
2001-06-05 18:40:44 +00:00
|
|
|
if ( mixer_l < 0 ) mixer_l = 0;
|
2001-09-11 16:26:41 +00:00
|
|
|
mixer_r -= MIXER_CHANGE;
|
2001-06-05 18:40:44 +00:00
|
|
|
if ( mixer_r < 0 ) mixer_r = 0;
|
2001-04-15 18:37:07 +00:00
|
|
|
mixer_setvolume( mixer_l,mixer_r );
|
|
|
|
}
|
|
|
|
|
2001-06-05 18:40:44 +00:00
|
|
|
float mixer_getbothvolume( void )
|
2001-04-15 18:37:07 +00:00
|
|
|
{
|
2001-06-05 18:40:44 +00:00
|
|
|
float mixer_l, mixer_r;
|
2001-04-15 18:37:07 +00:00
|
|
|
mixer_getvolume( &mixer_l,&mixer_r );
|
|
|
|
return ( mixer_l + mixer_r ) / 2;
|
|
|
|
}
|
2002-02-21 16:02:26 +00:00
|
|
|
|
2002-06-06 07:13:57 +00:00
|
|
|
void mixer_mute( void )
|
|
|
|
{
|
|
|
|
if ( muted ) mixer_setvolume( mute_l,mute_r );
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mixer_getvolume( &mute_l,&mute_r );
|
|
|
|
mixer_setvolume( 0,0 );
|
|
|
|
muted=1;
|
|
|
|
}
|
|
|
|
}
|
2002-02-21 16:02:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|