[pulseaudio-discuss] [PATCH 1/8] alsa, solaris, oss: remove unnecessary error handling when suspending

Tanu Kaskinen tanuk at iki.fi
Mon Feb 19 14:48:19 UTC 2018


Suspending never fails.
---
 src/modules/alsa/alsa-sink.c   |  9 ++-------
 src/modules/alsa/alsa-source.c |  9 ++-------
 src/modules/module-solaris.c   | 18 +++++++-----------
 src/modules/oss/module-oss.c   | 16 +++++-----------
 4 files changed, 16 insertions(+), 36 deletions(-)

diff --git a/src/modules/alsa/alsa-sink.c b/src/modules/alsa/alsa-sink.c
index a80caab2e..44f006b1f 100644
--- a/src/modules/alsa/alsa-sink.c
+++ b/src/modules/alsa/alsa-sink.c
@@ -939,7 +939,7 @@ static int build_pollfd(struct userdata *u) {
 }
 
 /* Called from IO context */
-static int suspend(struct userdata *u) {
+static void suspend(struct userdata *u) {
     pa_assert(u);
     pa_assert(u->pcm_handle);
 
@@ -964,8 +964,6 @@ static int suspend(struct userdata *u) {
     pa_sink_set_max_request_within_thread(u->sink, 0);
 
     pa_log_info("Device suspended...");
-
-    return 0;
 }
 
 /* Called from IO context */
@@ -1192,12 +1190,9 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
             switch ((pa_sink_state_t) PA_PTR_TO_UINT(data)) {
 
                 case PA_SINK_SUSPENDED: {
-                    int r;
-
                     pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
 
-                    if ((r = suspend(u)) < 0)
-                        return r;
+                    suspend(u);
 
                     break;
                 }
diff --git a/src/modules/alsa/alsa-source.c b/src/modules/alsa/alsa-source.c
index 3f87a4792..608cb0d63 100644
--- a/src/modules/alsa/alsa-source.c
+++ b/src/modules/alsa/alsa-source.c
@@ -837,7 +837,7 @@ static int build_pollfd(struct userdata *u) {
 }
 
 /* Called from IO context */
-static int suspend(struct userdata *u) {
+static void suspend(struct userdata *u) {
     pa_assert(u);
     pa_assert(u->pcm_handle);
 
@@ -853,8 +853,6 @@ static int suspend(struct userdata *u) {
     }
 
     pa_log_info("Device suspended...");
-
-    return 0;
 }
 
 /* Called from IO context */
@@ -1047,12 +1045,9 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
             switch ((pa_source_state_t) PA_PTR_TO_UINT(data)) {
 
                 case PA_SOURCE_SUSPENDED: {
-                    int r;
-
                     pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
 
-                    if ((r = suspend(u)) < 0)
-                        return r;
+                    suspend(u);
 
                     break;
                 }
diff --git a/src/modules/module-solaris.c b/src/modules/module-solaris.c
index 880aa43e7..a4960b8b7 100644
--- a/src/modules/module-solaris.c
+++ b/src/modules/module-solaris.c
@@ -348,7 +348,7 @@ static int open_audio_device(struct userdata *u, pa_sample_spec *ss) {
     return u->fd;
 }
 
-static int suspend(struct userdata *u) {
+static void suspend(struct userdata *u) {
     pa_assert(u);
     pa_assert(u->fd >= 0);
 
@@ -364,8 +364,6 @@ static int suspend(struct userdata *u) {
     }
 
     pa_log_info("Device suspended.");
-
-    return 0;
 }
 
 static int unsuspend(struct userdata *u) {
@@ -403,10 +401,9 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
 
                     pa_smoother_pause(u->smoother, pa_rtclock_now());
 
-                    if (!u->source || u->source_suspended) {
-                        if (suspend(u) < 0)
-                            return -1;
-                    }
+                    if (!u->source || u->source_suspended)
+                        suspend(u);
+
                     u->sink_suspended = true;
                     break;
 
@@ -457,10 +454,9 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
 
                     pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
 
-                    if (!u->sink || u->sink_suspended) {
-                        if (suspend(u) < 0)
-                            return -1;
-                    }
+                    if (!u->sink || u->sink_suspended)
+                        suspend(u);
+
                     u->source_suspended = true;
                     break;
 
diff --git a/src/modules/oss/module-oss.c b/src/modules/oss/module-oss.c
index 93b55ad8b..fb978b5ee 100644
--- a/src/modules/oss/module-oss.c
+++ b/src/modules/oss/module-oss.c
@@ -485,7 +485,7 @@ static void build_pollfd(struct userdata *u) {
 }
 
 /* Called from IO context */
-static int suspend(struct userdata *u) {
+static void suspend(struct userdata *u) {
     pa_assert(u);
     pa_assert(u->fd >= 0);
 
@@ -530,8 +530,6 @@ static int suspend(struct userdata *u) {
     }
 
     pa_log_info("Device suspended...");
-
-    return 0;
 }
 
 /* Called from IO context */
@@ -670,10 +668,8 @@ static int sink_process_msg(pa_msgobject *o, int code, void *data, int64_t offse
                 case PA_SINK_SUSPENDED:
                     pa_assert(PA_SINK_IS_OPENED(u->sink->thread_info.state));
 
-                    if (!u->source || u->source_suspended) {
-                        if (suspend(u) < 0)
-                            return -1;
-                    }
+                    if (!u->source || u->source_suspended)
+                        suspend(u);
 
                     do_trigger = true;
 
@@ -753,10 +749,8 @@ static int source_process_msg(pa_msgobject *o, int code, void *data, int64_t off
                 case PA_SOURCE_SUSPENDED:
                     pa_assert(PA_SOURCE_IS_OPENED(u->source->thread_info.state));
 
-                    if (!u->sink || u->sink_suspended) {
-                        if (suspend(u) < 0)
-                            return -1;
-                    }
+                    if (!u->sink || u->sink_suspended)
+                        suspend(u);
 
                     do_trigger = true;
 
-- 
2.15.1



More information about the pulseaudio-discuss mailing list