summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-08-28 16:19:14 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-08-28 16:31:44 -0300
commit0a8136c3cdb2444f141504d0201180701fb7526f (patch)
tree5d8357d202b8483fdb1be6c2acfaba638a3db2de
parent1eb97bade85944673b1c9ba814bf351f4ef2fb85 (diff)
emix: Make backend's init function returns boolean
It's necessary for who is using the library be able to take an action when the backend fails.
-rw-r--r--src/bin/main.c8
-rw-r--r--src/lib/backends/alsa/alsa.c4
-rw-r--r--src/lib/backends/pulseaudio/pulse.c9
-rw-r--r--src/lib/emix.c5
-rw-r--r--src/lib/emix.h2
-rw-r--r--src/module/e_mod_main.c15
6 files changed, 28 insertions, 15 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index b74940b..3045268 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -17,9 +17,15 @@ elm_main(int argc EINA_UNUSED, char *argv[] EINA_UNUSED)
17 evas_object_resize(win, DEFAULT_WIDTH, DEFAULT_HEIGHT); 17 evas_object_resize(win, DEFAULT_WIDTH, DEFAULT_HEIGHT);
18 evas_object_show(win); 18 evas_object_show(win);
19 19
20 emix_backend_set("PULSEAUDIO"); 20 if (emix_backend_set("PULSEAUDIO") == EINA_FALSE)
21 {
22 ERR("Could not start the backend !");
23 goto end;
24 }
25
21 elm_run(); 26 elm_run();
22 27
28end:
23 emixer_common_shutdown(); 29 emixer_common_shutdown();
24 emix_shutdown(); 30 emix_shutdown();
25 return 0; 31 return 0;
diff --git a/src/lib/backends/alsa/alsa.c b/src/lib/backends/alsa/alsa.c
index 237ece2..f3d42e3 100644
--- a/src/lib/backends/alsa/alsa.c
+++ b/src/lib/backends/alsa/alsa.c
@@ -439,7 +439,7 @@ _alsa_cards_refresh(void)
439 eina_stringshare_del(card_name); 439 eina_stringshare_del(card_name);
440} 440}
441 441
442static void 442static Eina_Bool
443_alsa_init(sink_event_cb sink_cb, sink_input_event_cb input_cb, 443_alsa_init(sink_event_cb sink_cb, sink_input_event_cb input_cb,
444 source_event_cb source_cb, disconnect_event_cb disconnect_cb, 444 source_event_cb source_cb, disconnect_event_cb disconnect_cb,
445 ready_event_cb ready_cb EINA_UNUSED) 445 ready_event_cb ready_cb EINA_UNUSED)
@@ -453,6 +453,8 @@ _alsa_init(sink_event_cb sink_cb, sink_input_event_cb input_cb,
453 ctx->disconnect_cb = disconnect_cb; 453 ctx->disconnect_cb = disconnect_cb;
454 ctx->ready_cb = ready_cb; 454 ctx->ready_cb = ready_cb;
455 _alsa_cards_refresh(); 455 _alsa_cards_refresh();
456
457 return EINA_TRUE;
456} 458}
457 459
458static void 460static void
diff --git a/src/lib/backends/pulseaudio/pulse.c b/src/lib/backends/pulseaudio/pulse.c
index f8daa8f..74dc101 100644
--- a/src/lib/backends/pulseaudio/pulse.c
+++ b/src/lib/backends/pulseaudio/pulse.c
@@ -760,19 +760,19 @@ _pulse_connect(void *data)
760 return ECORE_CALLBACK_RENEW; 760 return ECORE_CALLBACK_RENEW;
761} 761}
762 762
763static void 763static Eina_Bool
764_init(sink_event_cb sink_cb, sink_input_event_cb input_cb, 764_init(sink_event_cb sink_cb, sink_input_event_cb input_cb,
765 source_event_cb source_cb, disconnect_event_cb disconnect_cb, 765 source_event_cb source_cb, disconnect_event_cb disconnect_cb,
766 ready_event_cb ready_cb) 766 ready_event_cb ready_cb)
767{ 767{
768 if (ctx) 768 if (ctx)
769 return; 769 return EINA_TRUE;
770 770
771 ctx = calloc(1, sizeof(Context)); 771 ctx = calloc(1, sizeof(Context));
772 if (!ctx) 772 if (!ctx)
773 { 773 {
774 ERR("Could not create Epulse Context"); 774 ERR("Could not create Epulse Context");
775 return; 775 return EINA_FALSE;
776 } 776 }
777 777
778 ctx->sink_cb = sink_cb; 778 ctx->sink_cb = sink_cb;
@@ -792,7 +792,10 @@ _init(sink_event_cb sink_cb, sink_input_event_cb input_cb,
792 { 792 {
793 free(ctx); 793 free(ctx);
794 ctx = NULL; 794 ctx = NULL;
795 return EINA_FALSE;
795 } 796 }
797
798 return EINA_TRUE;
796 } 799 }
797 800
798static void 801static void
diff --git a/src/lib/emix.c b/src/lib/emix.c
index 13eb17d..589a844 100644
--- a/src/lib/emix.c
+++ b/src/lib/emix.c
@@ -275,9 +275,8 @@ emix_backend_set(const char *backend)
275 if (!ctx->loaded || !ctx->loaded->ebackend_init) 275 if (!ctx->loaded || !ctx->loaded->ebackend_init)
276 return EINA_FALSE; 276 return EINA_FALSE;
277 277
278 ctx->loaded->ebackend_init(_sink_cb, _sink_input_cb, _source_cb, 278 return ctx->loaded->ebackend_init(_sink_cb, _sink_input_cb, _source_cb,
279 _disconnect_cb, _ready_cb); 279 _disconnect_cb, _ready_cb);
280 return EINA_TRUE;
281} 280}
282 281
283const Eina_List* 282const Eina_List*
diff --git a/src/lib/emix.h b/src/lib/emix.h
index c43d31c..bdd4487 100644
--- a/src/lib/emix.h
+++ b/src/lib/emix.h
@@ -65,7 +65,7 @@ typedef void (*disconnect_event_cb)(void);
65typedef void (*ready_event_cb)(void); 65typedef void (*ready_event_cb)(void);
66 66
67typedef struct _Emix_Backend { 67typedef struct _Emix_Backend {
68 void (*ebackend_init)(sink_event_cb sink_cb, 68 Eina_Bool (*ebackend_init)(sink_event_cb sink_cb,
69 sink_input_event_cb input_cb, 69 sink_input_event_cb input_cb,
70 source_event_cb source_cb, 70 source_event_cb source_cb,
71 disconnect_event_cb disconnect_cb, 71 disconnect_event_cb disconnect_cb,
diff --git a/src/module/e_mod_main.c b/src/module/e_mod_main.c
index 5392970..439fcb9 100644
--- a/src/module/e_mod_main.c
+++ b/src/module/e_mod_main.c
@@ -701,13 +701,11 @@ e_modapi_init(E_Module *m)
701 701
702 backend = emix_config_backend_get(); 702 backend = emix_config_backend_get();
703 if (!backend) 703 if (!backend)
704 { 704 goto err;
705 emix_config_shutdown(); 705
706 emix_shutdown(); 706 if (emix_backend_set(backend) == EINA_FALSE)
707 return NULL; 707 goto err;
708 }
709 708
710 emix_backend_set(backend);
711 if (!mixer_context) 709 if (!mixer_context)
712 { 710 {
713 mixer_context = E_NEW(Context, 1); 711 mixer_context = E_NEW(Context, 1);
@@ -742,6 +740,11 @@ e_modapi_init(E_Module *m)
742 _actions_register(); 740 _actions_register();
743 741
744 return m; 742 return m;
743
744err:
745 emix_config_shutdown();
746 emix_shutdown();
747 return NULL;
745} 748}
746 749
747EAPI int 750EAPI int