annotate mixer.c @ 36288:63e8bfb208c6

Remove property wsWaitMap and function wsWindowMapWait(). There was a false check of the property (wsShowWindow instead of wsWaitMap) in wsWindowCreate(), so wsWindowMapWait() was actually never used on window creation. The function seems pointless.
author ib
date Thu, 01 Aug 2013 17:20:16 +0000
parents b1b974133fa1
children 3a9a804e488b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
30429
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
1 /*
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
2 * This file is part of MPlayer.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
3 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
5 * it under the terms of the GNU General Public License as published by
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
7 * (at your option) any later version.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
8 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
12 * GNU General Public License for more details.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
13 *
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
14 * You should have received a copy of the GNU General Public License along
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
17 */
c1a3f1bbba26 Add license header to all top-level files missing them.
diego
parents: 29263
diff changeset
18
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
19 #include <string.h>
9772
6586ec1f6ee4 MINGW32 port
faust3
parents: 9633
diff changeset
20 #ifndef __MINGW32__
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
21 #include <sys/ioctl.h>
9772
6586ec1f6ee4 MINGW32 port
faust3
parents: 9633
diff changeset
22 #endif
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
23 #include <fcntl.h>
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
24 #include <stdio.h>
605
abd7391a31e3 warnings killed
szabii
parents: 556
diff changeset
25 #include <unistd.h>
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
26
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
27 #include "config.h"
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
28 #include "libao2/audio_out.h"
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
29 #include "libaf/af.h"
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
30 #include "mixer.h"
34174
a93891202051 Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents: 30633
diff changeset
31 #include "mp_msg.h"
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
32 #include "help_mp.h"
1061
0f7be115a4db patch by J¸«ärgen Keil
arpi_esp
parents: 1038
diff changeset
33
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
34 char * mixer_device=NULL;
11837
4e8f8efb6906 add option to select mixer channel
attila
parents: 9772
diff changeset
35 char * mixer_channel=NULL;
13933
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
36 int soft_vol = 0;
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
37 float soft_vol_max = 110.0;
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
38
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
39 void mixer_getvolume(mixer_t *mixer, float *l, float *r)
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
40 {
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
41 ao_control_vol_t vol;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
42 *l=0; *r=0;
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
43 if(mixer->audio_out){
13933
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
44 if(soft_vol ||
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
45 CONTROL_OK != mixer->audio_out->control(AOCONTROL_GET_VOLUME,&vol)) {
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
46 if (!mixer->afilter)
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
47 return;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
48 else {
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
49 float db_vals[AF_NCH];
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
50 if (!af_control_any_rev(mixer->afilter,
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
51 AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_GET, db_vals))
12908
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
52 db_vals[0] = db_vals[1] = 1.0;
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
53 else
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
54 af_from_dB (2, db_vals, db_vals, 20.0, -200.0, 60.0);
13933
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
55 vol.left = (db_vals[0] / (soft_vol_max / 100.0)) * 100.0;
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
56 vol.right = (db_vals[1] / (soft_vol_max / 100.0)) * 100.0;
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
57 }
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
58 }
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
59 *r=vol.right;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
60 *l=vol.left;
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
61 }
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
62 }
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
63
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
64 void mixer_setvolume(mixer_t *mixer, float l, float r)
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
65 {
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
66 ao_control_vol_t vol;
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
67 vol.right=r; vol.left=l;
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
68 if(mixer->audio_out){
13933
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
69 if(soft_vol ||
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
70 CONTROL_OK != mixer->audio_out->control(AOCONTROL_SET_VOLUME,&vol)) {
12688
alex
parents: 12672
diff changeset
71 if (!mixer->afilter)
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
72 return;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
73 else {
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
74 // af_volume uses values in dB
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
75 float db_vals[AF_NCH];
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
76 int i;
13933
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
77 db_vals[0] = (l / 100.0) * (soft_vol_max / 100.0);
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
78 db_vals[1] = (r / 100.0) * (soft_vol_max / 100.0);
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
79 for (i = 2; i < AF_NCH; i++) {
13933
75b84965d137 allow forcing of software volume control and setting maximum amplification.
reimar
parents: 12908
diff changeset
80 db_vals[i] = ((l + r) / 100.0) * (soft_vol_max / 100.0) / 2.0;
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
81 }
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
82 af_to_dB (AF_NCH, db_vals, db_vals, 20.0);
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
83 if (!af_control_any_rev(mixer->afilter,
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
84 AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) {
12908
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
85 mp_msg(MSGT_GLOBAL, MSGL_INFO, MSGTR_InsertingAfVolume);
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
86 if (af_add(mixer->afilter, "volume")) {
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
87 if (!af_control_any_rev(mixer->afilter,
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
88 AF_CONTROL_VOLUME_LEVEL | AF_CONTROL_SET, db_vals)) {
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
89 mp_msg(MSGT_GLOBAL, MSGL_ERR, MSGTR_NoVolume);
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
90 return;
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
91 }
34799
b1b974133fa1 Avoid repeating mixer error messages from ao.
reimar
parents: 34174
diff changeset
92 soft_vol = 1;
12908
7b9b4f07d2c4 automatic loading of af_volume, original patch by Dan Christiansen (danchr (at) daimi (dot) au (dot) dk)
reimar
parents: 12688
diff changeset
93 }
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
94 }
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
95 }
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
96 }
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
97 }
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
98 mixer->muted=0;
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
99 }
1061
0f7be115a4db patch by J¸«ärgen Keil
arpi_esp
parents: 1038
diff changeset
100
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
101 void mixer_incvolume(mixer_t *mixer)
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
102 {
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
103 float mixer_l, mixer_r;
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
104 mixer_getvolume(mixer, &mixer_l, &mixer_r);
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
105 mixer_l += mixer->volstep;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
106 if ( mixer_l > 100 ) mixer_l = 100;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
107 mixer_r += mixer->volstep;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
108 if ( mixer_r > 100 ) mixer_r = 100;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
109 mixer_setvolume(mixer, mixer_l, mixer_r);
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
110 }
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
111
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
112 void mixer_decvolume(mixer_t *mixer)
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
113 {
1038
b36fb1ae4b53 applied solaris8/netbsd/other fixes patch by J¸«ärgen Keil <jk@tools.de>
arpi_esp
parents: 1020
diff changeset
114 float mixer_l, mixer_r;
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
115 mixer_getvolume(mixer, &mixer_l, &mixer_r);
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
116 mixer_l -= mixer->volstep;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
117 if ( mixer_l < 0 ) mixer_l = 0;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
118 mixer_r -= mixer->volstep;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
119 if ( mixer_r < 0 ) mixer_r = 0;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
120 mixer_setvolume(mixer, mixer_l, mixer_r);
441
c4b4e2aac9de ups, I missed'em..
gabucino
parents:
diff changeset
121 }
4788
d678ce495a75 Moved HW dependent mixer stuff to libao and removed master switch
anders
parents: 4749
diff changeset
122
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
123 void mixer_getbothvolume(mixer_t *mixer, float *b)
6311
da2dda48b7ec add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents: 4788
diff changeset
124 {
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
125 float mixer_l, mixer_r;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
126 mixer_getvolume(mixer, &mixer_l, &mixer_r);
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
127 *b = ( mixer_l + mixer_r ) / 2;
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
128 }
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
129
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
130 void mixer_mute(mixer_t *mixer)
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
131 {
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
132 if (mixer->muted) mixer_setvolume(mixer, mixer->last_l, mixer->last_r);
6311
da2dda48b7ec add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents: 4788
diff changeset
133 else
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 23568
diff changeset
134 {
12672
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
135 mixer_getvolume(mixer, &mixer->last_l, &mixer->last_r);
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
136 mixer_setvolume(mixer, 0, 0);
9709ce101949 New 'Mixer API' with ability to change volume through libaf (this part was written by Reimar Doffinger) and lesser global variables
alex
parents: 11837
diff changeset
137 mixer->muted=1;
6311
da2dda48b7ec add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents: 4788
diff changeset
138 }
da2dda48b7ec add mute support ( step 1 ) and fixed panscan bugs (1000l for me)
pontscho
parents: 4788
diff changeset
139 }
23568
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
140
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
141 void mixer_getbalance(mixer_t *mixer, float *val)
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
142 {
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
143 *val = 0.f;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
144 if(!mixer->afilter)
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
145 return;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
146 af_control_any_rev(mixer->afilter,
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
147 AF_CONTROL_PAN_BALANCE | AF_CONTROL_GET, val);
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
148 }
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
149
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
150 void mixer_setbalance(mixer_t *mixer, float val)
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
151 {
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
152 float level[AF_NCH];
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
153 int i;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
154 af_control_ext_t arg_ext = { .arg = level };
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
155 af_instance_t* af_pan_balance;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
156
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
157 if(!mixer->afilter)
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
158 return;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
159 if (af_control_any_rev(mixer->afilter,
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
160 AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val))
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
161 return;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
162
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
163 if (!(af_pan_balance = af_add(mixer->afilter, "pan"))) {
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
164 mp_msg(MSGT_GLOBAL, MSGL_ERR, MSGTR_NoBalance);
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
165 return;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
166 }
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
167
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
168 af_init(mixer->afilter);
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
169 /* make all other channels pass thru since by default pan blocks all */
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
170 memset(level, 0, sizeof(level));
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
171 for (i = 2; i < AF_NCH; i++) {
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
172 arg_ext.ch = i;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
173 level[i] = 1.f;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
174 af_pan_balance->control(af_pan_balance,
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
175 AF_CONTROL_PAN_LEVEL | AF_CONTROL_SET, &arg_ext);
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
176 level[i] = 0.f;
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
177 }
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
178
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
179 af_pan_balance->control(af_pan_balance,
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
180 AF_CONTROL_PAN_BALANCE | AF_CONTROL_SET, &val);
519e42b716aa The audio balance feature implemented with af_pan.
zuxy
parents: 13933
diff changeset
181 }