summaryrefslogtreecommitdiff
path: root/src/lib/emix.c
blob: 4c45ca45cdd7e7bdf410e4b7ef24aaf767b230bd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#include "config.h"
#include "emix.h"

#include <common.h>

typedef struct Context {
   /* Valid backends *.so */
   Eina_Array *backends;

   Emix_Backend *loaded;
} Context;

static int _init_count = 0;
static Context *ctx = NULL;

int EMIX_SINK_EVENT = 0;
int EMIX_SINK_INPUT_EVENT = 0;
int EMIX_SOURCE_EVENT = 0;
int EMIX_DISCONNECTED_EVENT = 0;

static Eina_Bool
_backend_get_cb(Eina_Module *module, void *data)
{
   Emix_Backend* (*emix_backend_get)(void);

   if (eina_module_load(module) == EINA_FALSE)
     {
        ERR("%s is not a module", eina_module_file_get(module));
        return EINA_FALSE;
     }

   emix_backend_get = eina_module_symbol_get(module, "emix_backend_get");
   if (!emix_backend_get)
     {
        ERR("%s is not a valid module", eina_module_file_get(module));
        goto err;
     }

   return EINA_TRUE;

 err:
   eina_module_unload(module);
   return EINA_FALSE;
}

void
emix_init(void)
{
   if (_init_count > 0)
      goto end;

   ctx = calloc(1, sizeof(Context));
   if (!ctx)
     {
        ERR("Could not create Epulse Context");
        return 0;
     }

   ctx->backends = eina_module_list_get(ctx->backends,
                                        BACKENDS_DIR, EINA_TRUE,
                                        _backend_get_cb, NULL);
   if (ctx->backends == NULL)
     {
        ERR("Could not find any valid backend");
        goto err;
     }

   EMIX_DISCONNECTED_EVENT = ecore_event_type_new();
   EMIX_SINK_EVENT = ecore_event_type_new();
   EMIX_SINK_INPUT_EVENT = ecore_event_type_new();
   EMIX_SOURCE_EVENT = ecore_event_type_new();
  /* init(); */

 end:
   _init_count++;
   return _init_count;
 err:
   free(ctx);
   ctx = NULL;
   return -1;
}

void
emix_shutdown()
{
   if (_init_count == 0)
      return;

   _init_count--;
   if (_init_count > 0)
      return;

   free(ctx);
   ctx = NULL;
   /* shutdown(); */
}

Eina_List*
emix_backends_available(void)
{
   return NULL;
}

void
emix_backend_set(const char *backend)
{
}

const Eina_List*
emix_sinks_get(void)
{
   return NULL;
}

Eina_Bool
emix_sink_default_support(void)
{
   return EINA_FALSE;
}

Emix_Sink*
emix_sink_default_get(void)
{
   return NULL;
}

void
emix_sink_default_set(Emix_Sink *sink)
{
}

void
emix_sink_mute_set(Emix_Sink *sink, Eina_Bool mute)
{
}

void
emix_sink_volume_set(Emix_Sink *sink, Emix_Volume *volume)
{
}

Eina_Bool
emix_sink_change_support(void)
{
   return EINA_FALSE;
}

const Eina_List*
emix_sink_inputs_get(void)
{
   return NULL;
}

void
emix_sink_input_mute_set(Emix_Sink_Input *input, Eina_Bool mute)
{
}

void
emix_sink_input_volume_set(Emix_Sink_Input *input, Emix_Volume *volume)
{
}

void
emix_sink_input_sink_change(Emix_Sink_Input *input, Emix_Sink *sink)
{
}

const Eina_List*
emix_source_get(void)
{
   return NULL;
}

void
emix_source_mute_set(Emix_Source *source, Eina_Bool mute)
{
}

void
emix_source_volume_set(Emix_Source *source, Emix_Volume *volume)
{
}