diff options
Diffstat (limited to 'src/pulse')
47 files changed, 309 insertions, 58 deletions
diff --git a/src/pulse/browser.c b/src/pulse/browser.c index 1a3f657f..4cf5d0c3 100644 --- a/src/pulse/browser.c +++ b/src/pulse/browser.c @@ -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 + published 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 diff --git a/src/pulse/browser.h b/src/pulse/browser.h index 499fae2e..c843e2a2 100644 --- a/src/pulse/browser.h +++ b/src/pulse/browser.h @@ -8,7 +8,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 + published 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 diff --git a/src/pulse/cdecl.h b/src/pulse/cdecl.h index 8c5b2d0f..dd0d14f7 100644 --- a/src/pulse/cdecl.h +++ b/src/pulse/cdecl.h @@ -8,7 +8,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 diff --git a/src/pulse/channelmap.c b/src/pulse/channelmap.c index 82e36c00..ce7dadc9 100644 --- a/src/pulse/channelmap.c +++ b/src/pulse/channelmap.c @@ -6,7 +6,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 diff --git a/src/pulse/channelmap.h b/src/pulse/channelmap.h index a6d37d85..eef0ac17 100644 --- a/src/pulse/channelmap.h +++ b/src/pulse/channelmap.h @@ -9,7 +9,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 diff --git a/src/pulse/client-conf-x11.c b/src/pulse/client-conf-x11.c index a8a90fb8..3bec742f 100644 --- a/src/pulse/client-conf-x11.c +++ b/src/pulse/client-conf-x11.c @@ -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 diff --git a/src/pulse/client-conf-x11.h b/src/pulse/client-conf-x11.h index f2f40e03..dca9f0d2 100644 --- a/src/pulse/client-conf-x11.h +++ b/src/pulse/client-conf-x11.h @@ -8,7 +8,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 diff --git a/src/pulse/client-conf.c b/src/pulse/client-conf.c index 71f8443d..58bc3f90 100644 --- a/src/pulse/client-conf.c +++ b/src/pulse/client-conf.c @@ -6,7 +6,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 diff --git a/src/pulse/client-conf.h b/src/pulse/client-conf.h index 4eac467e..78844a12 100644 --- a/src/pulse/client-conf.h +++ b/src/pulse/client-conf.h @@ -8,7 +8,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 diff --git a/src/pulse/context.c b/src/pulse/context.c index 62fe5356..00dffc25 100644 --- a/src/pulse/context.c +++ b/src/pulse/context.c @@ -6,7 +6,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 @@ -74,6 +74,7 @@ #include "internal.h" #include "client-conf.h" +#include "fork-detect.h" #ifdef HAVE_X11 #include "client-conf-x11.h" @@ -127,6 +128,9 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char * pa_assert(mainloop); + if (pa_detect_fork()) + return NULL; + pa_init_i18n(); c = pa_xnew(pa_context, 1); @@ -822,6 +826,7 @@ int pa_context_connect( pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + PA_CHECK_VALIDITY(c, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(c, c->state == PA_CONTEXT_UNCONNECTED, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(c, !(flags & ~PA_CONTEXT_NOAUTOSPAWN), PA_ERR_INVALID); PA_CHECK_VALIDITY(c, !server || *server, PA_ERR_INVALID); @@ -894,6 +899,9 @@ void pa_context_disconnect(pa_context *c) { pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + if (pa_detect_fork()) + return; + if (PA_CONTEXT_IS_GOOD(c->state)) pa_context_set_state(c, PA_CONTEXT_TERMINATED); } @@ -916,6 +924,9 @@ void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, voi pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + if (pa_detect_fork()) + return; + if (c->state == PA_CONTEXT_TERMINATED || c->state == PA_CONTEXT_FAILED) return; @@ -927,6 +938,9 @@ void pa_context_set_event_callback(pa_context *c, pa_context_event_cb_t cb, void pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + if (pa_detect_fork()) + return; + if (c->state == PA_CONTEXT_TERMINATED || c->state == PA_CONTEXT_FAILED) return; @@ -938,6 +952,7 @@ int pa_context_is_pending(pa_context *c) { pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + PA_CHECK_VALIDITY(c, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(c, PA_CONTEXT_IS_GOOD(c->state), PA_ERR_BADSTATE); return (c->pstream && pa_pstream_is_pending(c->pstream)) || @@ -994,6 +1009,7 @@ pa_operation* pa_context_drain(pa_context *c, pa_context_notify_cb_t cb, void *u 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, pa_context_is_pending(c), PA_ERR_BADSTATE); @@ -1042,6 +1058,7 @@ pa_operation* pa_context_send_simple_command(pa_context *c, uint32_t command, pa 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); o = pa_operation_new(c, NULL, cb, userdata); @@ -1068,6 +1085,7 @@ pa_operation* pa_context_set_default_sink(pa_context *c, const char *name, pa_co 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); o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); @@ -1087,6 +1105,7 @@ pa_operation* pa_context_set_default_source(pa_context *c, const char *name, pa_ 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); o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); @@ -1102,6 +1121,7 @@ int pa_context_is_local(pa_context *c) { pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, -1); PA_CHECK_VALIDITY_RETURN_ANY(c, PA_CONTEXT_IS_GOOD(c->state), PA_ERR_BADSTATE, -1); return !!c->is_local; @@ -1114,6 +1134,7 @@ pa_operation* pa_context_set_name(pa_context *c, const char *name, pa_context_su pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(name); + 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); if (c->version >= 13) { @@ -1144,8 +1165,8 @@ const char* pa_context_get_server(pa_context *c) { pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); - if (!c->server) - return NULL; + PA_CHECK_VALIDITY_RETURN_NULL(c, !pa_detect_fork(), PA_ERR_FORKED); + PA_CHECK_VALIDITY_RETURN_NULL(c, c->server, PA_ERR_NOENTITY); if (*c->server == '{') { char *e = strchr(c->server+1, '}'); @@ -1163,6 +1184,7 @@ uint32_t pa_context_get_server_protocol_version(pa_context *c) { pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(c, PA_CONTEXT_IS_GOOD(c->state), PA_ERR_BADSTATE, PA_INVALID_INDEX); return c->version; @@ -1185,6 +1207,7 @@ uint32_t pa_context_get_index(pa_context *c) { pa_assert(c); pa_assert(PA_REFCNT_VALUE(c) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(c, !pa_detect_fork(), PA_ERR_FORKED, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(c, c->version >= 13, PA_ERR_NOTSUPPORTED, PA_INVALID_INDEX); @@ -1199,6 +1222,7 @@ pa_operation *pa_context_proplist_update(pa_context *c, pa_update_mode_t mode, p 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, mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 13, PA_ERR_NOTSUPPORTED); @@ -1227,6 +1251,7 @@ pa_operation *pa_context_proplist_remove(pa_context *c, const char *const keys[] 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, keys && keys[0], PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 13, PA_ERR_NOTSUPPORTED); diff --git a/src/pulse/context.h b/src/pulse/context.h index 2ae4c013..c32cf443 100644 --- a/src/pulse/context.h +++ b/src/pulse/context.h @@ -9,7 +9,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 diff --git a/src/pulse/def.h b/src/pulse/def.h index 7f3a0c5d..3629aabc 100644 --- a/src/pulse/def.h +++ b/src/pulse/def.h @@ -389,6 +389,7 @@ enum { PA_ERR_NOEXTENSION, /**< Extension does not exist. \since 0.9.12 */ PA_ERR_OBSOLETE, /**< Obsolete functionality. \since 0.9.15 */ PA_ERR_NOTIMPLEMENTED, /**< Missing implementation. \since 0.9.15 */ + PA_ERR_FORKED, /**< The caler forked without calling execve() and tried to reuse the context. \since 0.9.15 */ PA_ERR_MAX /**< Not really an error but the first invalid error code */ }; @@ -417,6 +418,7 @@ enum { #define PA_ERR_NOEXTENSION PA_ERR_NOEXTENSION #define PA_ERR_OBSOLETE PA_ERR_OBSOLETE #define PA_ERR_NOTIMPLEMENTED PA_ERR_NOTIMPLEMENTED +#define PA_ERR_FORKED PA_ERR_FORKED #define PA_ERR_MAX PA_ERR_MAX /** \endcond */ diff --git a/src/pulse/error.c b/src/pulse/error.c index d37084bb..93a13fc6 100644 --- a/src/pulse/error.c +++ b/src/pulse/error.c @@ -6,7 +6,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 @@ -63,12 +63,16 @@ const char*pa_strerror(int error) { [PA_ERR_UNKNOWN] = N_("Unknown error code"), [PA_ERR_NOEXTENSION] = N_("No such extension"), [PA_ERR_OBSOLETE] = N_("Obsolete functionality"), - [PA_ERR_NOTIMPLEMENTED] = N_("Missing implementation") + [PA_ERR_NOTIMPLEMENTED] = N_("Missing implementation"), + [PA_ERR_FORKED] = N_("Client forked") }; pa_init_i18n(); - if (error < 0 || error >= PA_ERR_MAX) + if (error < 0) + error = -error; + + if (error >= PA_ERR_MAX) return NULL; return _(errortab[error]); diff --git a/src/pulse/error.h b/src/pulse/error.h index c30b80bd..ea535608 100644 --- a/src/pulse/error.h +++ b/src/pulse/error.h @@ -9,7 +9,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 diff --git a/src/pulse/ext-stream-restore.c b/src/pulse/ext-stream-restore.c index 469c822a..63c911f8 100644 --- a/src/pulse/ext-stream-restore.c +++ b/src/pulse/ext-stream-restore.c @@ -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 @@ -31,6 +31,7 @@ #include "internal.h" #include "operation.h" +#include "fork-detect.h" #include "ext-stream-restore.h" @@ -87,6 +88,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 +169,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 +203,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); @@ -262,6 +266,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); @@ -310,6 +315,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 +340,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; } diff --git a/src/pulse/ext-stream-restore.h b/src/pulse/ext-stream-restore.h index cf9f4ccc..0b5d8eb6 100644 --- a/src/pulse/ext-stream-restore.h +++ b/src/pulse/ext-stream-restore.h @@ -8,7 +8,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 diff --git a/src/pulse/fork-detect.c b/src/pulse/fork-detect.c new file mode 100644 index 00000000..f10fc029 --- /dev/null +++ b/src/pulse/fork-detect.c @@ -0,0 +1,59 @@ +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + 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.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <unistd.h> + +#include <pulsecore/atomic.h> +#include <pulsecore/macro.h> + +#include "fork-detect.h" + +int pa_detect_fork(void) { + static pa_atomic_t pid = PA_ATOMIC_INIT((int) -1); + + /* Some really stupid applications (Hey, vim, that means you!) + * love to fork after initializing + * gtk/libcanberra/pulseaudio. This is really bad style. We + * however have to deal with this cleanly, so we try to detect the + * forks making sure all our calls fail cleanly after the fork. */ + + pa_assert(sizeof(pa_atomic_t) >= sizeof(pid_t)); + + for (;;) { + pid_t stored_pid = (pid_t) pa_atomic_load(&pid); + + /* First let's check whether the current pid matches the stored one */ + if (stored_pid == getpid()) + return FALSE; + + /* Does it contain a different PID than ours? Then the process got forked. */ + if ((int) stored_pid != (int) -1) + return TRUE; + + /* Ok, it still contains no PID, then store it */ + if (pa_atomic_cmpxchg(&pid, (int) -1, (int) getpid())) + return FALSE; + } +} diff --git a/src/pulse/fork-detect.h b/src/pulse/fork-detect.h new file mode 100644 index 00000000..649d9818 --- /dev/null +++ b/src/pulse/fork-detect.h @@ -0,0 +1,27 @@ +#ifndef fooforkdetecthfoo +#define fooforkdetecthfoo + +/*** + This file is part of PulseAudio. + + Copyright 2009 Lennart Poettering + + 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.1 of the License, + or (at your option) any later version. + + PulseAudio is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU Lesser General Public License + along with PulseAudio; if not, write to the Free Software + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 + USA. +***/ + +int pa_detect_fork(void); + +#endif diff --git a/src/pulse/gccmacro.h b/src/pulse/gccmacro.h index 58188ee2..e85ecb66 100644 --- a/src/pulse/gccmacro.h +++ b/src/pulse/gccmacro.h @@ -8,7 +8,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 diff --git a/src/pulse/glib-mainloop.c b/src/pulse/glib-mainloop.c index 5f5dc494..6afb7a2d 100644 --- a/src/pulse/glib-mainloop.c +++ b/src/pulse/glib-mainloop.c @@ -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 diff --git a/src/pulse/glib-mainloop.h b/src/pulse/glib-mainloop.h index fd68f8ac..189513a8 100644 --- a/src/pulse/glib-mainloop.h +++ b/src/pulse/glib-mainloop.h @@ -9,7 +9,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 diff --git a/src/pulse/internal.h b/src/pulse/internal.h index e533625d..9646d8a6 100644 --- a/src/pulse/internal.h +++ b/src/pulse/internal.h @@ -9,7 +9,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 diff --git a/src/pulse/introspect.c b/src/pulse/introspect.c index befeb242..ac8a11aa 100644 --- a/src/pulse/introspect.c +++ b/src/pulse/introspect.c @@ -6,7 +6,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 @@ -35,6 +35,7 @@ #include <pulsecore/pstream-util.h> #include "internal.h" +#include "fork-detect.h" #include "introspect.h" @@ -232,6 +233,7 @@ pa_operation* pa_context_get_sink_info_by_index(pa_context *c, uint32_t idx, pa_ pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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); o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); @@ -254,6 +256,7 @@ pa_operation* pa_context_get_sink_info_by_name(pa_context *c, const char *name, pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, !name || *name, PA_ERR_INVALID); @@ -365,6 +368,7 @@ pa_operation* pa_context_get_source_info_by_index(pa_context *c, uint32_t idx, p pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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); o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); @@ -387,6 +391,7 @@ pa_operation* pa_context_get_source_info_by_name(pa_context *c, const char *name pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, !name || *name, PA_ERR_INVALID); @@ -466,6 +471,7 @@ pa_operation* pa_context_get_client_info(pa_context *c, uint32_t idx, pa_client_ pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -528,7 +534,8 @@ static void context_get_card_info_callback(pa_pdispatch *pd, uint32_t command, u if (pa_tagstruct_gets(t, &i.profiles[j].name) < 0 || pa_tagstruct_gets(t, &i.profiles[j].description) < 0 || pa_tagstruct_getu32(t, &i.profiles[j].n_sinks) < 0 || - pa_tagstruct_getu32(t, &i.profiles[j].n_sources)< 0) { + pa_tagstruct_getu32(t, &i.profiles[j].n_sources) < 0 || + pa_tagstruct_getu32(t, &i.profiles[j].priority) < 0) { pa_context_fail(o->context, PA_ERR_PROTOCOL); pa_xfree(i.profiles); @@ -589,6 +596,7 @@ pa_operation* pa_context_get_card_info_by_index(pa_context *c, uint32_t idx, pa_ pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); @@ -613,6 +621,7 @@ pa_operation* pa_context_get_card_info_by_name(pa_context *c, const char*name, p pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, !name || *name, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); @@ -640,6 +649,7 @@ pa_operation* pa_context_set_card_profile_by_index(pa_context *c, uint32_t idx, 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); @@ -664,6 +674,7 @@ pa_operation* pa_context_set_card_profile_by_name(pa_context *c, const char *nam 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, !name || *name, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15, PA_ERR_NOTSUPPORTED); @@ -747,6 +758,7 @@ pa_operation* pa_context_get_module_info(pa_context *c, uint32_t idx, pa_module_ pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -841,6 +853,7 @@ pa_operation* pa_context_get_sink_input_info(pa_context *c, uint32_t idx, pa_sin pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -930,6 +943,7 @@ pa_operation* pa_context_get_source_output_info(pa_context *c, uint32_t idx, pa_ pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -958,6 +972,7 @@ pa_operation* pa_context_set_sink_volume_by_index(pa_context *c, uint32_t idx, c pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(volume); + 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, pa_cvolume_valid(volume), PA_ERR_INVALID); @@ -983,6 +998,7 @@ pa_operation* pa_context_set_sink_volume_by_name(pa_context *c, const char *name pa_assert(name); pa_assert(volume); + 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, pa_cvolume_valid(volume), PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); @@ -1007,6 +1023,7 @@ pa_operation* pa_context_set_sink_mute_by_index(pa_context *c, uint32_t idx, int 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); o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); @@ -1030,6 +1047,7 @@ pa_operation* pa_context_set_sink_mute_by_name(pa_context *c, const char *name, pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(name); + 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, !name || *name, PA_ERR_INVALID); @@ -1054,6 +1072,7 @@ pa_operation* pa_context_set_sink_input_volume(pa_context *c, uint32_t idx, cons pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(volume); + 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, pa_cvolume_valid(volume), PA_ERR_INVALID); @@ -1077,6 +1096,7 @@ pa_operation* pa_context_set_sink_input_mute(pa_context *c, uint32_t idx, int mu 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 11, PA_ERR_NOTSUPPORTED); @@ -1101,6 +1121,7 @@ pa_operation* pa_context_set_source_volume_by_index(pa_context *c, uint32_t idx, pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(volume); + 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, pa_cvolume_valid(volume), PA_ERR_INVALID); @@ -1126,6 +1147,7 @@ pa_operation* pa_context_set_source_volume_by_name(pa_context *c, const char *na pa_assert(name); pa_assert(volume); + 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, pa_cvolume_valid(volume), PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, !name || *name, PA_ERR_INVALID); @@ -1150,6 +1172,7 @@ pa_operation* pa_context_set_source_mute_by_index(pa_context *c, uint32_t idx, i 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); o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata); @@ -1173,6 +1196,7 @@ pa_operation* pa_context_set_source_mute_by_name(pa_context *c, const char *name pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(name); + 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, !name || *name, PA_ERR_INVALID); @@ -1260,6 +1284,7 @@ pa_operation* pa_context_get_sample_info_by_name(pa_context *c, const char *name pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, name && *name, PA_ERR_INVALID); @@ -1283,6 +1308,7 @@ pa_operation* pa_context_get_sample_info_by_index(pa_context *c, uint32_t idx, p pa_assert(PA_REFCNT_VALUE(c) >= 1); pa_assert(cb); + 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -1309,6 +1335,7 @@ static pa_operation* command_kill(pa_context *c, uint32_t command, uint32_t idx, 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, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -1375,6 +1402,7 @@ pa_operation* pa_context_load_module(pa_context *c, const char*name, const char 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, name && *name, PA_ERR_INVALID); @@ -1458,6 +1486,7 @@ pa_operation* pa_context_move_sink_input_by_name(pa_context *c, uint32_t idx, co 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 >= 10, PA_ERR_NOTSUPPORTED); PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -1483,6 +1512,7 @@ pa_operation* pa_context_move_sink_input_by_index(pa_context *c, uint32_t idx, u 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 >= 10, PA_ERR_NOTSUPPORTED); PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -1508,6 +1538,7 @@ pa_operation* pa_context_move_source_output_by_name(pa_context *c, uint32_t idx, 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 >= 10, PA_ERR_NOTSUPPORTED); PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -1533,6 +1564,7 @@ pa_operation* pa_context_move_source_output_by_index(pa_context *c, uint32_t idx 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 >= 10, PA_ERR_NOTSUPPORTED); PA_CHECK_VALIDITY_RETURN_NULL(c, idx != PA_INVALID_INDEX, PA_ERR_INVALID); @@ -1558,6 +1590,7 @@ pa_operation* pa_context_suspend_sink_by_name(pa_context *c, const char *sink_na 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 >= 11, PA_ERR_NOTSUPPORTED); PA_CHECK_VALIDITY_RETURN_NULL(c, !sink_name || *sink_name, PA_ERR_INVALID); @@ -1582,6 +1615,7 @@ pa_operation* pa_context_suspend_sink_by_index(pa_context *c, uint32_t idx, int 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 >= 11, PA_ERR_NOTSUPPORTED); @@ -1605,6 +1639,7 @@ pa_operation* pa_context_suspend_source_by_name(pa_context *c, const char *sourc 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 >= 11, PA_ERR_NOTSUPPORTED); PA_CHECK_VALIDITY_RETURN_NULL(c, !source_name || *source_name, PA_ERR_INVALID); @@ -1629,6 +1664,7 @@ pa_operation* pa_context_suspend_source_by_index(pa_context *c, uint32_t idx, in 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 >= 11, PA_ERR_NOTSUPPORTED); diff --git a/src/pulse/introspect.h b/src/pulse/introspect.h index aa67e43d..ec8a2c06 100644 --- a/src/pulse/introspect.h +++ b/src/pulse/introspect.h @@ -9,7 +9,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 @@ -401,6 +401,7 @@ typedef struct pa_card_profile_info { const char *description; /**< Description of this profile */ uint32_t n_sinks; /**< Number of sinks this profile would create */ uint32_t n_sources; /**< Number of sources this profile would create */ + uint32_t priority; /**< The higher this value is the more useful this profile is as a default */ } pa_card_profile_info; /** Stores information about cards. Please note that this structure diff --git a/src/pulse/mainloop-signal.c b/src/pulse/mainloop-signal.c index d09f4b0a..52f11c80 100644 --- a/src/pulse/mainloop-signal.c +++ b/src/pulse/mainloop-signal.c @@ -6,7 +6,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 diff --git a/src/pulse/mainloop-signal.h b/src/pulse/mainloop-signal.h index a9e250bc..fdb1f9db 100644 --- a/src/pulse/mainloop-signal.h +++ b/src/pulse/mainloop-signal.h @@ -9,7 +9,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 diff --git a/src/pulse/mainloop.c b/src/pulse/mainloop.c index 60e5d1ff..225fd098 100644 --- a/src/pulse/mainloop.c +++ b/src/pulse/mainloop.c @@ -6,7 +6,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 diff --git a/src/pulse/mainloop.h b/src/pulse/mainloop.h index 907e94a7..3a03ac9a 100644 --- a/src/pulse/mainloop.h +++ b/src/pulse/mainloop.h @@ -9,7 +9,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 diff --git a/src/pulse/operation.c b/src/pulse/operation.c index aa2bbc05..fe160a3c 100644 --- a/src/pulse/operation.c +++ b/src/pulse/operation.c @@ -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 diff --git a/src/pulse/operation.h b/src/pulse/operation.h index b68e7816..7b0dabdd 100644 --- a/src/pulse/operation.h +++ b/src/pulse/operation.h @@ -8,7 +8,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 diff --git a/src/pulse/proplist.h b/src/pulse/proplist.h index d30dc3b9..d5f5bc04 100644 --- a/src/pulse/proplist.h +++ b/src/pulse/proplist.h @@ -45,8 +45,10 @@ PA_C_DECL_BEGIN /** For streams: source filename if applicable, in URI format or local path. e.g. "/home/lennart/music/foobar.ogg" */ #define PA_PROP_MEDIA_FILENAME "media.filename" +/** \cond fulldocs */ /** For streams: icon for the media. A binary blob containing PNG image data */ #define PA_PROP_MEDIA_ICON "media.icon" +/** \endcond */ /** For streams: an XDG icon name for the media. e.g. "audio-x-mp3" */ #define PA_PROP_MEDIA_ICON_NAME "media.icon_name" @@ -81,8 +83,10 @@ PA_C_DECL_BEGIN /** For streams that belong to a window on the screen: a textual id for identifying a window logically. e.g. "org.gnome.Totem.MainWindow" */ #define PA_PROP_WINDOW_ID "window.id" +/** \cond fulldocs */ /** For streams that belong to a window on the screen: window icon. A binary blob containing PNG image data */ #define PA_PROP_WINDOW_ICON "window.icon" +/** \endcond */ /** For streams that belong to a window on the screen: an XDG icon name for the window. e.g. "totem" */ #define PA_PROP_WINDOW_ICON_NAME "window.icon_name" @@ -108,8 +112,10 @@ PA_C_DECL_BEGIN /** For clients/streams: a version string e.g. "0.6.88" */ #define PA_PROP_APPLICATION_VERSION "application.version" +/** \cond fulldocs */ /** For clients/streams: application icon. A binary blob containing PNG image data */ #define PA_PROP_APPLICATION_ICON "application.icon" +/** \endcond */ /** For clients/streams: an XDG icon name for the application. e.g. "totem" */ #define PA_PROP_APPLICATION_ICON_NAME "application.icon_name" @@ -150,17 +156,34 @@ PA_C_DECL_BEGIN /** For devices: serial number if applicable. e.g. "4711-0815-1234" */ #define PA_PROP_DEVICE_SERIAL "device.serial" -/** For devices: vendor/product ID if applicable. e.g. 1274:1371 */ -#define PA_PROP_DEVICE_VENDOR_PRODUCT_ID "device.vendor_product_id" +/** For devices: vendor ID if applicable. e.g. 1274 */ +#define PA_PROP_DEVICE_VENDOR_ID "device.vendor.id" + +/** For devices: vendor name if applicable. e.g. "Foocorp Heavy Industries" */ +#define PA_PROP_DEVICE_VENDOR_NAME "device.vendor.name" + +/** For devices: product ID if applicable. e.g. 4565 */ +#define PA_PROP_DEVICE_PRODUCT_ID "device.product.id" + +/** For devices: product name if applicable. e.g. "SuperSpeakers 2000 Pro" */ +#define PA_PROP_DEVICE_PRODUCT_NAME "device.product.name" /** For devices: device class. One of "sound", "modem", "monitor", "filter" */ #define PA_PROP_DEVICE_CLASS "device.class" -/** For devices: form factor if applicable. One of "laptop-speakers", "external-speakers", "telephone", "tv-capture", "webcam-capture", "microphone-capture", "headset", "headphones", "hands-free", "car", "hifi", "computer", "portable" */ +/** For devices: form factor if applicable. One of "internal", "speaker", "handset", "tv", "webcam", "microphone", "headset", "headphone", "hands-free", "car", "hifi", "computer", "portable" */ #define PA_PROP_DEVICE_FORM_FACTOR "device.form_factor" -/** For devices: connector of the device if applicable. One of "isa", "pci", "usb", "firewire", "bluetooth" */ -#define PA_PROP_DEVICE_CONNECTOR "device.connector" +/** For devices: bus of the device if applicable. One of "isa", "pci", "usb", "firewire", "bluetooth" */ +#define PA_PROP_DEVICE_BUS "device.bus" + +/** \cond fulldocs */ +/** For devices: icon for the device. A binary blob containing PNG image data */ +#define PA_PROP_DEVICE_ICON "device.icon" +/** \endcond */ + +/** For devices: an XDG icon name for the device. e.g. "sound-card-speakers-usb" */ +#define PA_PROP_DEVICE_ICON_NAME "device.icon_name" /** For devices: access mode of the device if applicable. One of "mmap", "mmap_rewrite", "serial" */ #define PA_PROP_DEVICE_ACCESS_MODE "device.access_mode" diff --git a/src/pulse/sample.c b/src/pulse/sample.c index 4b13a337..1e67b037 100644 --- a/src/pulse/sample.c +++ b/src/pulse/sample.c @@ -6,7 +6,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 diff --git a/src/pulse/sample.h b/src/pulse/sample.h index 3c05b54a..aef34b6b 100644 --- a/src/pulse/sample.h +++ b/src/pulse/sample.h @@ -9,7 +9,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 diff --git a/src/pulse/scache.c b/src/pulse/scache.c index a7e3cd81..77f60d72 100644 --- a/src/pulse/scache.c +++ b/src/pulse/scache.c @@ -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 diff --git a/src/pulse/scache.h b/src/pulse/scache.h index 79fcfbc5..cd579d2e 100644 --- a/src/pulse/scache.h +++ b/src/pulse/scache.h @@ -9,7 +9,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 diff --git a/src/pulse/simple.c b/src/pulse/simple.c index 79e39ebb..e70b7b1f 100644 --- a/src/pulse/simple.c +++ b/src/pulse/simple.c @@ -6,7 +6,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 diff --git a/src/pulse/simple.h b/src/pulse/simple.h index 3f57a654..6f1ba414 100644 --- a/src/pulse/simple.h +++ b/src/pulse/simple.h @@ -9,7 +9,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 diff --git a/src/pulse/stream.c b/src/pulse/stream.c index b36bf9b1..9a0ea0fd 100644 --- a/src/pulse/stream.c +++ b/src/pulse/stream.c @@ -6,7 +6,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 @@ -38,6 +38,7 @@ #include <pulsecore/macro.h> #include <pulsecore/rtclock.h> +#include "fork-detect.h" #include "internal.h" #define LATENCY_IPOL_INTERVAL_USEC (333*PA_USEC_PER_MSEC) @@ -87,6 +88,7 @@ pa_stream *pa_stream_new_with_proplist( 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, ss && pa_sample_spec_valid(ss), PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 12 || (ss->format != PA_SAMPLE_S32LE && ss->format != PA_SAMPLE_S32BE), PA_ERR_NOTSUPPORTED); PA_CHECK_VALIDITY_RETURN_NULL(c, c->version >= 15 || (ss->format != PA_SAMPLE_S24LE && ss->format != PA_SAMPLE_S24BE), PA_ERR_NOTSUPPORTED); @@ -267,6 +269,7 @@ uint32_t pa_stream_get_index(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(s->context, !pa_detect_fork(), PA_ERR_FORKED, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, PA_INVALID_INDEX); return s->stream_index; @@ -921,6 +924,7 @@ static int create_stream( pa_assert(PA_REFCNT_VALUE(s) >= 1); pa_assert(direction == PA_STREAM_PLAYBACK || direction == PA_STREAM_RECORD); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direct_on_input == PA_INVALID_INDEX || direction == PA_STREAM_RECORD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, !(flags & ~(PA_STREAM_START_CORKED| @@ -1122,6 +1126,7 @@ int pa_stream_write( pa_assert(PA_REFCNT_VALUE(s) >= 1); pa_assert(data); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_PLAYBACK || s->direction == PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, seek <= PA_SEEK_RELATIVE_END, PA_ERR_INVALID); @@ -1216,6 +1221,7 @@ int pa_stream_peek(pa_stream *s, const void **data, size_t *length) { pa_assert(data); pa_assert(length); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE); @@ -1240,6 +1246,7 @@ int pa_stream_drop(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->peek_memchunk.memblock, PA_ERR_BADSTATE); @@ -1262,6 +1269,7 @@ size_t pa_stream_writable_size(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(s->context, !pa_detect_fork(), PA_ERR_FORKED, (size_t) -1); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, (size_t) -1); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_RECORD, PA_ERR_BADSTATE, (size_t) -1); @@ -1272,6 +1280,7 @@ size_t pa_stream_readable_size(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(s->context, !pa_detect_fork(), PA_ERR_FORKED, (size_t) -1); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, (size_t) -1); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction == PA_STREAM_RECORD, PA_ERR_BADSTATE, (size_t) -1); @@ -1286,6 +1295,7 @@ pa_operation * pa_stream_drain(pa_stream *s, pa_stream_success_cb_t cb, void *us pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE); @@ -1557,6 +1567,7 @@ pa_operation* pa_stream_update_timing_info(pa_stream *s, pa_stream_success_cb_t pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -1627,6 +1638,7 @@ int pa_stream_disconnect(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->channel_valid, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->context->state == PA_CONTEXT_READY, PA_ERR_BADSTATE); @@ -1649,6 +1661,9 @@ void pa_stream_set_read_callback(pa_stream *s, pa_stream_request_cb_t cb, void * pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1660,6 +1675,9 @@ void pa_stream_set_write_callback(pa_stream *s, pa_stream_request_cb_t cb, void pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1671,6 +1689,9 @@ void pa_stream_set_state_callback(pa_stream *s, pa_stream_notify_cb_t cb, void * pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1682,6 +1703,9 @@ void pa_stream_set_overflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, voi pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1693,6 +1717,9 @@ void pa_stream_set_underflow_callback(pa_stream *s, pa_stream_notify_cb_t cb, vo pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1704,6 +1731,9 @@ void pa_stream_set_latency_update_callback(pa_stream *s, pa_stream_notify_cb_t c pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1715,6 +1745,9 @@ void pa_stream_set_moved_callback(pa_stream *s, pa_stream_notify_cb_t cb, void * pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1726,6 +1759,9 @@ void pa_stream_set_suspended_callback(pa_stream *s, pa_stream_notify_cb_t cb, vo pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1737,6 +1773,9 @@ void pa_stream_set_started_callback(pa_stream *s, pa_stream_notify_cb_t cb, void pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1748,6 +1787,9 @@ void pa_stream_set_event_callback(pa_stream *s, pa_stream_event_cb_t cb, void *u pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + if (pa_detect_fork()) + return; + if (s->state == PA_STREAM_TERMINATED || s->state == PA_STREAM_FAILED) return; @@ -1794,6 +1836,7 @@ pa_operation* pa_stream_cork(pa_stream *s, int b, pa_stream_success_cb_t cb, voi pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -1827,6 +1870,7 @@ static pa_operation* stream_send_simple_command(pa_stream *s, uint32_t command, pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); o = pa_operation_new(s->context, s, (pa_operation_cb_t) cb, userdata); @@ -1845,6 +1889,7 @@ pa_operation* pa_stream_flush(pa_stream *s, pa_stream_success_cb_t cb, void *use pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -1877,6 +1922,7 @@ pa_operation* pa_stream_prebuf(pa_stream *s, pa_stream_success_cb_t cb, void *us pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE); @@ -1897,6 +1943,7 @@ pa_operation* pa_stream_trigger(pa_stream *s, pa_stream_success_cb_t cb, void *u pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction == PA_STREAM_PLAYBACK, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->buffer_attr.prebuf > 0, PA_ERR_BADSTATE); @@ -1918,6 +1965,7 @@ pa_operation* pa_stream_set_name(pa_stream *s, const char *name, pa_stream_succe pa_assert(PA_REFCNT_VALUE(s) >= 1); pa_assert(name); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -1951,6 +1999,7 @@ int pa_stream_get_time(pa_stream *s, pa_usec_t *r_usec) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->timing_info_valid, PA_ERR_NODATA); @@ -2003,6 +2052,7 @@ int pa_stream_get_latency(pa_stream *s, pa_usec_t *r_usec, int *negative) { pa_assert(PA_REFCNT_VALUE(s) >= 1); pa_assert(r_usec); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->timing_info_valid, PA_ERR_NODATA); @@ -2034,6 +2084,7 @@ const pa_timing_info* pa_stream_get_timing_info(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->timing_info_valid, PA_ERR_NODATA); @@ -2045,6 +2096,8 @@ const pa_sample_spec* pa_stream_get_sample_spec(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); + return &s->sample_spec; } @@ -2052,6 +2105,8 @@ const pa_channel_map* pa_stream_get_channel_map(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); + return &s->channel_map; } @@ -2139,6 +2194,7 @@ pa_operation* pa_stream_set_buffer_attr(pa_stream *s, const pa_buffer_attr *attr pa_assert(PA_REFCNT_VALUE(s) >= 1); pa_assert(attr); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->context->version >= 12, PA_ERR_NOTSUPPORTED); @@ -2183,6 +2239,7 @@ uint32_t pa_stream_get_device_index(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(s->context, !pa_detect_fork(), PA_ERR_FORKED, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->context->version >= 12, PA_ERR_NOTSUPPORTED, PA_INVALID_INDEX); @@ -2195,6 +2252,7 @@ const char *pa_stream_get_device_name(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->context->version >= 12, PA_ERR_NOTSUPPORTED); @@ -2207,6 +2265,7 @@ int pa_stream_is_suspended(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->context->version >= 12, PA_ERR_NOTSUPPORTED); @@ -2218,6 +2277,7 @@ int pa_stream_is_corked(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -2270,6 +2330,7 @@ pa_operation *pa_stream_update_sample_rate(pa_stream *s, uint32_t rate, pa_strea pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, rate > 0 && rate <= PA_RATE_MAX, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -2300,6 +2361,7 @@ pa_operation *pa_stream_proplist_update(pa_stream *s, pa_update_mode_t mode, pa_ pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, mode == PA_UPDATE_SET || mode == PA_UPDATE_MERGE || mode == PA_UPDATE_REPLACE, PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -2333,6 +2395,7 @@ pa_operation *pa_stream_proplist_remove(pa_stream *s, const char *const keys[], pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_NULL(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY_RETURN_NULL(s->context, keys && keys[0], PA_ERR_INVALID); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->state == PA_STREAM_READY, PA_ERR_BADSTATE); PA_CHECK_VALIDITY_RETURN_NULL(s->context, s->direction != PA_STREAM_UPLOAD, PA_ERR_BADSTATE); @@ -2364,6 +2427,7 @@ int pa_stream_set_monitor_stream(pa_stream *s, uint32_t sink_input_idx) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY(s->context, !pa_detect_fork(), PA_ERR_FORKED); PA_CHECK_VALIDITY(s->context, sink_input_idx != PA_INVALID_INDEX, PA_ERR_INVALID); PA_CHECK_VALIDITY(s->context, s->state == PA_STREAM_UNCONNECTED, PA_ERR_BADSTATE); PA_CHECK_VALIDITY(s->context, s->context->version >= 13, PA_ERR_NOTSUPPORTED); @@ -2377,6 +2441,7 @@ uint32_t pa_stream_get_monitor_stream(pa_stream *s) { pa_assert(s); pa_assert(PA_REFCNT_VALUE(s) >= 1); + PA_CHECK_VALIDITY_RETURN_ANY(s->context, !pa_detect_fork(), PA_ERR_FORKED, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->direct_on_input != PA_INVALID_INDEX, PA_ERR_BADSTATE, PA_INVALID_INDEX); PA_CHECK_VALIDITY_RETURN_ANY(s->context, s->context->version >= 13, PA_ERR_NOTSUPPORTED, PA_INVALID_INDEX); diff --git a/src/pulse/stream.h b/src/pulse/stream.h index 3965e9a2..e80bc65d 100644 --- a/src/pulse/stream.h +++ b/src/pulse/stream.h @@ -9,7 +9,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 diff --git a/src/pulse/subscribe.c b/src/pulse/subscribe.c index e12d1446..203bc928 100644 --- a/src/pulse/subscribe.c +++ b/src/pulse/subscribe.c @@ -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 diff --git a/src/pulse/subscribe.h b/src/pulse/subscribe.h index 2707cec5..a93510ad 100644 --- a/src/pulse/subscribe.h +++ b/src/pulse/subscribe.h @@ -9,7 +9,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 diff --git a/src/pulse/thread-mainloop.c b/src/pulse/thread-mainloop.c index fb73ff1b..c77cc64e 100644 --- a/src/pulse/thread-mainloop.c +++ b/src/pulse/thread-mainloop.c @@ -6,7 +6,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 diff --git a/src/pulse/thread-mainloop.h b/src/pulse/thread-mainloop.h index 4de338a1..8eddce4c 100644 --- a/src/pulse/thread-mainloop.h +++ b/src/pulse/thread-mainloop.h @@ -9,7 +9,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 @@ -108,10 +108,10 @@ PA_C_DECL_BEGIN * Example: * * \code - * static void my_drain_callback(pa_stream*s, int success, void *userdata) { + * static void my_drain_callback(pa_stream *s, int success, void *userdata) { * pa_threaded_mainloop *m; * - * m = (pa_threaded_mainloop*)userdata; + * m = userdata; * assert(m); * * pa_threaded_mainloop_signal(m, 0); @@ -125,7 +125,7 @@ PA_C_DECL_BEGIN * o = pa_stream_drain(s, my_drain_callback, m); * assert(o); * - * while (pa_operation_get_state(o) != OPERATION_DONE) + * while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) * pa_threaded_mainloop_wait(m); * * pa_operation_unref(o); @@ -167,7 +167,7 @@ PA_C_DECL_BEGIN * static void my_drain_callback(pa_stream*s, int success, void *userdata) { * pa_threaded_mainloop *m; * - * m = (pa_threaded_mainloop*)userdata; + * m = userdata; * assert(m); * * drain_result = &success; @@ -183,7 +183,7 @@ PA_C_DECL_BEGIN * o = pa_stream_drain(s, my_drain_callback, m); * assert(o); * - * while (pa_operation_get_state(o) != OPERATION_DONE) + * while (pa_operation_get_state(o) == PA_OPERATION_RUNNING) * pa_threaded_mainloop_wait(m); * * pa_operation_unref(o); diff --git a/src/pulse/volume.c b/src/pulse/volume.c index 54838e89..c865058d 100644 --- a/src/pulse/volume.c +++ b/src/pulse/volume.c @@ -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 diff --git a/src/pulse/volume.h b/src/pulse/volume.h index 8bfd0687..c3c396c8 100644 --- a/src/pulse/volume.h +++ b/src/pulse/volume.h @@ -9,7 +9,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 diff --git a/src/pulse/xmalloc.c b/src/pulse/xmalloc.c index c570e40f..e17a354a 100644 --- a/src/pulse/xmalloc.c +++ b/src/pulse/xmalloc.c @@ -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 diff --git a/src/pulse/xmalloc.h b/src/pulse/xmalloc.h index c30d4df1..db20496f 100644 --- a/src/pulse/xmalloc.h +++ b/src/pulse/xmalloc.h @@ -8,7 +8,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 |