[pulseaudio-commits] r1608 - /branches/lennart/src/modules/module-rescue-streams.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Thu Aug 9 14:57:03 PDT 2007


Author: lennart
Date: Thu Aug  9 23:57:01 2007
New Revision: 1608

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1608&root=3Dpulseaudio&vi=
ew=3Drev
Log:
don't assume that sink/source is already unregistered from namereg when dis=
connect hook is called

Modified:
    branches/lennart/src/modules/module-rescue-streams.c

Modified: branches/lennart/src/modules/module-rescue-streams.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/modules/mo=
dule-rescue-streams.c?rev=3D1608&root=3Dpulseaudio&r1=3D1607&r2=3D1608&view=
=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/modules/module-rescue-streams.c (original)
+++ branches/lennart/src/modules/module-rescue-streams.c Thu Aug  9 23:57:0=
1 2007
@@ -52,20 +52,26 @@
     pa_sink_input *i;
     pa_sink *target;
 =

-    assert(c);
-    assert(sink);
+    pa_assert(c);
+    pa_assert(sink);
 =

     if (!pa_idxset_size(sink->inputs)) {
         pa_log_debug("No sink inputs to move away.");
         return PA_HOOK_OK;
     }
 =

-    if (!(target =3D pa_namereg_get(c, NULL, PA_NAMEREG_SINK, 0))) {
-        pa_log_info("No evacuation sink found.");
-        return PA_HOOK_OK;
+    if (!(target =3D pa_namereg_get(c, NULL, PA_NAMEREG_SINK, 0)) || targe=
t =3D=3D sink) {
+        uint32_t idx;
+        =

+        for (target =3D pa_idxset_first(c->sinks, &idx); target; target =
=3D pa_idxset_next(c->sinks, &idx))
+            if (target !=3D sink)
+                break;
+
+        if (!target) {
+            pa_log_info("No evacuation sink found.");
+            return PA_HOOK_OK;
+        }
     }
-
-    assert(target !=3D sink);
 =

     while ((i =3D pa_idxset_first(sink->inputs, NULL))) {
         if (pa_sink_input_move_to(i, target, 1) < 0) {
@@ -84,20 +90,28 @@
     pa_source_output *o;
     pa_source *target;
 =

-    assert(c);
-    assert(source);
+    pa_assert(c);
+    pa_assert(source);
 =

     if (!pa_idxset_size(source->outputs)) {
         pa_log_debug("No source outputs to move away.");
         return PA_HOOK_OK;
     }
 =

-    if (!(target =3D pa_namereg_get(c, NULL, PA_NAMEREG_SOURCE, 0))) {
-        pa_log_info("No evacuation source found.");
-        return PA_HOOK_OK;
+    if (!(target =3D pa_namereg_get(c, NULL, PA_NAMEREG_SOURCE, 0)) || tar=
get =3D=3D source) {
+        uint32_t idx;
+
+        for (target =3D pa_idxset_first(c->sources, &idx); target; target =
=3D pa_idxset_next(c->sources, &idx))
+            if (target !=3D source && !target->monitor_of =3D=3D !source->=
monitor_of)
+                break;
+
+        if (!target) {
+            pa_log_info("No evacuation source found.");
+            return PA_HOOK_OK;
+        }
     }
 =

-    assert(target !=3D source);
+    pa_assert(target !=3D source);
 =

     while ((o =3D pa_idxset_first(source->outputs, NULL))) {
         if (pa_source_output_move_to(o, target) < 0) {
@@ -116,8 +130,8 @@
     pa_modargs *ma =3D NULL;
     struct userdata *u;
 =

-    assert(c);
-    assert(m);
+    pa_assert(c);
+    pa_assert(m);
 =

     if (!(ma =3D pa_modargs_new(m->argument, valid_modargs))) {
         pa_log("Failed to parse module arguments");
@@ -135,8 +149,8 @@
 void pa__done(pa_core *c, pa_module*m) {
     struct userdata *u;
 =

-    assert(c);
-    assert(m);
+    pa_assert(c);
+    pa_assert(m);
 =

     if (!m->userdata)
         return;




More information about the pulseaudio-commits mailing list