root / audio / audio.h @ c0fe3827
History | View | Annotate | Download (3.9 kB)
1 |
/*
|
---|---|
2 |
* QEMU Audio subsystem header
|
3 |
*
|
4 |
* Copyright (c) 2003-2005 Vassili Karpov (malc)
|
5 |
*
|
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 |
|
27 |
#include "sys-queue.h" |
28 |
|
29 |
typedef void (*audio_callback_fn_t) (void *opaque, int avail); |
30 |
|
31 |
typedef enum { |
32 |
AUD_FMT_U8, |
33 |
AUD_FMT_S8, |
34 |
AUD_FMT_U16, |
35 |
AUD_FMT_S16 |
36 |
} audfmt_e; |
37 |
|
38 |
typedef struct { |
39 |
int freq;
|
40 |
int nchannels;
|
41 |
audfmt_e fmt; |
42 |
} audsettings_t; |
43 |
|
44 |
typedef struct AudioState AudioState; |
45 |
typedef struct SWVoiceOut SWVoiceOut; |
46 |
typedef struct SWVoiceIn SWVoiceIn; |
47 |
|
48 |
typedef struct QEMUSoundCard { |
49 |
AudioState *audio; |
50 |
char *name;
|
51 |
LIST_ENTRY (QEMUSoundCard) entries; |
52 |
} QEMUSoundCard; |
53 |
|
54 |
typedef struct QEMUAudioTimeStamp { |
55 |
uint64_t old_ts; |
56 |
} QEMUAudioTimeStamp; |
57 |
|
58 |
void AUD_vlog (const char *cap, const char *fmt, va_list ap); |
59 |
void AUD_log (const char *cap, const char *fmt, ...) |
60 |
#ifdef __GNUC__
|
61 |
__attribute__ ((__format__ (__printf__, 2, 3))) |
62 |
#endif
|
63 |
; |
64 |
|
65 |
AudioState *AUD_init (void);
|
66 |
void AUD_help (void); |
67 |
void AUD_register_card (AudioState *s, const char *name, QEMUSoundCard *card); |
68 |
void AUD_remove_card (QEMUSoundCard *card);
|
69 |
|
70 |
SWVoiceOut *AUD_open_out ( |
71 |
QEMUSoundCard *card, |
72 |
SWVoiceOut *sw, |
73 |
const char *name, |
74 |
void *callback_opaque,
|
75 |
audio_callback_fn_t callback_fn, |
76 |
audsettings_t *settings |
77 |
); |
78 |
|
79 |
void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
|
80 |
int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size); |
81 |
int AUD_get_buffer_size_out (SWVoiceOut *sw);
|
82 |
void AUD_set_active_out (SWVoiceOut *sw, int on); |
83 |
int AUD_is_active_out (SWVoiceOut *sw);
|
84 |
|
85 |
void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
|
86 |
uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts); |
87 |
|
88 |
SWVoiceIn *AUD_open_in ( |
89 |
QEMUSoundCard *card, |
90 |
SWVoiceIn *sw, |
91 |
const char *name, |
92 |
void *callback_opaque,
|
93 |
audio_callback_fn_t callback_fn, |
94 |
audsettings_t *settings |
95 |
); |
96 |
|
97 |
void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
|
98 |
int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size); |
99 |
void AUD_set_active_in (SWVoiceIn *sw, int on); |
100 |
int AUD_is_active_in (SWVoiceIn *sw);
|
101 |
|
102 |
void AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
|
103 |
uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts); |
104 |
|
105 |
static inline void *advance (void *p, int incr) |
106 |
{ |
107 |
uint8_t *d = p; |
108 |
return (d + incr);
|
109 |
} |
110 |
|
111 |
uint32_t popcount (uint32_t u); |
112 |
inline uint32_t lsbindex (uint32_t u);
|
113 |
|
114 |
#ifdef __GNUC__
|
115 |
#define audio_MIN(a, b) ( __extension__ ({ \
|
116 |
__typeof (a) ta = a; \ |
117 |
__typeof (b) tb = b; \ |
118 |
((ta)>(tb)?(tb):(ta)); \ |
119 |
})) |
120 |
|
121 |
#define audio_MAX(a, b) ( __extension__ ({ \
|
122 |
__typeof (a) ta = a; \ |
123 |
__typeof (b) tb = b; \ |
124 |
((ta)<(tb)?(tb):(ta)); \ |
125 |
})) |
126 |
#else
|
127 |
#define audio_MIN(a, b) ((a)>(b)?(b):(a))
|
128 |
#define audio_MAX(a, b) ((a)<(b)?(b):(a))
|
129 |
#endif
|
130 |
|
131 |
#endif /* audio.h */ |