[pulseaudio-commits] r2359 - in /branches/glitch-free/src/modules: module-ladspa-sink.c module-remap-sink.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Fri May 2 19:01:33 PDT 2008
Author: lennart
Date: Sat May 3 04:01:29 2008
New Revision: 2359
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=2359&root=pulseaudio&view=rev
Log:
fix remapping sink for glitch-free
Modified:
branches/glitch-free/src/modules/module-ladspa-sink.c
branches/glitch-free/src/modules/module-remap-sink.c
Modified: branches/glitch-free/src/modules/module-ladspa-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/modules/module-ladspa-sink.c?rev=2359&root=pulseaudio&r1=2358&r2=2359&view=diff
==============================================================================
--- branches/glitch-free/src/modules/module-ladspa-sink.c (original)
+++ branches/glitch-free/src/modules/module-ladspa-sink.c Sat May 3 04:01:29 2008
@@ -3,7 +3,7 @@
/***
This file is part of PulseAudio.
- Copyright 2004-2006 Lennart Poettering
+ Copyright 2004-2008 Lennart Poettering
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
@@ -264,10 +264,11 @@
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
+ if (!u->sink)
+ return;
+
pa_memblockq_set_maxrewind(u->memblockq, nbytes);
-
- if (u->sink)
- pa_sink_set_max_rewind(u->sink, nbytes);
+ pa_sink_set_max_rewind(u->sink, nbytes);
}
/* Called from I/O thread context */
@@ -277,11 +278,12 @@
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
- if (u->sink) {
- pa_sink_detach_within_thread(u->sink);
- pa_sink_set_asyncmsgq(u->sink, NULL);
- pa_sink_set_rtpoll(u->sink, NULL);
- }
+ if (!u->sink)
+ return;
+
+ pa_sink_detach_within_thread(u->sink);
+ pa_sink_set_asyncmsgq(u->sink, NULL);
+ pa_sink_set_rtpoll(u->sink, NULL);
}
/* Called from I/O thread context */
@@ -291,14 +293,15 @@
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
- if (u->sink) {
- pa_sink_set_asyncmsgq(u->sink, i->sink->asyncmsgq);
- pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
- pa_sink_attach_within_thread(u->sink);
-
- u->sink->max_latency = u->master->max_latency;
- u->sink->min_latency = u->master->min_latency;
- }
+ if (!u->sink)
+ return;
+
+ pa_sink_set_asyncmsgq(u->sink, i->sink->asyncmsgq);
+ pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
+ pa_sink_attach_within_thread(u->sink);
+
+ u->sink->max_latency = u->master->max_latency;
+ u->sink->min_latency = u->master->min_latency;
}
/* Called from main context */
@@ -663,6 +666,7 @@
z = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION);
pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "LADSPA Plugin %s on %s", label, z ? z : master->name);
pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_MASTER_DEVICE, master->name);
+ pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_CLASS, "filter");
pa_proplist_sets(sink_data.proplist, "device.ladspa.module", plugin);
pa_proplist_sets(sink_data.proplist, "device.ladspa.label", d->Label);
pa_proplist_sets(sink_data.proplist, "device.ladspa.name", d->Name);
@@ -693,7 +697,7 @@
sink_input_data.module = m;
sink_input_data.sink = u->master;
pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_NAME, "LADSPA Stream");
- pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "routing");
+ pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "filter");
pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
pa_sink_input_new_data_set_channel_map(&sink_input_data, &map);
@@ -741,14 +745,14 @@
if (!(u = m->userdata))
return;
+ if (u->sink) {
+ pa_sink_unlink(u->sink);
+ pa_sink_unref(u->sink);
+ }
+
if (u->sink_input) {
pa_sink_input_unlink(u->sink_input);
pa_sink_input_unref(u->sink_input);
- }
-
- if (u->sink) {
- pa_sink_unlink(u->sink);
- pa_sink_unref(u->sink);
}
for (c = 0; c < u->channels; c++)
Modified: branches/glitch-free/src/modules/module-remap-sink.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/glitch-free/src/modules/module-remap-sink.c?rev=2359&root=pulseaudio&r1=2358&r2=2359&view=diff
==============================================================================
--- branches/glitch-free/src/modules/module-remap-sink.c (original)
+++ branches/glitch-free/src/modules/module-remap-sink.c Sat May 3 04:01:29 2008
@@ -3,7 +3,7 @@
/***
This file is part of PulseAudio.
- Copyright 2004-2006 Lennart Poettering
+ Copyright 2004-2008 Lennart Poettering
PulseAudio is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published
@@ -119,7 +119,10 @@
pa_sink_assert_ref(s);
pa_assert_se(u = s->userdata);
- pa_sink_input_request_rewind(u->sink_input, s->thread_info.rewind_nbytes, FALSE, FALSE);
+ pa_sink_input_request_rewind(
+ u->sink_input,
+ s->thread_info.rewind_nbytes,
+ FALSE, FALSE);
}
/* Called from I/O thread context */
@@ -143,6 +146,9 @@
pa_assert(chunk);
pa_assert_se(u = i->userdata);
+ if (!u->sink)
+ return -1;
+
pa_sink_render(u->sink, nbytes, chunk);
return 0;
}
@@ -155,7 +161,18 @@
pa_assert_se(u = i->userdata);
pa_assert(nbytes > 0);
- pa_sink_process_rewind(u->sink, nbytes);
+ if (!u->sink)
+ return;
+
+ if (u->sink->thread_info.rewind_nbytes > 0) {
+ size_t amount;
+
+ amount = PA_MIN(u->sink->thread_info.rewind_nbytes, nbytes);
+ u->sink->thread_info.rewind_nbytes = 0;
+
+ if (amount > 0)
+ pa_sink_process_rewind(u->sink, amount);
+ }
}
/* Called from I/O thread context */
@@ -165,6 +182,9 @@
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
+ if (!u->sink)
+ return;
+
pa_sink_set_max_rewind(u->sink, nbytes);
}
@@ -175,8 +195,10 @@
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
+ if (!u->sink)
+ return;
+
pa_sink_detach_within_thread(u->sink);
-
pa_sink_set_asyncmsgq(u->sink, NULL);
pa_sink_set_rtpoll(u->sink, NULL);
}
@@ -188,10 +210,15 @@
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
+ if (!u->sink)
+ return;
+
pa_sink_set_asyncmsgq(u->sink, i->sink->asyncmsgq);
pa_sink_set_rtpoll(u->sink, i->sink->rtpoll);
-
pa_sink_attach_within_thread(u->sink);
+
+ u->sink->max_latency = u->master->max_latency;
+ u->sink->min_latency = u->master->min_latency;
}
/* Called from main context */
@@ -200,16 +227,32 @@
pa_sink_input_assert_ref(i);
pa_assert_se(u = i->userdata);
+
+ pa_sink_unlink(u->sink);
+ pa_sink_unref(u->sink);
+ u->sink = NULL;
pa_sink_input_unlink(u->sink_input);
pa_sink_input_unref(u->sink_input);
u->sink_input = NULL;
- pa_sink_unlink(u->sink);
- pa_sink_unref(u->sink);
- u->sink = NULL;
-
pa_module_unload_request(u->module);
+}
+
+/* Called from IO thread context */
+static void sink_input_state_change_cb(pa_sink_input *i, pa_sink_input_state_t state) {
+ struct userdata *u;
+
+ pa_sink_input_assert_ref(i);
+ pa_assert_se(u = i->userdata);
+
+ /* If we are added for the first time, ask for a rewinding so that
+ * we are heard right-away. */
+ if (PA_SINK_INPUT_IS_LINKED(state) &&
+ i->thread_info.state == PA_SINK_INPUT_INIT) {
+ pa_log_debug("Requesting rewind due to state change.");
+ pa_sink_input_request_rewind(i, 0, TRUE, TRUE);
+ }
}
int pa__init(pa_module*m) {
@@ -217,7 +260,6 @@
pa_sample_spec ss;
pa_channel_map sink_map, stream_map;
pa_modargs *ma;
- char *t;
const char *k;
pa_sink *master;
pa_sink_input_new_data sink_input_data;
@@ -273,11 +315,11 @@
pa_sink_new_data_set_sample_spec(&sink_data, &ss);
pa_sink_new_data_set_channel_map(&sink_data, &sink_map);
k = pa_proplist_gets(master->proplist, PA_PROP_DEVICE_DESCRIPTION);
- pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, t = pa_sprintf_malloc("Remapped %s", k ? k : master->name));
- pa_xfree(t);
+ pa_proplist_setf(sink_data.proplist, PA_PROP_DEVICE_DESCRIPTION, "Remapped %s", k ? k : master->name);
pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_MASTER_DEVICE, master->name);
-
- u->sink = pa_sink_new(m->core, &sink_data, 0);
+ pa_proplist_sets(sink_data.proplist, PA_PROP_DEVICE_CLASS, "filter");
+
+ u->sink = pa_sink_new(m->core, &sink_data, PA_SINK_LATENCY);
pa_sink_new_data_done(&sink_data);
if (!u->sink) {
@@ -290,7 +332,6 @@
u->sink->update_requested_latency = sink_update_requested_latency;
u->sink->request_rewind = sink_request_rewind;
u->sink->userdata = u;
- u->sink->flags = PA_SINK_LATENCY;
pa_sink_set_asyncmsgq(u->sink, master->asyncmsgq);
pa_sink_set_rtpoll(u->sink, master->rtpoll);
@@ -301,7 +342,7 @@
sink_input_data.module = m;
sink_input_data.sink = u->master;
pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_NAME, "Remapped Stream");
- pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "routing");
+ pa_proplist_sets(sink_input_data.proplist, PA_PROP_MEDIA_ROLE, "filter");
pa_sink_input_new_data_set_sample_spec(&sink_input_data, &ss);
pa_sink_input_new_data_set_channel_map(&sink_input_data, &stream_map);
@@ -317,6 +358,7 @@
u->sink_input->kill = sink_input_kill_cb;
u->sink_input->attach = sink_input_attach_cb;
u->sink_input->detach = sink_input_detach_cb;
+ u->sink_input->state_change = sink_input_state_change_cb;
u->sink_input->userdata = u;
pa_sink_put(u->sink);
@@ -343,15 +385,15 @@
if (!(u = m->userdata))
return;
+ if (u->sink) {
+ pa_sink_unlink(u->sink);
+ pa_sink_unref(u->sink);
+ }
+
if (u->sink_input) {
pa_sink_input_unlink(u->sink_input);
pa_sink_input_unref(u->sink_input);
}
- if (u->sink) {
- pa_sink_unlink(u->sink);
- pa_sink_unref(u->sink);
- }
-
pa_xfree(u);
}
More information about the pulseaudio-commits
mailing list