]> code.delx.au - pulseaudio/commitdiff
Some crappy hardware generate noise on the output when reading input. To
authorPierre Ossman <ossman@cendio.se>
Thu, 12 Jan 2006 16:11:54 +0000 (16:11 +0000)
committerPierre Ossman <ossman@cendio.se>
Thu, 12 Jan 2006 16:11:54 +0000 (16:11 +0000)
avoid triggering this needlesly we tweak the algorithm a bit to avoid reading
when nothing is connected to the source.

git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@454 fefdeb5f-60dc-0310-8127-8f9354f1896f

polyp/module-oss.c

index 12cedf19ae7010237da4189b1cfc59f007cc37d2..06679a97d4d2184138416e028a4cbcecf41bafe7 100644 (file)
@@ -161,7 +161,7 @@ static void do_read(struct userdata *u) {
     int loop = 0;
     assert(u);
     
-    if (!u->source || !pa_iochannel_is_readable(u->io))
+    if (!u->source || !pa_iochannel_is_readable(u->io) || !pa_idxset_size(u->source->outputs))
         return;
 
     update_usage(u);
@@ -209,6 +209,12 @@ static void io_callback(PA_GCC_UNUSED pa_iochannel *io, void*userdata) {
     do_read(u);
 }
 
+static void source_notify_cb(pa_source *s) {
+    struct userdata *u = s->userdata;
+    assert(u);
+    do_read(u);
+}
+
 static pa_usec_t sink_get_latency_cb(pa_sink *s) {
     pa_usec_t r = 0;
     int arg;
@@ -329,6 +335,7 @@ int pa__init(pa_core *c, pa_module*m) {
         u->source = pa_source_new(c, PA_TYPEID_OSS, pa_modargs_get_value(ma, "source_name", DEFAULT_SOURCE_NAME), 0, &ss);
         assert(u->source);
         u->source->userdata = u;
+        u->source->notify = source_notify_cb;
         u->source->get_latency = source_get_latency_cb;
         pa_source_set_owner(u->source, m);
         u->source->description = pa_sprintf_malloc("Open Sound System PCM on '%s'", p);