summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Hollerbach <marcel-hollerbach@t-online.de>2014-07-19 14:47:36 +0200
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-08-14 23:33:18 -0300
commit076da6a68453d72ff497b1df632d0eb4d260f09e (patch)
treebbb63cf6c04ed5791e72a2c3f1a57be5dfd69571
parent151e1eb8da1e5ee7cc97784809b31cfbc9ff0d8b (diff)
alsa: added mute stuff, mutes are set correctly and written correctly.
-rw-r--r--src/lib/backends/alsa/alsa.c35
1 files changed, 30 insertions, 5 deletions
diff --git a/src/lib/backends/alsa/alsa.c b/src/lib/backends/alsa/alsa.c
index 3616bca..ecc303a 100644
--- a/src/lib/backends/alsa/alsa.c
+++ b/src/lib/backends/alsa/alsa.c
@@ -190,6 +190,28 @@ _alsa_volume_free(Emix_Volume volume)
190 free(volume.volumes); 190 free(volume.volumes);
191} 191}
192 192
193static void
194_alsa_sink_mute_get(Alsa_Emix_Sink *as)
195{
196 int i = 0;
197 snd_mixer_elem_t *elem;
198
199 elem = eina_list_data_get(as->channels);
200 snd_mixer_selem_get_playback_switch(elem,0, &i);
201 as->sink.mute = !i;
202}
203
204static void
205_alsa_sources_mute_get(Alsa_Emix_Source *as)
206{
207 int i = 0;
208 snd_mixer_elem_t *elem;
209
210 elem = eina_list_data_get(as->channels);
211 snd_mixer_selem_get_capture_switch(elem, 0, &i);
212 as->source.mute = !i;
213}
214
193static Alsa_Emix_Sink* 215static Alsa_Emix_Sink*
194_alsa_device_sink_create(snd_mixer_t *mixer, const char *name, const char* hw_name, Eina_List *channels) 216_alsa_device_sink_create(snd_mixer_t *mixer, const char *name, const char* hw_name, Eina_List *channels)
195{ 217{
@@ -205,9 +227,9 @@ _alsa_device_sink_create(snd_mixer_t *mixer, const char *name, const char* hw_na
205 sink->hw_name = eina_stringshare_add(hw_name); 227 sink->hw_name = eina_stringshare_add(hw_name);
206 sink->handle = mixer; 228 sink->handle = mixer;
207 sink->channels = channels; 229 sink->channels = channels;
230 _alsa_sink_mute_get(sink);
208 ctx->sink_cb((Emix_Sink*) sink, EMIX_EVENT_ADDED); 231 ctx->sink_cb((Emix_Sink*) sink, EMIX_EVENT_ADDED);
209 ctx->sinks = eina_list_append(ctx->sinks, sink); 232 ctx->sinks = eina_list_append(ctx->sinks, sink);
210 //TODO set mute
211 ctx->ready_cb(); 233 ctx->ready_cb();
212 return sink; 234 return sink;
213} 235}
@@ -227,9 +249,9 @@ _alsa_device_source_create(snd_mixer_t *mixer, const char *name, const char* hw_
227 source->hw_name = eina_stringshare_add(hw_name); 249 source->hw_name = eina_stringshare_add(hw_name);
228 source->handle = mixer; 250 source->handle = mixer;
229 source->channels = channels; 251 source->channels = channels;
252 _alsa_sources_mute_get(source);
230 ctx->source_cb((Emix_Source*) source, EMIX_EVENT_ADDED); 253 ctx->source_cb((Emix_Source*) source, EMIX_EVENT_ADDED);
231 ctx->sources = eina_list_append(ctx->sources, source); 254 ctx->sources = eina_list_append(ctx->sources, source);
232 //TODO set mute
233 return source; 255 return source;
234} 256}
235 257
@@ -451,9 +473,11 @@ _alsa_sources_mute_set(Emix_Source *source, Eina_Bool mute)
451 Alsa_Emix_Source *s = (Alsa_Emix_Source*) source; 473 Alsa_Emix_Source *s = (Alsa_Emix_Source*) source;
452 Eina_List *node; 474 Eina_List *node;
453 snd_mixer_elem_t *elem; 475 snd_mixer_elem_t *elem;
476
454 EINA_LIST_FOREACH(s->channels, node, elem) 477 EINA_LIST_FOREACH(s->channels, node, elem)
455 { 478 {
456 if (snd_mixer_selem_set_playback_switch_all(elem, !mute) < 0) 479 if ( snd_mixer_selem_has_capture_switch(elem) &&
480 snd_mixer_selem_set_capture_switch_all(elem, !mute) < 0)
457 ERR("Failed to mute device\n"); 481 ERR("Failed to mute device\n");
458 } 482 }
459} 483}
@@ -507,8 +531,9 @@ _alsa_sink_mute_set(Emix_Sink *sink, Eina_Bool mute)
507 snd_mixer_elem_t *elem; 531 snd_mixer_elem_t *elem;
508 EINA_LIST_FOREACH(as->channels, node, elem) 532 EINA_LIST_FOREACH(as->channels, node, elem)
509 { 533 {
510 if (snd_mixer_selem_set_playback_switch_all(elem, !mute) < 0) 534 if (snd_mixer_selem_has_playback_switch(elem) &&
511 ERR("Failed to mute device\n"); 535 snd_mixer_selem_set_playback_switch_all(elem, !mute) < 0)
536 ERR("Failed to set mute(%d) device(%p)", mute, elem);
512 } 537 }
513} 538}
514static void 539static void