00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __EKG_AUDIO_H
00021 #define __EKG_AUDIO_H
00022
00023 #include "dynstuff.h"
00024 #include "plugins.h"
00025
00026 #ifdef __cplusplus
00027 extern "C" {
00028 #endif
00029
00030 typedef enum { AUDIO_CONTROL_INIT = 0, AUDIO_CONTROL_SET, AUDIO_CONTROL_GET, AUDIO_CONTROL_DEINIT, AUDIO_CONTROL_HELP }
00031 audio_control_t;
00032 typedef enum { AUDIO_READ = 0, AUDIO_WRITE, AUDIO_RDWR, }
00033 audio_way_t;
00034 typedef enum { CODEC_CODE = 0, CODEC_DECODE, }
00035 codec_way_t;
00036
00037 #define WATCHER_AUDIO(x) int x(int type, int fd, string_t buf, void *data)
00038 typedef WATCHER_AUDIO(audio_handler_func_t);
00039
00040 #define __AINIT(a, way, args...) a ? a->control_handler(AUDIO_CONTROL_SET, way, NULL, args, NULL) : NULL
00041 #define __CINIT(c, args...) c ? c->control_handler(AUDIO_CONTROL_SET, AUDIO_RDWR, NULL, args, NULL) : NULL
00042
00043 #define __AINIT_F(name, way, args...) __AINIT((audio_find(name)), way, args)
00044 #define __CINIT_F(name, args...) __CINIT((codec_find(name)), args)
00045
00046
00047 #define CODEC_RECODE(x) int x(int type, string_t input, string_t output, void *data)
00048 #define AUDIO_CONTROL(x) audio_io_t *x(audio_control_t type, audio_way_t way, audio_io_t *aio, ...)
00049 #define CODEC_CONTROL(x) audio_codec_t *x(audio_control_t type, audio_way_t way, audio_codec_t *aco, ...)
00050
00051 #define AUDIO_DEFINE(x)\
00052 extern AUDIO_CONTROL(x##_audio_control);\
00053 extern WATCHER_AUDIO(x##_audio_read); \
00054 extern WATCHER_AUDIO(x##_audio_write); \
00055 audio_t x##_audio = { \
00056 .name = #x, \
00057 .control_handler= (void*) x##_audio_control, \
00058 .read_handler = x##_audio_read, \
00059 .write_handler = x##_audio_write, \
00060 }
00061
00062 #define CODEC_DEFINE(x)\
00063 extern CODEC_CONTROL(x##_codec_control);\
00064 extern CODEC_RECODE(x##_codec_code); \
00065 extern CODEC_RECODE(x##_codec_decode); \
00066 codec_t x##_codec = { \
00067 .name = #x, \
00068 .control_handler= (void*) x##_codec_control, \
00069 .code_handler = x##_codec_code, \
00070 .decode_handler = x##_codec_decode, \
00071 }
00072
00073 typedef struct audio {
00074 struct audio *next;
00075
00076 char *name;
00077
00078 void *(*control_handler)(audio_control_t, audio_way_t, void *, ...);
00079 audio_handler_func_t *read_handler;
00080 audio_handler_func_t *write_handler;
00081
00082 void *priv_data;
00083 } audio_t;
00084
00085 typedef struct {
00086 audio_t *a;
00087 int fd;
00088 unsigned int outb;
00089 string_t buffer;
00090 void *priv_data;
00091 } audio_io_t;
00092
00093 typedef struct codec {
00094 struct codec *next;
00095
00096 char *name;
00097
00098 void *(*control_handler)(audio_control_t, audio_way_t, void *, ...);
00099
00100
00101
00102 int (*code_handler)(int, string_t, string_t, void *);
00103 int (*decode_handler)(int, string_t, string_t, void *);
00104 void *priv_data;
00105 } codec_t;
00106
00107 typedef struct {
00108 codec_t *c;
00109 codec_way_t way;
00110
00111 void *priv_data;
00112 } audio_codec_t;
00113
00114 typedef struct stream {
00115 struct stream *next;
00116
00117 char *stream_name;
00118 audio_io_t *input;
00119 audio_codec_t *codec;
00120 audio_io_t *output;
00121
00122 void *priv_data;
00123 } stream_t;
00124
00125 int stream_create(char *name, audio_io_t *in, audio_codec_t *co, audio_io_t *out);
00126
00127 int audio_register(audio_t *audio);
00128 audio_t *audio_find(const char *name);
00129 void audio_unregister(audio_t *audio);
00130
00131 int codec_register(codec_t *codec);
00132 codec_t *codec_find(const char *name);
00133 void codec_unregister(codec_t *codec);
00134
00135 int audio_initialize();
00136 int audio_deinitialize();
00137
00138 #ifdef __cplusplus
00139 }
00140 #endif
00141
00142 #endif
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152