summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-06-29 16:50:50 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-08-14 23:33:18 -0300
commit043dba125bb80bbe6454263df49abd2c8b8dddec (patch)
treeb91bbe94f3555ab59d7f83fdb4d061e2323ce923
parentce0a9ca1c29093dfa5ac91519e7571766d796b97 (diff)
backends:pulseaudio: Fixing internal lists and stringshares
Sources, Sinks and Inputs were not been added to the lists and the strings on Port's structure were not using eina_stringshare.
-rw-r--r--src/lib/backends/pulseaudio/pulse.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/lib/backends/pulseaudio/pulse.c b/src/lib/backends/pulseaudio/pulse.c
index b9ec31c..448b927 100644
--- a/src/lib/backends/pulseaudio/pulse.c
+++ b/src/lib/backends/pulseaudio/pulse.c
@@ -94,6 +94,7 @@ _sink_del(Sink *sink)
94 free(port); 94 free(port);
95 } 95 }
96 96
97 free(sink->base.volume.volumes);
97 eina_stringshare_del(sink->base.name); 98 eina_stringshare_del(sink->base.name);
98 free(sink); 99 free(sink);
99} 100}
@@ -156,12 +157,14 @@ _sink_cb(pa_context *c EINA_UNUSED, const pa_sink_info *info, int eol,
156 } 157 }
157 158
158 port->available = !!info->ports[i]->available; 159 port->available = !!info->ports[i]->available;
159 port->name = strdup(info->ports[i]->name); 160 port->name = eina_stringshare_add(info->ports[i]->name);
160 port->description = strdup(info->ports[i]->description); 161 port->description = eina_stringshare_add(info->ports[i]->description);
161 sink->ports = eina_list_append(sink->ports, port); 162 sink->ports = eina_list_append(sink->ports, port);
162 if (info->ports[i]->name == info->active_port->name) 163 if (info->ports[i]->name == info->active_port->name)
163 port->active = EINA_TRUE; 164 port->active = EINA_TRUE;
164 } 165 }
166
167 ctx->sinks = eina_list_append(ctx->sinks, sink);
165 if (ctx->sink_cb) 168 if (ctx->sink_cb)
166 ctx->sink_cb((Emix_Sink *)sink, EMIX_EVENT_ADDED); 169 ctx->sink_cb((Emix_Sink *)sink, EMIX_EVENT_ADDED);
167} 170}
@@ -205,10 +208,14 @@ _sink_changed_cb(pa_context *c EINA_UNUSED, const pa_sink_info *info, int eol,
205 sink = calloc(1, sizeof(Sink)); 208 sink = calloc(1, sizeof(Sink));
206 ev = EMIX_EVENT_ADDED; 209 ev = EMIX_EVENT_ADDED;
207 EINA_SAFETY_ON_NULL_RETURN(sink); 210 EINA_SAFETY_ON_NULL_RETURN(sink);
211 ctx->sinks = eina_list_append(ctx->sinks, sink);
208 } 212 }
209 213
210 sink->idx = info->index; 214 sink->idx = info->index;
211 sink->base.name = eina_stringshare_add(info->name); 215 if (sink->base.name)
216 eina_stringshare_replace(&sink->base.name, info->description);
217 else
218 sink->base.name = eina_stringshare_add(info->description);
212 sink->base.volume = _pa_cvolume_convert(info->volume); 219 sink->base.volume = _pa_cvolume_convert(info->volume);
213 sink->base.mute = !!info->mute; 220 sink->base.mute = !!info->mute;
214 221
@@ -240,7 +247,6 @@ _sink_remove_cb(int index, void *data EINA_UNUSED)
240 Eina_List *l; 247 Eina_List *l;
241 DBG("Removing sink: %d", index); 248 DBG("Removing sink: %d", index);
242 249
243
244 EINA_LIST_FOREACH(ctx->sinks, l, sink) 250 EINA_LIST_FOREACH(ctx->sinks, l, sink)
245 { 251 {
246 if (sink->idx == index) 252 if (sink->idx == index)
@@ -325,6 +331,7 @@ _sink_input_cb(pa_context *c EINA_UNUSED, const pa_sink_input_info *info,
325 input->base.sink = (Emix_Sink *)s; 331 input->base.sink = (Emix_Sink *)s;
326 } 332 }
327 input->icon = eina_stringshare_add(_icon_from_properties(info->proplist)); 333 input->icon = eina_stringshare_add(_icon_from_properties(info->proplist));
334 ctx->inputs = eina_list_append(ctx->inputs, input);
328 if (ctx->sink_input_cb) 335 if (ctx->sink_input_cb)
329 ctx->sink_input_cb((Emix_Sink_Input *)input, EMIX_EVENT_ADDED); 336 ctx->sink_input_cb((Emix_Sink_Input *)input, EMIX_EVENT_ADDED);
330} 337}
@@ -366,6 +373,7 @@ _sink_input_changed_cb(pa_context *c EINA_UNUSED,
366 ev = EMIX_EVENT_ADDED; 373 ev = EMIX_EVENT_ADDED;
367 input = calloc(1, sizeof(Sink_Input)); 374 input = calloc(1, sizeof(Sink_Input));
368 EINA_SAFETY_ON_NULL_RETURN(input); 375 EINA_SAFETY_ON_NULL_RETURN(input);
376 ctx->inputs = eina_list_append(ctx->inputs, input);
369 } 377 }
370 input->idx = info->index; 378 input->idx = info->index;
371 input->base.volume = _pa_cvolume_convert(info->volume); 379 input->base.volume = _pa_cvolume_convert(info->volume);
@@ -425,6 +433,7 @@ _source_cb(pa_context *c EINA_UNUSED, const pa_source_info *info,
425 source->base.volume = _pa_cvolume_convert(info->volume); 433 source->base.volume = _pa_cvolume_convert(info->volume);
426 source->base.mute = !!info->mute; 434 source->base.mute = !!info->mute;
427 435
436 ctx->sources = eina_list_append(ctx->sources, source);
428 if (ctx->source_cb) 437 if (ctx->source_cb)
429 ctx->source_cb((Emix_Source *)source, EMIX_EVENT_ADDED); 438 ctx->source_cb((Emix_Source *)source, EMIX_EVENT_ADDED);
430} 439}
@@ -467,6 +476,7 @@ _source_changed_cb(pa_context *c EINA_UNUSED,
467 source = calloc(1, sizeof(Source)); 476 source = calloc(1, sizeof(Source));
468 EINA_SAFETY_ON_NULL_RETURN(source); 477 EINA_SAFETY_ON_NULL_RETURN(source);
469 ev = EMIX_EVENT_ADDED; 478 ev = EMIX_EVENT_ADDED;
479 ctx->sources = eina_list_append(ctx->sources, source);
470 } 480 }
471 source->idx= info->index; 481 source->idx= info->index;
472 source->base.volume = _pa_cvolume_convert(info->volume); 482 source->base.volume = _pa_cvolume_convert(info->volume);