2004-06-08 23:54:24 +00:00
|
|
|
#ifndef foocorehfoo
|
|
|
|
|
#define foocorehfoo
|
|
|
|
|
|
2004-07-16 19:56:36 +00:00
|
|
|
/***
|
2006-06-19 21:53:48 +00:00
|
|
|
This file is part of PulseAudio.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2007-02-13 15:35:19 +00:00
|
|
|
Copyright 2004-2006 Lennart Poettering
|
|
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is free software; you can redistribute it and/or modify
|
2004-11-14 14:58:54 +00:00
|
|
|
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,
|
2004-07-16 19:56:36 +00:00
|
|
|
or (at your option) any later version.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-06-19 21:53:48 +00:00
|
|
|
PulseAudio is distributed in the hope that it will be useful, but
|
2004-07-16 19:56:36 +00:00
|
|
|
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.
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2004-11-14 14:58:54 +00:00
|
|
|
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/>.
|
2004-07-16 19:56:36 +00:00
|
|
|
***/
|
|
|
|
|
|
2015-11-26 18:29:58 +01:00
|
|
|
#include <pulsecore/typedefs.h>
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulse/mainloop-api.h>
|
|
|
|
|
#include <pulse/sample.h>
|
2010-09-14 15:21:49 +05:30
|
|
|
#include <pulsecore/cpu.h>
|
2006-08-13 16:19:56 +00:00
|
|
|
|
2009-06-05 19:05:07 +02:00
|
|
|
/* This is a bitmask that encodes the cause why a sink/source is
|
2017-12-28 12:09:19 +02:00
|
|
|
* suspended.
|
|
|
|
|
*
|
|
|
|
|
* When adding new causes, remember to update pa_suspend_cause_to_string() and
|
|
|
|
|
* PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE! */
|
2009-06-05 19:05:07 +02:00
|
|
|
typedef enum pa_suspend_cause {
|
|
|
|
|
PA_SUSPEND_USER = 1, /* Exposed to the user via some protocol */
|
|
|
|
|
PA_SUSPEND_APPLICATION = 2, /* Used by the device reservation logic */
|
|
|
|
|
PA_SUSPEND_IDLE = 4, /* Used by module-suspend-on-idle */
|
|
|
|
|
PA_SUSPEND_SESSION = 8, /* Used by module-hal for mark inactive sessions */
|
2011-03-03 19:02:45 +05:30
|
|
|
PA_SUSPEND_PASSTHROUGH = 16, /* Used to suspend monitor sources when the sink is in passthrough mode */
|
2012-07-23 14:20:05 +05:30
|
|
|
PA_SUSPEND_INTERNAL = 32, /* This is used for short period server-internal suspends, such as for sample rate updates */
|
2017-12-28 12:09:17 +02:00
|
|
|
PA_SUSPEND_UNAVAILABLE = 64, /* Used by device implementations that have to suspend when the device is unavailable */
|
2009-06-05 19:05:07 +02:00
|
|
|
PA_SUSPEND_ALL = 0xFFFF /* Magic cause that can be used to resume forcibly */
|
|
|
|
|
} pa_suspend_cause_t;
|
|
|
|
|
|
2006-08-12 02:18:24 +00:00
|
|
|
#include <pulsecore/idxset.h>
|
|
|
|
|
#include <pulsecore/hashmap.h>
|
2006-06-19 21:53:48 +00:00
|
|
|
#include <pulsecore/memblock.h>
|
|
|
|
|
#include <pulsecore/resampler.h>
|
2006-08-12 02:18:24 +00:00
|
|
|
#include <pulsecore/llist.h>
|
2006-08-13 16:19:56 +00:00
|
|
|
#include <pulsecore/hook-list.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <pulsecore/asyncmsgq.h>
|
2008-05-15 23:34:41 +00:00
|
|
|
#include <pulsecore/sample-util.h>
|
2009-01-28 01:46:27 +01:00
|
|
|
#include <pulsecore/sink.h>
|
|
|
|
|
#include <pulsecore/source.h>
|
2006-08-13 16:19:56 +00:00
|
|
|
#include <pulsecore/core-subscribe.h>
|
2007-10-28 19:13:50 +00:00
|
|
|
#include <pulsecore/msgobject.h>
|
|
|
|
|
|
2009-06-16 19:03:22 +03:00
|
|
|
typedef enum pa_server_type {
|
|
|
|
|
PA_SERVER_TYPE_UNSET,
|
|
|
|
|
PA_SERVER_TYPE_USER,
|
|
|
|
|
PA_SERVER_TYPE_SYSTEM,
|
|
|
|
|
PA_SERVER_TYPE_NONE
|
|
|
|
|
} pa_server_type_t;
|
|
|
|
|
|
2009-01-23 22:29:02 +01:00
|
|
|
typedef enum pa_core_state {
|
|
|
|
|
PA_CORE_STARTUP,
|
|
|
|
|
PA_CORE_RUNNING,
|
|
|
|
|
PA_CORE_SHUTDOWN
|
|
|
|
|
} pa_core_state_t;
|
|
|
|
|
|
2007-10-28 19:13:50 +00:00
|
|
|
typedef enum pa_core_hook {
|
2008-05-15 23:34:41 +00:00
|
|
|
PA_CORE_HOOK_SINK_NEW,
|
|
|
|
|
PA_CORE_HOOK_SINK_FIXATE,
|
|
|
|
|
PA_CORE_HOOK_SINK_PUT,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SINK_UNLINK,
|
|
|
|
|
PA_CORE_HOOK_SINK_UNLINK_POST,
|
|
|
|
|
PA_CORE_HOOK_SINK_STATE_CHANGED,
|
2008-05-15 23:34:41 +00:00
|
|
|
PA_CORE_HOOK_SINK_PROPLIST_CHANGED,
|
2010-10-15 09:25:12 +02:00
|
|
|
PA_CORE_HOOK_SINK_PORT_CHANGED,
|
2013-03-28 17:30:16 +02:00
|
|
|
PA_CORE_HOOK_SINK_FLAGS_CHANGED,
|
2014-04-15 13:56:13 +03:00
|
|
|
PA_CORE_HOOK_SINK_VOLUME_CHANGED,
|
2014-04-15 13:56:15 +03:00
|
|
|
PA_CORE_HOOK_SINK_MUTE_CHANGED,
|
2017-04-10 21:47:23 +02:00
|
|
|
PA_CORE_HOOK_SINK_PORT_LATENCY_OFFSET_CHANGED,
|
2008-05-15 23:34:41 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_NEW,
|
|
|
|
|
PA_CORE_HOOK_SOURCE_FIXATE,
|
|
|
|
|
PA_CORE_HOOK_SOURCE_PUT,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_UNLINK,
|
|
|
|
|
PA_CORE_HOOK_SOURCE_UNLINK_POST,
|
|
|
|
|
PA_CORE_HOOK_SOURCE_STATE_CHANGED,
|
2008-05-15 23:34:41 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_PROPLIST_CHANGED,
|
2010-10-15 09:25:12 +02:00
|
|
|
PA_CORE_HOOK_SOURCE_PORT_CHANGED,
|
2013-03-28 17:30:16 +02:00
|
|
|
PA_CORE_HOOK_SOURCE_FLAGS_CHANGED,
|
2014-04-15 13:56:13 +03:00
|
|
|
PA_CORE_HOOK_SOURCE_VOLUME_CHANGED,
|
2014-04-15 13:56:15 +03:00
|
|
|
PA_CORE_HOOK_SOURCE_MUTE_CHANGED,
|
2017-04-10 21:47:23 +02:00
|
|
|
PA_CORE_HOOK_SOURCE_PORT_LATENCY_OFFSET_CHANGED,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_NEW,
|
2007-11-21 01:30:40 +00:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_FIXATE,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_PUT,
|
|
|
|
|
PA_CORE_HOOK_SINK_INPUT_UNLINK,
|
|
|
|
|
PA_CORE_HOOK_SINK_INPUT_UNLINK_POST,
|
2009-01-23 22:38:30 +01:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_MOVE_START,
|
|
|
|
|
PA_CORE_HOOK_SINK_INPUT_MOVE_FINISH,
|
2009-02-11 19:16:42 +02:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_MOVE_FAIL,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_STATE_CHANGED,
|
2008-05-15 23:34:41 +00:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_PROPLIST_CHANGED,
|
2014-04-15 13:56:14 +03:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_VOLUME_CHANGED,
|
2014-04-15 13:56:16 +03:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_MUTE_CHANGED,
|
2021-04-05 17:13:27 +03:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_PREFERRED_SINK_CHANGED,
|
2009-02-12 03:18:05 +01:00
|
|
|
PA_CORE_HOOK_SINK_INPUT_SEND_EVENT,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_NEW,
|
2007-11-21 01:30:40 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_FIXATE,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_PUT,
|
|
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK,
|
|
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_UNLINK_POST,
|
2009-01-23 22:38:30 +01:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_START,
|
|
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FINISH,
|
2009-02-11 19:16:42 +02:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_MOVE_FAIL,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_STATE_CHANGED,
|
2008-05-15 23:34:41 +00:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_PROPLIST_CHANGED,
|
2014-04-15 13:56:14 +03:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_VOLUME_CHANGED,
|
2014-04-15 13:56:16 +03:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_MUTE_CHANGED,
|
2021-04-05 17:13:27 +03:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_PREFERRED_SOURCE_CHANGED,
|
2009-02-12 03:18:05 +01:00
|
|
|
PA_CORE_HOOK_SOURCE_OUTPUT_SEND_EVENT,
|
2009-01-15 17:52:29 +01:00
|
|
|
PA_CORE_HOOK_CLIENT_NEW,
|
|
|
|
|
PA_CORE_HOOK_CLIENT_PUT,
|
|
|
|
|
PA_CORE_HOOK_CLIENT_UNLINK,
|
2009-02-05 04:09:27 +01:00
|
|
|
PA_CORE_HOOK_CLIENT_PROPLIST_CHANGED,
|
2009-02-12 03:18:05 +01:00
|
|
|
PA_CORE_HOOK_CLIENT_SEND_EVENT,
|
2009-01-15 18:29:16 +01:00
|
|
|
PA_CORE_HOOK_CARD_NEW,
|
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
|
|
|
PA_CORE_HOOK_CARD_CHOOSE_INITIAL_PROFILE,
|
2009-01-15 18:29:16 +01:00
|
|
|
PA_CORE_HOOK_CARD_PUT,
|
|
|
|
|
PA_CORE_HOOK_CARD_UNLINK,
|
2016-03-04 15:23:30 +02:00
|
|
|
PA_CORE_HOOK_CARD_PREFERRED_PORT_CHANGED,
|
2011-02-25 10:27:23 +00:00
|
|
|
PA_CORE_HOOK_CARD_PROFILE_CHANGED,
|
2012-10-23 16:41:55 +02:00
|
|
|
PA_CORE_HOOK_CARD_PROFILE_ADDED,
|
2013-02-18 09:10:31 +01:00
|
|
|
PA_CORE_HOOK_CARD_PROFILE_AVAILABLE_CHANGED,
|
2016-05-09 15:09:57 +05:30
|
|
|
PA_CORE_HOOK_CARD_SUSPEND_CHANGED,
|
2011-11-25 15:17:14 +01:00
|
|
|
PA_CORE_HOOK_PORT_AVAILABLE_CHANGED,
|
2013-01-17 20:55:17 +01:00
|
|
|
PA_CORE_HOOK_PORT_LATENCY_OFFSET_CHANGED,
|
2015-03-19 13:50:48 +02:00
|
|
|
PA_CORE_HOOK_DEFAULT_SINK_CHANGED,
|
|
|
|
|
PA_CORE_HOOK_DEFAULT_SOURCE_CHANGED,
|
2015-03-19 13:50:51 +02:00
|
|
|
PA_CORE_HOOK_MODULE_NEW,
|
|
|
|
|
PA_CORE_HOOK_MODULE_PROPLIST_CHANGED,
|
|
|
|
|
PA_CORE_HOOK_MODULE_UNLINK,
|
2015-03-19 13:50:54 +02:00
|
|
|
PA_CORE_HOOK_SAMPLE_CACHE_NEW,
|
|
|
|
|
PA_CORE_HOOK_SAMPLE_CACHE_CHANGED,
|
|
|
|
|
PA_CORE_HOOK_SAMPLE_CACHE_UNLINK,
|
2007-10-28 19:13:50 +00:00
|
|
|
PA_CORE_HOOK_MAX
|
|
|
|
|
} pa_core_hook_t;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2006-06-19 23:51:58 +00:00
|
|
|
/* The core structure of PulseAudio. Every PulseAudio daemon contains
|
2004-11-21 21:31:28 +00:00
|
|
|
* exactly one of these. It is used for storing kind of global
|
|
|
|
|
* variables for the daemon. */
|
|
|
|
|
|
2004-07-03 23:35:12 +00:00
|
|
|
struct pa_core {
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_msgobject parent;
|
|
|
|
|
|
2009-01-23 22:29:02 +01:00
|
|
|
pa_core_state_t state;
|
|
|
|
|
|
2004-12-12 22:58:53 +00:00
|
|
|
/* A random value which may be used to identify this instance of
|
2006-06-19 23:51:58 +00:00
|
|
|
* PulseAudio. Not cryptographically secure in any way. */
|
2004-12-12 22:58:53 +00:00
|
|
|
uint32_t cookie;
|
2007-01-04 13:43:45 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_mainloop_api *mainloop;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
/* idxset of all kinds of entities */
|
2009-01-15 20:07:13 +01:00
|
|
|
pa_idxset *clients, *cards, *sinks, *sources, *sink_inputs, *source_outputs, *modules, *scache;
|
2004-06-08 23:54:24 +00:00
|
|
|
|
2004-11-21 21:31:28 +00:00
|
|
|
/* Some hashmaps for all sorts of entities */
|
2019-03-26 10:41:05 +01:00
|
|
|
pa_hashmap *namereg, *shared, *message_handlers;
|
2004-08-04 16:39:30 +00:00
|
|
|
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
/* The default sink/source as configured by the user. If the user hasn't
|
2017-06-30 00:09:34 +03:00
|
|
|
* explicitly configured anything, these are set to NULL. These are strings
|
|
|
|
|
* instead of sink/source pointers, because that allows us to reference
|
|
|
|
|
* devices that don't currently exist. That's useful for remembering that
|
|
|
|
|
* a hotplugged USB sink was previously set as the default sink. */
|
|
|
|
|
char *configured_default_sink;
|
|
|
|
|
char *configured_default_source;
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
|
2023-03-11 18:05:26 +01:00
|
|
|
/* The default sink/source set by some policy module. This will override
|
|
|
|
|
* the user configured default sink/source, so that the default will
|
|
|
|
|
* return to the user configured sink/source once the sink/source set by
|
|
|
|
|
* the policy module is no longer available. */
|
|
|
|
|
char *policy_default_sink;
|
|
|
|
|
char *policy_default_source;
|
|
|
|
|
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
/* The effective default sink/source. If no sink or source is explicitly
|
|
|
|
|
* configured as the default, we pick the device that ranks highest
|
|
|
|
|
* according to the compare_sinks() and compare_sources() functions in
|
|
|
|
|
* core.c. pa_core_update_default_sink/source() has to be called whenever
|
|
|
|
|
* anything changes that might change the comparison results. */
|
2009-01-28 01:46:27 +01:00
|
|
|
pa_sink *default_sink;
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
pa_source *default_source;
|
2004-07-15 20:12:21 +00:00
|
|
|
|
2009-02-21 16:32:42 +01:00
|
|
|
pa_channel_map default_channel_map;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_sample_spec default_sample_spec;
|
2011-08-02 18:37:27 -05:00
|
|
|
uint32_t alternate_sample_rate;
|
2007-10-28 19:13:50 +00:00
|
|
|
unsigned default_n_fragments, default_fragment_size_msec;
|
2011-09-13 21:15:49 +01:00
|
|
|
unsigned deferred_volume_safety_margin_usec;
|
|
|
|
|
int deferred_volume_extra_delay_usec;
|
2015-03-24 10:29:16 +01:00
|
|
|
unsigned lfe_crossover_freq;
|
2007-10-28 19:13:50 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_defer_event *module_defer_unload_event;
|
2014-12-05 15:51:35 +02:00
|
|
|
pa_hashmap *modules_pending_unload; /* pa_module -> pa_module (hashmap-as-a-set) */
|
2004-08-11 00:11:12 +00:00
|
|
|
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_defer_event *subscription_defer_event;
|
2006-08-12 02:18:24 +00:00
|
|
|
PA_LLIST_HEAD(pa_subscription, subscriptions);
|
|
|
|
|
PA_LLIST_HEAD(pa_subscription_event, subscription_event_queue);
|
|
|
|
|
pa_subscription_event *subscription_event_last;
|
2004-08-17 19:37:29 +00:00
|
|
|
|
2016-03-13 00:53:34 +02:00
|
|
|
/* The mempool is used for data we write to, it's readonly for the client. */
|
|
|
|
|
pa_mempool *mempool;
|
2016-03-13 00:48:15 +02:00
|
|
|
|
|
|
|
|
/* Shared memory size, as specified either by daemon configuration
|
|
|
|
|
* or PA daemon defaults (~ 64 MiB). */
|
|
|
|
|
size_t shm_size;
|
|
|
|
|
|
2008-05-15 23:34:41 +00:00
|
|
|
pa_silence_cache silence_cache;
|
2004-09-03 22:44:55 +00:00
|
|
|
|
2008-08-06 19:39:12 +02:00
|
|
|
pa_time_event *exit_event;
|
2006-01-11 01:17:39 +00:00
|
|
|
pa_time_event *scache_auto_unload_event;
|
2004-09-17 19:45:44 +00:00
|
|
|
|
2009-01-29 16:25:29 +01:00
|
|
|
int exit_idle_time, scache_idle_time;
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
bool flat_volumes:1;
|
2020-01-22 08:12:59 +01:00
|
|
|
bool rescue_streams:1;
|
2013-06-27 19:28:09 +02:00
|
|
|
bool disallow_module_loading:1;
|
|
|
|
|
bool disallow_exit:1;
|
|
|
|
|
bool running_as_daemon:1;
|
|
|
|
|
bool realtime_scheduling:1;
|
2017-01-28 13:19:08 +05:30
|
|
|
bool avoid_resampling:1;
|
2013-06-27 19:28:09 +02:00
|
|
|
bool disable_remixing:1;
|
2017-01-04 11:55:49 -05:00
|
|
|
bool remixing_use_all_sink_channels:1;
|
2019-12-10 06:50:59 +00:00
|
|
|
bool remixing_produce_lfe:1;
|
|
|
|
|
bool remixing_consume_lfe:1;
|
2013-06-27 19:28:09 +02:00
|
|
|
bool deferred_volume:1;
|
2008-06-27 21:37:33 +02:00
|
|
|
|
2006-01-27 16:25:31 +00:00
|
|
|
pa_resample_method_t resample_method;
|
2007-11-01 02:58:26 +00:00
|
|
|
int realtime_priority;
|
2006-08-13 16:19:56 +00:00
|
|
|
|
2009-06-16 19:03:22 +03:00
|
|
|
pa_server_type_t server_type;
|
2010-09-14 15:21:49 +05:30
|
|
|
pa_cpu_info cpu_info;
|
2009-06-16 19:03:22 +03:00
|
|
|
|
2006-08-13 16:19:56 +00:00
|
|
|
/* hooks */
|
2007-10-28 19:13:50 +00:00
|
|
|
pa_hook hooks[PA_CORE_HOOK_MAX];
|
|
|
|
|
};
|
|
|
|
|
|
2009-08-21 21:27:44 +02:00
|
|
|
PA_DECLARE_PUBLIC_CLASS(pa_core);
|
2007-10-28 19:13:50 +00:00
|
|
|
#define PA_CORE(o) pa_core_cast(o)
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
PA_CORE_MESSAGE_UNLOAD_MODULE,
|
|
|
|
|
PA_CORE_MESSAGE_MAX
|
2004-06-08 23:54:24 +00:00
|
|
|
};
|
|
|
|
|
|
2016-04-15 23:07:36 +02:00
|
|
|
pa_core* pa_core_new(pa_mainloop_api *m, bool shared, bool enable_memfd, size_t shm_size);
|
2004-11-21 21:31:28 +00:00
|
|
|
|
2017-06-30 00:09:34 +03:00
|
|
|
void pa_core_set_configured_default_sink(pa_core *core, const char *sink);
|
|
|
|
|
void pa_core_set_configured_default_source(pa_core *core, const char *source);
|
2023-03-11 18:05:26 +01:00
|
|
|
void pa_core_set_policy_default_sink(pa_core *core, const char *sink);
|
|
|
|
|
void pa_core_set_policy_default_source(pa_core *core, const char *source);
|
improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.
I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.
This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.
pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().
I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-02-16 12:09:38 +02:00
|
|
|
|
|
|
|
|
/* These should be called whenever something changes that may affect the
|
|
|
|
|
* default sink or source choice.
|
|
|
|
|
*
|
|
|
|
|
* If the default source choice happens between two monitor sources, the
|
|
|
|
|
* monitored sinks are compared, so if the default sink changes, the default
|
|
|
|
|
* source may change too. However, pa_core_update_default_sink() calls
|
|
|
|
|
* pa_core_update_default_source() internally, so it's sufficient to only call
|
|
|
|
|
* pa_core_update_default_sink() when something happens that affects the sink
|
|
|
|
|
* ordering. */
|
|
|
|
|
void pa_core_update_default_sink(pa_core *core);
|
|
|
|
|
void pa_core_update_default_source(pa_core *core);
|
|
|
|
|
|
2021-02-04 15:14:01 +01:00
|
|
|
pa_sink *pa_core_find_best_sink(pa_core *core, bool ignore_configured_virtual_default);
|
|
|
|
|
pa_source *pa_core_find_best_source(pa_core *core, bool ignore_configured_virtual_default);
|
|
|
|
|
|
2018-03-06 15:09:06 +02:00
|
|
|
void pa_core_set_exit_idle_time(pa_core *core, int time);
|
|
|
|
|
|
2011-08-24 18:24:46 +02:00
|
|
|
/* Check whether no one is connected to this core */
|
2008-08-06 19:39:12 +02:00
|
|
|
void pa_core_check_idle(pa_core *c);
|
|
|
|
|
|
2013-06-27 19:28:09 +02:00
|
|
|
int pa_core_exit(pa_core *c, bool force, int retval);
|
2004-09-04 00:27:36 +00:00
|
|
|
|
2009-02-25 09:13:19 +01:00
|
|
|
void pa_core_maybe_vacuum(pa_core *c);
|
|
|
|
|
|
2009-04-05 02:13:43 +03:00
|
|
|
/* wrapper for c->mainloop->time_*() RT time events */
|
|
|
|
|
pa_time_event* pa_core_rttime_new(pa_core *c, pa_usec_t usec, pa_time_event_cb_t cb, void *userdata);
|
|
|
|
|
void pa_core_rttime_restart(pa_core *c, pa_time_event *e, pa_usec_t usec);
|
|
|
|
|
|
2017-12-28 12:09:19 +02:00
|
|
|
static const size_t PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE =
|
|
|
|
|
sizeof("USER|APPLICATION|IDLE|SESSION|PASSTHROUGH|INTERNAL|UNAVAILABLE");
|
|
|
|
|
|
|
|
|
|
/* Converts the given suspend cause to a string. The string is written to the
|
|
|
|
|
* provided buffer. The same buffer is the return value of this function. */
|
|
|
|
|
const char *pa_suspend_cause_to_string(pa_suspend_cause_t cause, char buf[PA_SUSPEND_CAUSE_TO_STRING_BUF_SIZE]);
|
|
|
|
|
|
2019-01-16 12:10:38 +08:00
|
|
|
void pa_core_move_streams_to_newly_available_preferred_sink(pa_core *c, pa_sink *s);
|
|
|
|
|
|
2019-12-07 11:36:25 +08:00
|
|
|
void pa_core_move_streams_to_newly_available_preferred_source(pa_core *c, pa_source *s);
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#endif
|