]> code.delx.au - pulseaudio/blobdiff - src/pulse/ext-stream-restore.c
Remove unnecessary #includes
[pulseaudio] / src / pulse / ext-stream-restore.c
index 469c822a74fc1103ed6115d44e9ea961ef04e897..1f72c1c40e40fec08b1ff30288cebb2235b54676 100644 (file)
@@ -5,7 +5,7 @@
 
   PulseAudio is free software; you can redistribute it and/or modify
   it under the terms of the GNU Lesser General Public License as published
-  by the Free Software Foundation; either version 2 of the License,
+  by the Free Software Foundation; either version 2.1 of the License,
   or (at your option) any later version.
 
   PulseAudio is distributed in the hope that it will be useful, but
 #endif
 
 #include <pulse/context.h>
-#include <pulse/gccmacro.h>
+#include <pulse/fork-detect.h>
+#include <pulse/operation.h>
 
 #include <pulsecore/macro.h>
 #include <pulsecore/pstream-util.h>
 
 #include "internal.h"
-#include "operation.h"
-
 #include "ext-stream-restore.h"
 
 enum {
@@ -87,6 +86,7 @@ pa_operation *pa_ext_stream_restore_test(
     pa_assert(c);
     pa_assert(PA_REFCNT_VALUE(c) >= 1);
 
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 14, PA_ERR_NOTSUPPORTED);
 
@@ -167,6 +167,7 @@ pa_operation *pa_ext_stream_restore_read(
     pa_assert(c);
     pa_assert(PA_REFCNT_VALUE(c) >= 1);
 
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 14, PA_ERR_NOTSUPPORTED);
 
@@ -200,6 +201,7 @@ pa_operation *pa_ext_stream_restore_write(
     pa_assert(mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE || mode == PA_UPDATE_SET);
     pa_assert(data);
 
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 14, PA_ERR_NOTSUPPORTED);
 
@@ -235,13 +237,10 @@ pa_operation *pa_ext_stream_restore_write(
     return o;
 
 fail:
-    if (o) {
-        pa_operation_cancel(o);
-        pa_operation_unref(o);
-    }
+    pa_operation_cancel(o);
+    pa_operation_unref(o);
 
-    if (t)
-        pa_tagstruct_free(t);
+    pa_tagstruct_free(t);
 
     pa_context_set_error(c, PA_ERR_INVALID);
     return NULL;
@@ -262,6 +261,7 @@ pa_operation *pa_ext_stream_restore_delete(
     pa_assert(PA_REFCNT_VALUE(c) >= 1);
     pa_assert(s);
 
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 14, PA_ERR_NOTSUPPORTED);
 
@@ -285,13 +285,10 @@ pa_operation *pa_ext_stream_restore_delete(
     return o;
 
 fail:
-    if (o) {
-        pa_operation_cancel(o);
-        pa_operation_unref(o);
-    }
+    pa_operation_cancel(o);
+    pa_operation_unref(o);
 
-    if (t)
-        pa_tagstruct_free(t);
+    pa_tagstruct_free(t);
 
     pa_context_set_error(c, PA_ERR_INVALID);
     return NULL;
@@ -310,6 +307,7 @@ pa_operation *pa_ext_stream_restore_subscribe(
     pa_assert(c);
     pa_assert(PA_REFCNT_VALUE(c) >= 1);
 
+    PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
     PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 14, PA_ERR_NOTSUPPORTED);
 
@@ -334,6 +332,9 @@ void pa_ext_stream_restore_set_subscribe_cb(
     pa_assert(c);
     pa_assert(PA_REFCNT_VALUE(c) >= 1);
 
+    if (pa_detect_fork())
+        return;
+
     c->ext_stream_restore.callback = cb;
     c->ext_stream_restore.userdata = userdata;
 }