Mercurial > mplayer.hg
annotate mixer.c @ 8964:9f3a0da01917
preferences cosmetics
author | pontscho |
---|---|
date | Thu, 16 Jan 2003 19:51:08 +0000 |
parents | da2dda48b7ec |
children | 12b1790038b0 |
rev | line source |
---|---|
441 | 1 |
2 #include <string.h> | |
3 #include <sys/ioctl.h> | |
4 #include <fcntl.h> | |
5 #include <stdio.h> | |
605 | 6 #include <unistd.h> |
441 | 7 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
8 #include "config.h" |
441 | 9 #include "mixer.h" |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
10 #include "libao2/audio_out.h" |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
11 |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
12 extern ao_functions_t *audio_out; |
1061 | 13 |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
14 char * mixer_device=NULL; |
441 | 15 |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
16 int muted = 0; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
17 float mute_l = 0.0f; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
18 float mute_r = 0.0f; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
19 |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
20 void mixer_getvolume( float *l,float *r ) |
441 | 21 { |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
22 ao_control_vol_t vol; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
23 *l=0; *r=0; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
24 if(audio_out){ |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
25 if(CONTROL_OK != audio_out->control(AOCONTROL_GET_VOLUME,(int)&vol)) |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
26 return; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
27 *r=vol.right; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
28 *l=vol.left; |
441 | 29 } |
30 } | |
31 | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
32 void mixer_setvolume( float l,float r ) |
441 | 33 { |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
34 ao_control_vol_t vol; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
35 vol.right=r; vol.left=l; |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
36 if(audio_out){ |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
37 if(CONTROL_OK != audio_out->control(AOCONTROL_SET_VOLUME,(int)&vol)) |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
38 return; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
39 } |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
40 muted=0; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
41 } |
1061 | 42 |
1881
d75b24bda7ce
Applied fix for mixercontrol w/alsa ossemu by Christian Ohm.
atmos4
parents:
1061
diff
changeset
|
43 #define MIXER_CHANGE 3 |
441 | 44 |
45 void mixer_incvolume( void ) | |
46 { | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
47 float mixer_l, mixer_r; |
441 | 48 mixer_getvolume( &mixer_l,&mixer_r ); |
1881
d75b24bda7ce
Applied fix for mixercontrol w/alsa ossemu by Christian Ohm.
atmos4
parents:
1061
diff
changeset
|
49 mixer_l += MIXER_CHANGE; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
50 if ( mixer_l > 100 ) mixer_l = 100; |
1881
d75b24bda7ce
Applied fix for mixercontrol w/alsa ossemu by Christian Ohm.
atmos4
parents:
1061
diff
changeset
|
51 mixer_r += MIXER_CHANGE; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
52 if ( mixer_r > 100 ) mixer_r = 100; |
441 | 53 mixer_setvolume( mixer_l,mixer_r ); |
54 } | |
55 | |
56 void mixer_decvolume( void ) | |
57 { | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
58 float mixer_l, mixer_r; |
441 | 59 mixer_getvolume( &mixer_l,&mixer_r ); |
1881
d75b24bda7ce
Applied fix for mixercontrol w/alsa ossemu by Christian Ohm.
atmos4
parents:
1061
diff
changeset
|
60 mixer_l -= MIXER_CHANGE; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
61 if ( mixer_l < 0 ) mixer_l = 0; |
1881
d75b24bda7ce
Applied fix for mixercontrol w/alsa ossemu by Christian Ohm.
atmos4
parents:
1061
diff
changeset
|
62 mixer_r -= MIXER_CHANGE; |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
63 if ( mixer_r < 0 ) mixer_r = 0; |
441 | 64 mixer_setvolume( mixer_l,mixer_r ); |
65 } | |
66 | |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
67 float mixer_getbothvolume( void ) |
441 | 68 { |
1038
b36fb1ae4b53
applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents:
1020
diff
changeset
|
69 float mixer_l, mixer_r; |
441 | 70 mixer_getvolume( &mixer_l,&mixer_r ); |
71 return ( mixer_l + mixer_r ) / 2; | |
72 } | |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
73 |
6311
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
74 void mixer_mute( void ) |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
75 { |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
76 if ( muted ) mixer_setvolume( mute_l,mute_r ); |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
77 else |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
78 { |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
79 mixer_getvolume( &mute_l,&mute_r ); |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
80 mixer_setvolume( 0,0 ); |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
81 muted=1; |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
82 } |
da2dda48b7ec
add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents:
4788
diff
changeset
|
83 } |
4788
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
84 |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
85 |
d678ce495a75
Moved HW dependent mixer stuff to libao and removed master switch
anders
parents:
4749
diff
changeset
|
86 |