2009-01-15 18:29:16 +01:00
|
|
|
#ifndef foopulsecardhfoo
|
|
|
|
|
#define foopulsecardhfoo
|
|
|
|
|
|
|
|
|
|
/***
|
|
|
|
|
This file is part of PulseAudio.
|
|
|
|
|
|
|
|
|
|
Copyright 2009 Lennart Poettering
|
|
|
|
|
|
|
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Lesser General Public License as published
|
2009-03-03 20:23:02 +00:00
|
|
|
by the Free Software Foundation; either version 2.1 of the License,
|
2009-01-15 18:29:16 +01:00
|
|
|
or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
|
|
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
|
General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
2014-11-26 14:14:51 +01:00
|
|
|
along with PulseAudio; if not, see <http://www.gnu.org/licenses/>.
|
2009-01-15 18:29:16 +01:00
|
|
|
***/
|
|
|
|
|
|
2015-11-26 18:29:58 +01:00
|
|
|
#include <pulsecore/typedefs.h>
|
2009-01-15 18:29:16 +01:00
|
|
|
#include <pulse/proplist.h>
|
|
|
|
|
#include <pulsecore/core.h>
|
|
|
|
|
#include <pulsecore/module.h>
|
|
|
|
|
#include <pulsecore/idxset.h>
|
|
|
|
|
|
2013-02-18 16:13:24 +01:00
|
|
|
/* This enum replaces pa_port_available_t (defined in pulse/def.h) for
|
|
|
|
|
* internal use, so make sure both enum types stay in sync. */
|
|
|
|
|
typedef enum pa_available {
|
|
|
|
|
PA_AVAILABLE_UNKNOWN = 0,
|
|
|
|
|
PA_AVAILABLE_NO = 1,
|
|
|
|
|
PA_AVAILABLE_YES = 2,
|
|
|
|
|
} pa_available_t;
|
|
|
|
|
|
2015-11-26 18:29:58 +01:00
|
|
|
struct pa_card_profile {
|
2012-06-29 18:04:55 +03:00
|
|
|
pa_card *card;
|
2009-01-15 18:29:16 +01:00
|
|
|
char *name;
|
2009-01-17 02:03:35 +01:00
|
|
|
char *description;
|
2009-01-15 18:29:16 +01:00
|
|
|
|
2015-11-17 15:10:29 +01:00
|
|
|
/* Identifiers for the profile's input and output parts, i e, if two different profiles
|
|
|
|
|
have the same input_name string, they have the same source(s).
|
|
|
|
|
Same for output_name and sink(s).
|
|
|
|
|
Can be NULL (and in case of an input- or output- only profile, the other direction
|
|
|
|
|
will be NULL). */
|
|
|
|
|
char *input_name;
|
|
|
|
|
char *output_name;
|
|
|
|
|
|
2009-01-20 20:35:18 +01:00
|
|
|
unsigned priority;
|
2013-02-18 09:10:31 +01:00
|
|
|
pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */
|
2009-01-20 20:35:18 +01:00
|
|
|
|
2009-01-17 02:03:35 +01:00
|
|
|
/* We probably want to have different properties later on here */
|
2009-01-15 18:29:16 +01:00
|
|
|
unsigned n_sinks;
|
|
|
|
|
unsigned n_sources;
|
|
|
|
|
|
|
|
|
|
unsigned max_sink_channels;
|
|
|
|
|
unsigned max_source_channels;
|
2009-01-17 02:03:35 +01:00
|
|
|
|
|
|
|
|
/* .. followed by some implementation specific data */
|
2015-11-26 18:29:58 +01:00
|
|
|
};
|
2009-01-15 18:29:16 +01:00
|
|
|
|
2009-01-17 02:03:35 +01:00
|
|
|
#define PA_CARD_PROFILE_DATA(d) ((void*) ((uint8_t*) d + PA_ALIGN(sizeof(pa_card_profile))))
|
|
|
|
|
|
2009-01-15 18:29:16 +01:00
|
|
|
struct pa_card {
|
|
|
|
|
uint32_t index;
|
|
|
|
|
pa_core *core;
|
|
|
|
|
|
|
|
|
|
char *name;
|
|
|
|
|
|
|
|
|
|
pa_proplist *proplist;
|
|
|
|
|
pa_module *module;
|
|
|
|
|
char *driver;
|
|
|
|
|
|
|
|
|
|
pa_idxset *sinks;
|
|
|
|
|
pa_idxset *sources;
|
|
|
|
|
|
2009-01-15 23:44:46 +01:00
|
|
|
pa_hashmap *profiles;
|
|
|
|
|
pa_card_profile *active_profile;
|
2009-01-15 18:29:16 +01:00
|
|
|
|
2011-11-25 15:17:13 +01:00
|
|
|
pa_hashmap *ports;
|
2016-03-04 15:23:30 +02:00
|
|
|
pa_device_port *preferred_input_port;
|
|
|
|
|
pa_device_port *preferred_output_port;
|
2011-11-25 15:17:13 +01:00
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
bool save_profile:1;
|
2009-03-23 19:31:36 +01:00
|
|
|
|
2016-04-20 15:35:13 +03:00
|
|
|
pa_suspend_cause_t suspend_cause;
|
|
|
|
|
|
card: move profile selection after pa_card_new()
I want module-alsa-card to set the availability of unavailable
profiles before the initial card profile gets selected, so that the
selection logic can use correct availability information.
module-alsa-card initializes the jack state after calling
pa_card_new(), however, and the profile selection happens in
pa_card_new(). This patch solves that by moving parts of pa_card_new()
to pa_card_choose_initial_profile() and pa_card_put().
pa_card_choose_initial_profile() applies the profile selection policy,
so module-alsa-card can first call pa_card_new(), then initialize the
jack state, and then call pa_card_choose_initial_profile(). After that
module-alsa-card can still override the profile selection policy, in
case module-alsa-card was loaded with the "profile" argument. Finally,
pa_card_put() finalizes the card creation.
An alternative solution would have been to move the jack
initialization to happen before pa_card_new() and use pa_card_new_data
instead of pa_card in the jack initialization code, but I disliked
that idea (I want to get rid of the "new data" pattern eventually).
The order in which the initial profile policy is applied is reversed
in this patch. Previously the first one to set it won, now the last
one to set it wins. I think this is better, because if you have N
parties that want to set the profile, we avoid checking N times
whether someone else has already set the profile.
2015-10-23 12:59:53 +03:00
|
|
|
bool linked;
|
|
|
|
|
|
2009-01-15 18:29:16 +01:00
|
|
|
void *userdata;
|
|
|
|
|
|
2009-01-15 23:44:46 +01:00
|
|
|
int (*set_profile)(pa_card *c, pa_card_profile *profile);
|
2009-01-15 18:29:16 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
typedef struct pa_card_new_data {
|
|
|
|
|
char *name;
|
|
|
|
|
pa_proplist *proplist;
|
2009-06-17 03:16:13 +02:00
|
|
|
|
2009-01-15 18:29:16 +01:00
|
|
|
const char *driver;
|
|
|
|
|
pa_module *module;
|
|
|
|
|
|
2009-01-15 23:44:46 +01:00
|
|
|
pa_hashmap *profiles;
|
2011-11-25 15:17:13 +01:00
|
|
|
pa_hashmap *ports;
|
2016-03-04 15:23:30 +02:00
|
|
|
pa_device_port *preferred_input_port;
|
|
|
|
|
pa_device_port *preferred_output_port;
|
2011-11-25 15:17:13 +01:00
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
bool namereg_fail:1;
|
2009-01-15 18:29:16 +01:00
|
|
|
} pa_card_new_data;
|
|
|
|
|
|
2016-03-04 15:23:30 +02:00
|
|
|
typedef struct {
|
|
|
|
|
pa_card *card;
|
|
|
|
|
pa_direction_t direction;
|
|
|
|
|
} pa_card_preferred_port_changed_hook_data;
|
|
|
|
|
|
2009-01-17 02:03:35 +01:00
|
|
|
pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra);
|
2009-01-15 23:44:46 +01:00
|
|
|
void pa_card_profile_free(pa_card_profile *c);
|
2009-01-15 18:29:16 +01:00
|
|
|
|
2013-02-18 09:10:31 +01:00
|
|
|
/* The profile's available status has changed */
|
|
|
|
|
void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available);
|
|
|
|
|
|
2009-01-15 18:29:16 +01:00
|
|
|
pa_card_new_data *pa_card_new_data_init(pa_card_new_data *data);
|
|
|
|
|
void pa_card_new_data_set_name(pa_card_new_data *data, const char *name);
|
2016-03-04 15:23:30 +02:00
|
|
|
void pa_card_new_data_set_preferred_port(pa_card_new_data *data, pa_direction_t direction, pa_device_port *port);
|
2009-01-15 18:29:16 +01:00
|
|
|
void pa_card_new_data_done(pa_card_new_data *data);
|
|
|
|
|
|
|
|
|
|
pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);
|
card: move profile selection after pa_card_new()
I want module-alsa-card to set the availability of unavailable
profiles before the initial card profile gets selected, so that the
selection logic can use correct availability information.
module-alsa-card initializes the jack state after calling
pa_card_new(), however, and the profile selection happens in
pa_card_new(). This patch solves that by moving parts of pa_card_new()
to pa_card_choose_initial_profile() and pa_card_put().
pa_card_choose_initial_profile() applies the profile selection policy,
so module-alsa-card can first call pa_card_new(), then initialize the
jack state, and then call pa_card_choose_initial_profile(). After that
module-alsa-card can still override the profile selection policy, in
case module-alsa-card was loaded with the "profile" argument. Finally,
pa_card_put() finalizes the card creation.
An alternative solution would have been to move the jack
initialization to happen before pa_card_new() and use pa_card_new_data
instead of pa_card in the jack initialization code, but I disliked
that idea (I want to get rid of the "new data" pattern eventually).
The order in which the initial profile policy is applied is reversed
in this patch. Previously the first one to set it won, now the last
one to set it wins. I think this is better, because if you have N
parties that want to set the profile, we avoid checking N times
whether someone else has already set the profile.
2015-10-23 12:59:53 +03:00
|
|
|
|
|
|
|
|
/* Select the initial card profile according to the configured policies. This
|
|
|
|
|
* must be called between pa_card_new() and pa_card_put(), after the port and
|
2018-08-07 20:39:24 -07:00
|
|
|
* profile availabilities have been initialized. */
|
card: move profile selection after pa_card_new()
I want module-alsa-card to set the availability of unavailable
profiles before the initial card profile gets selected, so that the
selection logic can use correct availability information.
module-alsa-card initializes the jack state after calling
pa_card_new(), however, and the profile selection happens in
pa_card_new(). This patch solves that by moving parts of pa_card_new()
to pa_card_choose_initial_profile() and pa_card_put().
pa_card_choose_initial_profile() applies the profile selection policy,
so module-alsa-card can first call pa_card_new(), then initialize the
jack state, and then call pa_card_choose_initial_profile(). After that
module-alsa-card can still override the profile selection policy, in
case module-alsa-card was loaded with the "profile" argument. Finally,
pa_card_put() finalizes the card creation.
An alternative solution would have been to move the jack
initialization to happen before pa_card_new() and use pa_card_new_data
instead of pa_card in the jack initialization code, but I disliked
that idea (I want to get rid of the "new data" pattern eventually).
The order in which the initial profile policy is applied is reversed
in this patch. Previously the first one to set it won, now the last
one to set it wins. I think this is better, because if you have N
parties that want to set the profile, we avoid checking N times
whether someone else has already set the profile.
2015-10-23 12:59:53 +03:00
|
|
|
void pa_card_choose_initial_profile(pa_card *card);
|
|
|
|
|
|
|
|
|
|
void pa_card_put(pa_card *c);
|
2009-01-15 18:29:16 +01:00
|
|
|
void pa_card_free(pa_card *c);
|
|
|
|
|
|
2012-10-23 16:41:55 +02:00
|
|
|
void pa_card_add_profile(pa_card *c, pa_card_profile *profile);
|
|
|
|
|
|
2013-11-20 15:42:26 +02:00
|
|
|
int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save);
|
2009-01-15 18:29:16 +01:00
|
|
|
|
2016-03-04 15:23:30 +02:00
|
|
|
void pa_card_set_preferred_port(pa_card *c, pa_direction_t direction, pa_device_port *port);
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
int pa_card_suspend(pa_card *c, bool suspend, pa_suspend_cause_t cause);
|
2009-01-22 00:17:11 +01:00
|
|
|
|
2009-01-15 18:29:16 +01:00
|
|
|
#endif
|