|
|
1.1 root 1: /*
2: * QEMU Audio subsystem header
1.1.1.2 root 3: *
4: * Copyright (c) 2003-2005 Vassili Karpov (malc)
5: *
1.1 root 6: * Permission is hereby granted, free of charge, to any person obtaining a copy
7: * of this software and associated documentation files (the "Software"), to deal
8: * in the Software without restriction, including without limitation the rights
9: * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10: * copies of the Software, and to permit persons to whom the Software is
11: * furnished to do so, subject to the following conditions:
12: *
13: * The above copyright notice and this permission notice shall be included in
14: * all copies or substantial portions of the Software.
15: *
16: * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17: * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18: * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19: * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20: * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21: * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22: * THE SOFTWARE.
23: */
24: #ifndef QEMU_AUDIO_H
25: #define QEMU_AUDIO_H
26:
1.1.1.4 root 27: #include "config-host.h"
1.1.1.7 root 28: #include "qemu-queue.h"
1.1.1.2 root 29:
1.1.1.7 root 30: typedef void (*audio_callback_fn) (void *opaque, int avail);
1.1 root 31:
32: typedef enum {
1.1.1.2 root 33: AUD_FMT_U8,
34: AUD_FMT_S8,
35: AUD_FMT_U16,
1.1.1.4 root 36: AUD_FMT_S16,
37: AUD_FMT_U32,
38: AUD_FMT_S32
1.1 root 39: } audfmt_e;
40:
1.1.1.7 root 41: #ifdef HOST_WORDS_BIGENDIAN
1.1.1.3 root 42: #define AUDIO_HOST_ENDIANNESS 1
43: #else
44: #define AUDIO_HOST_ENDIANNESS 0
45: #endif
46:
1.1.1.5 root 47: struct audsettings {
1.1.1.2 root 48: int freq;
49: int nchannels;
50: audfmt_e fmt;
1.1.1.3 root 51: int endianness;
1.1.1.5 root 52: };
1.1.1.2 root 53:
1.1.1.3 root 54: typedef enum {
55: AUD_CNOTIFY_ENABLE,
56: AUD_CNOTIFY_DISABLE
57: } audcnotification_e;
58:
59: struct audio_capture_ops {
60: void (*notify) (void *opaque, audcnotification_e cmd);
61: void (*capture) (void *opaque, void *buf, int size);
62: void (*destroy) (void *opaque);
63: };
64:
65: struct capture_ops {
66: void (*info) (void *opaque);
67: void (*destroy) (void *opaque);
68: };
69:
70: typedef struct CaptureState {
71: void *opaque;
72: struct capture_ops ops;
1.1.1.7 root 73: QLIST_ENTRY (CaptureState) entries;
1.1.1.3 root 74: } CaptureState;
75:
1.1.1.2 root 76: typedef struct SWVoiceOut SWVoiceOut;
1.1.1.3 root 77: typedef struct CaptureVoiceOut CaptureVoiceOut;
1.1.1.2 root 78: typedef struct SWVoiceIn SWVoiceIn;
79:
80: typedef struct QEMUSoundCard {
81: char *name;
1.1.1.7 root 82: QLIST_ENTRY (QEMUSoundCard) entries;
1.1.1.2 root 83: } QEMUSoundCard;
84:
85: typedef struct QEMUAudioTimeStamp {
86: uint64_t old_ts;
87: } QEMUAudioTimeStamp;
88:
1.1.1.8 ! root 89: void AUD_vlog (const char *cap, const char *fmt, va_list ap) GCC_FMT_ATTR(2, 0);
! 90: void AUD_log (const char *cap, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
1.1.1.2 root 91:
92: void AUD_help (void);
1.1.1.6 root 93: void AUD_register_card (const char *name, QEMUSoundCard *card);
1.1.1.2 root 94: void AUD_remove_card (QEMUSoundCard *card);
1.1.1.3 root 95: CaptureVoiceOut *AUD_add_capture (
1.1.1.5 root 96: struct audsettings *as,
1.1.1.3 root 97: struct audio_capture_ops *ops,
98: void *opaque
99: );
100: void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque);
1.1.1.2 root 101:
102: SWVoiceOut *AUD_open_out (
103: QEMUSoundCard *card,
104: SWVoiceOut *sw,
105: const char *name,
106: void *callback_opaque,
1.1.1.7 root 107: audio_callback_fn callback_fn,
1.1.1.5 root 108: struct audsettings *settings
1.1.1.2 root 109: );
110:
111: void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
112: int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size);
113: int AUD_get_buffer_size_out (SWVoiceOut *sw);
114: void AUD_set_active_out (SWVoiceOut *sw, int on);
115: int AUD_is_active_out (SWVoiceOut *sw);
116:
117: void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
118: uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
119:
1.1.1.5 root 120: void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol);
121: void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol);
122:
1.1.1.2 root 123: SWVoiceIn *AUD_open_in (
124: QEMUSoundCard *card,
125: SWVoiceIn *sw,
126: const char *name,
127: void *callback_opaque,
1.1.1.7 root 128: audio_callback_fn callback_fn,
1.1.1.5 root 129: struct audsettings *settings
1.1.1.2 root 130: );
131:
132: void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
133: int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size);
134: void AUD_set_active_in (SWVoiceIn *sw, int on);
135: int AUD_is_active_in (SWVoiceIn *sw);
1.1 root 136:
1.1.1.2 root 137: void AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
138: uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
1.1 root 139:
140: static inline void *advance (void *p, int incr)
141: {
142: uint8_t *d = p;
143: return (d + incr);
144: }
145:
1.1.1.2 root 146: #ifdef __GNUC__
147: #define audio_MIN(a, b) ( __extension__ ({ \
148: __typeof (a) ta = a; \
149: __typeof (b) tb = b; \
150: ((ta)>(tb)?(tb):(ta)); \
151: }))
152:
153: #define audio_MAX(a, b) ( __extension__ ({ \
154: __typeof (a) ta = a; \
155: __typeof (b) tb = b; \
156: ((ta)<(tb)?(tb):(ta)); \
157: }))
158: #else
1.1 root 159: #define audio_MIN(a, b) ((a)>(b)?(b):(a))
160: #define audio_MAX(a, b) ((a)<(b)?(b):(a))
1.1.1.2 root 161: #endif
1.1 root 162:
1.1.1.5 root 163: int wav_start_capture (CaptureState *s, const char *path, int freq,
164: int bits, int nchannels);
165:
1.1 root 166: #endif /* audio.h */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.