summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-12-14 09:38:59 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-12-14 09:38:59 +0000
commit2d51ede3ad5acbbb565ecd8193e564a1b40fdda8 (patch)
treea3b643cee9838b245fde0dcb1210a367e781d9d5
parent7f5b33003f0f6701458d6ad031b34fe667532458 (diff)
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
-rw-r--r--pa.c25
-rw-r--r--serial.c7
2 files changed, 15 insertions, 17 deletions
diff --git a/pa.c b/pa.c
index 5616409..d1acf3d 100644
--- a/pa.c
+++ b/pa.c
@@ -174,12 +174,13 @@ login_setup(Pulse *conn)
174 return tag; 174 return tag;
175} 175}
176 176
177static Pulse_Tag * 177static Eina_Bool
178pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh) 178pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh, Pulse_Tag **ret_tag)
179{ 179{
180 Pulse_Tag *tag; 180 Pulse_Tag *tag;
181 uint32_t x; 181 uint32_t x;
182 182
183 if (ret_tag) *ret_tag = NULL;
183 tag = eina_list_data_get(conn->iq); 184 tag = eina_list_data_get(conn->iq);
184 if (!tag) 185 if (!tag)
185 { 186 {
@@ -189,7 +190,7 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh)
189 if (!tag->auth) 190 if (!tag->auth)
190 { 191 {
191 msg_recv_creds(conn, tag); 192 msg_recv_creds(conn, tag);
192 if (!tag->auth) return NULL; 193 if (!tag->auth) return EINA_FALSE;
193 } 194 }
194 if (!tag->data) 195 if (!tag->data)
195 { 196 {
@@ -198,14 +199,14 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh)
198 { 199 {
199 ERR("Kicked!"); 200 ERR("Kicked!");
200 pulse_disconnect(conn); 201 pulse_disconnect(conn);
201 return NULL; 202 return EINA_FALSE;
202 } 203 }
203 tag->data = malloc(tag->dsize); 204 tag->data = malloc(tag->dsize);
204 } 205 }
205 if (tag->pos < tag->dsize) 206 if (tag->pos < tag->dsize)
206 { 207 {
207 if (!msg_recv(conn, tag)) 208 if (!msg_recv(conn, tag))
208 return NULL; 209 return EINA_FALSE;
209 } 210 }
210 untag_uint32(tag, &x); 211 untag_uint32(tag, &x);
211 EINA_SAFETY_ON_TRUE_GOTO((x != PA_COMMAND_REPLY) && (x != PA_COMMAND_SUBSCRIBE_EVENT), error); 212 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)
218 { 219 {
219 ecore_main_fd_handler_active_set(fdh, ECORE_FD_WRITE); 220 ecore_main_fd_handler_active_set(fdh, ECORE_FD_WRITE);
220 pulse_tag_free(tag); 221 pulse_tag_free(tag);
221 return (void*)1;
222 } 222 }
223 return tag; 223 else if (ret_tag)
224 *ret_tag = tag;
225 return EINA_TRUE;
224error: 226error:
225 ERR("Received error command %"PRIu32"!", x); 227 ERR("Received error command %"PRIu32"!", x);
226 pulse_tag_free(tag); 228 pulse_tag_free(tag);
227 return NULL; 229 return EINA_FALSE;
228} 230}
229 231
230static void 232static void
@@ -281,7 +283,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
281 } 283 }
282 break; 284 break;
283 case PA_STATE_AUTH: 285 case PA_STATE_AUTH:
284 if (pulse_recv(conn, fdh)) 286 if (pulse_recv(conn, fdh, NULL))
285 login_finish(conn, fdh); 287 login_finish(conn, fdh);
286 break; 288 break;
287 case PA_STATE_MOREAUTH: 289 case PA_STATE_MOREAUTH:
@@ -291,7 +293,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
291 ecore_main_fd_handler_active_set(fdh, ECORE_FD_READ); 293 ecore_main_fd_handler_active_set(fdh, ECORE_FD_READ);
292 break; 294 break;
293 } 295 }
294 if (pulse_recv(conn, fdh)) 296 if (pulse_recv(conn, fdh, NULL))
295 { 297 {
296 conn->state++; 298 conn->state++;
297 INF("Login complete!"); 299 INF("Login complete!");
@@ -323,8 +325,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
323 { 325 {
324 Pulse_Tag *tag; 326 Pulse_Tag *tag;
325 PA_Commands command; 327 PA_Commands command;
326 tag = pulse_recv(conn, fdh); 328 if (!pulse_recv(conn, fdh, &tag)) break;
327 if (!tag) break;
328 329
329 command = (uintptr_t)eina_hash_find(conn->tag_handlers, &tag->tag_count); 330 command = (uintptr_t)eina_hash_find(conn->tag_handlers, &tag->tag_count);
330 eina_hash_del_by_key(conn->tag_handlers, &tag->tag_count); 331 eina_hash_del_by_key(conn->tag_handlers, &tag->tag_count);
diff --git a/serial.c b/serial.c
index 277d06c..51a7d56 100644
--- a/serial.c
+++ b/serial.c
@@ -139,10 +139,10 @@ deserialize_tag(Pulse *conn, PA_Commands command, Pulse_Tag *tag)
139 if (!cb) return EINA_TRUE; 139 if (!cb) return EINA_TRUE;
140 ev = NULL; 140 ev = NULL;
141 ev = deserialize_server_info(conn, tag); 141 ev = deserialize_server_info(conn, tag);
142 if (!cb) pulse_server_info_free(ev);
143 break; 142 break;
144 case PA_COMMAND_GET_SINK_INFO_LIST: 143 case PA_COMMAND_GET_SINK_INFO_LIST:
145 case PA_COMMAND_GET_SOURCE_INFO_LIST: 144 case PA_COMMAND_GET_SOURCE_INFO_LIST:
145 if (!cb) return EINA_TRUE;
146 ev = NULL; 146 ev = NULL;
147 while (tag->size < tag->dsize - PA_TAG_SIZE_STRING_NULL) 147 while (tag->size < tag->dsize - PA_TAG_SIZE_STRING_NULL)
148 { 148 {
@@ -155,16 +155,13 @@ deserialize_tag(Pulse *conn, PA_Commands command, Pulse_Tag *tag)
155 pulse_sink_free(sink); 155 pulse_sink_free(sink);
156 break; 156 break;
157 } 157 }
158 if (!cb) pulse_sink_free(sink); 158 if (cb) ev = eina_list_append(ev, sink);
159 else
160 ev = eina_list_append(ev, sink);
161 } 159 }
162 break; 160 break;
163 case PA_COMMAND_GET_SINK_INFO: 161 case PA_COMMAND_GET_SINK_INFO:
164 case PA_COMMAND_GET_SOURCE_INFO: 162 case PA_COMMAND_GET_SOURCE_INFO:
165 if ((!cb) && (!conn->watching)) return EINA_TRUE; 163 if ((!cb) && (!conn->watching)) return EINA_TRUE;
166 ev = deserialize_sink(conn, tag, (command == PA_COMMAND_GET_SOURCE_INFO)); 164 ev = deserialize_sink(conn, tag, (command == PA_COMMAND_GET_SOURCE_INFO));
167 if (!cb) pulse_sink_free(ev);
168 break; 165 break;
169 case 0: 166 case 0:
170 deserialize_sinks_watcher(conn, tag); 167 deserialize_sinks_watcher(conn, tag);