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
|
|
|
|
|
* suspended. */
|
|
|
|
|
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 */
|
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,
|
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,
|
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,
|
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,
|
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 */
|
2009-01-15 20:07:13 +01:00
|
|
|
pa_hashmap *namereg, *shared;
|
2004-08-04 16:39:30 +00:00
|
|
|
|
2009-01-29 16:25:29 +01:00
|
|
|
/* The default sink/source */
|
2009-01-28 01:46:27 +01:00
|
|
|
pa_source *default_source;
|
|
|
|
|
pa_sink *default_sink;
|
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;
|
|
|
|
|
bool disallow_module_loading:1;
|
|
|
|
|
bool disallow_exit:1;
|
|
|
|
|
bool running_as_daemon:1;
|
|
|
|
|
bool realtime_scheduling:1;
|
|
|
|
|
bool disable_remixing:1;
|
|
|
|
|
bool disable_lfe_remixing:1;
|
|
|
|
|
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
|
|
|
|
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);
|
|
|
|
|
|
2004-06-08 23:54:24 +00:00
|
|
|
#endif
|