static void source_get_volume_cb(pa_source *s) {
struct userdata *u = s->userdata;
pa_cvolume r;
- char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX];
+ char volume_buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
pa_assert(u);
pa_assert(u->mixer_path);
/* Shift down by the base volume, so that 0dB becomes maximum volume */
pa_sw_cvolume_multiply_scalar(&r, &r, s->base_volume);
- pa_log_debug("Read hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &r));
-
- if (u->mixer_path->has_dB) {
- char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX];
-
- pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &r));
- }
+ pa_log_debug("Read hardware volume: %s",
+ pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &r, &s->channel_map, u->mixer_path->has_dB));
if (pa_cvolume_equal(&u->hardware_volume, &r))
return;
static void source_set_volume_cb(pa_source *s) {
struct userdata *u = s->userdata;
pa_cvolume r;
- char vol_str_pcnt[PA_CVOLUME_SNPRINT_MAX];
+ char volume_buf[PA_CVOLUME_SNPRINT_VERBOSE_MAX];
bool deferred_volume = !!(s->flags & PA_SOURCE_DEFERRED_VOLUME);
pa_assert(u);
if (u->mixer_path->has_dB) {
pa_cvolume new_soft_volume;
bool accurate_enough;
- char vol_str_db[PA_SW_CVOLUME_SNPRINT_DB_MAX];
/* Match exactly what the user requested by software */
pa_sw_cvolume_divide(&new_soft_volume, &s->real_volume, &u->hardware_volume);
(pa_cvolume_min(&new_soft_volume) >= (PA_VOLUME_NORM - VOLUME_ACCURACY)) &&
(pa_cvolume_max(&new_soft_volume) <= (PA_VOLUME_NORM + VOLUME_ACCURACY));
- pa_log_debug("Requested volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &s->real_volume));
- pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &s->real_volume));
- pa_log_debug("Got hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &u->hardware_volume));
- pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &u->hardware_volume));
+ pa_log_debug("Requested volume: %s",
+ pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &s->real_volume, &s->channel_map, true));
+ pa_log_debug("Got hardware volume: %s",
+ pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &u->hardware_volume, &s->channel_map, true));
pa_log_debug("Calculated software volume: %s (accurate-enough=%s)",
- pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &new_soft_volume),
+ pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &new_soft_volume, &s->channel_map, true),
pa_yes_no(accurate_enough));
- pa_log_debug(" in dB: %s", pa_sw_cvolume_snprint_dB(vol_str_db, sizeof(vol_str_db), &new_soft_volume));
if (!accurate_enough)
s->soft_volume = new_soft_volume;
} else {
- pa_log_debug("Wrote hardware volume: %s", pa_cvolume_snprint(vol_str_pcnt, sizeof(vol_str_pcnt), &r));
+ pa_log_debug("Wrote hardware volume: %s",
+ pa_cvolume_snprint_verbose(volume_buf, sizeof(volume_buf), &r, &s->channel_map, false));
/* We can't match exactly what the user requested, hence let's
* at least tell the user about it */
(pa_cvolume_max(&tmp_vol) <= (PA_VOLUME_NORM + VOLUME_ACCURACY));
if (!accurate_enough) {
- union {
- char db[2][PA_SW_CVOLUME_SNPRINT_DB_MAX];
- char pcnt[2][PA_CVOLUME_SNPRINT_MAX];
- } vol;
+ char volume_buf[2][PA_CVOLUME_SNPRINT_VERBOSE_MAX];
pa_log_debug("Written HW volume did not match with the request: %s (request) != %s",
- pa_cvolume_snprint(vol.pcnt[0], sizeof(vol.pcnt[0]), &s->thread_info.current_hw_volume),
- pa_cvolume_snprint(vol.pcnt[1], sizeof(vol.pcnt[1]), &hw_vol));
- pa_log_debug(" in dB: %s (request) != %s",
- pa_sw_cvolume_snprint_dB(vol.db[0], sizeof(vol.db[0]), &s->thread_info.current_hw_volume),
- pa_sw_cvolume_snprint_dB(vol.db[1], sizeof(vol.db[1]), &hw_vol));
+ pa_cvolume_snprint_verbose(volume_buf[0],
+ sizeof(volume_buf[0]),
+ &s->thread_info.current_hw_volume,
+ &s->channel_map,
+ true),
+ pa_cvolume_snprint_verbose(volume_buf[1], sizeof(volume_buf[1]), &hw_vol, &s->channel_map, true));
}
}
}
update_sw_params(u);
}
-static bool source_update_rate_cb(pa_source *s, uint32_t rate) {
+static int source_update_rate_cb(pa_source *s, uint32_t rate) {
struct userdata *u = s->userdata;
int i;
bool supported = false;
if (!supported) {
pa_log_info("Source does not support sample rate of %d Hz", rate);
- return false;
+ return -1;
}
if (!PA_SOURCE_IS_OPENED(s->state)) {
pa_log_info("Updating rate for device %s, new rate is %d", u->device_name, rate);
u->source->sample_spec.rate = rate;
- return true;
+ return 0;
}
- return false;
+ return -1;
}
static void thread_func(void *userdata) {
ss = m->core->default_sample_spec;
map = m->core->default_channel_map;
+
+ /* Pick sample spec overrides from the mapping, if any */
+ if (mapping) {
+ if (mapping->sample_spec.format != PA_SAMPLE_INVALID)
+ ss.format = mapping->sample_spec.format;
+ if (mapping->sample_spec.rate != 0)
+ ss.rate = mapping->sample_spec.rate;
+ if (mapping->sample_spec.channels != 0) {
+ ss.channels = mapping->sample_spec.channels;
+ if (pa_channel_map_valid(&mapping->channel_map))
+ pa_assert(pa_channel_map_compatible(&mapping->channel_map, &ss));
+ }
+ }
+
+ /* Override with modargs if provided */
if (pa_modargs_get_sample_spec_and_channel_map(ma, &ss, &map, PA_CHANNEL_MAP_ALSA) < 0) {
pa_log("Failed to parse sample specification and channel map");
goto fail;
pa_proplist_sets(data.proplist, key, pa_proplist_gets(mapping->proplist, key));
}
- pa_alsa_init_description(data.proplist);
+ pa_alsa_init_description(data.proplist, card);
if (u->control_device)
pa_alsa_init_proplist_ctl(data.proplist, u->control_device);