forked from enlightenment/enlightenment
update pa interface to allow fetching server info
SVN revision: 76511
This commit is contained in:
parent
8a004228af
commit
0ccd179ab8
|
@ -21,6 +21,17 @@ typedef struct Pulse_Sink_Port_Info {
|
|||
uint32_t priority; /**< The higher this value is the more useful this port is as a default */
|
||||
} Pulse_Sink_Port_Info;
|
||||
|
||||
typedef struct Pulse_Server_Info
|
||||
{
|
||||
Pulse *conn;
|
||||
const char *name;
|
||||
const char *version;
|
||||
const char *username;
|
||||
const char *hostname;
|
||||
const char *default_sink;
|
||||
const char *default_source;
|
||||
} Pulse_Server_Info;
|
||||
|
||||
int pulse_init(void);
|
||||
void pulse_shutdown(void);
|
||||
|
||||
|
@ -28,7 +39,9 @@ Pulse *pulse_new(void);
|
|||
Eina_Bool pulse_connect(Pulse *conn);
|
||||
void pulse_free(Pulse *conn);
|
||||
void pulse_cb_set(Pulse *conn, uint32_t tagnum, Pulse_Cb cb);
|
||||
void pulse_server_info_free(Pulse_Server_Info *ev);
|
||||
|
||||
uint32_t pulse_server_info_get(Pulse *conn);
|
||||
uint32_t pulse_cards_get(Pulse *conn);
|
||||
#define pulse_sinks_get(conn) pulse_types_get((conn), EINA_FALSE)
|
||||
#define pulse_sources_get(conn) pulse_types_get((conn), EINA_TRUE)
|
||||
|
|
|
@ -497,6 +497,28 @@ pulse_type_volume_set(Pulse *conn, uint32_t sink_num, uint8_t channels, double v
|
|||
return tag->tag_count;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
pulse_server_info_get(Pulse *conn)
|
||||
{
|
||||
Pulse_Tag *tag;
|
||||
int pa_read;
|
||||
uint32_t type = PA_COMMAND_GET_SERVER_INFO;
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(conn, 0);
|
||||
tag = calloc(1, sizeof(Pulse_Tag));
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(tag, 0);
|
||||
tag->dsize = 2 * PA_TAG_SIZE_U32;
|
||||
tag->data = malloc(tag->dsize);
|
||||
tag->tag_count = conn->tag_count;
|
||||
tag_simple_init(conn, tag, type, PA_TAG_U32);
|
||||
tag_finish(tag);
|
||||
pa_read = !!ecore_main_fd_handler_active_get(conn->fdh, ECORE_FD_READ) * ECORE_FD_READ;
|
||||
ecore_main_fd_handler_active_set(conn->fdh, pa_read | ECORE_FD_WRITE);
|
||||
conn->oq = eina_list_append(conn->oq, tag);
|
||||
eina_hash_add(conn->tag_handlers, &tag->tag_count, (uintptr_t*)((uintptr_t)type));
|
||||
return tag->tag_count;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
pulse_sink_channel_volume_set(Pulse *conn, Pulse_Sink *sink, uint32_t id, double vol)
|
||||
{
|
||||
|
@ -718,3 +740,17 @@ pulse_connect(Pulse *conn)
|
|||
conn->svr = ecore_con_server_connect(ECORE_CON_LOCAL_SYSTEM, conn->socket, -1, conn);
|
||||
return !!conn->svr;
|
||||
}
|
||||
|
||||
void
|
||||
pulse_server_info_free(Pulse_Server_Info *ev)
|
||||
{
|
||||
if (!ev) return;
|
||||
|
||||
eina_stringshare_del(ev->name);
|
||||
eina_stringshare_del(ev->version);
|
||||
eina_stringshare_del(ev->username);
|
||||
eina_stringshare_del(ev->hostname);
|
||||
eina_stringshare_del(ev->default_sink);
|
||||
eina_stringshare_del(ev->default_source);
|
||||
free(ev);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,28 @@
|
|||
#include "pa.h"
|
||||
|
||||
static Pulse_Server_Info *
|
||||
deserialize_server_info(Pulse *conn, Pulse_Tag *tag)
|
||||
{
|
||||
Pulse_Server_Info *ev;
|
||||
pa_sample_spec spec;
|
||||
|
||||
ev = calloc(1, sizeof(Pulse_Server_Info));
|
||||
ev->conn = conn;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ev, NULL);
|
||||
EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->name), error);
|
||||
EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->version), error);
|
||||
EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->username), error);
|
||||
EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->hostname), error);
|
||||
EINA_SAFETY_ON_FALSE_GOTO(untag_sample(tag, &spec), error);
|
||||
EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->default_sink), error);
|
||||
EINA_SAFETY_ON_FALSE_GOTO(untag_string(tag, &ev->default_source), error);
|
||||
|
||||
return ev;
|
||||
error:
|
||||
pulse_server_info_free(ev);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
deserialize_sinks_watcher(Pulse *conn, Pulse_Tag *tag)
|
||||
{
|
||||
|
@ -113,6 +136,11 @@ deserialize_tag(Pulse *conn, PA_Commands command, Pulse_Tag *tag)
|
|||
conn->watching = EINA_TRUE;
|
||||
switch (command)
|
||||
{
|
||||
case PA_COMMAND_GET_SERVER_INFO:
|
||||
if (!cb) return EINA_TRUE;
|
||||
ev = NULL;
|
||||
ev = deserialize_server_info(conn, tag);
|
||||
break;
|
||||
case PA_COMMAND_GET_SINK_INFO_LIST:
|
||||
case PA_COMMAND_GET_SOURCE_INFO_LIST:
|
||||
if (!cb) return EINA_TRUE;
|
||||
|
|
Loading…
Reference in New Issue