summaryrefslogtreecommitdiffstats
path: root/src/modules
diff options
context:
space:
mode:
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/alsa/alsa-sink.c22
-rw-r--r--src/modules/alsa/alsa-source.c20
-rw-r--r--src/modules/alsa/alsa-util.c63
-rw-r--r--src/modules/alsa/alsa-util.h12
-rw-r--r--src/modules/module-cork-music-on-phone.c1
-rw-r--r--src/modules/module-device-restore.c2
-rw-r--r--src/modules/module-lirc.c33
-rw-r--r--src/modules/module-match.c2
-rw-r--r--src/modules/module-mmkbd-evdev.c39
-rw-r--r--src/modules/module-stream-restore.c142
-rw-r--r--src/modules/module-x11-publish.c8
-rw-r--r--src/modules/oss/module-oss.c2
12 files changed, 177 insertions, 169 deletions
diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index 401b003f..2fbcd7be 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -483,7 +483,13 @@ static int mmap_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) - process_usec;
+ *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec);
+
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+
return work_done ? 1 : 0;
}
@@ -605,7 +611,13 @@ static int unix_write(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polle
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec) - process_usec;
+ *sleep_usec = pa_bytes_to_usec(left_to_play, &u->sink->sample_spec);
+
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+
return work_done ? 1 : 0;
}
@@ -919,7 +931,7 @@ static int mixer_callback(snd_mixer_elem_t *elem, unsigned int mask) {
return 0;
if (mask & SND_CTL_EVENT_MASK_VALUE) {
- pa_sink_get_volume(u->sink, TRUE);
+ pa_sink_get_volume(u->sink, TRUE, FALSE);
pa_sink_get_mute(u->sink, TRUE);
}
@@ -1652,7 +1664,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
/* ALSA might tweak the sample spec, so recalculate the frame size */
frame_size = pa_frame_size(&ss);
- pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem, pa_modargs_get_value(ma, "control", NULL));
+ pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem, pa_modargs_get_value(ma, "control", NULL), profile);
pa_sink_new_data_init(&data);
data.driver = driver;
@@ -1662,7 +1674,7 @@ pa_sink *pa_alsa_sink_new(pa_module *m, pa_modargs *ma, const char*driver, pa_ca
pa_sink_new_data_set_sample_spec(&data, &ss);
pa_sink_new_data_set_channel_map(&data, &map);
- pa_alsa_init_proplist_pcm(m->core, data.proplist, u->pcm_handle);
+ pa_alsa_init_proplist_pcm(m->core, data.proplist, u->pcm_handle, u->mixer_elem);
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_name);
pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE, "%lu", (unsigned long) (period_frames * frame_size * nfrags));
pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size));
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 99e825c4..c59fc75f 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -465,7 +465,13 @@ static int mmap_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec) - process_usec;
+ *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec);
+
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+
return work_done ? 1 : 0;
}
@@ -575,7 +581,13 @@ static int unix_read(struct userdata *u, pa_usec_t *sleep_usec, pa_bool_t polled
}
}
- *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec) - process_usec;
+ *sleep_usec = pa_bytes_to_usec(left_to_record, &u->source->sample_spec);
+
+ if (*sleep_usec > process_usec)
+ *sleep_usec -= process_usec;
+ else
+ *sleep_usec = 0;
+
return work_done ? 1 : 0;
}
@@ -1507,7 +1519,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
/* ALSA might tweak the sample spec, so recalculate the frame size */
frame_size = pa_frame_size(&ss);
- pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem, pa_modargs_get_value(ma, "control", NULL));
+ pa_alsa_find_mixer_and_elem(u->pcm_handle, &u->mixer_handle, &u->mixer_elem, pa_modargs_get_value(ma, "control", NULL), profile);
pa_source_new_data_init(&data);
data.driver = driver;
@@ -1517,7 +1529,7 @@ pa_source *pa_alsa_source_new(pa_module *m, pa_modargs *ma, const char*driver, p
pa_source_new_data_set_sample_spec(&data, &ss);
pa_source_new_data_set_channel_map(&data, &map);
- pa_alsa_init_proplist_pcm(m->core, data.proplist, u->pcm_handle);
+ pa_alsa_init_proplist_pcm(m->core, data.proplist, u->pcm_handle, u->mixer_elem);
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_STRING, u->device_name);
pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_BUFFER_SIZE, "%lu", (unsigned long) (period_frames * frame_size * nfrags));
pa_proplist_setf(data.proplist, PA_PROP_DEVICE_BUFFERING_FRAGMENT_SIZE, "%lu", (unsigned long) (period_frames * frame_size));
diff --git a/src/modules/alsa/alsa-util.c b/src/modules/alsa/alsa-util.c
index fbf88b08..d2dc6e87 100644
--- a/src/modules/alsa/alsa-util.c
+++ b/src/modules/alsa/alsa-util.c
@@ -529,39 +529,51 @@ static const struct pa_alsa_profile_info device_table[] = {
"hw",
N_("Analog Mono"),
"analog-mono",
- 1 },
+ 1,
+ "Master", "PCM",
+ "Capture", "Mic" },
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
"front",
N_("Analog Stereo"),
"analog-stereo",
- 10 },
+ 10,
+ "Master", "PCM",
+ "Capture", "Mic" },
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
"iec958",
N_("Digital Stereo (IEC958)"),
"iec958-stereo",
- 5 },
+ 5,
+ "IEC958", NULL,
+ "IEC958 In", NULL },
{{ 2, { PA_CHANNEL_POSITION_LEFT, PA_CHANNEL_POSITION_RIGHT }},
"hdmi",
N_("Digital Stereo (HDMI)"),
"hdmi-stereo",
- 4 },
+ 4,
+ "IEC958", NULL,
+ "IEC958 In", NULL },
{{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
"surround40",
N_("Analog Surround 4.0"),
"analog-surround-40",
- 7 },
+ 7,
+ "Master", "PCM",
+ "Capture", "Mic" },
{{ 4, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT }},
"a52",
N_("Digital Surround 4.0 (IEC958/AC3)"),
"iec958-ac3-surround-40",
- 2 },
+ 2,
+ "Master", "PCM",
+ "Capture", "Mic" },
{{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
@@ -569,7 +581,9 @@ static const struct pa_alsa_profile_info device_table[] = {
"surround41",
N_("Analog Surround 4.1"),
"analog-surround-41",
- 7 },
+ 7,
+ "Master", "PCM",
+ "Capture", "Mic" },
{{ 5, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
@@ -577,7 +591,9 @@ static const struct pa_alsa_profile_info device_table[] = {
"surround50",
N_("Analog Surround 5.0"),
"analog-surround-50",
- 7 },
+ 7,
+ "Master", "PCM",
+ "Capture", "Mic" },
{{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
@@ -585,7 +601,9 @@ static const struct pa_alsa_profile_info device_table[] = {
"surround51",
N_("Analog Surround 5.1"),
"analog-surround-51",
- 8 },
+ 8,
+ "Master", "PCM",
+ "Capture", "Mic" },
{{ 6, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
@@ -593,7 +611,9 @@ static const struct pa_alsa_profile_info device_table[] = {
"a52",
N_("Digital Surround 5.1 (IEC958/AC3)"),
"iec958-ac3-surround-51",
- 3 },
+ 3,
+ "IEC958", NULL,
+ "IEC958 In", NULL },
{{ 8, { PA_CHANNEL_POSITION_FRONT_LEFT, PA_CHANNEL_POSITION_FRONT_RIGHT,
PA_CHANNEL_POSITION_REAR_LEFT, PA_CHANNEL_POSITION_REAR_RIGHT,
@@ -602,9 +622,11 @@ static const struct pa_alsa_profile_info device_table[] = {
"surround71",
N_("Analog Surround 7.1"),
"analog-surround-71",
- 7 },
+ 7,
+ "Master", "PCM",
+ "Capture", "Mic" },
- {{ 0, { 0 }}, NULL, NULL, NULL, 0 }
+ {{ 0, { 0 }}, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL }
};
snd_pcm_t *pa_alsa_open_by_device_id_auto(
@@ -1095,7 +1117,8 @@ int pa_alsa_find_mixer_and_elem(
snd_pcm_t *pcm,
snd_mixer_t **_m,
snd_mixer_elem_t **_e,
- const char *control_name) {
+ const char *control_name,
+ const pa_alsa_profile_info *profile) {
int err;
snd_mixer_t *m;
@@ -1107,6 +1130,11 @@ int pa_alsa_find_mixer_and_elem(
pa_assert(_m);
pa_assert(_e);
+ if (control_name && *control_name == 0) {
+ pa_log_debug("Hardware mixer usage disabled because empty control name passed");
+ return -1;
+ }
+
if ((err = snd_mixer_open(&m, 0)) < 0) {
pa_log("Error opening mixer: %s", snd_strerror(err));
return -1;
@@ -1149,6 +1177,8 @@ int pa_alsa_find_mixer_and_elem(
case SND_PCM_STREAM_PLAYBACK:
if (control_name)
e = pa_alsa_find_elem(m, control_name, NULL, TRUE);
+ else if (profile)
+ e = pa_alsa_find_elem(m, profile->playback_control_name, profile->playback_control_fallback, TRUE);
else
e = pa_alsa_find_elem(m, "Master", "PCM", TRUE);
break;
@@ -1156,6 +1186,8 @@ int pa_alsa_find_mixer_and_elem(
case SND_PCM_STREAM_CAPTURE:
if (control_name)
e = pa_alsa_find_elem(m, control_name, NULL, FALSE);
+ else if (profile)
+ e = pa_alsa_find_elem(m, profile->record_control_name, profile->record_control_fallback, FALSE);
else
e = pa_alsa_find_elem(m, "Capture", "Mic", FALSE);
break;
@@ -1483,7 +1515,7 @@ void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *
pa_alsa_init_proplist_card(c, p, card);
}
-void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm) {
+void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm, snd_mixer_elem_t *elem) {
snd_pcm_hw_params_t *hwparams;
snd_pcm_info_t *info;
int bits, err;
@@ -1499,6 +1531,9 @@ void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm) {
pa_proplist_setf(p, "alsa.resolution_bits", "%i", bits);
}
+ if (elem)
+ pa_proplist_sets(p, "alsa.mixer_element", snd_mixer_selem_get_name(elem));
+
if ((err = snd_pcm_info(pcm, info)) < 0)
pa_log_warn("Error fetching PCM info: %s", snd_strerror(err));
else
diff --git a/src/modules/alsa/alsa-util.h b/src/modules/alsa/alsa-util.h
index 9fce6daf..c8acc7c9 100644
--- a/src/modules/alsa/alsa-util.h
+++ b/src/modules/alsa/alsa-util.h
@@ -53,18 +53,20 @@ int pa_alsa_set_hw_params(
int pa_alsa_set_sw_params(snd_pcm_t *pcm, snd_pcm_uframes_t avail_min);
-int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev);
-snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback, pa_bool_t playback);
-int pa_alsa_find_mixer_and_elem(snd_pcm_t *pcm, snd_mixer_t **_m, snd_mixer_elem_t **_e, const char *control_name);
-
typedef struct pa_alsa_profile_info {
pa_channel_map map;
const char *alsa_name;
const char *description; /* internationalized */
const char *name;
unsigned priority;
+ const char *playback_control_name, *playback_control_fallback;
+ const char *record_control_name, *record_control_fallback;
} pa_alsa_profile_info;
+int pa_alsa_prepare_mixer(snd_mixer_t *mixer, const char *dev);
+snd_mixer_elem_t *pa_alsa_find_elem(snd_mixer_t *mixer, const char *name, const char *fallback, pa_bool_t playback);
+int pa_alsa_find_mixer_and_elem(snd_pcm_t *pcm, snd_mixer_t **_m, snd_mixer_elem_t **_e, const char *control_name, const pa_alsa_profile_info*profile);
+
/* Picks a working profile based on the specified ss/map */
snd_pcm_t *pa_alsa_open_by_device_id_auto(
const char *dev_id,
@@ -123,7 +125,7 @@ void pa_alsa_redirect_errors_dec(void);
void pa_alsa_init_proplist_pcm_info(pa_core *c, pa_proplist *p, snd_pcm_info_t *pcm_info);
void pa_alsa_init_proplist_card(pa_core *c, pa_proplist *p, int card);
-void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm);
+void pa_alsa_init_proplist_pcm(pa_core *c, pa_proplist *p, snd_pcm_t *pcm, snd_mixer_elem_t *elem);
pa_bool_t pa_alsa_init_description(pa_proplist *p);
int pa_alsa_recover_from_poll(snd_pcm_t *pcm, int revents);
diff --git a/src/modules/module-cork-music-on-phone.c b/src/modules/module-cork-music-on-phone.c
index c0f5eea4..d3a2b00e 100644
--- a/src/modules/module-cork-music-on-phone.c
+++ b/src/modules/module-cork-music-on-phone.c
@@ -143,7 +143,6 @@ static pa_hook_result_t sink_input_put_cb(pa_core *core, pa_sink_input *i, struc
}
static pa_hook_result_t sink_input_unlink_cb(pa_core *core, pa_sink_input *i, struct userdata *u) {
- pa_core_assert_ref(core);
pa_sink_input_assert_ref(i);
return process(u, i, FALSE);
diff --git a/src/modules/module-device-restore.c b/src/modules/module-device-restore.c
index 0ca3dd83..7d87ca0f 100644
--- a/src/modules/module-device-restore.c
+++ b/src/modules/module-device-restore.c
@@ -191,7 +191,7 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
name = pa_sprintf_malloc("sink:%s", sink->name);
entry.channel_map = sink->channel_map;
- entry.volume = *pa_sink_get_volume(sink, FALSE);
+ entry.volume = *pa_sink_get_volume(sink, FALSE, TRUE);
entry.muted = pa_sink_get_mute(sink, FALSE);
} else {
diff --git a/src/modules/module-lirc.c b/src/modules/module-lirc.c
index bdb8bb71..a1a8726f 100644
--- a/src/modules/module-lirc.c
+++ b/src/modules/module-lirc.c
@@ -63,8 +63,6 @@ struct userdata {
float mute_toggle_save;
};
-static int lirc_in_use = 0;
-
static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event_flags_t events, void*userdata) {
struct userdata *u = userdata;
char *name = NULL, *code = NULL;
@@ -122,39 +120,39 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
pa_log("Failed to get sink '%s'", u->sink_name);
else {
int i;
- pa_cvolume cv = *pa_sink_get_volume(s, FALSE);
+ pa_cvolume cv = *pa_sink_get_volume(s, FALSE, FALSE);
#define DELTA (PA_VOLUME_NORM/20)
switch (volchange) {
case UP:
for (i = 0; i < cv.channels; i++) {
- cv.values[i] += DELTA;
-
- if (cv.values[i] > PA_VOLUME_NORM)
- cv.values[i] = PA_VOLUME_NORM;
+ if (cv.values[i] < PA_VOLUME_MAX - DELTA)
+ cv.values[i] += DELTA;
+ else
+ cv.values[i] = PA_VOLUME_MAX;
}
- pa_sink_set_volume(s, &cv, TRUE, TRUE);
+ pa_sink_set_volume(s, &cv, TRUE, TRUE, TRUE);
break;
case DOWN:
for (i = 0; i < cv.channels; i++) {
- if (cv.values[i] >= DELTA)
+ if (cv.values[i] > DELTA)
cv.values[i] -= DELTA;
else
cv.values[i] = PA_VOLUME_MUTED;
}
- pa_sink_set_volume(s, &cv, TRUE, TRUE);
+ pa_sink_set_volume(s, &cv, TRUE, TRUE, TRUE);
break;
case MUTE:
- pa_sink_set_mute(s, 0);
+ pa_sink_set_mute(s, TRUE);
break;
case RESET:
- pa_sink_set_mute(s, 1);
+ pa_sink_set_mute(s, FALSE);
break;
case MUTE_TOGGLE:
@@ -163,7 +161,7 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
break;
case INVALID:
- ;
+ pa_assert_not_reached();
}
}
}
@@ -189,11 +187,6 @@ int pa__init(pa_module*m) {
pa_assert(m);
- if (lirc_in_use) {
- pa_log("module-lirc may no be loaded twice.");
- return -1;
- }
-
if (!(ma = pa_modargs_new(m->argument, valid_modargs))) {
pa_log("Failed to parse module arguments");
goto fail;
@@ -219,8 +212,6 @@ int pa__init(pa_module*m) {
u->io = m->core->mainloop->io_new(m->core->mainloop, u->lirc_fd, PA_IO_EVENT_INPUT|PA_IO_EVENT_HANGUP, io_callback, u);
- lirc_in_use = 1;
-
pa_modargs_free(ma);
return 0;
@@ -252,6 +243,4 @@ void pa__done(pa_module*m) {
pa_xfree(u->sink_name);
pa_xfree(u);
-
- lirc_in_use = 0;
}
diff --git a/src/modules/module-match.c b/src/modules/module-match.c
index d7365ca7..625f2a8b 100644
--- a/src/modules/module-match.c
+++ b/src/modules/module-match.c
@@ -216,7 +216,7 @@ static void callback(pa_core *c, pa_subscription_event_type_t t, uint32_t idx, v
pa_cvolume cv;
pa_log_debug("changing volume of sink input '%s' to 0x%03x", n, r->volume);
pa_cvolume_set(&cv, si->sample_spec.channels, r->volume);
- pa_sink_input_set_volume(si, &cv, TRUE);
+ pa_sink_input_set_volume(si, &cv, TRUE, TRUE);
}
}
}
diff --git a/src/modules/module-mmkbd-evdev.c b/src/modules/module-mmkbd-evdev.c
index 2f87dd22..d8b9c79e 100644
--- a/src/modules/module-mmkbd-evdev.c
+++ b/src/modules/module-mmkbd-evdev.c
@@ -52,17 +52,6 @@ PA_MODULE_USAGE("device=<evdev device> sink=<sink name>");
#define DEFAULT_DEVICE "/dev/input/event0"
-/*
- * This isn't defined in older kernel headers and there is no way of
- * detecting it.
- */
-struct _input_id {
- __u16 bustype;
- __u16 vendor;
- __u16 product;
- __u16 version;
-};
-
static const char* const valid_modargs[] = {
"device",
"sink",
@@ -113,31 +102,31 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
pa_log("Failed to get sink '%s'", u->sink_name);
else {
int i;
- pa_cvolume cv = *pa_sink_get_volume(s, FALSE);
+ pa_cvolume cv = *pa_sink_get_volume(s, FALSE, FALSE);
#define DELTA (PA_VOLUME_NORM/20)
switch (volchange) {
case UP:
for (i = 0; i < cv.channels; i++) {
- cv.values[i] += DELTA;
-
- if (cv.values[i] > PA_VOLUME_NORM)
- cv.values[i] = PA_VOLUME_NORM;
+ if (cv.values[i] < PA_VOLUME_MAX - DELTA)
+ cv.values[i] += DELTA;
+ else
+ cv.values[i] = PA_VOLUME_MAX;
}
- pa_sink_set_volume(s, &cv, TRUE, TRUE);
+ pa_sink_set_volume(s, &cv, TRUE, TRUE, TRUE);
break;
case DOWN:
for (i = 0; i < cv.channels; i++) {
- if (cv.values[i] >= DELTA)
+ if (cv.values[i] > DELTA)
cv.values[i] -= DELTA;
else
cv.values[i] = PA_VOLUME_MUTED;
}
- pa_sink_set_volume(s, &cv, TRUE, TRUE);
+ pa_sink_set_volume(s, &cv, TRUE, TRUE, TRUE);
break;
case MUTE_TOGGLE:
@@ -146,7 +135,7 @@ static void io_callback(pa_mainloop_api *io, pa_io_event *e, int fd, pa_io_event
break;
case INVALID:
- ;
+ pa_assert_not_reached();
}
}
}
@@ -169,7 +158,7 @@ int pa__init(pa_module*m) {
pa_modargs *ma = NULL;
struct userdata *u;
int version;
- struct _input_id input_id;
+ struct input_id input_id;
char name[256];
uint8_t evtype_bitmask[EV_MAX/8 + 1];
@@ -180,15 +169,15 @@ int pa__init(pa_module*m) {
goto fail;
}
- m->userdata = u = pa_xnew(struct userdata,1);
+ m->userdata = u = pa_xnew(struct userdata, 1);
u->module = m;
u->io = NULL;
u->sink_name = pa_xstrdup(pa_modargs_get_value(ma, "sink", NULL));
u->fd = -1;
u->fd_type = 0;
- if ((u->fd = open(pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), O_RDONLY)) < 0) {
- pa_log("failed to open evdev device: %s", pa_cstrerror(errno));
+ if ((u->fd = open(pa_modargs_get_value(ma, "device", DEFAULT_DEVICE), O_RDONLY|O_NOCTTY)) < 0) {
+ pa_log("Failed to open evdev device: %s", pa_cstrerror(errno));
goto fail;
}
@@ -208,7 +197,7 @@ int pa__init(pa_module*m) {
input_id.vendor, input_id.product, input_id.version, input_id.bustype);
memset(name, 0, sizeof(name));
- if(ioctl(u->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
+ if (ioctl(u->fd, EVIOCGNAME(sizeof(name)), name) < 0) {
pa_log("EVIOCGNAME failed: %s", pa_cstrerror(errno));
goto fail;
}
diff --git a/src/modules/module-stream-restore.c b/src/modules/module-stream-restore.c
index 2c90e726..70cd89a7 100644
--- a/src/modules/module-stream-restore.c
+++ b/src/modules/module-stream-restore.c
@@ -91,15 +91,14 @@ struct userdata {
pa_idxset *subscribed;
};
-#define ENTRY_VERSION 1
+#define ENTRY_VERSION 2
struct entry {
uint8_t version;
- pa_bool_t muted_valid:1, relative_volume_valid:1, absolute_volume_valid:1, device_valid:1;
+ pa_bool_t muted_valid:1, volume_valid:1, device_valid:1;
pa_bool_t muted:1;
pa_channel_map channel_map;
- pa_cvolume relative_volume;
- pa_cvolume absolute_volume;
+ pa_cvolume volume;
char device[PA_NAME_MAX];
} PA_GCC_PACKED;
@@ -192,13 +191,12 @@ static struct entry* read_entry(struct userdata *u, const char *name) {
goto fail;
}
- if ((e->relative_volume_valid || e->absolute_volume_valid) && !pa_channel_map_valid(&e->channel_map)) {
+ if (e->volume_valid && !pa_channel_map_valid(&e->channel_map)) {
pa_log_warn("Invalid channel map stored in database for stream %s", name);
goto fail;
}
- if ((e->relative_volume_valid && (!pa_cvolume_valid(&e->relative_volume) || e->relative_volume.channels != e->channel_map.channels)) ||
- (e->absolute_volume_valid && (!pa_cvolume_valid(&e->absolute_volume) || e->absolute_volume.channels != e->channel_map.channels))) {
+ if (e->volume_valid && (!pa_cvolume_valid(&e->volume) || !pa_cvolume_compatible_with_channel_map(&e->volume, &e->channel_map))) {
pa_log_warn("Invalid volume stored in database for stream %s", name);
goto fail;
}
@@ -251,14 +249,9 @@ static pa_bool_t entries_equal(const struct entry *a, const struct entry *b) {
(a->muted_valid && (a->muted != b->muted)))
return FALSE;
- t = b->relative_volume;
- if (a->relative_volume_valid != b->relative_volume_valid ||
- (a->relative_volume_valid && !pa_cvolume_equal(pa_cvolume_remap(&t, &b->channel_map, &a->channel_map), &a->relative_volume)))
- return FALSE;
-
- t = b->absolute_volume;
- if (a->absolute_volume_valid != b->absolute_volume_valid ||
- (a->absolute_volume_valid && !pa_cvolume_equal(pa_cvolume_remap(&t, &b->channel_map, &a->channel_map), &a->absolute_volume)))
+ t = b->volume;
+ if (a->volume_valid != b->volume_valid ||
+ (a->volume_valid && !pa_cvolume_equal(pa_cvolume_remap(&t, &b->channel_map, &a->channel_map), &a->volume)))
return FALSE;
return TRUE;
@@ -291,22 +284,24 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (!(name = get_name(sink_input->proplist, "sink-input")))
return;
- entry.channel_map = sink_input->channel_map;
-
- pa_sink_input_get_relative_volume(sink_input, &entry.relative_volume);
- entry.relative_volume_valid = sink_input->save_volume;
+ if ((old = read_entry(u, name)))
+ entry = *old;
- if (sink_input->sink->flags & PA_SINK_FLAT_VOLUME) {
- entry.absolute_volume = *pa_sink_input_get_volume(sink_input);
- entry.absolute_volume_valid = sink_input->save_volume;
- } else
- entry.absolute_volume_valid = FALSE;
+ if (sink_input->save_volume) {
+ entry.channel_map = sink_input->channel_map;
+ pa_sink_input_get_volume(sink_input, &entry.volume, FALSE);
+ entry.volume_valid = TRUE;
+ }
- entry.muted = pa_sink_input_get_mute(sink_input);
- entry.muted_valid = sink_input->save_muted;
+ if (sink_input->save_muted) {
+ entry.muted = pa_sink_input_get_mute(sink_input);
+ entry.muted_valid = TRUE;
+ }
- pa_strlcpy(entry.device, sink_input->sink->name, sizeof(entry.device));
- entry.device_valid = sink_input->save_sink;
+ if (sink_input->save_sink) {
+ pa_strlcpy(entry.device, sink_input->sink->name, sizeof(entry.device));
+ entry.device_valid = TRUE;
+ }
} else {
pa_source_output *source_output;
@@ -319,13 +314,16 @@ static void subscribe_callback(pa_core *c, pa_subscription_event_type_t t, uint3
if (!(name = get_name(source_output->proplist, "source-output")))
return;
- entry.channel_map = source_output->channel_map;
+ if ((old = read_entry(u, name)))
+ entry = *old;
- pa_strlcpy(entry.device, source_output->source->name, sizeof(entry.device));
- entry.device_valid = source_output->save_source;
+ if (source_output->save_source) {
+ pa_strlcpy(entry.device, source_output->source->name, sizeof(entry.device));
+ entry.device_valid = source_output->save_source;
+ }
}
- if ((old = read_entry(u, name))) {
+ if (old) {
if (entries_equal(old, &entry)) {
pa_xfree(old);
@@ -400,42 +398,24 @@ static pa_hook_result_t sink_input_fixate_hook_callback(pa_core *c, pa_sink_inpu
if ((e = read_entry(u, name))) {
- if (u->restore_volume) {
+ if (u->restore_volume && e->volume_valid) {
if (!new_data->volume_is_set) {
pa_cvolume v;
- pa_cvolume_init(&v);
-
- if (new_data->sink->flags & PA_SINK_FLAT_VOLUME) {
-
- /* We don't check for e->device_valid here because
- that bit marks whether it is a good choice for
- restoring, not just if the data is filled in. */
- if (e->absolute_volume_valid &&
- (e->device[0] == 0 || pa_streq(new_data->sink->name, e->device))) {
-
- v = e->absolute_volume;
- new_data->volume_is_absolute = TRUE;
- } else if (e->relative_volume_valid) {
- v = e->relative_volume;
- new_data->volume_is_absolute = FALSE;
- }
-
- } else if (e->relative_volume_valid) {
- v = e->relative_volume;
- new_data->volume_is_absolute = FALSE;
- }
- if (v.channels > 0) {
- pa_log_info("Restoring volume for sink input %s.", name);
- pa_sink_input_new_data_set_volume(new_data, pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map));
- new_data->save_volume = TRUE;
- }
+ pa_log_info("Restoring volume for sink input %s.", name);
+ v = e->volume;
+ pa_cvolume_remap(&v, &e->channel_map, &new_data->channel_map);
+ pa_sink_input_new_data_set_volume(new_data, &v);
+
+ new_data->volume_is_absolute = FALSE;
+ new_data->save_volume = FALSE;
} else
pa_log_debug("Not restoring volume for sink input %s, because already set.", name);
}
if (u->restore_muted && e->muted_valid) {
+
if (!new_data->muted_is_set) {
pa_log_info("Restoring mute state for sink input %s.", name);
pa_sink_input_new_data_set_muted(new_data, e->muted);
@@ -532,30 +512,15 @@ static void apply_entry(struct userdata *u, const char *name, struct entry *e) {
}
pa_xfree(n);
- if (u->restore_volume) {
+ if (u->restore_volume && e->volume_valid) {
pa_cvolume v;
- pa_cvolume_init(&v);
- if (si->sink->flags & PA_SINK_FLAT_VOLUME) {
-
- if (e->absolute_volume_valid &&
- (e->device[0] == 0 || pa_streq(e->device, si->sink->name)))
- v = e->absolute_volume;
- else if (e->relative_volume_valid) {
- pa_cvolume t = *pa_sink_get_volume(si->sink, FALSE);
- pa_sw_cvolume_multiply(&v, &e->relative_volume, pa_cvolume_remap(&t, &si->sink->channel_map, &e->channel_map));
- }
- } else if (e->relative_volume_valid)
- v = e->relative_volume;
-
- if (v.channels > 0) {
- pa_log_info("Restoring volume for sink input %s.", name);
- pa_sink_input_set_volume(si, pa_cvolume_remap(&v, &e->channel_map, &si->channel_map), TRUE);
- }
+ v = e->volume;
+ pa_log_info("Restoring volume for sink input %s.", name);
+ pa_sink_input_set_volume(si, pa_cvolume_remap(&v, &e->channel_map, &si->channel_map), FALSE, FALSE);
}
- if (u->restore_muted &&
- e->muted_valid) {
+ if (u->restore_muted && e->muted_valid) {
pa_log_info("Restoring mute state for sink input %s.", name);
pa_sink_input_set_mute(si, e->muted, TRUE);
}
@@ -610,10 +575,10 @@ static void dump_database(struct userdata *u) {
if ((e = read_entry(u, name))) {
char t[256];
pa_log("name=%s", name);
- pa_log("device=%s", e->device);
+ pa_log("device=%s %s", e->device, pa_yes_no(e->device_valid));
pa_log("channel_map=%s", pa_channel_map_snprint(t, sizeof(t), &e->channel_map));
- pa_log("volume=%s", pa_cvolume_snprint(t, sizeof(t), &e->volume));
- pa_log("mute=%s", pa_yes_no(e->muted));
+ pa_log("volume=%s %s", pa_cvolume_snprint(t, sizeof(t), &e->volume), pa_yes_no(e->volume_valid));
+ pa_log("mute=%s %s", pa_yes_no(e->muted), pa_yes_no(e->volume_valid));
pa_xfree(e);
}
@@ -674,8 +639,8 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
pa_channel_map cm;
pa_tagstruct_puts(reply, name);
- pa_tagstruct_put_channel_map(reply, (e->relative_volume_valid || e->absolute_volume_valid) ? &e->channel_map : pa_channel_map_init(&cm));
- pa_tagstruct_put_cvolume(reply, e->absolute_volume_valid ? &e->absolute_volume : (e->relative_volume_valid ? &e->relative_volume : pa_cvolume_init(&r)));
+ pa_tagstruct_put_channel_map(reply, e->volume_valid ? &e->channel_map : pa_channel_map_init(&cm));
+ pa_tagstruct_put_cvolume(reply, e->volume_valid ? &e->volume : pa_cvolume_init(&r));
pa_tagstruct_puts(reply, e->device_valid ? e->device : NULL);
pa_tagstruct_put_boolean(reply, e->muted_valid ? e->muted : FALSE);
@@ -718,7 +683,7 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
if (pa_tagstruct_gets(t, &name) < 0 ||
pa_tagstruct_get_channel_map(t, &entry.channel_map) ||
- pa_tagstruct_get_cvolume(t, &entry.absolute_volume) < 0 ||
+ pa_tagstruct_get_cvolume(t, &entry.volume) < 0 ||
pa_tagstruct_gets(t, &device) < 0 ||
pa_tagstruct_get_boolean(t, &muted) < 0)
goto fail;
@@ -726,11 +691,10 @@ static int extension_cb(pa_native_protocol *p, pa_module *m, pa_native_connectio
if (!name || !*name)
goto fail;
- entry.relative_volume = entry.absolute_volume;
- entry.absolute_volume_valid = entry.relative_volume_valid = entry.relative_volume.channels > 0;
+ entry.volume_valid = entry.volume.channels > 0;
- if (entry.relative_volume_valid)
- if (!pa_cvolume_compatible_with_channel_map(&entry.relative_volume, &entry.channel_map))
+ if (entry.volume_valid)
+ if (!pa_cvolume_compatible_with_channel_map(&entry.volume, &entry.channel_map))
goto fail;
entry.muted = muted;
diff --git a/src/modules/module-x11-publish.c b/src/modules/module-x11-publish.c
index 83e69d1b..2c7fdc12 100644
--- a/src/modules/module-x11-publish.c
+++ b/src/modules/module-x11-publish.c
@@ -136,7 +136,7 @@ static void x11_kill_cb(pa_x11_wrapper *w, void *userdata) {
int pa__init(pa_module*m) {
struct userdata *u;
pa_modargs *ma = NULL;
- char *mid;
+ char *mid, *sid;
char hx[PA_NATIVE_COOKIE_LENGTH*2+1];
const char *t;
@@ -170,6 +170,11 @@ int pa__init(pa_module*m) {
pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_ID", u->id);
+ if ((sid = pa_session_id())) {
+ pa_x11_set_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SESSION_ID", sid);
+ pa_xfree(sid);
+ }
+
publish_servers(u, pa_native_protocol_servers(u->protocol));
if ((t = pa_modargs_get_value(ma, "source", NULL)))
@@ -219,6 +224,7 @@ void pa__done(pa_module*m) {
pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SINK");
pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SOURCE");
pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_COOKIE");
+ pa_x11_del_prop(pa_x11_wrapper_get_display(u->x11_wrapper), "PULSE_SESSION_ID");
XSync(pa_x11_wrapper_get_display(u->x11_wrapper), False);
}
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 855e8a35..9f7863f5 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -617,7 +617,7 @@ static int unsuspend(struct userdata *u) {
build_pollfd(u);
if (u->sink)
- pa_sink_get_volume(u->sink, TRUE);
+ pa_sink_get_volume(u->sink, TRUE, FALSE);
if (u->source)
pa_source_get_volume(u->source, TRUE);