summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-08-08 00:05:38 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-08-14 23:33:18 -0300
commitcd169f8418578d999865ef8680760334409966d5 (patch)
tree0cbe0faa33af519973c1829c410c073ddf996426 /src
parent04a15339c34edd7defdad9bbb58ad296fab6f35d (diff)
emix: Make the ports part of the Sink
Diffstat (limited to 'src')
-rw-r--r--src/lib/backends/pulseaudio/pulse.c26
-rw-r--r--src/lib/emix.c10
-rw-r--r--src/lib/emix.h4
3 files changed, 28 insertions, 12 deletions
diff --git a/src/lib/backends/pulseaudio/pulse.c b/src/lib/backends/pulseaudio/pulse.c
index 61fb069..97b9467 100644
--- a/src/lib/backends/pulseaudio/pulse.c
+++ b/src/lib/backends/pulseaudio/pulse.c
@@ -30,7 +30,6 @@ typedef struct _Context {
30 30
31typedef struct _Sink { 31typedef struct _Sink {
32 Emix_Sink base; 32 Emix_Sink base;
33 Eina_List *ports;
34 int idx; 33 int idx;
35} Sink; 34} Sink;
36 35
@@ -88,7 +87,7 @@ _sink_del(Sink *sink)
88 Emix_Port *port; 87 Emix_Port *port;
89 88
90 EINA_SAFETY_ON_NULL_RETURN(sink); 89 EINA_SAFETY_ON_NULL_RETURN(sink);
91 EINA_LIST_FREE(sink->ports, port) 90 EINA_LIST_FREE(sink->base.ports, port)
92 { 91 {
93 eina_stringshare_del(port->name); 92 eina_stringshare_del(port->name);
94 eina_stringshare_del(port->description); 93 eina_stringshare_del(port->description);
@@ -160,7 +159,7 @@ _sink_cb(pa_context *c EINA_UNUSED, const pa_sink_info *info, int eol,
160 port->available = !!info->ports[i]->available; 159 port->available = !!info->ports[i]->available;
161 port->name = eina_stringshare_add(info->ports[i]->name); 160 port->name = eina_stringshare_add(info->ports[i]->name);
162 port->description = eina_stringshare_add(info->ports[i]->description); 161 port->description = eina_stringshare_add(info->ports[i]->description);
163 sink->ports = eina_list_append(sink->ports, port); 162 sink->base.ports = eina_list_append(sink->base.ports, port);
164 if (info->ports[i]->name == info->active_port->name) 163 if (info->ports[i]->name == info->active_port->name)
165 port->active = EINA_TRUE; 164 port->active = EINA_TRUE;
166 } 165 }
@@ -210,9 +209,9 @@ _sink_changed_cb(pa_context *c EINA_UNUSED, const pa_sink_info *info, int eol,
210 sink->base.volume = _pa_cvolume_convert(info->volume); 209 sink->base.volume = _pa_cvolume_convert(info->volume);
211 sink->base.mute = !!info->mute; 210 sink->base.mute = !!info->mute;
212 211
213 if (sink->ports) 212 if (sink->base.ports)
214 { 213 {
215 EINA_LIST_FREE(sink->ports, port) 214 EINA_LIST_FREE(sink->base.ports, port)
216 { 215 {
217 eina_stringshare_del(port->name); 216 eina_stringshare_del(port->name);
218 eina_stringshare_del(port->description); 217 eina_stringshare_del(port->description);
@@ -231,7 +230,7 @@ _sink_changed_cb(pa_context *c EINA_UNUSED, const pa_sink_info *info, int eol,
231 port->available = !!info->ports[i]->available; 230 port->available = !!info->ports[i]->available;
232 port->name = eina_stringshare_add(info->ports[i]->description ?: 231 port->name = eina_stringshare_add(info->ports[i]->description ?:
233 info->ports[i]->name); 232 info->ports[i]->name);
234 sink->ports = eina_list_append(sink->ports, port); 233 sink->base.ports = eina_list_append(sink->base.ports, port);
235 if (info->ports[i]->name == info->active_port->name) 234 if (info->ports[i]->name == info->active_port->name)
236 port->active = EINA_TRUE; 235 port->active = EINA_TRUE;
237 } 236 }
@@ -937,18 +936,23 @@ _sink_input_move(Emix_Sink_Input *input, Emix_Sink *sink)
937 ERR("pa_context_move_sink_input_by_index() failed"); 936 ERR("pa_context_move_sink_input_by_index() failed");
938} 937}
939 938
940static void 939static Eina_Bool
941_sink_port_set(Emix_Sink *sink, const Emix_Port *port) 940_sink_port_set(Emix_Sink *sink, const Emix_Port *port)
942{ 941{
943 pa_operation* o; 942 pa_operation* o;
944 Sink *s = (Sink *)sink; 943 Sink *s = (Sink *)sink;
945 EINA_SAFETY_ON_FALSE_RETURN(ctx && ctx->context && 944 EINA_SAFETY_ON_FALSE_RETURN_VAL(ctx && ctx->context &&
946 sink != NULL && port != NULL); 945 sink != NULL && port != NULL, EINA_FALSE);
947 946
948 if (!(o = pa_context_set_sink_port_by_index(ctx->context, 947 if (!(o = pa_context_set_sink_port_by_index(ctx->context,
949 s->idx, port->name, NULL, 948 s->idx, port->name, NULL,
950 NULL))) 949 NULL)))
951 ERR("pa_context_set_source_port_by_index() failed"); 950 {
951 ERR("pa_context_set_source_port_by_index() failed");
952 return EINA_FALSE;
953 }
954
955 return EINA_TRUE;
952} 956}
953 957
954static Eina_Bool 958static Eina_Bool
@@ -963,7 +967,7 @@ _sink_default_get(void)
963 Sink *s; 967 Sink *s;
964 Eina_List *l; 968 Eina_List *l;
965 969
966 EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL); 970 EINA_SAFETY_ON_NULL_RETURN_VAL(ctx, NULL);
967 EINA_LIST_FOREACH(ctx->sinks, l, s) 971 EINA_LIST_FOREACH(ctx->sinks, l, s)
968 if (s->idx == ctx->default_sink) 972 if (s->idx == ctx->default_sink)
969 return (Emix_Sink *)s; 973 return (Emix_Sink *)s;
diff --git a/src/lib/emix.c b/src/lib/emix.c
index f03b2f0..93d89dc 100644
--- a/src/lib/emix.c
+++ b/src/lib/emix.c
@@ -317,6 +317,16 @@ emix_sink_default_set(Emix_Sink *sink)
317 ctx->loaded->ebackend_sink_default_set(sink); 317 ctx->loaded->ebackend_sink_default_set(sink);
318} 318}
319 319
320Eina_Bool
321emix_sink_port_set(Emix_Sink *sink, Emix_Port *port)
322{
323 EINA_SAFETY_ON_FALSE_RETURN_VAL((ctx && ctx->loaded &&
324 ctx->loaded->ebackend_sink_port_set &&
325 sink && port), EINA_FALSE);
326
327 return ctx->loaded->ebackend_sink_port_set(sink, port);
328}
329
320void 330void
321emix_sink_mute_set(Emix_Sink *sink, Eina_Bool mute) 331emix_sink_mute_set(Emix_Sink *sink, Eina_Bool mute)
322{ 332{
diff --git a/src/lib/emix.h b/src/lib/emix.h
index 86443f8..0c40151 100644
--- a/src/lib/emix.h
+++ b/src/lib/emix.h
@@ -34,6 +34,7 @@ typedef struct _Emix_Sink {
34 const char *name; 34 const char *name;
35 Emix_Volume volume; 35 Emix_Volume volume;
36 Eina_Bool mute; 36 Eina_Bool mute;
37 Eina_List *ports;
37} Emix_Sink; 38} Emix_Sink;
38 39
39typedef struct _Emix_Sink_Input { 40typedef struct _Emix_Sink_Input {
@@ -78,7 +79,7 @@ typedef struct _Emix_Backend {
78 Eina_Bool mute); 79 Eina_Bool mute);
79 void (*ebackend_sink_volume_set)(Emix_Sink *sink, 80 void (*ebackend_sink_volume_set)(Emix_Sink *sink,
80 Emix_Volume volume); 81 Emix_Volume volume);
81 void (*ebackend_sink_port_set)(Emix_Sink *sink, 82 Eina_Bool (*ebackend_sink_port_set)(Emix_Sink *sink,
82 const Emix_Port *port); 83 const Emix_Port *port);
83 Eina_Bool (*ebackend_sink_change_support)(void); 84 Eina_Bool (*ebackend_sink_change_support)(void);
84 85
@@ -106,6 +107,7 @@ EAPI Eina_Bool emix_backend_set(const char *backend);
106EAPI const Eina_List* emix_sinks_get(void); 107EAPI const Eina_List* emix_sinks_get(void);
107EAPI Eina_Bool emix_sink_default_support(void); 108EAPI Eina_Bool emix_sink_default_support(void);
108EAPI const Emix_Sink* emix_sink_default_get(void); 109EAPI const Emix_Sink* emix_sink_default_get(void);
110EAPI Eina_Bool emix_sink_port_set(Emix_Sink *sink, Emix_Port *port);
109EAPI void emix_sink_default_set(Emix_Sink *sink); 111EAPI void emix_sink_default_set(Emix_Sink *sink);
110EAPI void emix_sink_mute_set(Emix_Sink *sink, Eina_Bool mute); 112EAPI void emix_sink_mute_set(Emix_Sink *sink, Eina_Bool mute);
111EAPI void emix_sink_volume_set(Emix_Sink *sink, 113EAPI void emix_sink_volume_set(Emix_Sink *sink,