ekg2
 All Struktury Danych Pliki Funkcje Zmienne Definicje typów Wyliczenia Wartości wyliczeń Definicje Grupay Strony
audio.h
Idź do dokumentacji tego pliku.
1 /* $Id$ */
2 
3 /*
4  * (C) Copyright 2003 Wojtek Kaniewski <wojtekka@irc.pl>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License Version 2 as
8  * published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */
19 
20 #ifndef __EKG_AUDIO_H
21 #define __EKG_AUDIO_H
22 
23 #include "dynstuff.h"
24 #include "plugins.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
32 typedef enum { AUDIO_READ = 0, AUDIO_WRITE, AUDIO_RDWR, }
34 typedef enum { CODEC_CODE = 0, CODEC_DECODE, }
36 
37 #define WATCHER_AUDIO(x) int x(int type, int fd, string_t buf, void *data)
39 
40 #define __AINIT(a, way, args...) a ? a->control_handler(AUDIO_CONTROL_SET, way, NULL, args, NULL) : NULL
41 #define __CINIT(c, args...) c ? c->control_handler(AUDIO_CONTROL_SET, AUDIO_RDWR, NULL, args, NULL) : NULL
42 
43 #define __AINIT_F(name, way, args...) __AINIT((audio_find(name)), way, args)
44 #define __CINIT_F(name, args...) __CINIT((codec_find(name)), args)
45 
46 
47 #define CODEC_RECODE(x) int x(int type, string_t input, string_t output, void *data)
48 #define AUDIO_CONTROL(x) audio_io_t *x(audio_control_t type, audio_way_t way, audio_io_t *aio, ...)
49 #define CODEC_CONTROL(x) audio_codec_t *x(audio_control_t type, audio_way_t way, audio_codec_t *aco, ...)
50 
51 #define AUDIO_DEFINE(x)\
52  extern AUDIO_CONTROL(x##_audio_control);\
53  extern WATCHER_AUDIO(x##_audio_read); \
54  extern WATCHER_AUDIO(x##_audio_write); \
55  audio_t x##_audio = { \
56  .name = #x, \
57  .control_handler= (void*) x##_audio_control, \
58  .read_handler = x##_audio_read, \
59  .write_handler = x##_audio_write, \
60  }
61 
62 #define CODEC_DEFINE(x)\
63  extern CODEC_CONTROL(x##_codec_control);\
64  extern CODEC_RECODE(x##_codec_code); \
65  extern CODEC_RECODE(x##_codec_decode); \
66  codec_t x##_codec = { \
67  .name = #x, \
68  .control_handler= (void*) x##_codec_control, \
69  .code_handler = x##_codec_code, \
70  .decode_handler = x##_codec_decode, \
71  }
72 
73 typedef struct audio {
74  struct audio *next;
75 
76  char *name; /* nazwa urzadzenia */
77 
78  void *(*control_handler)(audio_control_t, audio_way_t, void *, ...); /* initing / checking if audio_io_t is correct / deiniting */
81 
82  void *priv_data;
83 } audio_t;
84 
85 typedef struct {
87  int fd;
88  unsigned int outb; /* how many bytes go through handler */
90  void *priv_data;
91 } audio_io_t;
92 
93 typedef struct codec {
94  struct codec *next;
95 
96  char *name; /* nazwa codeca */
97 
98  void *(*control_handler)(audio_control_t, audio_way_t, void *, ...); /* initing / checking if audio_codec_t is correct / deiniting */
99 
100  /* IN: int type, string_t input, string_t output, void *priv_data
101  * OUT: how many bytes he code/decode */
102  int (*code_handler)(int, string_t, string_t, void *);
103  int (*decode_handler)(int, string_t, string_t, void *);
104  void *priv_data;
105 } codec_t;
106 
107 typedef struct {
108  codec_t *c; /* codec_t * */
109  codec_way_t way; /* CODEC_CODE CODEC_DECODE */
110 
111  void *priv_data;
112 } audio_codec_t;
113 
114 typedef struct stream {
115  struct stream *next;
116 
117  char *stream_name;
121 
122  void *priv_data;
123 } stream_t;
124 
125 int stream_create(char *name, audio_io_t *in, audio_codec_t *co, audio_io_t *out);
126 
128 audio_t *audio_find(const char *name);
130 
132 codec_t *codec_find(const char *name);
134 
135 int audio_initialize();
136 int audio_deinitialize();
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* __EKG_AUDIO_H */
143 
144 
145 /*
146  * Local Variables:
147  * mode: c
148  * c-file-style: "k&r"
149  * c-basic-offset: 8
150  * indent-tabs-mode: t
151  * End:
152  */