summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-09-12 09:48:04 +0000
committerMike Blumenkrantz <michael.blumenkrantz@gmail.com>2012-09-12 09:48:04 +0000
commit3a6a7c6bd530c44106e51a50e0193517078dfb44 (patch)
treebf6856123f0055ca1fcf19e7eda2f5950f130151
parentb71fcc83099ce0c7efef62209a9caf6d39e74f63 (diff)
update standalone epulse to match e17
SVN revision: 76512
-rw-r--r--Pulse.h13
-rw-r--r--msg.c25
-rw-r--r--pa.c110
-rw-r--r--serial.c28
4 files changed, 139 insertions, 37 deletions
diff --git a/Pulse.h b/Pulse.h
index 44d0d62..dc6e1a4 100644
--- a/Pulse.h
+++ b/Pulse.h
@@ -21,6 +21,17 @@ typedef struct Pulse_Sink_Port_Info {
21 uint32_t priority; /**< The higher this value is the more useful this port is as a default */ 21 uint32_t priority; /**< The higher this value is the more useful this port is as a default */
22} Pulse_Sink_Port_Info; 22} Pulse_Sink_Port_Info;
23 23
24typedef struct Pulse_Server_Info
25{
26 Pulse *conn;
27 const char *name;
28 const char *version;
29 const char *username;
30 const char *hostname;
31 const char *default_sink;
32 const char *default_source;
33} Pulse_Server_Info;
34
24int pulse_init(void); 35int pulse_init(void);
25void pulse_shutdown(void); 36void pulse_shutdown(void);
26 37
@@ -28,7 +39,9 @@ Pulse *pulse_new(void);
28Eina_Bool pulse_connect(Pulse *conn); 39Eina_Bool pulse_connect(Pulse *conn);
29void pulse_free(Pulse *conn); 40void pulse_free(Pulse *conn);
30void pulse_cb_set(Pulse *conn, uint32_t tagnum, Pulse_Cb cb); 41void pulse_cb_set(Pulse *conn, uint32_t tagnum, Pulse_Cb cb);
42void pulse_server_info_free(Pulse_Server_Info *ev);
31 43
44uint32_t pulse_server_info_get(Pulse *conn);
32uint32_t pulse_cards_get(Pulse *conn); 45uint32_t pulse_cards_get(Pulse *conn);
33#define pulse_sinks_get(conn) pulse_types_get((conn), EINA_FALSE) 46#define pulse_sinks_get(conn) pulse_types_get((conn), EINA_FALSE)
34#define pulse_sources_get(conn) pulse_types_get((conn), EINA_TRUE) 47#define pulse_sources_get(conn) pulse_types_get((conn), EINA_TRUE)
diff --git a/msg.c b/msg.c
index 450fb08..f9c15d0 100644
--- a/msg.c
+++ b/msg.c
@@ -6,6 +6,7 @@
6void 6void
7msg_recv_creds(Pulse *conn, Pulse_Tag *tag) 7msg_recv_creds(Pulse *conn, Pulse_Tag *tag)
8{ 8{
9#ifdef __linux__
9 int r; 10 int r;
10 struct msghdr mh; 11 struct msghdr mh;
11 struct iovec iov; 12 struct iovec iov;
@@ -36,11 +37,16 @@ msg_recv_creds(Pulse *conn, Pulse_Tag *tag)
36 DBG("%zu bytes left", sizeof(tag->header) - r); 37 DBG("%zu bytes left", sizeof(tag->header) - r);
37 tag->pos += r; 38 tag->pos += r;
38 } 39 }
40#else
41 conn = NULL;
42 tag = NULL;
43#endif
39} 44}
40 45
41Eina_Bool 46Eina_Bool
42msg_recv(Pulse *conn, Pulse_Tag *tag) 47msg_recv(Pulse *conn, Pulse_Tag *tag)
43{ 48{
49#ifdef __linux__
44 long r; 50 long r;
45 struct msghdr mh; 51 struct msghdr mh;
46 struct iovec iov; 52 struct iovec iov;
@@ -74,12 +80,17 @@ msg_recv(Pulse *conn, Pulse_Tag *tag)
74 } 80 }
75 else 81 else
76 tag->pos += r; 82 tag->pos += r;
83#else
84 conn = NULL;
85 tag = NULL;
86#endif
77 return EINA_FALSE; 87 return EINA_FALSE;
78} 88}
79 89
80void 90void
81msg_sendmsg_creds(Pulse *conn, Pulse_Tag *tag) 91msg_sendmsg_creds(Pulse *conn, Pulse_Tag *tag)
82{ 92{
93#ifdef __linux__
83 int r; 94 int r;
84 struct msghdr mh; 95 struct msghdr mh;
85 struct iovec iov; 96 struct iovec iov;
@@ -118,11 +129,16 @@ msg_sendmsg_creds(Pulse *conn, Pulse_Tag *tag)
118 } 129 }
119 else 130 else
120 tag->pos += r; 131 tag->pos += r;
132#else
133 conn = NULL;
134 tag = NULL;
135#endif
121} 136}
122 137
123void 138void
124msg_send_creds(Pulse *conn, Pulse_Tag *tag) 139msg_send_creds(Pulse *conn, Pulse_Tag *tag)
125{ 140{
141#ifdef __linux__
126 int r; 142 int r;
127 143
128 INF("trying to send 20 byte auth header"); 144 INF("trying to send 20 byte auth header");
@@ -135,11 +151,16 @@ msg_send_creds(Pulse *conn, Pulse_Tag *tag)
135 } 151 }
136 else 152 else
137 tag->pos += r; 153 tag->pos += r;
154#else
155 conn = NULL;
156 tag = NULL;
157#endif
138} 158}
139 159
140Eina_Bool 160Eina_Bool
141msg_send(Pulse *conn, Pulse_Tag *tag) 161msg_send(Pulse *conn, Pulse_Tag *tag)
142{ 162{
163#ifdef __linux__
143 int r; 164 int r;
144 165
145 INF("trying to send %zu bytes", tag->dsize - tag->pos); 166 INF("trying to send %zu bytes", tag->dsize - tag->pos);
@@ -158,5 +179,9 @@ msg_send(Pulse *conn, Pulse_Tag *tag)
158 } 179 }
159 else 180 else
160 tag->pos += r; 181 tag->pos += r;
182#else
183 conn = NULL;
184 tag = NULL;
185#endif
161 return EINA_FALSE; 186 return EINA_FALSE;
162} 187}
diff --git a/pa.c b/pa.c
index 6d5f700..8593acb 100644
--- a/pa.c
+++ b/pa.c
@@ -223,7 +223,7 @@ pulse_recv(Pulse *conn, Ecore_Fd_Handler *fdh)
223 } 223 }
224 return tag; 224 return tag;
225error: 225error:
226 CRI("Received error command %"PRIu32"!", x); 226 ERR("Received error command %"PRIu32"!", x);
227 pulse_tag_free(tag); 227 pulse_tag_free(tag);
228 return NULL; 228 return NULL;
229} 229}
@@ -253,12 +253,12 @@ static Eina_Bool
253fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh) 253fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
254{ 254{
255 Pulse_Tag *rprev, *wprev; 255 Pulse_Tag *rprev, *wprev;
256 int read, write; 256 int pa_read, pa_write;
257 257
258 if (conn->watching) read = ECORE_FD_READ; 258 if (conn->watching) pa_read = ECORE_FD_READ;
259 else 259 else
260 read = !!ecore_main_fd_handler_active_get(fdh, ECORE_FD_READ) * ECORE_FD_READ; 260 pa_read = !!ecore_main_fd_handler_active_get(fdh, ECORE_FD_READ) * ECORE_FD_READ;
261 write = !!ecore_main_fd_handler_active_get(fdh, ECORE_FD_WRITE) * ECORE_FD_WRITE; 261 pa_write = !!ecore_main_fd_handler_active_get(fdh, ECORE_FD_WRITE) * ECORE_FD_WRITE;
262 rprev = eina_list_data_get(conn->iq); 262 rprev = eina_list_data_get(conn->iq);
263 wprev = eina_list_data_get(conn->oq); 263 wprev = eina_list_data_get(conn->oq);
264 264
@@ -285,7 +285,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
285 login_finish(conn, fdh); 285 login_finish(conn, fdh);
286 break; 286 break;
287 case PA_STATE_MOREAUTH: 287 case PA_STATE_MOREAUTH:
288 if (write) 288 if (pa_write)
289 { 289 {
290 if (msg_send(conn, wprev)) 290 if (msg_send(conn, wprev))
291 ecore_main_fd_handler_active_set(fdh, ECORE_FD_READ); 291 ecore_main_fd_handler_active_set(fdh, ECORE_FD_READ);
@@ -300,7 +300,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
300 } 300 }
301 break; 301 break;
302 case PA_STATE_CONNECTED: 302 case PA_STATE_CONNECTED:
303 if (write) 303 if (pa_write)
304 { 304 {
305 if (wprev) 305 if (wprev)
306 { 306 {
@@ -316,7 +316,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
316 else 316 else
317 ecore_main_fd_handler_active_set(conn->fdh, ECORE_FD_READ); 317 ecore_main_fd_handler_active_set(conn->fdh, ECORE_FD_READ);
318 } 318 }
319 if (read) 319 if (pa_read)
320 { 320 {
321 DBG("read"); 321 DBG("read");
322 if ((!rprev) || (!rprev->auth) || (rprev->pos < rprev->dsize)) 322 if ((!rprev) || (!rprev->auth) || (rprev->pos < rprev->dsize))
@@ -330,7 +330,7 @@ fdh_func(Pulse *conn, Ecore_Fd_Handler *fdh)
330 eina_hash_del_by_key(conn->tag_handlers, &tag->tag_count); 330 eina_hash_del_by_key(conn->tag_handlers, &tag->tag_count);
331 deserialize_tag(conn, command, tag); 331 deserialize_tag(conn, command, tag);
332 if (!eina_list_count(conn->oq)) 332 if (!eina_list_count(conn->oq))
333 ecore_main_fd_handler_active_set(conn->fdh, write | conn->watching * ECORE_FD_READ); 333 ecore_main_fd_handler_active_set(conn->fdh, pa_write | conn->watching * ECORE_FD_READ);
334 pulse_tag_free(tag); 334 pulse_tag_free(tag);
335 } 335 }
336 } 336 }
@@ -365,7 +365,7 @@ uint32_t
365pulse_cards_get(Pulse *conn) 365pulse_cards_get(Pulse *conn)
366{ 366{
367 Pulse_Tag *tag; 367 Pulse_Tag *tag;
368 int read; 368 int pa_read;
369 uint32_t type = PA_COMMAND_GET_CARD_INFO_LIST; 369 uint32_t type = PA_COMMAND_GET_CARD_INFO_LIST;
370 370
371 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0); 371 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0);
@@ -376,8 +376,8 @@ pulse_cards_get(Pulse *conn)
376 tag->tag_count = conn->tag_count; 376 tag->tag_count = conn->tag_count;
377 tag_simple_init(conn, tag, type, PA_TAG_U32); 377 tag_simple_init(conn, tag, type, PA_TAG_U32);
378 tag_finish(tag); 378 tag_finish(tag);
379 read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ; 379 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
380 ecore_main_fd_handler_active_set(conn->fdh, read | ECORE_FD_WRITE); 380 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
381 conn->oq = eina_list_append(conn->oq, tag); 381 conn->oq = eina_list_append(conn->oq, tag);
382 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type)); 382 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
383 return tag->tag_count; 383 return tag->tag_count;
@@ -396,7 +396,7 @@ uint32_t
396pulse_type_get(Pulse *conn, uint32_t idx, Eina_Bool source) 396pulse_type_get(Pulse *conn, uint32_t idx, Eina_Bool source)
397{ 397{
398 Pulse_Tag *tag; 398 Pulse_Tag *tag;
399 int read; 399 int pa_read;
400 uint32_t type = source ? PA_COMMAND_GET_SOURCE_INFO : PA_COMMAND_GET_SINK_INFO; 400 uint32_t type = source ? PA_COMMAND_GET_SOURCE_INFO : PA_COMMAND_GET_SINK_INFO;
401 401
402 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0); 402 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0);
@@ -409,8 +409,8 @@ pulse_type_get(Pulse *conn, uint32_t idx, Eina_Bool source)
409 tag_uint32(tag, idx); 409 tag_uint32(tag, idx);
410 tag_string(tag, NULL); 410 tag_string(tag, NULL);
411 tag_finish(tag); 411 tag_finish(tag);
412 read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ; 412 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
413 ecore_main_fd_handler_active_set(conn->fdh, read | ECORE_FD_WRITE); 413 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
414 conn->oq = eina_list_append(conn->oq, tag); 414 conn->oq = eina_list_append(conn->oq, tag);
415 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type)); 415 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
416 return tag->tag_count; 416 return tag->tag_count;
@@ -420,7 +420,7 @@ uint32_t
420pulse_types_get(Pulse *conn, Eina_Bool source) 420pulse_types_get(Pulse *conn, Eina_Bool source)
421{ 421{
422 Pulse_Tag *tag; 422 Pulse_Tag *tag;
423 int read; 423 int pa_read;
424 uint32_t type = source ? PA_COMMAND_GET_SOURCE_INFO_LIST : PA_COMMAND_GET_SINK_INFO_LIST; 424 uint32_t type = source ? PA_COMMAND_GET_SOURCE_INFO_LIST : PA_COMMAND_GET_SINK_INFO_LIST;
425 425
426 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0); 426 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0);
@@ -431,8 +431,8 @@ pulse_types_get(Pulse *conn, Eina_Bool source)
431 tag->tag_count = conn->tag_count; 431 tag->tag_count = conn->tag_count;
432 tag_simple_init(conn, tag, type, PA_TAG_U32); 432 tag_simple_init(conn, tag, type, PA_TAG_U32);
433 tag_finish(tag); 433 tag_finish(tag);
434 read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ; 434 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
435 ecore_main_fd_handler_active_set(conn->fdh, read | ECORE_FD_WRITE); 435 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
436 conn->oq = eina_list_append(conn->oq, tag); 436 conn->oq = eina_list_append(conn->oq, tag);
437 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type)); 437 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
438 return tag->tag_count; 438 return tag->tag_count;
@@ -442,7 +442,7 @@ uint32_t
442pulse_type_mute_set(Pulse *conn, uint32_t sink_num, Eina_Bool mute, Eina_Bool source) 442pulse_type_mute_set(Pulse *conn, uint32_t sink_num, Eina_Bool mute, Eina_Bool source)
443{ 443{
444 Pulse_Tag *tag; 444 Pulse_Tag *tag;
445 int read; 445 int pa_read;
446 uint32_t type = source ? PA_COMMAND_SET_SOURCE_MUTE : PA_COMMAND_SET_SINK_MUTE; 446 uint32_t type = source ? PA_COMMAND_SET_SOURCE_MUTE : PA_COMMAND_SET_SINK_MUTE;
447 Eina_Hash *h; 447 Eina_Hash *h;
448 448
@@ -457,8 +457,8 @@ pulse_type_mute_set(Pulse *conn, uint32_t sink_num, Eina_Bool mute, Eina_Bool so
457 tag_string(tag, NULL); 457 tag_string(tag, NULL);
458 tag_bool(tag, !!mute); 458 tag_bool(tag, !!mute);
459 tag_finish(tag); 459 tag_finish(tag);
460 read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ; 460 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
461 ecore_main_fd_handler_active_set(conn->fdh, read | ECORE_FD_WRITE); 461 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
462 conn->oq = eina_list_append(conn->oq, tag); 462 conn->oq = eina_list_append(conn->oq, tag);
463 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type)); 463 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
464 h = (source) ? pulse_sources : pulse_sinks; 464 h = (source) ? pulse_sources : pulse_sinks;
@@ -476,7 +476,7 @@ uint32_t
476pulse_type_volume_set(Pulse *conn, uint32_t sink_num, uint8_t channels, double vol, Eina_Bool source) 476pulse_type_volume_set(Pulse *conn, uint32_t sink_num, uint8_t channels, double vol, Eina_Bool source)
477{ 477{
478 Pulse_Tag *tag; 478 Pulse_Tag *tag;
479 int read; 479 int pa_read;
480 uint32_t type = source ? PA_COMMAND_SET_SOURCE_MUTE : PA_COMMAND_SET_SINK_VOLUME; 480 uint32_t type = source ? PA_COMMAND_SET_SOURCE_MUTE : PA_COMMAND_SET_SINK_VOLUME;
481 481
482 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0); 482 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0);
@@ -490,8 +490,30 @@ pulse_type_volume_set(Pulse *conn, uint32_t sink_num, uint8_t channels, double v
490 tag_string(tag, NULL); 490 tag_string(tag, NULL);
491 tag_volume(tag, channels, vol); 491 tag_volume(tag, channels, vol);
492 tag_finish(tag); 492 tag_finish(tag);
493 read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ; 493 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
494 ecore_main_fd_handler_active_set(conn->fdh, read | ECORE_FD_WRITE); 494 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
495 conn->oq = eina_list_append(conn->oq, tag);
496 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
497 return tag->tag_count;
498}
499
500uint32_t
501pulse_server_info_get(Pulse *conn)
502{
503 Pulse_Tag *tag;
504 int pa_read;
505 uint32_t type = PA_COMMAND_GET_SERVER_INFO;
506
507 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0);
508 tag = calloc(1, sizeof(Pulse_Tag));
509 EINA_SAFETY_ON_NULL_RETURN_VAL(tag, 0);
510 tag->dsize = 2 * PA_TAG_SIZE_U32;
511 tag->data = malloc(tag->dsize);
512 tag->tag_count = conn->tag_count;
513 tag_simple_init(conn, tag, type, PA_TAG_U32);
514 tag_finish(tag);
515 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
516 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
495 conn->oq = eina_list_append(conn->oq, tag); 517 conn->oq = eina_list_append(conn->oq, tag);
496 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type)); 518 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
497 return tag->tag_count; 519 return tag->tag_count;
@@ -501,7 +523,7 @@ uint32_t
501pulse_sink_channel_volume_set(Pulse *conn, Pulse_Sink *sink, uint32_t id, double vol) 523pulse_sink_channel_volume_set(Pulse *conn, Pulse_Sink *sink, uint32_t id, double vol)
502{ 524{
503 Pulse_Tag *tag; 525 Pulse_Tag *tag;
504 int read; 526 int pa_read;
505 uint32_t type; 527 uint32_t type;
506 528
507 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0); 529 EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0);
@@ -519,8 +541,8 @@ pulse_sink_channel_volume_set(Pulse *conn, Pulse_Sink *sink, uint32_t id, double
519 tag_string(tag, NULL); 541 tag_string(tag, NULL);
520 tag_cvol(tag, &sink->volume); 542 tag_cvol(tag, &sink->volume);
521 tag_finish(tag); 543 tag_finish(tag);
522 read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ; 544 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
523 ecore_main_fd_handler_active_set(conn->fdh, read | ECORE_FD_WRITE); 545 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
524 conn->oq = eina_list_append(conn->oq, tag); 546 conn->oq = eina_list_append(conn->oq, tag);
525 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type)); 547 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
526 return tag->tag_count; 548 return tag->tag_count;
@@ -530,7 +552,7 @@ uint32_t
530pulse_sink_port_set(Pulse *conn, Pulse_Sink *sink, const char *port) 552pulse_sink_port_set(Pulse *conn, Pulse_Sink *sink, const char *port)
531{ 553{
532 Pulse_Tag *tag; 554 Pulse_Tag *tag;
533 int read; 555 int pa_read;
534 uint32_t type; 556 uint32_t type;
535 Eina_List *l; 557 Eina_List *l;
536 const char *p; 558 const char *p;
@@ -555,8 +577,8 @@ pulse_sink_port_set(Pulse *conn, Pulse_Sink *sink, const char *port)
555 tag_string(tag, sink->name); 577 tag_string(tag, sink->name);
556 tag_string(tag, port); 578 tag_string(tag, port);
557 tag_finish(tag); 579 tag_finish(tag);
558 read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ; 580 pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
559 ecore_main_fd_handler_active_set(conn->fdh, read | ECORE_FD_WRITE); 581 ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
560 conn->oq = eina_list_append(conn->oq, tag); 582 conn->oq = eina_list_append(conn->oq, tag);
561 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type)); 583 eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
562 return tag->tag_count; 584 return tag->tag_count;
@@ -619,8 +641,8 @@ pulse_new(void)
619{ 641{
620 Pulse *conn; 642 Pulse *conn;
621 Eina_Iterator *it; 643 Eina_Iterator *it;
622 const char *prev = NULL, *buf = NULL;; 644 const char *prev = NULL, *buf = NULL;
623 time_t time = 0; 645 time_t t = 0;
624 char *home, h[4096]; 646 char *home, h[4096];
625 const Eina_File_Direct_Info *info; 647 const Eina_File_Direct_Info *info;
626 648
@@ -653,14 +675,14 @@ pulse_new(void)
653 buf = NULL; 675 buf = NULL;
654 continue; 676 continue;
655 } 677 }
656 if (!time) 678 if (!t)
657 { 679 {
658 time = st.st_atime; 680 t = st.st_atime;
659 prev = buf; 681 prev = buf;
660 buf = NULL; 682 buf = NULL;
661 continue; 683 continue;
662 } 684 }
663 if (time > st.st_atime) 685 if (t > st.st_atime)
664 { 686 {
665 eina_stringshare_del(buf); 687 eina_stringshare_del(buf);
666 buf = NULL; 688 buf = NULL;
@@ -668,7 +690,7 @@ pulse_new(void)
668 } 690 }
669 eina_stringshare_del(prev); 691 eina_stringshare_del(prev);
670 prev = buf; 692 prev = buf;
671 time = st.st_atime; 693 t = st.st_atime;
672 buf = NULL; 694 buf = NULL;
673 } 695 }
674 } 696 }
@@ -680,7 +702,7 @@ pulse_new(void)
680 buf = eina_stringshare_add(STATEDIR "/run/pulse/native"); 702 buf = eina_stringshare_add(STATEDIR "/run/pulse/native");
681 if (stat(buf, &st)) 703 if (stat(buf, &st))
682 { 704 {
683 CRI("could not locate local socket '%s'!", buf); 705 INF("could not locate local socket '%s'!", buf);
684 free(conn); 706 free(conn);
685 return NULL; 707 return NULL;
686 } 708 }
@@ -718,3 +740,17 @@ pulse_connect(Pulse *conn)
718 conn->svr = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM, conn->socket, -1, conn); 740 conn->svr = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM, conn->socket, -1, conn);
719 return !!conn->svr; 741 return !!conn->svr;
720} 742}
743
744void
745pulse_server_info_free(Pulse_Server_Info *ev)
746{
747 if (!ev) return;
748
749 eina_stringshare_del(ev->name);
750 eina_stringshare_del(ev->version);
751 eina_stringshare_del(ev->username);
752 eina_stringshare_del(ev->hostname);
753 eina_stringshare_del(ev->default_sink);
754 eina_stringshare_del(ev->default_source);
755 free(ev);
756}
diff --git a/serial.c b/serial.c
index 278e585..7ccdff9 100644
--- a/serial.c
+++ b/serial.c
@@ -1,5 +1,28 @@
1#include "pa.h" 1#include "pa.h"
2 2
3static Pulse_Server_Info *
4deserialize_server_info(Pulse *conn, Pulse_Tag *tag)
5{
6 Pulse_Server_Info *ev;
7 pa_sample_spec spec;
8
9 ev = calloc(1, sizeof(Pulse_Server_Info));
10 ev->conn = conn;
11 EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
12 EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->name), error);
13 EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->version), error);
14 EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->username), error);
15 EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->hostname), error);
16 EINA_SAFETY_ON_FALSE_GOTO(untag_sample(tag, &spec), error);
17 EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->default_sink), error);
18 EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->default_source), error);
19
20 return ev;
21error:
22 pulse_server_info_free(ev);
23 return NULL;
24}
25
3static void 26static void
4deserialize_sinks_watcher(Pulse *conn, Pulse_Tag *tag) 27deserialize_sinks_watcher(Pulse *conn, Pulse_Tag *tag)
5{ 28{
@@ -113,6 +136,11 @@ deserialize_tag(Pulse *conn, PA_Commands command, Pulse_Tag *tag)
113 conn->watching = EINA_TRUE; 136 conn->watching = EINA_TRUE;
114 switch (command) 137 switch (command)
115 { 138 {
139 case PA_COMMAND_GET_SERVER_INFO:
140 if (!cb) return EINA_TRUE;
141 ev = NULL;
142 ev = deserialize_server_info(conn, tag);
143 break;
116 case PA_COMMAND_GET_SINK_INFO_LIST: 144 case PA_COMMAND_GET_SINK_INFO_LIST:
117 case PA_COMMAND_GET_SOURCE_INFO_LIST: 145 case PA_COMMAND_GET_SOURCE_INFO_LIST:
118 if (!cb) return EINA_TRUE; 146 if (!cb) return EINA_TRUE;