summaryrefslogtreecommitdiff
path: root/src/lib/emix.h
blob: ec91e4043c2ab882ab9f7315c206f2fd2ae6aae5 (plain) (blame)
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
#ifndef EMIX_H
#define EMIX_H

#include <Eina.h>
#include <Evas.h>

#ifdef EAPI
#undef EAPI
#endif

#ifdef __GNUC__
# if __GNUC__ >= 4
#  define EAPI __attribute__ ((visibility("default")))
# else
#  define EAPI
# endif
#else
# define EAPI
#endif


#define EMIX_VOLUME_MAX 100

enum Emix_Event {
   EMIX_READY_EVENT = 0,
   EMIX_DISCONNECTED_EVENT,
   EMIX_SINK_ADDED_EVENT,
   EMIX_SINK_REMOVED_EVENT,
   EMIX_SINK_CHANGED_EVENT,
   EMIX_SINK_INPUT_ADDED_EVENT,
   EMIX_SINK_INPUT_REMOVED_EVENT,
   EMIX_SINK_INPUT_CHANGED_EVENT,
   EMIX_SOURCE_ADDED_EVENT,
   EMIX_SOURCE_REMOVED_EVENT,
   EMIX_SOURCE_CHANGED_EVENT
};

typedef struct _Emix_Volume {
   unsigned int channel_count;
   // the index of the field is the id of the channel, the value the volume
   int *volumes;
} Emix_Volume;

typedef struct _Emix_Port {
   Eina_Bool active;
   Eina_Bool available;
   const char *name;
   const char *description;
} Emix_Port;

typedef struct _Emix_Sink {
   const char *name;
   Emix_Volume volume;
   Eina_Bool mute;
   Eina_List *ports;
} Emix_Sink;

typedef struct _Emix_Sink_Input {
   const char *name;
   Emix_Volume volume;
   Eina_Bool mute;
   Emix_Sink *sink;
} Emix_Sink_Input;

typedef struct _Emix_Source {
   const char *name;
   Emix_Volume volume;
   Eina_Bool mute;
} Emix_Source;

typedef void (*Emix_Event_Cb)(void *data, enum Emix_Event event,
                              void *event_info);

typedef struct _Emix_Backend {
   Eina_Bool             (*ebackend_init)(Emix_Event_Cb cb, const void *data);
   void                  (*ebackend_shutdown)(void);

   const Eina_List*      (*ebackend_sinks_get)(void);
   Eina_Bool             (*ebackend_sink_default_support)(void);
   const Emix_Sink*      (*ebackend_sink_default_get)(void);
   void                  (*ebackend_sink_default_set)(Emix_Sink *sink);
   void                  (*ebackend_sink_mute_set)(Emix_Sink *sink,
                                                   Eina_Bool mute);
   void                  (*ebackend_sink_volume_set)(Emix_Sink *sink,
                                                     Emix_Volume volume);
   Eina_Bool             (*ebackend_sink_port_set)(Emix_Sink *sink,
                                                   const Emix_Port *port);
   Eina_Bool             (*ebackend_sink_change_support)(void);

   const Eina_List*      (*ebackend_sink_inputs_get)(void);
   void                  (*ebackend_sink_input_mute_set)(
                                        Emix_Sink_Input *input, Eina_Bool mute);
   void                  (*ebackend_sink_input_volume_set)(
                                    Emix_Sink_Input *input, Emix_Volume volume);
   void                  (*ebackend_sink_input_sink_change)(
                                       Emix_Sink_Input *input, Emix_Sink *sink);

   const Eina_List*      (*ebackend_sources_get)(void);
   void                  (*ebackend_source_mute_set)(Emix_Source *source,
                                                     Eina_Bool bool);
   void                  (*ebackend_source_volume_set)(Emix_Source *source,
                                                       Emix_Volume volume);

   Evas_Object*          (*ebackend_advanced_options_add)(Evas_Object *parent);
} Emix_Backend;


EAPI Eina_Bool           emix_init(void);
EAPI void                emix_shutdown(void);
EAPI const Eina_List*    emix_backends_available(void);
EAPI Eina_Bool           emix_backend_set(const char *backend);

EAPI Eina_Bool           emix_event_callback_add(Emix_Event_Cb cb,
                                                 const void *data);
EAPI Eina_Bool           emix_event_callback_del(Emix_Event_Cb cb);

EAPI const Eina_List*    emix_sinks_get(void);
EAPI Eina_Bool           emix_sink_default_support(void);
EAPI const Emix_Sink*    emix_sink_default_get(void);
EAPI Eina_Bool           emix_sink_port_set(Emix_Sink *sink, Emix_Port *port);
EAPI void                emix_sink_default_set(Emix_Sink *sink);
EAPI void                emix_sink_mute_set(Emix_Sink *sink, Eina_Bool mute);
EAPI void                emix_sink_volume_set(Emix_Sink *sink,
                                              Emix_Volume volume);
EAPI Eina_Bool           emix_sink_change_support(void);

EAPI const Eina_List*    emix_sink_inputs_get(void);
EAPI void                emix_sink_input_mute_set(Emix_Sink_Input *input,
                                                  Eina_Bool mute);
EAPI void                emix_sink_input_volume_set(Emix_Sink_Input *input,
                                                    Emix_Volume volume);
EAPI void                emix_sink_input_sink_change(Emix_Sink_Input *input,
                                                     Emix_Sink *sink);

EAPI const Eina_List*    emix_sources_get(void);
EAPI void                emix_source_mute_set(Emix_Source *source,
                                                  Eina_Bool mute);
EAPI void                emix_source_volume_set(Emix_Source *source,
                                                Emix_Volume volume);

EAPI Evas_Object*        emix_advanced_options_add(Evas_Object *parent);

#endif  /* EMIX_H */