common: Implement stream handling using device and mix ports.
This commit is contained in:
parent
0b1221a047
commit
b08cc4d219
2 changed files with 930 additions and 796 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -2,7 +2,7 @@
|
||||||
#define foodroidutilfoo
|
#define foodroidutilfoo
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2013-2018 Jolla Ltd.
|
* Copyright (C) 2013-2022 Jolla Ltd.
|
||||||
*
|
*
|
||||||
* Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
|
* Contact: Juho Hämäläinen <juho.hamalainen@jolla.com>
|
||||||
*
|
*
|
||||||
|
|
@ -44,8 +44,10 @@
|
||||||
#define PROP_DROID_OUTPUT_LOW_LATENCY "droid.output.low_latency"
|
#define PROP_DROID_OUTPUT_LOW_LATENCY "droid.output.low_latency"
|
||||||
#define PROP_DROID_OUTPUT_MEDIA_LATENCY "droid.output.media_latency"
|
#define PROP_DROID_OUTPUT_MEDIA_LATENCY "droid.output.media_latency"
|
||||||
#define PROP_DROID_OUTPUT_OFFLOAD "droid.output.offload"
|
#define PROP_DROID_OUTPUT_OFFLOAD "droid.output.offload"
|
||||||
|
#define PROP_DROID_OUTPUT_VOIP "droid.output.voip"
|
||||||
#define PROP_DROID_INPUT_BUILTIN "droid.input.builtin"
|
#define PROP_DROID_INPUT_BUILTIN "droid.input.builtin"
|
||||||
#define PROP_DROID_INPUT_EXTERNAL "droid.input.external"
|
#define PROP_DROID_INPUT_EXTERNAL "droid.input.external"
|
||||||
|
#define PROP_DROID_INPUT_VOIP "droid.input.voip"
|
||||||
|
|
||||||
#define EXT_PROP_AUDIO_SOURCE "audio.source"
|
#define EXT_PROP_AUDIO_SOURCE "audio.source"
|
||||||
|
|
||||||
|
|
@ -85,8 +87,8 @@ struct pa_droid_hw_module {
|
||||||
pa_core *core;
|
pa_core *core;
|
||||||
char *shared_name;
|
char *shared_name;
|
||||||
|
|
||||||
pa_droid_config_audio *config;
|
dm_config_device *config;
|
||||||
const pa_droid_config_hw_module *enabled_module;
|
dm_config_module *enabled_module;
|
||||||
pa_mutex *hw_mutex;
|
pa_mutex *hw_mutex;
|
||||||
pa_mutex *output_mutex;
|
pa_mutex *output_mutex;
|
||||||
pa_mutex *input_mutex;
|
pa_mutex *input_mutex;
|
||||||
|
|
@ -96,8 +98,8 @@ struct pa_droid_hw_module {
|
||||||
|
|
||||||
const char *module_id;
|
const char *module_id;
|
||||||
|
|
||||||
uint32_t stream_out_id;
|
uint32_t stream_id;
|
||||||
uint32_t stream_in_id;
|
bool bt_sco_enabled;
|
||||||
|
|
||||||
pa_idxset *outputs;
|
pa_idxset *outputs;
|
||||||
pa_idxset *inputs;
|
pa_idxset *inputs;
|
||||||
|
|
@ -111,9 +113,6 @@ struct pa_droid_hw_module {
|
||||||
/* Mode and input control */
|
/* Mode and input control */
|
||||||
struct _state {
|
struct _state {
|
||||||
audio_mode_t mode;
|
audio_mode_t mode;
|
||||||
audio_devices_t input_device;
|
|
||||||
audio_source_t audio_source;
|
|
||||||
pa_droid_stream *active_input;
|
|
||||||
} state;
|
} state;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -121,8 +120,6 @@ struct pa_droid_output_stream {
|
||||||
struct audio_stream_out *stream;
|
struct audio_stream_out *stream;
|
||||||
pa_sample_spec sample_spec;
|
pa_sample_spec sample_spec;
|
||||||
pa_channel_map channel_map;
|
pa_channel_map channel_map;
|
||||||
uint32_t flags;
|
|
||||||
uint32_t device;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct pa_droid_input_stream {
|
struct pa_droid_input_stream {
|
||||||
|
|
@ -133,6 +130,12 @@ struct pa_droid_input_stream {
|
||||||
pa_channel_map channel_map;
|
pa_channel_map channel_map;
|
||||||
pa_sample_spec req_sample_spec;
|
pa_sample_spec req_sample_spec;
|
||||||
pa_channel_map req_channel_map;
|
pa_channel_map req_channel_map;
|
||||||
|
|
||||||
|
audio_source_t audio_source;
|
||||||
|
dm_config_port *default_mix_port;
|
||||||
|
dm_config_port *input_port;
|
||||||
|
pa_droid_stream *active_input;
|
||||||
|
|
||||||
uint32_t flags;
|
uint32_t flags;
|
||||||
uint32_t device;
|
uint32_t device;
|
||||||
bool first;
|
bool first;
|
||||||
|
|
@ -142,10 +145,14 @@ struct pa_droid_stream {
|
||||||
PA_REFCNT_DECLARE;
|
PA_REFCNT_DECLARE;
|
||||||
|
|
||||||
pa_droid_hw_module *module;
|
pa_droid_hw_module *module;
|
||||||
const pa_droid_config_device *device_def;
|
dm_config_port *mix_port;
|
||||||
size_t buffer_size;
|
size_t buffer_size;
|
||||||
void *data;
|
void *data;
|
||||||
|
|
||||||
|
audio_io_handle_t io_handle;
|
||||||
|
audio_patch_handle_t audio_patch;
|
||||||
|
const dm_config_port *active_device_port;
|
||||||
|
|
||||||
pa_droid_output_stream *output;
|
pa_droid_output_stream *output;
|
||||||
pa_droid_input_stream *input;
|
pa_droid_input_stream *input;
|
||||||
};
|
};
|
||||||
|
|
@ -162,13 +169,13 @@ typedef struct pa_droid_profile_set pa_droid_profile_set;
|
||||||
typedef struct pa_droid_mapping pa_droid_mapping;
|
typedef struct pa_droid_mapping pa_droid_mapping;
|
||||||
|
|
||||||
typedef struct pa_droid_port_data {
|
typedef struct pa_droid_port_data {
|
||||||
audio_devices_t device;
|
dm_config_port *device_port;
|
||||||
} pa_droid_port_data;
|
} pa_droid_port_data;
|
||||||
|
|
||||||
typedef struct pa_droid_port {
|
typedef struct pa_droid_port {
|
||||||
pa_droid_mapping *mapping;
|
pa_droid_mapping *mapping;
|
||||||
|
|
||||||
audio_devices_t device;
|
dm_config_port *device_port;
|
||||||
char *name;
|
char *name;
|
||||||
char *description;
|
char *description;
|
||||||
unsigned priority;
|
unsigned priority;
|
||||||
|
|
@ -177,9 +184,9 @@ typedef struct pa_droid_port {
|
||||||
struct pa_droid_mapping {
|
struct pa_droid_mapping {
|
||||||
pa_droid_profile_set *profile_set;
|
pa_droid_profile_set *profile_set;
|
||||||
|
|
||||||
const pa_droid_config_device *output;
|
dm_config_module *module;
|
||||||
/* Use all devices in one input */
|
dm_config_port *mix_port;
|
||||||
const pa_droid_config_device *inputs;
|
dm_list *device_ports;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
char *description;
|
char *description;
|
||||||
|
|
@ -198,7 +205,7 @@ struct pa_droid_mapping {
|
||||||
typedef struct pa_droid_profile {
|
typedef struct pa_droid_profile {
|
||||||
pa_droid_profile_set *profile_set;
|
pa_droid_profile_set *profile_set;
|
||||||
|
|
||||||
const pa_droid_config_hw_module *module;
|
dm_config_module *module;
|
||||||
|
|
||||||
char *name;
|
char *name;
|
||||||
char *description;
|
char *description;
|
||||||
|
|
@ -210,12 +217,13 @@ typedef struct pa_droid_profile {
|
||||||
* hashmaps. */
|
* hashmaps. */
|
||||||
pa_idxset *output_mappings;
|
pa_idxset *output_mappings;
|
||||||
/* Only one input */
|
/* Only one input */
|
||||||
|
pa_idxset *input_mappings;
|
||||||
pa_droid_mapping *input_mapping;
|
pa_droid_mapping *input_mapping;
|
||||||
|
|
||||||
} pa_droid_profile;
|
} pa_droid_profile;
|
||||||
|
|
||||||
struct pa_droid_profile_set {
|
struct pa_droid_profile_set {
|
||||||
const pa_droid_config_audio *config;
|
dm_config_device *config;
|
||||||
|
|
||||||
pa_hashmap *all_ports;
|
pa_hashmap *all_ports;
|
||||||
pa_hashmap *output_mappings;
|
pa_hashmap *output_mappings;
|
||||||
|
|
@ -228,8 +236,8 @@ struct pa_droid_profile_set {
|
||||||
|
|
||||||
/* Open hardware module */
|
/* Open hardware module */
|
||||||
/* 'config' can be NULL if it is assumed that hw module with module_id already is open. */
|
/* 'config' can be NULL if it is assumed that hw module with module_id already is open. */
|
||||||
pa_droid_hw_module *pa_droid_hw_module_get(pa_core *core, const pa_droid_config_audio *config, const char *module_id);
|
pa_droid_hw_module *pa_droid_hw_module_get(pa_core *core, dm_config_device *config, const char *module_id);
|
||||||
/* First try to get already open hw module and if none found parse config and quirks from modargs
|
/* First try to get already open hw module and if none found parse config and options from modargs
|
||||||
* and do initial open. */
|
* and do initial open. */
|
||||||
pa_droid_hw_module *pa_droid_hw_module_get2(pa_core *core, pa_modargs *ma, const char *module_id);
|
pa_droid_hw_module *pa_droid_hw_module_get2(pa_core *core, pa_modargs *ma, const char *module_id);
|
||||||
pa_droid_hw_module *pa_droid_hw_module_ref(pa_droid_hw_module *hw);
|
pa_droid_hw_module *pa_droid_hw_module_ref(pa_droid_hw_module *hw);
|
||||||
|
|
@ -239,8 +247,7 @@ void pa_droid_hw_module_lock(pa_droid_hw_module *hw);
|
||||||
bool pa_droid_hw_module_try_lock(pa_droid_hw_module *hw);
|
bool pa_droid_hw_module_try_lock(pa_droid_hw_module *hw);
|
||||||
void pa_droid_hw_module_unlock(pa_droid_hw_module *hw);
|
void pa_droid_hw_module_unlock(pa_droid_hw_module *hw);
|
||||||
|
|
||||||
bool pa_droid_quirk_parse(pa_droid_quirks *quirks, const char *quirks_def);
|
void pa_droid_options_log(pa_droid_hw_module *hw);
|
||||||
void pa_droid_quirk_log(pa_droid_hw_module *hw);
|
|
||||||
|
|
||||||
static inline bool pa_droid_option(pa_droid_hw_module *hw, enum pa_droid_option_type option) {
|
static inline bool pa_droid_option(pa_droid_hw_module *hw, enum pa_droid_option_type option) {
|
||||||
return hw && hw->options.enabled[option];
|
return hw && hw->options.enabled[option];
|
||||||
|
|
@ -252,14 +259,11 @@ int pa_droid_hw_mic_get_mute(pa_droid_hw_module *hw_module, bool *muted);
|
||||||
void pa_droid_hw_mic_set_mute(pa_droid_hw_module *hw_module, bool muted);
|
void pa_droid_hw_mic_set_mute(pa_droid_hw_module *hw_module, bool muted);
|
||||||
|
|
||||||
/* Profiles */
|
/* Profiles */
|
||||||
pa_droid_profile_set *pa_droid_profile_set_new(const pa_droid_config_hw_module *module);
|
pa_droid_profile_set *pa_droid_profile_set_default_new(dm_config_module *module);
|
||||||
pa_droid_profile_set *pa_droid_profile_set_default_new(const pa_droid_config_hw_module *module);
|
|
||||||
void pa_droid_profile_set_free(pa_droid_profile_set *ps);
|
void pa_droid_profile_set_free(pa_droid_profile_set *ps);
|
||||||
|
|
||||||
void pa_droid_profile_add_mapping(pa_droid_profile *p, pa_droid_mapping *am);
|
|
||||||
void pa_droid_profile_free(pa_droid_profile *p);
|
void pa_droid_profile_free(pa_droid_profile *p);
|
||||||
|
|
||||||
pa_droid_mapping *pa_droid_mapping_get(pa_droid_profile_set *ps, const pa_droid_config_device *device);
|
|
||||||
bool pa_droid_mapping_is_primary(pa_droid_mapping *am);
|
bool pa_droid_mapping_is_primary(pa_droid_mapping *am);
|
||||||
/* Go through idxset containing pa_droid_mapping objects and if primary output or input
|
/* Go through idxset containing pa_droid_mapping objects and if primary output or input
|
||||||
* mapping is found, return pointer to that mapping. */
|
* mapping is found, return pointer to that mapping. */
|
||||||
|
|
@ -287,8 +291,8 @@ int pa_droid_stream_set_parameters(pa_droid_stream *s, const char *parameters);
|
||||||
pa_droid_stream *pa_droid_open_output_stream(pa_droid_hw_module *module,
|
pa_droid_stream *pa_droid_open_output_stream(pa_droid_hw_module *module,
|
||||||
const pa_sample_spec *spec,
|
const pa_sample_spec *spec,
|
||||||
const pa_channel_map *map,
|
const pa_channel_map *map,
|
||||||
const char *module_output_name,
|
dm_config_port *mix_port,
|
||||||
audio_devices_t devices);
|
dm_config_port *device_port);
|
||||||
|
|
||||||
/* Set routing to the input or output stream, with following side-effects:
|
/* Set routing to the input or output stream, with following side-effects:
|
||||||
* Output:
|
* Output:
|
||||||
|
|
@ -299,13 +303,14 @@ pa_droid_stream *pa_droid_open_output_stream(pa_droid_hw_module *module,
|
||||||
* Input:
|
* Input:
|
||||||
* - buffer size or channel count may change
|
* - buffer size or channel count may change
|
||||||
*/
|
*/
|
||||||
int pa_droid_stream_set_route(pa_droid_stream *s, audio_devices_t device);
|
int pa_droid_stream_set_route(pa_droid_stream *s, dm_config_port *device_port);
|
||||||
|
|
||||||
/* Open input stream with currently active routing, sample_spec and channel_map
|
/* Open input stream with currently active routing, sample_spec and channel_map
|
||||||
* are requests and may change when opening the stream. */
|
* are requests and may change when opening the stream. */
|
||||||
pa_droid_stream *pa_droid_open_input_stream(pa_droid_hw_module *hw_module,
|
pa_droid_stream *pa_droid_open_input_stream(pa_droid_hw_module *hw_module,
|
||||||
const pa_sample_spec *default_sample_spec,
|
const pa_sample_spec *default_sample_spec,
|
||||||
const pa_channel_map *default_channel_map);
|
const pa_channel_map *default_channel_map,
|
||||||
|
const char *mix_port_name);
|
||||||
/* Test if reconfiguring of input stream is needed */
|
/* Test if reconfiguring of input stream is needed */
|
||||||
bool pa_droid_stream_reconfigure_input_needed(pa_droid_stream *s,
|
bool pa_droid_stream_reconfigure_input_needed(pa_droid_stream *s,
|
||||||
const pa_sample_spec *requested_sample_spec,
|
const pa_sample_spec *requested_sample_spec,
|
||||||
|
|
@ -315,8 +320,8 @@ bool pa_droid_stream_reconfigure_input(pa_droid_stream *s,
|
||||||
const pa_sample_spec *requested_sample_spec,
|
const pa_sample_spec *requested_sample_spec,
|
||||||
const pa_channel_map *requested_channel_map,
|
const pa_channel_map *requested_channel_map,
|
||||||
const pa_proplist *proplist);
|
const pa_proplist *proplist);
|
||||||
bool pa_droid_hw_set_input_device(pa_droid_hw_module *hw_module,
|
bool pa_droid_hw_set_input_device(pa_droid_stream *s,
|
||||||
audio_devices_t device);
|
dm_config_port *device_port);
|
||||||
|
|
||||||
const pa_sample_spec *pa_droid_stream_sample_spec(pa_droid_stream *stream);
|
const pa_sample_spec *pa_droid_stream_sample_spec(pa_droid_stream *stream);
|
||||||
const pa_channel_map *pa_droid_stream_channel_map(pa_droid_stream *stream);
|
const pa_channel_map *pa_droid_stream_channel_map(pa_droid_stream *stream);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue