From 926ee6f3609cb088837e2a0fb8619d735fa0188c Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Fri, 14 Dec 2012 09:38:59 +0000 Subject: [PATCH] pulse_recv() no longer has the most confusing return of any function, also only prevent event list from building, not sinks (we need them!) SVN revision: 80925 --- src/modules/mixer/pa.c | 25 +++++++++++++------------ src/modules/mixer/serial.c | 7 ++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/modules/mixer/pa.c b/src/modules/mixer/pa.c index 5616409..d1acf3d 100644 --- a/src/modules/mixer/pa.c +++ b/src/modules/mixer/pa.c @@ -174,12 +174,13 @@ login_setup(Pulse *conn) return tag; } -static Pulse_Tag * -pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh) +static Eina_Bool +pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh, Pulse_Tag **ret_tag) { Pulse_Tag *tag; uint32_t x; + if (ret_tag) *ret_tag = NULL; tag = eina_list_data_get(conn->iq); if (!tag) { @@ -189,7 +190,7 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh) if (!tag->auth) { msg_recv_creds(conn, tag); - if (!tag->auth) return NULL; + if (!tag->auth) return EINA_FALSE; } if (!tag->data) { @@ -198,14 +199,14 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh) { ERR("Kicked!"); pulse_disconnect(conn); - return NULL; + return EINA_FALSE; } tag->data = malloc(tag->dsize); } if (tag->pos < tag->dsize) { if (!msg_recv(conn, tag)) - return NULL; + return EINA_FALSE; } untag_uint32(tag, &x); EINA_SAFETY_ON_TRUE_GOTO((x != PA_COMMAND_REPLY) && (x != PA_COMMAND_SUBSCRIBE_EVENT), error); @@ -218,13 +219,14 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh) { ecore_main_fd_handler_active_set(fdh, ECORE_FD_WRITE); pulse_tag_free(tag); - return (void*)1; } - return tag; + else if (ret_tag) + *ret_tag = tag; + return EINA_TRUE; error: ERR("Received error command %"PRIu32"!", x); pulse_tag_free(tag); - return NULL; + return EINA_FALSE; } static void @@ -281,7 +283,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh) } break; case PA_STATE_AUTH: - if (pulse_recv(conn, fdh)) + if (pulse_recv(conn, fdh, NULL)) login_finish(conn, fdh); break; case PA_STATE_MOREAUTH: @@ -291,7 +293,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh) ecore_main_fd_handler_active_set(fdh, ECORE_FD_READ); break; } - if (pulse_recv(conn, fdh)) + if (pulse_recv(conn, fdh, NULL)) { conn->state++; INF("Login complete!"); @@ -323,8 +325,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh) { Pulse_Tag *tag; PA_Commands command; - tag = pulse_recv(conn, fdh); - if (!tag) break; + if (!pulse_recv(conn, fdh, &tag)) break; command = (uintptr_t)eina_hash_find(conn->tag_handlers, &tag->tag_count); eina_hash_del_by_key(conn->tag_handlers, &tag->tag_count); diff --git a/src/modules/mixer/serial.c b/src/modules/mixer/serial.c index 277d06c..51a7d56 100644 --- a/src/modules/mixer/serial.c +++ b/src/modules/mixer/serial.c @@ -139,10 +139,10 @@ deserialize_tag(Pulse *conn, PA_Commands command, Pulse_Tag *tag) if (!cb) return EINA_TRUE; ev = NULL; ev = deserialize_server_info(conn, tag); - if (!cb) pulse_server_info_free(ev); break; case PA_COMMAND_GET_SINK_INFO_LIST: case PA_COMMAND_GET_SOURCE_INFO_LIST: + if (!cb) return EINA_TRUE; ev = NULL; while (tag->size < tag->dsize - PA_TAG_SIZE_STRING_NULL) { @@ -155,16 +155,13 @@ deserialize_tag(Pulse *conn, PA_Commands command, Pulse_Tag *tag) pulse_sink_free(sink); break; } - if (!cb) pulse_sink_free(sink); - else - ev = eina_list_append(ev, sink); + if (cb) ev = eina_list_append(ev, sink); } break; case PA_COMMAND_GET_SINK_INFO: case PA_COMMAND_GET_SOURCE_INFO: if ((!cb) && (!conn->watching)) return EINA_TRUE; ev = deserialize_sink(conn, tag, (command == PA_COMMAND_GET_SOURCE_INFO)); - if (!cb) pulse_sink_free(ev); break; case 0: deserialize_sinks_watcher(conn, tag); -- 2.7.4