Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

gui/audio: add mic boost support, enable by default

  • Loading branch information...
commit bbe0e769c0a4890923e1b65fbc9f390977382d3a 1 parent 202aca6
Xiangfu Liu authored March 20, 2012

Showing 1 changed file with 24 additions and 0 deletions. Show diff stats Hide diff stats

  1. 24  src/gui/audio.c
24  src/gui/audio.c
@@ -45,6 +45,7 @@ static int line_vol;
45 45
 static int line_mute;
46 46
 static int mic_vol;
47 47
 static int mic_mute;
  48
+static int mic_boost;
48 49
 
49 50
 static float bass, mid, treb;
50 51
 
@@ -118,17 +119,31 @@ static void mute_callback(mtk_event *e, void *arg)
118 119
 	}
119 120
 }
120 121
 
  122
+static void set_micboost(int boost)
  123
+{
  124
+	ioctl(mixer_fd, SOUND_MIXER_WRITE(SOUND_MIXER_MIC_BOOST), &boost);
  125
+}
  126
+
  127
+static void micboost_callback(mtk_event *e, void *arg)
  128
+{
  129
+	mic_boost = !mic_boost;
  130
+	mtk_cmdf(appid, "b_micboost.set(-state %s)", mic_boost ? "on" : "off");
  131
+	set_micboost(mic_boost);
  132
+}
  133
+
121 134
 void load_audio_config(void)
122 135
 {
123 136
 	line_vol = config_read_int("line_vol", 100);
124 137
 	line_mute = config_read_int("line_mute", 0);
125 138
 	mic_vol = config_read_int("mic_vol", 100);
126 139
 	mic_mute = config_read_int("mic_mute", 0);
  140
+	mic_boost = config_read_int("mic_boost", 1);
127 141
 	
128 142
 	mtk_cmdf(appid, "s_linevol.set(-value %d)", 100-line_vol);
129 143
 	mtk_cmdf(appid, "b_mutline.set(-state %s)", line_mute ? "on" : "off");
130 144
 	mtk_cmdf(appid, "s_micvol.set(-value %d)", 100-mic_vol);
131 145
 	mtk_cmdf(appid, "b_mutmic.set(-state %s)", mic_mute ? "on" : "off");
  146
+	mtk_cmdf(appid, "b_micboost.set(-state %s)", mic_boost ? "on" : "off");
132 147
 
133 148
 	if(line_mute)
134 149
 		set_level(0, 0);
@@ -138,6 +153,8 @@ void load_audio_config(void)
138 153
 		set_level(1, 0);
139 154
 	else
140 155
 		set_level(1, mic_vol);
  156
+
  157
+	set_micboost(mic_boost);
141 158
 }
142 159
 
143 160
 static void set_config(void)
@@ -146,6 +163,7 @@ static void set_config(void)
146 163
 	config_write_int("line_mute", line_mute);
147 164
 	config_write_int("mic_vol", mic_vol);
148 165
 	config_write_int("mic_mute", mic_mute);
  166
+	config_write_int("mic_boost", mic_boost);
149 167
 	cp_notify_changed();
150 168
 }
151 169
 
@@ -195,9 +213,11 @@ void init_audio(void)
195 213
 		"s_linevol = new Scale(-from 0 -to 100 -value 0 -orient vertical)",
196 214
 		"l_micvol = new Label(-text \"Mic volume\")",
197 215
 		"s_micvol = new Scale(-from 0 -to 100 -value 0 -orient vertical)",
  216
+		"l_micboost = new Label(-text \"Mic boost\")",
198 217
 
199 218
 		"b_mutline = new Button(-text \"Mute\")",
200 219
 		"b_mutmic = new Button(-text \"Mute\")",
  220
+		"b_micboost = new Button(-text \"Enable\")",
201 221
 
202 222
 		"gv.place(l_linevol, -column 1 -row 1)",
203 223
 		"gv.place(s_linevol, -column 1 -row 2)",
@@ -207,6 +227,9 @@ void init_audio(void)
207 227
 		"gv.place(s_micvol, -column 2 -row 2)",
208 228
 		"gv.place(b_mutmic, -column 2 -row 3)",
209 229
 
  230
+		"gv.place(l_micboost, -column 3 -row 1)",
  231
+		"gv.place(b_micboost, -column 3 -row 3)",
  232
+
210 233
 		"gv.rowconfig(2, -size 180)",
211 234
 
212 235
 		"g.place(gv, -column 1 -row 1)",
@@ -246,6 +269,7 @@ void init_audio(void)
246 269
 
247 270
 	mtk_bind(appid, "b_mutline", "press", mute_callback, (void *)0);
248 271
 	mtk_bind(appid, "b_mutmic", "press", mute_callback, (void *)1);
  272
+	mtk_bind(appid, "b_micboost", "press", micboost_callback, NULL);
249 273
 
250 274
 	mtk_bind(appid, "b_ok", "commit", ok_callback, NULL);
251 275
 	mtk_bind(appid, "b_cancel", "commit", close_callback, NULL);

0 notes on commit bbe0e76

Please sign in to comment.
Something went wrong with that request. Please try again.