#include <config.h>
#endif
+#include <signal.h>
#include <stdio.h>
#include <asoundlib.h>
pa_rtpoll_item *alsa_rtpoll_item;
- snd_mixer_selem_channel_id_t mixer_map[SND_MIXER_SCHN_LAST];
-
pa_smoother *smoother;
uint64_t read_count;
pa_usec_t smoother_interval;
if (!PA_SOURCE_IS_LINKED(u->source->state))
return 0;
- if (u->source->suspend_cause & PA_SUSPEND_SESSION)
+ if (u->source->suspend_cause & PA_SUSPEND_SESSION) {
+ pa_source_set_mixer_dirty(u->source, TRUE);
return 0;
+ }
if (mask & SND_CTL_EVENT_MASK_VALUE) {
pa_source_get_volume(u->source, TRUE);
if (mask == SND_CTL_EVENT_MASK_REMOVE)
return 0;
- if (u->source->suspend_cause & PA_SUSPEND_SESSION)
+ if (u->source->suspend_cause & PA_SUSPEND_SESSION) {
+ pa_source_set_mixer_dirty(u->source, TRUE);
return 0;
+ }
if (mask & SND_CTL_EVENT_MASK_VALUE)
pa_source_update_volume_and_mute(u->source);
if (u->mixer_path->has_dB && u->deferred_volume) {
pa_source_set_write_volume_callback(u->source, source_write_volume_cb);
- pa_log_info("Successfully enabled synchronous volume.");
+ pa_log_info("Successfully enabled deferred volume.");
} else
pa_source_set_write_volume_callback(u->source, NULL);
data = PA_DEVICE_PORT_DATA(p);
pa_assert_se(u->mixer_path = data->path);
- pa_alsa_path_select(u->mixer_path, u->mixer_handle);
-
- mixer_volume_init(u);
+ pa_alsa_path_select(u->mixer_path, u->mixer_handle, s->muted);
if (data->setting)
pa_alsa_setting_select(data->setting, u->mixer_handle);
+ mixer_volume_init(u);
+
if (s->set_mute)
s->set_mute(s);
- if (s->set_volume)
- s->set_volume(s);
+ if (s->flags & PA_SOURCE_DEFERRED_VOLUME) {
+ if (s->write_volume)
+ s->write_volume(s);
+ } else {
+ if (s->set_volume)
+ s->set_volume(s);
+ }
return 0;
}
}
static void find_mixer(struct userdata *u, pa_alsa_mapping *mapping, const char *element, pa_bool_t ignore_dB) {
+ snd_hctl_t *hctl;
if (!mapping && !element)
return;
- if (!(u->mixer_handle = pa_alsa_open_mixer_for_pcm(u->pcm_handle, &u->control_device))) {
+ if (!(u->mixer_handle = pa_alsa_open_mixer_for_pcm(u->pcm_handle, &u->control_device, &hctl))) {
pa_log_info("Failed to find a working mixer device.");
return;
}
if (!(u->mixer_path = pa_alsa_path_synthesize(element, PA_ALSA_DIRECTION_INPUT)))
goto fail;
- if (pa_alsa_path_probe(u->mixer_path, u->mixer_handle, ignore_dB) < 0)
+ if (pa_alsa_path_probe(u->mixer_path, u->mixer_handle, hctl, ignore_dB) < 0)
goto fail;
pa_log_debug("Probed mixer path %s:", u->mixer_path->name);
pa_alsa_path_dump(u->mixer_path);
- } else {
-
- if (!(u->mixer_path_set = pa_alsa_path_set_new(mapping, PA_ALSA_DIRECTION_INPUT, u->paths_dir)))
- goto fail;
-
- pa_alsa_path_set_probe(u->mixer_path_set, u->mixer_handle, ignore_dB);
- }
+ } else if (!(u->mixer_path_set = mapping->input_path_set))
+ goto fail;
return;
fail:
- if (u->mixer_path_set) {
- pa_alsa_path_set_free(u->mixer_path_set);
- u->mixer_path_set = NULL;
- } else if (u->mixer_path) {
+ if (u->mixer_path) {
pa_alsa_path_free(u->mixer_path);
u->mixer_path = NULL;
}
data = PA_DEVICE_PORT_DATA(u->source->active_port);
u->mixer_path = data->path;
- pa_alsa_path_select(data->path, u->mixer_handle);
+ pa_alsa_path_select(data->path, u->mixer_handle, u->source->muted);
if (data->setting)
pa_alsa_setting_select(data->setting, u->mixer_handle);
} else {
if (!u->mixer_path && u->mixer_path_set)
- u->mixer_path = u->mixer_path_set->paths;
+ u->mixer_path = pa_hashmap_first(u->mixer_path_set->paths);
if (u->mixer_path) {
/* Hmm, we have only a single path, then let's activate it */
- pa_alsa_path_select(u->mixer_path, u->mixer_handle);
+ pa_alsa_path_select(u->mixer_path, u->mixer_handle, u->source->muted);
if (u->mixer_path->settings)
pa_alsa_setting_select(u->mixer_path->settings, u->mixer_handle);
/* Will we need to register callbacks? */
if (u->mixer_path_set && u->mixer_path_set->paths) {
pa_alsa_path *p;
+ void *state;
- PA_LLIST_FOREACH(p, u->mixer_path_set->paths) {
+ PA_HASHMAP_FOREACH(p, u->mixer_path_set->paths, state) {
if (p->has_volume || p->has_mute)
need_mixer_callback = TRUE;
}
u->mixer_fdl = pa_alsa_fdlist_new();
mixer_callback = ctl_mixer_callback;
- if (pa_alsa_fdlist_set_mixer(u->mixer_fdl, u->mixer_handle, u->core->mainloop) < 0) {
+ if (pa_alsa_fdlist_set_handle(u->mixer_fdl, u->mixer_handle, NULL, u->core->mainloop) < 0) {
pa_log("Failed to initialize file descriptor monitoring");
return -1;
}
}
if (u->mixer_path_set)
- pa_alsa_add_ports(u->core, &data.ports, u->mixer_path_set);
+ pa_alsa_add_ports(&data, u->mixer_path_set, card);
u->source = pa_source_new(m->core, &data, PA_SOURCE_HARDWARE|PA_SOURCE_LATENCY|(u->use_tsched ? PA_SOURCE_DYNAMIC_LATENCY : 0));
pa_source_new_data_done(&data);
if (u->mixer_fdl)
pa_alsa_fdlist_free(u->mixer_fdl);
- if (u->mixer_path_set)
- pa_alsa_path_set_free(u->mixer_path_set);
- else if (u->mixer_path)
+ if (u->mixer_path && !u->mixer_path_set)
pa_alsa_path_free(u->mixer_path);
if (u->mixer_handle)