summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlavio Ceolin <flavio.ceolin@gmail.com>2014-06-15 01:00:59 -0300
committerFlavio Ceolin <flavio.ceolin@gmail.com>2014-08-14 23:33:17 -0300
commit968701784f460c7bbe62ff1ed458d381c4a466a4 (patch)
treeecd90fc7c2aee781d848f7e2d9735898f561e9bc
parent4bcad551f64006f54684c789f05775166b724414 (diff)
Making the backend interface simpler and more realistic
Added some missing functions and removed functions that could be accessed directly from structures. Added some basic code over structures and the module part.
-rw-r--r--configure.ac1
-rw-r--r--src/lib/emix.c143
-rw-r--r--src/lib/emix.h121
3 files changed, 155 insertions, 110 deletions
diff --git a/configure.ac b/configure.ac
index 60ab0a5..edb739c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -60,6 +60,7 @@ AC_ARG_ENABLE(homedir-install,
60) 60)
61 61
62AC_SUBST(pkgdir) 62AC_SUBST(pkgdir)
63AC_DEFINE_UNQUOTED(BACKENDS_DIR, "$prefix/lib/emix/backends", "Backends dir)
63 64
64# Checks for header files. 65# Checks for header files.
65 66
diff --git a/src/lib/emix.c b/src/lib/emix.c
index 2b6e518..4c45ca4 100644
--- a/src/lib/emix.c
+++ b/src/lib/emix.c
@@ -1,28 +1,47 @@
1#include "config.h"
1#include "emix.h" 2#include "emix.h"
2 3
3#include <common.h> 4#include <common.h>
4 5
5typedef struct Context { 6typedef struct Context {
6 Eina_List *backends_available; 7 /* Valid backends *.so */
8 Eina_Array *backends;
9
7 Emix_Backend *loaded; 10 Emix_Backend *loaded;
8} Context; 11} Context;
9 12
10static int _init_count = 0; 13static int _init_count = 0;
11static Context *ctx = NULL; 14static Context *ctx = NULL;
12 15
13int EMIX_SINK_ADDED = 0; 16int EMIX_SINK_EVENT = 0;
14int EMIX_SINK_CHANGED = 0; 17int EMIX_SINK_INPUT_EVENT = 0;
15int EMIX_SINK_DEFAULT = 0; 18int EMIX_SOURCE_EVENT = 0;
16int EMIX_SINK_REMOVED = 0; 19int EMIX_DISCONNECTED_EVENT = 0;
17int EMIX_SINK_INPUT_ADDED = 0; 20
18int EMIX_SINK_INPUT_CHANGED = 0; 21static Eina_Bool
19int EMIX_SINK_INPUT_REMOVED = 0; 22_backend_get_cb(Eina_Module *module, void *data)
20int EMIX_SOURCE_ADDED = 0; 23{
21int EMIX_SOURCE_CHANGED = 0; 24 Emix_Backend* (*emix_backend_get)(void);
22int EMIX_SOURCE_REMOVED = 0; 25
23int EMIX_SOURCE_INPUT_ADDED = 0; 26 if (eina_module_load(module) == EINA_FALSE)
24int EMIX_SOURCE_INPUT_REMOVED = 0; 27 {
25int EMIX_DISCONNECTED = 0; 28 ERR("%s is not a module", eina_module_file_get(module));
29 return EINA_FALSE;
30 }
31
32 emix_backend_get = eina_module_symbol_get(module, "emix_backend_get");
33 if (!emix_backend_get)
34 {
35 ERR("%s is not a valid module", eina_module_file_get(module));
36 goto err;
37 }
38
39 return EINA_TRUE;
40
41 err:
42 eina_module_unload(module);
43 return EINA_FALSE;
44}
26 45
27void 46void
28emix_init(void) 47emix_init(void)
@@ -37,24 +56,28 @@ emix_init(void)
37 return 0; 56 return 0;
38 } 57 }
39 58
40 EMIX_DISCONNECTED = ecore_event_type_new(); 59 ctx->backends = eina_module_list_get(ctx->backends,
41 EMIX_SINK_ADDED = ecore_event_type_new(); 60 BACKENDS_DIR, EINA_TRUE,
42 EMIX_SINK_CHANGED = ecore_event_type_new(); 61 _backend_get_cb, NULL);
43 EMIX_SINK_DEFAULT = ecore_event_type_new(); 62 if (ctx->backends == NULL)
44 EMIX_SINK_REMOVED = ecore_event_type_new(); 63 {
45 EMIX_SINK_INPUT_ADDED = ecore_event_type_new(); 64 ERR("Could not find any valid backend");
46 EMIX_SINK_INPUT_CHANGED = ecore_event_type_new(); 65 goto err;
47 EMIX_SINK_INPUT_REMOVED = ecore_event_type_new(); 66 }
48 EMIX_SOURCE_ADDED = ecore_event_type_new(); 67
49 EMIX_SOURCE_CHANGED = ecore_event_type_new(); 68 EMIX_DISCONNECTED_EVENT = ecore_event_type_new();
50 EMIX_SOURCE_REMOVED = ecore_event_type_new(); 69 EMIX_SINK_EVENT = ecore_event_type_new();
51 EMIX_SOURCE_INPUT_ADDED = ecore_event_type_new(); 70 EMIX_SINK_INPUT_EVENT = ecore_event_type_new();
52 EMIX_SOURCE_INPUT_REMOVED = ecore_event_type_new(); 71 EMIX_SOURCE_EVENT = ecore_event_type_new();
53 /* init(); */ 72 /* init(); */
54 73
55 end: 74 end:
56 _init_count++; 75 _init_count++;
57 return _init_count; 76 return _init_count;
77 err:
78 free(ctx);
79 ctx = NULL;
80 return -1;
58} 81}
59 82
60void 83void
@@ -72,73 +95,89 @@ emix_shutdown()
72 /* shutdown(); */ 95 /* shutdown(); */
73} 96}
74 97
75const Emix_Volume * 98Eina_List*
76emix_volume_get(Emix_Sink* sink) 99emix_backends_available(void)
77{ 100{
78 return NULL; 101 return NULL;
79} 102}
80 103
81void 104void
82emix_volume_set(Emix_Sink* sink, Emix_Volume* volume) 105emix_backend_set(const char *backend)
83{ 106{
84} 107}
85 108
86Eina_Bool 109const Eina_List*
87emix_mute_get(Emix_Sink *sink) 110emix_sinks_get(void)
88{ 111{
89 return EINA_TRUE; 112 return NULL;
90} 113}
91 114
92void 115Eina_Bool
93emix_mute_set(Emix_Sink *sink, Eina_Bool mute) 116emix_sink_default_support(void)
94{ 117{
118 return EINA_FALSE;
95} 119}
96 120
97Emix_Sink* 121Emix_Sink*
98emix_sink_default_get(void) 122emix_sink_default_get(void)
99{ 123{
100 return NULL; //TODO load this from eet 124 return NULL;
101} 125}
102 126
103void 127void
104emix_sink_default_set(Emix_Sink* sink) 128emix_sink_default_set(Emix_Sink *sink)
105{ 129{
106 return; //TODO save this in eet
107} 130}
108 131
109Emix_Source* 132void
110emix_source_default_get(void) 133emix_sink_mute_set(Emix_Sink *sink, Eina_Bool mute)
111{ 134{
112 return NULL; //TODO load this from eet
113} 135}
114 136
115void 137void
116emix_source_default_set(Emix_Source* source) 138emix_sink_volume_set(Emix_Sink *sink, Emix_Volume *volume)
117{ 139{
118 return; //TODO save this in eet
119} 140}
120 141
121Eina_Bool 142Eina_Bool
122emix_change_sink_support(void) 143emix_sink_change_support(void)
123{ 144{
124 return EINA_FALSE; 145 return EINA_FALSE;
125} 146}
126 147
148const Eina_List*
149emix_sink_inputs_get(void)
150{
151 return NULL;
152}
153
127void 154void
128emix_change_sink(Emix_Playback *playback, Emix_Sink *sink) 155emix_sink_input_mute_set(Emix_Sink_Input *input, Eina_Bool mute)
129{ 156{
130 /* ebackend_change_sink(playback, sink); */
131} 157}
132 158
133Eina_Bool 159void
134emix_change_source_support(void) 160emix_sink_input_volume_set(Emix_Sink_Input *input, Emix_Volume *volume)
161{
162}
163
164void
165emix_sink_input_sink_change(Emix_Sink_Input *input, Emix_Sink *sink)
166{
167}
168
169const Eina_List*
170emix_source_get(void)
171{
172 return NULL;
173}
174
175void
176emix_source_mute_set(Emix_Source *source, Eina_Bool mute)
135{ 177{
136 /* return ebackend_change_source_support(); */
137 return EINA_FALSE;
138} 178}
139 179
140void 180void
141emix_change_source(Emix_Playback *playback, Emix_Source *source) 181emix_source_volume_set(Emix_Source *source, Emix_Volume *volume)
142{ 182{
143 /* ebackend_change_source(playback, source); */
144} 183}
diff --git a/src/lib/emix.h b/src/lib/emix.h
index 0a8d1ee..6bbcdac 100644
--- a/src/lib/emix.h
+++ b/src/lib/emix.h
@@ -3,94 +3,99 @@
3 3
4#include <Eina.h> 4#include <Eina.h>
5 5
6EAPI extern int EMIX_DISCONNECTED; 6EAPI extern int EMIX_DISCONNECTED_EVENT;
7EAPI extern int EMIX_SINK_ADDED; 7EAPI extern int EMIX_SINK_EVENT;
8EAPI extern int EMIX_SINK_CHANGED; 8EAPI extern int EMIX_SINK_INPUT_EVENT;
9EAPI extern int EMIX_SINK_DEFAULT; 9EAPI extern int EMIX_SOURCE_EVENT;
10EAPI extern int EMIX_SINK_REMOVED;
11EAPI extern int EMIX_SINK_INPUT_ADDED;
12EAPI extern int EMIX_SINK_INPUT_CHANGED;
13EAPI extern int EMIX_SINK_INPUT_REMOVED;
14EAPI extern int EMIX_SOURCE_ADDED;
15EAPI extern int EMIX_SOURCE_CHANGED;
16EAPI extern int EMIX_SOURCE_REMOVED;
17EAPI extern int EMIX_SOURCE_INPUT_ADDED;
18EAPI extern int EMIX_SOURCE_INPUT_REMOVED;
19 10
20typedef struct _Emix_Volume { 11typedef struct _Emix_Volume {
21 int channel_count; 12 int channel_count;
22 // the index of the field is the id of the channel, the value the volume 13 // the index of the field is the id of the channel, the value the volume
23 int* volumes; 14 int *volumes;
24} Emix_Volume; 15} Emix_Volume;
25 16
26typedef struct _Emix_Sink { 17typedef struct _Emix_Sink {
27 const char *name; 18 const char *name;
28 void *b_data; 19 Emix_Volume *volume;
20 Eina_Bool mute;
29} Emix_Sink; 21} Emix_Sink;
30 22
31typedef struct _Emix_Playback { 23typedef struct _Emix_Sink_Input {
32 const char *name; 24 const char *name;
33 void *b_data; 25 Emix_Volume *volume;
34} Emix_Playback; 26 Eina_Bool mute;
27 Emix_Sink *sink;
28} Emix_Sink_Input;
35 29
36typedef struct _Emix_Source { 30typedef struct _Emix_Source {
37 void *b_data;
38 const char *name; 31 const char *name;
32 Emix_Volume *volume;
33 Eina_Bool mute;
39} Emix_Source; 34} Emix_Source;
40 35
41typedef struct _Emix_Source_Input { 36typedef enum _Emix_Event_Type {
42 const char *name; 37 EMIX_EVENT_ADDED,
43 void *b_data; 38 EMIX_EVENT_CHANGED,
44} Emix_Source_Input; 39 EMIX_EVENT_REMOVED
40} Emix_Event_Type;
45 41
46 42
47typedef struct _Emix_Backend { 43typedef struct _Emix_Backend {
48 void (*ebackend_init)(void); 44 void (*ebackend_init)(void);
49 void (*ebackend_shutdown)(void); 45 void (*ebackend_shutdown)(void);
50 46
51 const Emix_Volume* (*ebackend_volume_get)(Emix_Sink* sink); 47 const Eina_List* (*ebackend_sinks_get)(void);
52 void (*ebackend_volume_set)(Emix_Sink* sink,
53 Emix_Volume volume);
54 Eina_Bool (*ebackend_mute_get)(Emix_Sink *sink);
55 void (*ebackend_mute_set)(Emix_Sink *sink, Eina_Bool bool);
56
57 Eina_Bool (*ebackend_sink_default_support)(void); 48 Eina_Bool (*ebackend_sink_default_support)(void);
58 const Emix_Sink* (*ebackend_sink_default_get)(void); 49 const Emix_Sink* (*ebackend_sink_default_get)(void);
59 void (*ebackend_sink_default_set)(Emix_Sink* sink); 50 void (*ebackend_sink_default_set)(Emix_Sink *sink);
60 51 void (*ebackend_sink_mute_set)(Emix_Sink *sink,
61 Eina_Bool (*ebackend_source_default_support)(void); 52 Eina_Bool mute);
62 void (*ebackend_source_default_set)(Emix_Source* source); 53 void (*ebackend_sink_volume_set)(Emix_Sink *sink,
63 Eina_Bool (*ebackend_change_sink_support)(void); 54 Emix_Volume volume);
64 void (*ebackend_change_sink)(Emix_Playback *playback, 55 Eina_Bool (*ebackend_sink_change_support)(void);
65 Emix_Sink *sink); 56
66 57 const Eina_List* (*ebackend_sink_inputs_get)(void);
67 Eina_Bool (*ebackend_change_source_support)(void); 58 void (*ebackend_sink_input_mute_set)(
68 void (*ebackend_change_source)(Emix_Playback *playback, 59 Emix_Sink_Input *input, Eina_Bool mute);
69 Emix_Source *source); 60 void (*ebackend_sink_input_volume_set)(
61 Emix_Sink_Input *input, Emix_Volume volume);
62 void (*ebackend_sink_input_sink_change)(
63 Emix_Sink_Input *input, Emix_Sink *sink);
64
65 const Eina_List* (*ebackend_sources_get)(void);
66 void (*ebackend_source_mute_set)(Emix_Source *source,
67 Eina_Bool bool);
68 void (*ebackend_source_volume_set)(Emix_Source *source,
69 Emix_Volume volume);
70} Emix_Backend; 70} Emix_Backend;
71 71
72
72EAPI void emix_init(void); 73EAPI void emix_init(void);
73EAPI void emix_shutdown(void); 74EAPI void emix_shutdown(void);
75EAPI Eina_List* emix_backends_available(void);
76EAPI void emix_backend_set(const char *backend);
74 77
75EAPI const Emix_Volume* emix_volume_get(Emix_Sink* sink); 78EAPI const Eina_List* emix_sinks_get(void);
76EAPI void emix_volume_set(Emix_Sink* sink, Emix_Volume* volume);
77EAPI Eina_Bool emix_mute_get(Emix_Sink *sink);
78EAPI void emix_mute_set(Emix_Sink *sink, Eina_Bool);
79
80EAPI Eina_Bool emix_sink_default_support(void); 79EAPI Eina_Bool emix_sink_default_support(void);
81EAPI Emix_Sink* emix_sink_default_get(void); 80EAPI Emix_Sink* emix_sink_default_get(void);
82EAPI void emix_sink_default_set(Emix_Sink* sink); 81EAPI void emix_sink_default_set(Emix_Sink *sink);
83 82EAPI void emix_sink_mute_set(Emix_Sink *sink, Eina_Bool);
84EAPI Eina_Bool emix_source_default_support(void); 83EAPI void emix_sink_volume_set(Emix_Sink *sink,
85EAPI Emix_Source* emix_source_default_get(void); 84 Emix_Volume *volume);
86EAPI void emix_source_default_set(Emix_Source* source); 85EAPI Eina_Bool emix_sink_change_support(void);
87 86
88EAPI Eina_Bool emix_change_sink_support(void); 87EAPI const Eina_List* emix_sink_inputs_get(void);
89EAPI void emix_change_sink(Emix_Playback *playback, 88EAPI void emix_sink_input_mute_set(Emix_Sink_Input *input,
90 Emix_Sink *sink); 89 Eina_Bool mute);
91 90EAPI void emix_sink_input_volume_set(Emix_Sink_Input *input,
92EAPI Eina_Bool emix_change_source_support(void); 91 Emix_Volume *volume);
93EAPI void emix_change_source(Emix_Playback *playback, 92EAPI void emix_sink_input_sink_change(Emix_Sink_Input *input,
94 Emix_Source *source); 93 Emix_Sink *sink);
94
95EAPI const Eina_List* emix_source_get(void);
96EAPI void emix_source_mute_set(Emix_Source *source,
97 Eina_Bool mute);
98EAPI void emix_source_volume_set(Emix_Source *source,
99 Emix_Volume *volume);
95 100
96#endif /* EMIX_H */ 101#endif /* EMIX_H */