summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArun Raghavan <arun@arunraghavan.net>2016-07-04 14:02:18 +0530
committerArun Raghavan <arun@arunraghavan.net>2016-07-04 14:04:23 +0530
commite6051e5728d784bf4548b65d43aac86ff41d859b (patch)
tree4ff464af788b182bd1063302381cf7f3256bfea0
parent17e158dc99ea96a088cbaf3ac01a7ff5e3743759 (diff)
WIP protocol-native: Don't access pa_core structures directlyHEADmaster
First step to allowing access control. Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
-rw-r--r--src/pulsecore/core.c97
-rw-r--r--src/pulsecore/core.h28
-rw-r--r--src/pulsecore/protocol-native.c139
3 files changed, 202 insertions, 62 deletions
diff --git a/src/pulsecore/core.c b/src/pulsecore/core.c
index 1a8090fe8..91b43f268 100644
--- a/src/pulsecore/core.c
+++ b/src/pulsecore/core.c
@@ -300,3 +300,100 @@ void pa_core_rttime_restart(pa_core *c, pa_time_event *e, pa_usec_t usec) {
c->mainloop->time_restart(e, pa_timeval_rtstore(&tv, usec, true));
}
+
+pa_mainloop_api* pa_core_get_mainloop(pa_core *c) {
+ pa_assert(c);
+ pa_assert(c->mainloop);
+
+ return c->mainloop;
+}
+
+/* FIXME: Should we expose this at all? */
+pa_mempool* pa_core_get_mempool(pa_core *c) {
+ pa_assert(c);
+ pa_assert(c->mempool);
+
+ return c->mempool;
+}
+
+pa_mempool* pa_core_new_mempool(pa_core *c, pa_mem_type_t shm_type, bool per_client) {
+ return pa_mempool_new(shm_type, c->shm_size, per_client);
+}
+
+/* FIXME: Should these be taking a ref during the copy? */
+
+pa_idxset* pa_core_get_modules(pa_core *c) {
+ return pa_idxset_copy(c->modules, NULL);
+}
+
+pa_idxset* pa_core_get_clients(pa_core *c) {
+ return pa_idxset_copy(c->clients, NULL);
+}
+
+pa_idxset* pa_core_get_cards(pa_core *c) {
+ return pa_idxset_copy(c->cards, NULL);
+}
+
+pa_idxset* pa_core_get_sinks(pa_core *c) {
+ return pa_idxset_copy(c->sinks, NULL);
+}
+
+pa_idxset* pa_core_get_sources(pa_core *c) {
+ return pa_idxset_copy(c->sources, NULL);
+}
+
+pa_idxset* pa_core_get_sink_inputs(pa_core *c) {
+ return pa_idxset_copy(c->sink_inputs, NULL);
+}
+
+pa_idxset* pa_core_get_source_outputs(pa_core *c) {
+ return pa_idxset_copy(c->source_outputs, NULL);
+}
+
+pa_idxset* pa_core_get_scache(pa_core *c) {
+ return pa_idxset_copy(c->scache, NULL);
+}
+
+pa_module* pa_core_get_module(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->modules, idx);
+}
+
+pa_client* pa_core_get_client(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->clients, idx);
+}
+
+pa_card* pa_core_get_card(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->cards, idx);
+}
+
+pa_sink* pa_core_get_sink(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->sinks, idx);
+}
+
+pa_source* pa_core_get_source(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->sources, idx);
+}
+
+pa_sink_input* pa_core_get_sink_input(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->sink_inputs, idx);
+}
+
+pa_source_output* pa_core_get_source_output(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->source_outputs, idx);
+}
+
+pa_scache_entry* pa_core_get_scache_entry(pa_core *c, uint32_t idx) {
+ return pa_idxset_get_by_index(c->scache, idx);
+}
+
+const pa_sample_spec* pa_core_get_sample_spec(pa_core *c) {
+ return &c->default_sample_spec;
+}
+
+const pa_channel_map* pa_core_get_channel_map(pa_core *c) {
+ return &c->default_channel_map;
+}
+
+uint32_t pa_core_get_cookie(pa_core *c) {
+ return c->cookie;
+}
diff --git a/src/pulsecore/core.h b/src/pulsecore/core.h
index c7486f9ad..b872d683e 100644
--- a/src/pulsecore/core.h
+++ b/src/pulsecore/core.h
@@ -160,4 +160,32 @@ void pa_core_maybe_vacuum(pa_core *c);
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);
+pa_mainloop_api* pa_core_get_mainloop(pa_core *c);
+pa_mempool* pa_core_get_mempool(pa_core *c);
+pa_mempool* pa_core_new_mempool(pa_core *c, pa_mem_type_t shm_type, bool per_client);
+
+pa_idxset* pa_core_get_modules(pa_core *c);
+pa_idxset* pa_core_get_clients(pa_core *c);
+pa_idxset* pa_core_get_cards(pa_core *c);
+pa_idxset* pa_core_get_sinks(pa_core *c);
+pa_idxset* pa_core_get_sources(pa_core *c);
+pa_idxset* pa_core_get_sink_inputs(pa_core *c);
+pa_idxset* pa_core_get_source_outputs(pa_core *c);
+pa_idxset* pa_core_get_scache(pa_core *c);
+
+pa_module* pa_core_get_module(pa_core *c, uint32_t idx);
+pa_client* pa_core_get_client(pa_core *c, uint32_t idx);
+pa_card* pa_core_get_card(pa_core *c, uint32_t idx);
+pa_sink* pa_core_get_sink(pa_core *c, uint32_t idx);
+pa_source* pa_core_get_source(pa_core *c, uint32_t idx);
+pa_sink_input* pa_core_get_sink_input(pa_core *c, uint32_t idx);
+pa_source_output* pa_core_get_source_output(pa_core *c, uint32_t idx);
+typedef struct pa_scache_entry pa_scache_entry;
+pa_scache_entry* pa_core_get_scache_entry(pa_core *c, uint32_t idx);
+
+const pa_sample_spec* pa_core_get_sample_spec(pa_core *c);
+const pa_channel_map* pa_core_get_channel_map(pa_core *c);
+
+uint32_t pa_core_get_cookie(pa_core *c);
+
#endif
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index 0c588709d..089d49f25 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -45,7 +45,6 @@
#include <pulsecore/pdispatch.h>
#include <pulsecore/pstream-util.h>
#include <pulsecore/namereg.h>
-#include <pulsecore/core-struct.h>
#include <pulsecore/core-scache.h>
#include <pulsecore/core-subscribe.h>
#include <pulsecore/log.h>
@@ -1361,7 +1360,7 @@ static void native_connection_unlink(pa_native_connection *c) {
pa_pstream_unlink(c->pstream);
if (c->auth_timeout_event) {
- c->protocol->core->mainloop->time_free(c->auth_timeout_event);
+ pa_core_get_mainloop(c->protocol->core)->time_free(c->auth_timeout_event);
c->auth_timeout_event = NULL;
}
@@ -2032,7 +2031,7 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
int ret = PA_ERR_INVALID;
uint8_t n_formats = 0;
pa_format_info *format;
- pa_idxset *formats = NULL;
+ pa_idxset *sinks = NULL, *formats = NULL;
uint32_t i;
pa_native_connection_assert_ref(c);
@@ -2171,8 +2170,9 @@ static void command_create_playback_stream(pa_pdispatch *pd, uint32_t command, u
}
if (sink_index != PA_INVALID_INDEX) {
+ sinks = pa_core_get_sinks(c->protocol->core);
- if (!(sink = pa_idxset_get_by_index(c->protocol->core->sinks, sink_index))) {
+ if (!(sink = pa_idxset_get_by_index(sinks, sink_index))) {
pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY);
goto finish;
}
@@ -2262,6 +2262,8 @@ finish:
pa_proplist_free(p);
if (formats)
pa_idxset_free(formats, (pa_free_cb_t) pa_format_info_free);
+ if (sinks)
+ pa_idxset_free(sinks, NULL);
}
static void command_delete_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
@@ -2360,7 +2362,7 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
int ret = PA_ERR_INVALID;
uint8_t n_formats = 0;
pa_format_info *format;
- pa_idxset *formats = NULL;
+ pa_idxset *sources = NULL, *sink_inputs = NULL, *formats = NULL;
uint32_t i;
pa_native_connection_assert_ref(c);
@@ -2490,8 +2492,9 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
}
if (source_index != PA_INVALID_INDEX) {
+ sources = pa_core_get_sources(c->protocol->core);
- if (!(source = pa_idxset_get_by_index(c->protocol->core->sources, source_index))) {
+ if (!(source = pa_idxset_get_by_index(sources, source_index))) {
pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY);
goto finish;
}
@@ -2505,8 +2508,9 @@ static void command_create_record_stream(pa_pdispatch *pd, uint32_t command, uin
}
if (direct_on_input_idx != PA_INVALID_INDEX) {
+ sink_inputs = pa_core_get_sink_inputs(c->protocol->core);
- if (!(direct_on_input = pa_idxset_get_by_index(c->protocol->core->sink_inputs, direct_on_input_idx))) {
+ if (!(direct_on_input = pa_idxset_get_by_index(sink_inputs, direct_on_input_idx))) {
pa_pstream_send_error(c->pstream, tag, PA_ERR_NOENTITY);
goto finish;
}
@@ -2576,6 +2580,10 @@ finish:
pa_proplist_free(p);
if (formats)
pa_idxset_free(formats, (pa_free_cb_t) pa_format_info_free);
+ if (sources)
+ pa_idxset_free(sources, NULL);
+ if (sink_inputs)
+ pa_idxset_free(sink_inputs, NULL);
}
static void command_exit(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_tagstruct *t, void *userdata) {
@@ -2632,7 +2640,7 @@ static void setup_srbchannel(pa_native_connection *c, pa_mem_type_t shm_type) {
return;
}
- if (!(c->rw_mempool = pa_mempool_new(shm_type, c->protocol->core->shm_size, true))) {
+ if (!(c->rw_mempool = pa_core_new_mempool(c->protocol->core, shm_type, true))) {
pa_log_warn("Disabling srbchannel, reason: Failed to allocate shared "
"writable memory pool.");
return;
@@ -2647,7 +2655,7 @@ static void setup_srbchannel(pa_native_connection *c, pa_mem_type_t shm_type) {
}
pa_mempool_set_is_remote_writable(c->rw_mempool, true);
- srb = pa_srbchannel_new(c->protocol->core->mainloop, c->rw_mempool);
+ srb = pa_srbchannel_new(pa_core_get_mainloop(c->protocol->core), c->rw_mempool);
if (!srb) {
pa_log_debug("Failed to create srbchannel");
goto fail;
@@ -2785,14 +2793,14 @@ static void command_auth(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
c->authorized = true;
if (c->auth_timeout_event) {
- c->protocol->core->mainloop->time_free(c->auth_timeout_event);
+ pa_core_get_mainloop(c->protocol->core)->time_free(c->auth_timeout_event);
c->auth_timeout_event = NULL;
}
}
/* Enable shared memory and memfd support if possible */
do_shm =
- pa_mempool_is_shared(c->protocol->core->mempool) &&
+ pa_mempool_is_shared(pa_core_get_mempool(c->protocol->core)) &&
c->is_local;
pa_log_debug("SHM possible: %s", pa_yes_no(do_shm));
@@ -2817,7 +2825,7 @@ static void command_auth(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
pa_pstream_enable_shm(c->pstream, do_shm);
do_memfd =
- do_shm && pa_mempool_is_memfd_backed(c->protocol->core->mempool);
+ do_shm && pa_mempool_is_memfd_backed(pa_core_get_mempool(c->protocol->core));
shm_type = PA_MEM_TYPE_PRIVATE;
if (do_shm) {
@@ -2858,7 +2866,7 @@ static void command_auth(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
if (shm_type == PA_MEM_TYPE_SHARED_MEMFD) {
const char *reason;
- if (pa_pstream_register_memfd_mempool(c->pstream, c->protocol->core->mempool, &reason))
+ if (pa_pstream_register_memfd_mempool(c->pstream, pa_core_get_mempool(c->protocol->core), &reason))
pa_log("Failed to register memfd mempool. Reason: %s", reason);
}
@@ -2988,7 +2996,7 @@ static void command_stat(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
- stat = pa_mempool_get_stat(c->protocol->core->mempool);
+ stat = pa_mempool_get_stat(pa_core_get_mempool(c->protocol->core));
reply = reply_new(tag);
pa_tagstruct_putu32(reply, (uint32_t) pa_atomic_load(&stat->n_allocated));
@@ -3205,7 +3213,7 @@ static void command_play_sample(pa_pdispatch *pd, uint32_t command, uint32_t tag
CHECK_VALIDITY(c->pstream, name && pa_namereg_is_valid_name(name), tag, PA_ERR_INVALID);
if (sink_index != PA_INVALID_INDEX)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, sink_index);
+ sink = pa_core_get_sink(c->protocol->core, sink_index);
else
sink = pa_namereg_get(c->protocol->core, sink_name, PA_NAMEREG_SINK);
@@ -3668,31 +3676,31 @@ static void command_get_info(pa_pdispatch *pd, uint32_t command, uint32_t tag, p
if (command == PA_COMMAND_GET_SINK_INFO) {
if (idx != PA_INVALID_INDEX)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
+ sink = pa_core_get_sink(c->protocol->core, idx);
else
sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK);
} else if (command == PA_COMMAND_GET_SOURCE_INFO) {
if (idx != PA_INVALID_INDEX)
- source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
+ source = pa_core_get_source(c->protocol->core, idx);
else
source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE);
} else if (command == PA_COMMAND_GET_CARD_INFO) {
if (idx != PA_INVALID_INDEX)
- card = pa_idxset_get_by_index(c->protocol->core->cards, idx);
+ card = pa_core_get_card(c->protocol->core, idx);
else
card = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_CARD);
} else if (command == PA_COMMAND_GET_CLIENT_INFO)
- client = pa_idxset_get_by_index(c->protocol->core->clients, idx);
+ client = pa_core_get_client(c->protocol->core, idx);
else if (command == PA_COMMAND_GET_MODULE_INFO)
- module = pa_idxset_get_by_index(c->protocol->core->modules, idx);
+ module = pa_core_get_module(c->protocol->core, idx);
else if (command == PA_COMMAND_GET_SINK_INPUT_INFO)
- si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
+ si = pa_core_get_sink_input(c->protocol->core, idx);
else if (command == PA_COMMAND_GET_SOURCE_OUTPUT_INFO)
- so = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx);
+ so = pa_core_get_source_output(c->protocol->core, idx);
else {
pa_assert(command == PA_COMMAND_GET_SAMPLE_INFO);
if (idx != PA_INVALID_INDEX)
- sce = pa_idxset_get_by_index(c->protocol->core->scache, idx);
+ sce = pa_core_get_scache_entry(c->protocol->core, idx);
else
sce = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SAMPLE);
}
@@ -3742,22 +3750,22 @@ static void command_get_info_list(pa_pdispatch *pd, uint32_t command, uint32_t t
reply = reply_new(tag);
if (command == PA_COMMAND_GET_SINK_INFO_LIST)
- i = c->protocol->core->sinks;
+ i = pa_core_get_sinks(c->protocol->core);
else if (command == PA_COMMAND_GET_SOURCE_INFO_LIST)
- i = c->protocol->core->sources;
+ i = pa_core_get_sources(c->protocol->core);
else if (command == PA_COMMAND_GET_CLIENT_INFO_LIST)
- i = c->protocol->core->clients;
+ i = pa_core_get_clients(c->protocol->core);
else if (command == PA_COMMAND_GET_CARD_INFO_LIST)
- i = c->protocol->core->cards;
+ i = pa_core_get_cards(c->protocol->core);
else if (command == PA_COMMAND_GET_MODULE_INFO_LIST)
- i = c->protocol->core->modules;
+ i = pa_core_get_modules(c->protocol->core);
else if (command == PA_COMMAND_GET_SINK_INPUT_INFO_LIST)
- i = c->protocol->core->sink_inputs;
+ i = pa_core_get_sink_inputs(c->protocol->core);
else if (command == PA_COMMAND_GET_SOURCE_OUTPUT_INFO_LIST)
- i = c->protocol->core->source_outputs;
+ i = pa_core_get_source_outputs(c->protocol->core);
else {
pa_assert(command == PA_COMMAND_GET_SAMPLE_INFO_LIST);
- i = c->protocol->core->scache;
+ i = pa_core_get_scache(c->protocol->core);
}
if (i) {
@@ -3781,6 +3789,8 @@ static void command_get_info_list(pa_pdispatch *pd, uint32_t command, uint32_t t
scache_fill_tagstruct(c, reply, p);
}
}
+
+ pa_idxset_free(i, NULL);
}
pa_pstream_send_tagstruct(c->pstream, reply);
@@ -3816,7 +3826,7 @@ static void command_get_server_info(pa_pdispatch *pd, uint32_t command, uint32_t
pa_tagstruct_puts(reply, h);
pa_xfree(h);
- fixup_sample_spec(c, &fixed_ss, &c->protocol->core->default_sample_spec);
+ fixup_sample_spec(c, &fixed_ss, pa_core_get_sample_spec(c->protocol->core));
pa_tagstruct_put_sample_spec(reply, &fixed_ss);
def_sink = pa_namereg_get_default_sink(c->protocol->core);
@@ -3824,10 +3834,10 @@ static void command_get_server_info(pa_pdispatch *pd, uint32_t command, uint32_t
def_source = pa_namereg_get_default_source(c->protocol->core);
pa_tagstruct_puts(reply, def_source ? def_source->name : NULL);
- pa_tagstruct_putu32(reply, c->protocol->core->cookie);
+ pa_tagstruct_putu32(reply, pa_core_get_cookie(c->protocol->core));
if (c->version >= 15)
- pa_tagstruct_put_channel_map(reply, &c->protocol->core->default_channel_map);
+ pa_tagstruct_put_channel_map(reply, pa_core_get_channel_map(c->protocol->core));
pa_pstream_send_tagstruct(c->pstream, reply);
}
@@ -3912,24 +3922,24 @@ static void command_set_volume(
case PA_COMMAND_SET_SINK_VOLUME:
if (idx != PA_INVALID_INDEX)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
+ sink = pa_core_get_sink(c->protocol->core, idx);
else
sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK);
break;
case PA_COMMAND_SET_SOURCE_VOLUME:
if (idx != PA_INVALID_INDEX)
- source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
+ source = pa_core_get_source(c->protocol->core, idx);
else
source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE);
break;
case PA_COMMAND_SET_SINK_INPUT_VOLUME:
- si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
+ si = pa_core_get_sink_input(c->protocol->core, idx);
break;
case PA_COMMAND_SET_SOURCE_OUTPUT_VOLUME:
- so = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx);
+ so = pa_core_get_source_output(c->protocol->core, idx);
break;
default:
@@ -4007,7 +4017,7 @@ static void command_set_mute(
case PA_COMMAND_SET_SINK_MUTE:
if (idx != PA_INVALID_INDEX)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
+ sink = pa_core_get_sink(c->protocol->core, idx);
else
sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK);
@@ -4015,18 +4025,18 @@ static void command_set_mute(
case PA_COMMAND_SET_SOURCE_MUTE:
if (idx != PA_INVALID_INDEX)
- source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
+ source = pa_core_get_source(c->protocol->core, idx);
else
source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE);
break;
case PA_COMMAND_SET_SINK_INPUT_MUTE:
- si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
+ si = pa_core_get_sink_input(c->protocol->core, idx);
break;
case PA_COMMAND_SET_SOURCE_OUTPUT_MUTE:
- so = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx);
+ so = pa_core_get_source_output(c->protocol->core, idx);
break;
default:
@@ -4571,7 +4581,7 @@ static void command_kill(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
if (command == PA_COMMAND_KILL_CLIENT) {
pa_client *client;
- client = pa_idxset_get_by_index(c->protocol->core->clients, idx);
+ client = pa_core_get_client(c->protocol->core, idx);
CHECK_VALIDITY(c->pstream, client, tag, PA_ERR_NOENTITY);
pa_native_connection_ref(c);
@@ -4580,7 +4590,7 @@ static void command_kill(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
} else if (command == PA_COMMAND_KILL_SINK_INPUT) {
pa_sink_input *s;
- s = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
+ s = pa_core_get_sink_input(c->protocol->core, idx);
CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY);
pa_native_connection_ref(c);
@@ -4590,7 +4600,7 @@ static void command_kill(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa_ta
pa_assert(command == PA_COMMAND_KILL_SOURCE_OUTPUT);
- s = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx);
+ s = pa_core_get_source_output(c->protocol->core, idx);
CHECK_VALIDITY(c->pstream, s, tag, PA_ERR_NOENTITY);
pa_native_connection_ref(c);
@@ -4646,7 +4656,7 @@ static void command_unload_module(pa_pdispatch *pd, uint32_t command, uint32_t t
}
CHECK_VALIDITY(c->pstream, c->authorized, tag, PA_ERR_ACCESS);
- m = pa_idxset_get_by_index(c->protocol->core->modules, idx);
+ m = pa_core_get_module(c->protocol->core, idx);
CHECK_VALIDITY(c->pstream, m, tag, PA_ERR_NOENTITY);
pa_module_unload_request(m, false);
@@ -4679,10 +4689,10 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag
pa_sink_input *si = NULL;
pa_sink *sink = NULL;
- si = pa_idxset_get_by_index(c->protocol->core->sink_inputs, idx);
+ si = pa_core_get_sink_input(c->protocol->core, idx);
if (idx_device != PA_INVALID_INDEX)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx_device);
+ sink = pa_core_get_sink(c->protocol->core, idx_device);
else
sink = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SINK);
@@ -4698,10 +4708,10 @@ static void command_move_stream(pa_pdispatch *pd, uint32_t command, uint32_t tag
pa_assert(command == PA_COMMAND_MOVE_SOURCE_OUTPUT);
- so = pa_idxset_get_by_index(c->protocol->core->source_outputs, idx);
+ so = pa_core_get_source_output(c->protocol->core, idx);
if (idx_device != PA_INVALID_INDEX)
- source = pa_idxset_get_by_index(c->protocol->core->sources, idx_device);
+ source = pa_core_get_source(c->protocol->core, idx_device);
else
source = pa_namereg_get(c->protocol->core, name_device, PA_NAMEREG_SOURCE);
@@ -4751,7 +4761,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa
pa_sink *sink = NULL;
if (idx != PA_INVALID_INDEX)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
+ sink = pa_core_get_sink(c->protocol->core, idx);
else
sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK);
@@ -4782,7 +4792,7 @@ static void command_suspend(pa_pdispatch *pd, uint32_t command, uint32_t tag, pa
pa_source *source;
if (idx != PA_INVALID_INDEX)
- source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
+ source = pa_core_get_source(c->protocol->core, idx);
else
source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE);
@@ -4822,12 +4832,17 @@ static void command_extension(pa_pdispatch *pd, uint32_t command, uint32_t tag,
CHECK_VALIDITY(c->pstream, (idx != PA_INVALID_INDEX) ^ (name != NULL), tag, PA_ERR_INVALID);
if (idx != PA_INVALID_INDEX)
- m = pa_idxset_get_by_index(c->protocol->core->modules, idx);
- else
- PA_IDXSET_FOREACH(m, c->protocol->core->modules, idx)
+ m = pa_core_get_module(c->protocol->core, idx);
+ else {
+ pa_idxset *modules = pa_core_get_modules (c->protocol->core);
+
+ PA_IDXSET_FOREACH(m, modules, idx)
if (pa_streq(name, m->name))
break;
+ pa_idxset_free (modules, NULL);
+ }
+
CHECK_VALIDITY(c->pstream, m, tag, PA_ERR_NOEXTENSION);
CHECK_VALIDITY(c->pstream, m->load_once || idx != PA_INVALID_INDEX, tag, PA_ERR_INVALID);
@@ -4863,7 +4878,7 @@ static void command_set_card_profile(pa_pdispatch *pd, uint32_t command, uint32_
CHECK_VALIDITY(c->pstream, profile_name, tag, PA_ERR_INVALID);
if (idx != PA_INVALID_INDEX)
- card = pa_idxset_get_by_index(c->protocol->core->cards, idx);
+ card = pa_core_get_card(c->protocol->core, idx);
else
card = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_CARD);
@@ -4907,7 +4922,7 @@ static void command_set_sink_or_source_port(pa_pdispatch *pd, uint32_t command,
pa_sink *sink;
if (idx != PA_INVALID_INDEX)
- sink = pa_idxset_get_by_index(c->protocol->core->sinks, idx);
+ sink = pa_core_get_sink(c->protocol->core, idx);
else
sink = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SINK);
@@ -4923,7 +4938,7 @@ static void command_set_sink_or_source_port(pa_pdispatch *pd, uint32_t command,
pa_assert(command == PA_COMMAND_SET_SOURCE_PORT);
if (idx != PA_INVALID_INDEX)
- source = pa_idxset_get_by_index(c->protocol->core->sources, idx);
+ source = pa_core_get_source(c->protocol->core, idx);
else
source = pa_namereg_get(c->protocol->core, name, PA_NAMEREG_SOURCE);
@@ -4964,7 +4979,7 @@ static void command_set_port_latency_offset(pa_pdispatch *pd, uint32_t command,
CHECK_VALIDITY(c->pstream, port_name, tag, PA_ERR_INVALID);
if (idx != PA_INVALID_INDEX)
- card = pa_idxset_get_by_index(c->protocol->core->cards, idx);
+ card = pa_core_get_card(c->protocol->core, idx);
else
card = pa_namereg_get(c->protocol->core, card_name, PA_NAMEREG_CARD);
@@ -5040,7 +5055,7 @@ static void pstream_memblock_callback(pa_pstream *p, uint32_t channel, int64_t o
pa_memblock_ref(u->memchunk.memblock);
u->length = 0;
} else {
- u->memchunk.memblock = pa_memblock_new(c->protocol->core->mempool, u->length);
+ u->memchunk.memblock = pa_memblock_new(pa_core_get_mempool(c->protocol->core), u->length);
u->memchunk.index = u->memchunk.length = 0;
}
}
@@ -5218,7 +5233,7 @@ void pa_native_protocol_connect(pa_native_protocol *p, pa_iochannel *io, pa_nati
c->rw_mempool = NULL;
- c->pstream = pa_pstream_new(p->core->mainloop, io, p->core->mempool);
+ c->pstream = pa_pstream_new(pa_core_get_mainloop(p->core), io, pa_core_get_mempool(p->core));
pa_pstream_set_receive_packet_callback(c->pstream, pstream_packet_callback, c);
pa_pstream_set_receive_memblock_callback(c->pstream, pstream_memblock_callback, c);
pa_pstream_set_die_callback(c->pstream, pstream_die_callback, c);
@@ -5226,7 +5241,7 @@ void pa_native_protocol_connect(pa_native_protocol *p, pa_iochannel *io, pa_nati
pa_pstream_set_revoke_callback(c->pstream, pstream_revoke_callback, c);
pa_pstream_set_release_callback(c->pstream, pstream_release_callback, c);
- c->pdispatch = pa_pdispatch_new(p->core->mainloop, true, command_table, PA_COMMAND_MAX);
+ c->pdispatch = pa_pdispatch_new(pa_core_get_mainloop(p->core), true, command_table, PA_COMMAND_MAX);
c->record_streams = pa_idxset_new(NULL, NULL);
c->output_streams = pa_idxset_new(NULL, NULL);