]> code.delx.au - pulseaudio/blobdiff - src/pulsecore/sink.c
sink, source: Remove useless attach/detach stuff
[pulseaudio] / src / pulsecore / sink.c
index 81fefbc078ec959dc83db2ffea35eb3b7c1bf149..f4647b8bf4aba48ae8051440f5a9e15b4257ca1f 100644 (file)
@@ -304,9 +304,18 @@ pa_sink* pa_sink_new(
         void *state;
         pa_device_port *p;
 
-        PA_HASHMAP_FOREACH(p, s->ports, state)
+        PA_HASHMAP_FOREACH(p, s->ports, state) {
+            if (p->available == PA_AVAILABLE_NO)
+                continue;
+
             if (!s->active_port || p->priority > s->active_port->priority)
                 s->active_port = p;
+        }
+        if (!s->active_port) {
+            PA_HASHMAP_FOREACH(p, s->ports, state)
+                if (!s->active_port || p->priority > s->active_port->priority)
+                    s->active_port = p;
+        }
     }
 
     if (s->active_port)
@@ -1411,8 +1420,7 @@ int pa_sink_update_rate(pa_sink *s, uint32_t rate, bool passthrough) {
         }
     }
 
-    if (PA_UNLIKELY (desired_rate < 8000 ||
-                     desired_rate > PA_RATE_MAX))
+    if (PA_UNLIKELY(!pa_sample_rate_valid(desired_rate)))
         return -1;
 
     if (!passthrough) {
@@ -2796,18 +2804,6 @@ int pa_sink_process_msg(pa_msgobject *o, int code, void *userdata, int64_t offse
             return 0;
         }
 
-        case PA_SINK_MESSAGE_DETACH:
-
-            /* Detach all streams */
-            pa_sink_detach_within_thread(s);
-            return 0;
-
-        case PA_SINK_MESSAGE_ATTACH:
-
-            /* Reattach all streams */
-            pa_sink_attach_within_thread(s);
-            return 0;
-
         case PA_SINK_MESSAGE_GET_REQUESTED_LATENCY: {
 
             pa_usec_t *usec = userdata;
@@ -2922,24 +2918,6 @@ int pa_sink_suspend_all(pa_core *c, bool suspend, pa_suspend_cause_t cause) {
     return ret;
 }
 
-/* Called from main thread */
-void pa_sink_detach(pa_sink *s) {
-    pa_sink_assert_ref(s);
-    pa_assert_ctl_context();
-    pa_assert(PA_SINK_IS_LINKED(s->state));
-
-    pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_DETACH, NULL, 0, NULL) == 0);
-}
-
-/* Called from main thread */
-void pa_sink_attach(pa_sink *s) {
-    pa_sink_assert_ref(s);
-    pa_assert_ctl_context();
-    pa_assert(PA_SINK_IS_LINKED(s->state));
-
-    pa_assert_se(pa_asyncmsgq_send(s->asyncmsgq, PA_MSGOBJECT(s), PA_SINK_MESSAGE_ATTACH, NULL, 0, NULL) == 0);
-}
-
 /* Called from IO thread */
 void pa_sink_detach_within_thread(pa_sink *s) {
     pa_sink_input *i;