Various upstream (sfos) fixes and avoid an assert on internal structure confusion caused by move to new upstream Pulseaudio that appears to do things differently, this will probably need revisiting

This commit is contained in:
Adam Boardman 2023-05-05 10:16:14 +01:00
parent f28da7fddf
commit 974ae573ad
5 changed files with 58 additions and 13 deletions

2
debian/changelog vendored
View file

@ -1,4 +1,4 @@
pulseaudio-modules-droid-modern (16.1.1+gemian1) unstable; urgency=medium
pulseaudio-modules-droid-modern (16.1.101+gemian1) unstable; urgency=medium
* New upstream nabbed from droidian

View file

@ -5,7 +5,7 @@
Name: pulseaudio-modules-droid
Summary: PulseAudio Droid HAL modules
Version: %{pulsemajorminor}.97
Version: %{pulsemajorminor}.101
Release: 1
License: LGPLv2+
URL: https://github.com/mer-hybris/pulseaudio-modules-droid

View file

@ -215,6 +215,12 @@ static const struct element_parser element_parse_attached_devices = {
&element_parse_item
};
/* Entries like
* <modules>
* <module name="primary"> <xi:include href="other.xml"/> </module>
* </modules>
* Where other.xml contains module elements
*/
static const struct element_parser element_parse_module_include = {
ELEMENT_include,
parse_module_include,
@ -223,11 +229,25 @@ static const struct element_parser element_parse_module_include = {
NULL
};
/* Entries like
* <modules>
* <xi:include href="other.xml"/>
* </modules>
* Where other.xml contains <module name="primary">...
*/
static const struct element_parser element_parse_modules_include = {
ELEMENT_include,
parse_module_include,
NULL,
NULL,
NULL
};
static const struct element_parser element_parse_module = {
ELEMENT_module,
parse_module,
NULL,
NULL,
&element_parse_modules_include,
&element_parse_module_include
};
@ -723,7 +743,7 @@ static bool parse_mix_port(struct parser_data *data, const char *element_name, c
/* maxActiveCount is not mandatory element attribute */
if (get_element_attr(data, attributes, false, ATTRIBUTE_maxActiveCount, &max_active_count))
pa_atoi(max_open_count, &p->max_active_count);
pa_atoi(max_active_count, &p->max_active_count);
parsed = true;
done:
@ -1007,6 +1027,27 @@ static dm_config_port *config_mix_port_new(dm_config_module *module,
return c_mix_port;
}
/* If a devicePort doesn't have any profiles defined let's just make something
* up that could work. */
static struct profile *default_profile(const char *role) {
struct profile *p;
bool output;
output = pa_safe_streq(role, PORT_TYPE_sink);
p = pa_xmalloc0(sizeof(*p));
p->name = pa_sprintf_malloc("generated-default");
pa_assert(pa_string_convert_str_to_num(CONV_STRING_FORMAT, "AUDIO_FORMAT_PCM_16_BIT", &p->format));
p->sampling_rates[0] = 48000;
pa_assert(pa_string_convert_str_to_num(output ? CONV_STRING_OUTPUT_CHANNELS : CONV_STRING_INPUT_CHANNELS,
output ? "AUDIO_CHANNEL_OUT_STEREO" : "AUDIO_CHANNEL_IN_STEREO",
&p->channel_masks[0]));
p->next = NULL;
return p;
}
static void generate_config_for_module(struct module *module, dm_config_device *config) {
dm_config_module *c_module;
struct mix_port *mix_port;
@ -1034,8 +1075,8 @@ static void generate_config_for_module(struct module *module, dm_config_device *
dm_config_port *c_device_port;
if (!device_port->profiles) {
pa_log("No profile defined for devicePort %s", device_port->tag_name);
continue;
pa_log_info("No profile defined for devicePort %s, generating default.", device_port->tag_name);
SLLIST_APPEND(struct profile, device_port->profiles, default_profile(device_port->role));
}
c_device_port = config_device_port_new(c_module, device_port);
@ -1181,8 +1222,8 @@ dm_config_device *pa_parse_droid_audio_config_xml(const char *filename) {
SLLIST_FOREACH(data.current_include, data.conf->includes) {
char *fn = NULL;
if (!data.current_include->module)
continue;
// if (!data.current_include->module)
// continue;
if (data.current_include->href[0] != '/')
fn = build_path(filename, data.current_include->href);

View file

@ -89,8 +89,9 @@ uint32_t conversion_table_input_channel[][2] = {
uint32_t conversion_table_format[][2] = {
{ PA_SAMPLE_U8, AUDIO_FORMAT_PCM_8_BIT },
{ PA_SAMPLE_S16LE, AUDIO_FORMAT_PCM_16_BIT },
{ PA_SAMPLE_S32LE, AUDIO_FORMAT_PCM_32_BIT },
{ PA_SAMPLE_S24LE, AUDIO_FORMAT_PCM_8_24_BIT }
{ PA_SAMPLE_S24_32LE, AUDIO_FORMAT_PCM_8_24_BIT },
{ PA_SAMPLE_S24LE, AUDIO_FORMAT_PCM_24_BIT_PACKED },
{ PA_SAMPLE_S32LE, AUDIO_FORMAT_PCM_32_BIT }
};
uint32_t conversion_table_default_audio_source[][2] = {

View file

@ -209,7 +209,7 @@ static pa_droid_mapping *droid_mapping_update(pa_droid_mapping *droid_mapping,
map = output_mapping ? profile_set->output_mappings : profile_set->input_mappings;
if (!(droid_mapping = pa_hashmap_get(map, mix_port->name))) {
pa_log_debug("New %s mapping \"%s\"", output_mapping ? "output" : "input", mix_port->name);
pa_log("New %s mapping \"%s\"", output_mapping ? "output" : "input", mix_port->name);
droid_mapping = pa_xnew0(pa_droid_mapping, 1);
droid_mapping->module = module;
@ -274,8 +274,10 @@ static void update_mapping(pa_droid_profile_set *profile_set,
droid_mapping = droid_mapping_update(droid_mapping, profile_set, module, sink, source);
} else {
pa_log("Internal data structures are confused, source pt: %d, sink pt: %d.", source->port_type, sink->port_type);
pa_assert_not_reached();
pa_log("Internal data structures are confused, source %s: %d, sink %s: %d.", source->name, source->port_type, sink->name, sink->port_type);
// GEMIAN - disabled assert as this totally stops things working, will need to revisit this later but for now this lets some audio out
//pa_assert_not_reached();
put = false;
}
@ -326,6 +328,7 @@ static void auto_add_profiles(pa_droid_profile_set *profile_set,
dm_config_port *source;
DM_LIST_FOREACH_DATA(source, route->sources, state2) {
pa_log("auto_add_profiles %s: %d, rt: %d, sink: %s", source->name, source->port_type, route->type, route->sink->name);
update_mapping(profile_set, profile, module, source, route->sink);
}
}