[pulseaudio-commits] Branch 'next' - 2 commits - src/pulse
Tanu Kaskinen
tanuk at kemper.freedesktop.org
Fri Jun 15 10:59:43 UTC 2018
src/pulse/context.c | 11 +++++++----
src/pulse/context.h | 2 +-
src/pulse/internal.h | 6 +++++-
3 files changed, 13 insertions(+), 6 deletions(-)
New commits:
commit 62cd37548c57ac4acfb07521fb602b39ab4a8aea
Author: Lyndon Brown <jnqnfe at gmail.com>
Date: Thu Jun 7 03:51:09 2018 +0100
context: pa_context_errno: constify
diff --git a/src/pulse/context.c b/src/pulse/context.c
index d298ae3e..1f32421b 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -1068,7 +1068,7 @@ pa_context_state_t pa_context_get_state(const pa_context *c) {
return c->state;
}
-int pa_context_errno(pa_context *c) {
+int pa_context_errno(const pa_context *c) {
if (!c)
return PA_ERR_INVALID;
diff --git a/src/pulse/context.h b/src/pulse/context.h
index 7a38ff23..37333fca 100644
--- a/src/pulse/context.h
+++ b/src/pulse/context.h
@@ -190,7 +190,7 @@ void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, voi
void pa_context_set_event_callback(pa_context *p, pa_context_event_cb_t cb, void *userdata);
/** Return the error number of the last failed operation */
-int pa_context_errno(pa_context *c);
+int pa_context_errno(const pa_context *c);
/** Return non-zero if some data is pending to be written to the connection */
int pa_context_is_pending(pa_context *c);
commit 5b4c9453f3b1c53290fc5f136716ef7af5193ef3
Author: Lyndon Brown <jnqnfe at gmail.com>
Date: Thu Jun 7 02:43:56 2018 +0100
context: hide error attr behind pointer
Paves the way towards more of the API using const pointers.
Some pa_context_* functions return their errors by setting the context
error, even when there's no other change in the context state. This
prevented constifying the pa_context arguments of such functions. This
patch puts the error in its own struct behind a pointer, so that setting
the error doesn't any more count as modifying the pa_context object.
diff --git a/src/pulse/context.c b/src/pulse/context.c
index adbeb153..d298ae3e 100644
--- a/src/pulse/context.c
+++ b/src/pulse/context.c
@@ -139,6 +139,9 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *
c = pa_xnew0(pa_context, 1);
PA_REFCNT_INIT(c);
+ c->error = pa_xnew0(pa_context_error, 1);
+ assert(c->error);
+
c->proplist = p ? pa_proplist_copy(p) : pa_proplist_new();
if (name)
@@ -156,7 +159,7 @@ pa_context *pa_context_new_with_proplist(pa_mainloop_api *mainloop, const char *
PA_LLIST_HEAD_INIT(pa_stream, c->streams);
PA_LLIST_HEAD_INIT(pa_operation, c->operations);
- c->error = PA_OK;
+ c->error->error = PA_OK;
c->state = PA_CONTEXT_UNCONNECTED;
reset_callbacks(c);
@@ -315,7 +318,7 @@ int pa_context_set_error(pa_context *c, int error) {
pa_assert(error < PA_ERR_MAX);
if (c)
- c->error = error;
+ c->error->error = error;
return error;
}
@@ -1072,7 +1075,7 @@ int pa_context_errno(pa_context *c) {
pa_assert(PA_REFCNT_VALUE(c) >= 1);
- return c->error;
+ return c->error->error;
}
void pa_context_set_state_callback(pa_context *c, pa_context_notify_cb_t cb, void *userdata) {
diff --git a/src/pulse/internal.h b/src/pulse/internal.h
index 01d2b6e4..04f35e9a 100644
--- a/src/pulse/internal.h
+++ b/src/pulse/internal.h
@@ -55,6 +55,10 @@
#define PA_PROTOCOL_FLAG_SHM 0x80000000U
#define PA_PROTOCOL_FLAG_MEMFD 0x40000000U
+typedef struct pa_context_error {
+ int error;
+} pa_context_error;
+
struct pa_context {
PA_REFCNT_DECLARE;
@@ -80,7 +84,7 @@ struct pa_context {
uint32_t version;
uint32_t ctag;
uint32_t csyncid;
- int error;
+ pa_context_error *error;
pa_context_state_t state;
pa_context_notify_cb_t state_callback;
More information about the pulseaudio-commits
mailing list