summaryrefslogtreecommitdiffstats
path: root/src/modules/module-null-sink.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2007-08-30 22:57:53 +0000
committerLennart Poettering <lennart@poettering.net>2007-08-30 22:57:53 +0000
commit4d623f0d4442148f20f2ffdc85cf95e54ef83721 (patch)
treef758269ece89edac69365e19317ee221af7a6889 /src/modules/module-null-sink.c
parentb552541dd1f65646a5963e7a8c8ec43e4ea416c8 (diff)
Lots of assorted minor cleanups and fixes:
* s/disconnect/unlink/ at many places where it makes sense * make "start_corked" a normal pa_sink_input/pa_source_output flag instead of a seperate boolean variable * add generic process() function to pa_sink_input/pa_source_output vtable that can be used by streams to do some arbitrary processing in each rt loop iteration even the sink/source is suspended * add detach()/attach() functions to pa_sink_input/pa_source_output vtable that are called when ever the rtpoll object of the event thread changes * add suspend() functions to pa_sink_input/pa_source_output vtable which are called whenever the sink/source they are attached to suspends/resumes * add PA_SINK_INIT/PA_SOURCE_INIT/PA_SINK_INPUT_INIT/PA_SINK_OUTPUT_INIT states to state machines which is active between _new() and _put() * seperate _put() from _new() for pa_sink/pa_source * add PA_SOURCE_OUTPUT_DONT_MOVE/PA_SINK_INPUT_DONT_MOVE flags * make the pa_rtpoll object a property of pa_sink/pa_source to allow streams attached to them make use of it * fix skipping over move_silence * update module-pipe-source to make use of pa_rtpoll * add pa_sink_skip() as optimization in cases where the actualy data returned by pa_sink_render() doesn't matter git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1733 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/modules/module-null-sink.c')
-rw-r--r--src/modules/module-null-sink.c39
1 files changed, 17 insertions, 22 deletions
diff --git a/src/modules/module-null-sink.c b/src/modules/module-null-sink.c
index 3b512371..78d99ceb 100644
--- a/src/modules/module-null-sink.c
+++ b/src/modules/module-null-sink.c
@@ -128,11 +128,7 @@ static void thread_func(void *userdata) {
pa_rtclock_get(&u->timestamp);
for (;;) {
- pa_msgobject *object;
- int code;
- void *data;
- pa_memchunk chunk;
- int64_t offset;
+ int ret;
/* Render some data and drop it immediately */
if (u->sink->thread_info.state == PA_SINK_RUNNING) {
@@ -141,30 +137,25 @@ static void thread_func(void *userdata) {
pa_rtclock_get(&now);
if (pa_timespec_cmp(&u->timestamp, &now) <= 0) {
-
- pa_sink_render(u->sink, u->block_size, &chunk);
- pa_memblock_unref(chunk.memblock);
-
- pa_timespec_add(&u->timestamp, pa_bytes_to_usec(chunk.length, &u->sink->sample_spec));
+ pa_sink_skip(u->sink, u->block_size);
+ pa_timespec_add(&u->timestamp, pa_bytes_to_usec(u->block_size, &u->sink->sample_spec));
}
pa_rtpoll_set_timer_absolute(u->rtpoll, &u->timestamp);
} else
pa_rtpoll_set_timer_disabled(u->rtpoll);
- /* Check whether there is a message for us to process */
- if (pa_asyncmsgq_get(u->thread_mq.inq, &object, &code, &data, &offset, &chunk, 0) == 0) {
- int ret;
-
- if (!object && code == PA_MESSAGE_SHUTDOWN) {
- pa_asyncmsgq_done(u->thread_mq.inq, 0);
- goto finish;
- }
+ /* Now give the sink inputs some to time to process their data */
+ if ((ret = pa_sink_process_inputs(u->sink)) < 0)
+ goto fail;
+ if (ret > 0)
+ continue;
- ret = pa_asyncmsgq_dispatch(object, code, data, offset, &chunk);
- pa_asyncmsgq_done(u->thread_mq.inq, ret);
+ /* Check whether there is a message for us to process */
+ if ((ret = pa_thread_mq_process(&u->thread_mq) < 0))
+ goto finish;
+ if (ret > 0)
continue;
- }
/* Hmm, nothing to do. Let's sleep */
if (pa_rtpoll_run(u->rtpoll) < 0) {
@@ -217,9 +208,11 @@ int pa__init(pa_module*m) {
u->sink->parent.process_msg = sink_process_msg;
u->sink->userdata = u;
+ u->sink->flags = PA_SINK_LATENCY;
pa_sink_set_module(u->sink, m);
pa_sink_set_asyncmsgq(u->sink, u->thread_mq.inq);
+ pa_sink_set_rtpoll(u->sink, u->rtpoll);
pa_sink_set_description(u->sink, pa_modargs_get_value(ma, "description", "NULL sink"));
u->block_size = pa_bytes_per_second(&ss) / 20; /* 50 ms */
@@ -231,6 +224,8 @@ int pa__init(pa_module*m) {
goto fail;
}
+ pa_sink_put(u->sink);
+
pa_modargs_free(ma);
return 0;
@@ -253,7 +248,7 @@ void pa__done(pa_module*m) {
return;
if (u->sink)
- pa_sink_disconnect(u->sink);
+ pa_sink_unlink(u->sink);
if (u->thread) {
pa_asyncmsgq_send(u->thread_mq.inq, NULL, PA_MESSAGE_SHUTDOWN, NULL, 0, NULL);