[pulseaudio-discuss] [PATCH 2/2] sink, source: Add a flag to inhibit suspend

Arun Raghavan arun.raghavan at collabora.co.uk
Mon Jul 23 01:57:28 PDT 2012


This adds the ability to inhibit the suspending of a sink/source. Policy
modules may override this, but should avoid doing so if they can.
---
 src/pulse/def.h        |    6 ++++++
 src/pulsecore/sink.c   |    3 +++
 src/pulsecore/source.c |    3 +++
 3 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/pulse/def.h b/src/pulse/def.h
index b939319..a957a28 100644
--- a/src/pulse/def.h
+++ b/src/pulse/def.h
@@ -784,6 +784,9 @@ typedef enum pa_sink_flags {
 
     PA_SINK_DEFERRED_VOLUME = 0x2000000U,
     /**< The HW volume changes are syncronized with SW volume. */
+
+    PA_SINK_ALWAYS_RUNNING = 0x4000000U,
+    /**< The sink should not be automatically suspended. */
 /** \endcond */
 #endif
 
@@ -903,6 +906,9 @@ typedef enum pa_source_flags {
 
     PA_SOURCE_DEFERRED_VOLUME = 0x2000000U,
     /**< The HW volume changes are syncronized with SW volume. */
+
+    PA_SOURCE_ALWAYS_RUNNING = 0x4000000U,
+    /**< The source should not be automatically suspended. */
 #endif
 } pa_source_flags_t;
 
diff --git a/src/pulsecore/sink.c b/src/pulsecore/sink.c
index b80f353..7cef788 100644
--- a/src/pulsecore/sink.c
+++ b/src/pulsecore/sink.c
@@ -816,6 +816,9 @@ int pa_sink_suspend(pa_sink *s, pa_bool_t suspend, pa_suspend_cause_t cause) {
     pa_assert(PA_SINK_IS_LINKED(s->state));
     pa_assert(cause != 0);
 
+    if ((s->flags & PA_SINK_ALWAYS_RUNNING) && (cause == PA_SUSPEND_IDLE))
+        return 0;
+
     if (suspend) {
         s->suspend_cause |= cause;
         s->monitor_source->suspend_cause |= cause;
diff --git a/src/pulsecore/source.c b/src/pulsecore/source.c
index b5b80c0..37f5a4a 100644
--- a/src/pulsecore/source.c
+++ b/src/pulsecore/source.c
@@ -734,6 +734,9 @@ int pa_source_suspend(pa_source *s, pa_bool_t suspend, pa_suspend_cause_t cause)
     pa_assert(PA_SOURCE_IS_LINKED(s->state));
     pa_assert(cause != 0);
 
+    if ((s->flags & PA_SINK_ALWAYS_RUNNING) && (cause == PA_SUSPEND_IDLE))
+        return 0;
+
     if (s->monitor_of && cause != PA_SUSPEND_PASSTHROUGH)
         return -PA_ERR_NOTSUPPORTED;
 
-- 
1.7.8.6



More information about the pulseaudio-discuss mailing list