#include <pulsecore/rtpoll.h>
#include <pulsecore/sample-util.h>
#include <pulsecore/ltdl-helper.h>
+#include <pulsecore/mix.h>
#include "module-virtual-source-symdef.h"
PA_MODULE_AUTHOR("Pierre-Louis Bossart");
PA_MODULE_DESCRIPTION("Virtual source");
PA_MODULE_VERSION(PACKAGE_VERSION);
-PA_MODULE_LOAD_ONCE(FALSE);
+PA_MODULE_LOAD_ONCE(false);
PA_MODULE_USAGE(
_("source_name=<name for the source> "
"source_properties=<properties for the source> "
pa_module *module;
/* FIXME: Uncomment this and take "autoloaded" as a modarg if this is a filter */
- /* pa_bool_t autoloaded; */
+ /* bool autoloaded; */
pa_source *source;
pa_source_output *source_output;
pa_memblockq *memblockq;
- pa_bool_t auto_desc;
+ bool auto_desc;
unsigned channels;
/* optional fields for uplink sink */
if (state == PA_SINK_RUNNING) {
/* need to wake-up source if it was suspended */
- pa_source_suspend(u->source, FALSE, PA_SUSPEND_ALL);
+ pa_log_debug("Resuming source %s, because its uplink sink became active.", u->source->name);
+ pa_source_suspend(u->source, false, PA_SUSPEND_ALL);
/* FIXME: if there's no client connected, the source will suspend
and playback will be stuck. You'd want to prevent the source from
}
-
/* Called from I/O thread context */
static void sink_request_rewind_cb(pa_sink *s) {
struct userdata *u;
!PA_SOURCE_OUTPUT_IS_LINKED(pa_source_output_get_state(u->source_output)))
return;
- pa_source_output_set_volume(u->source_output, &s->real_volume, s->save_volume, TRUE);
+ pa_source_output_set_volume(u->source_output, &s->real_volume, s->save_volume, true);
}
/* Called from main context */
/* if uplink sink exists, pull data from there; simplify by using
same length as chunk provided by source */
- if(u->sink && (pa_sink_get_state(u->sink) == PA_SINK_RUNNING)) {
+ if (u->sink && (pa_sink_get_state(u->sink) == PA_SINK_RUNNING)) {
pa_memchunk tchunk;
size_t nbytes = chunk->length;
pa_mix_info streams[2];
pa_assert( target_chunk.memblock );
/* get target pointer */
- target = (void*)((uint8_t*)pa_memblock_acquire(target_chunk.memblock)
- + target_chunk.index);
+ target = pa_memblock_acquire_chunk(&target_chunk);
/* set-up mixing structure
volume was taken care of in sink and source already */
chunk->length, /* same length as input */
(const pa_sample_spec *)&o->sample_spec, /* same sample spec for input and output */
NULL, /* no volume information */
- FALSE); /* no mute */
+ false); /* no mute */
pa_memblock_release(target_chunk.memblock);
pa_memblock_unref(tchunk.memblock); /* clean-up */
pa_source_post(u->source, chunk);
}
-
}
/* Called from input thread context */
#endif
}
-/* Called from output thread context */
-static int source_output_process_msg_cb(pa_msgobject *obj, int code, void *data, int64_t offset, pa_memchunk *chunk) {
-
- /* FIXME, nothing to do here ? */
-
- return pa_source_output_process_msg(obj, code, data, offset, chunk);
-}
-
/* Called from output thread context */
static void source_output_attach_cb(pa_source_output *o) {
struct userdata *u;
pa_source_unref(u->source);
u->source = NULL;
- pa_module_unload_request(u->module, TRUE);
-}
-
-/* Called from main thread */
-static pa_bool_t source_output_may_move_to_cb(pa_source_output *o, pa_source *dest) {
- struct userdata *u;
-
- pa_source_output_assert_ref(o);
- pa_assert_ctl_context();
- pa_assert_se(u = o->userdata);
-
- /* FIXME */
- //return dest != u->source_input->source->monitor_source;
-
- return TRUE;
+ pa_module_unload_request(u->module, true);
}
/* Called from main thread */
}
}
-
int pa__init(pa_module*m) {
struct userdata *u;
pa_sample_spec ss;
pa_source *master=NULL;
pa_source_output_new_data source_output_data;
pa_source_new_data source_data;
- pa_bool_t use_volume_sharing = TRUE;
- pa_bool_t force_flat_volume = FALSE;
+ bool use_volume_sharing = true;
+ bool force_flat_volume = false;
/* optional for uplink_sink */
pa_sink_new_data sink_data;
}
u = pa_xnew0(struct userdata, 1);
- if (!u) {
- pa_log("Failed to alloc userdata");
- goto fail;
- }
u->module = m;
m->userdata = u;
- u->memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, NULL);
+ u->memblockq = pa_memblockq_new("module-virtual-source memblockq", 0, MEMBLOCKQ_MAXLENGTH, 0, &ss, 1, 1, 0, NULL);
if (!u->memblockq) {
pa_log("Failed to create source memblockq.");
goto fail;
pa_source_set_set_mute_callback(u->source, source_set_mute_cb);
if (!use_volume_sharing) {
pa_source_set_set_volume_callback(u->source, source_set_volume_cb);
- pa_source_enable_decibel_volume(u->source, TRUE);
+ pa_source_enable_decibel_volume(u->source, true);
}
/* Normally this flag would be enabled automatically be we can force it. */
if (force_flat_volume)
pa_source_output_new_data_init(&source_output_data);
source_output_data.driver = __FILE__;
source_output_data.module = m;
- pa_source_output_new_data_set_source(&source_output_data, master, FALSE);
+ pa_source_output_new_data_set_source(&source_output_data, master, false);
source_output_data.destination_source = u->source;
- /* FIXME
- source_output_data.flags = PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND; */
pa_proplist_setf(source_output_data.proplist, PA_PROP_MEDIA_NAME, "Virtual Source Stream of %s", pa_proplist_gets(u->source->proplist, PA_PROP_DEVICE_DESCRIPTION));
pa_proplist_sets(source_output_data.proplist, PA_PROP_MEDIA_ROLE, "filter");
if (!u->source_output)
goto fail;
- u->source_output->parent.process_msg = source_output_process_msg_cb;
u->source_output->push = source_output_push_cb;
u->source_output->process_rewind = source_output_process_rewind_cb;
u->source_output->kill = source_output_kill_cb;
u->source_output->attach = source_output_attach_cb;
u->source_output->detach = source_output_detach_cb;
u->source_output->state_change = source_output_state_change_cb;
- u->source_output->may_move_to = source_output_may_move_to_cb;
u->source_output->moving = source_output_moving_cb;
u->source_output->userdata = u;
pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Uplink Sink %s on %s", sink_data.name, z ? z : master->name);
}
- u->sink_memblockq = pa_memblockq_new(0, MEMBLOCKQ_MAXLENGTH, 0, pa_frame_size(&ss), 1, 1, 0, NULL);
+ u->sink_memblockq = pa_memblockq_new("module-virtual-source sink_memblockq", 0, MEMBLOCKQ_MAXLENGTH, 0, &ss, 1, 1, 0, NULL);
if (!u->sink_memblockq) {
pa_sink_new_data_done(&sink_data);
pa_log("Failed to create sink memblockq.");