2 * QEMU Audio subsystem header
4 * Copyright (c) 2003-2005 Vassili Karpov (malc)
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:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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
27 #include "qemu/queue.h"
29 typedef void (*audio_callback_fn
) (void *opaque
, int avail
);
40 #ifdef HOST_WORDS_BIGENDIAN
41 #define AUDIO_HOST_ENDIANNESS 1
43 #define AUDIO_HOST_ENDIANNESS 0
58 struct audio_capture_ops
{
59 void (*notify
) (void *opaque
, audcnotification_e cmd
);
60 void (*capture
) (void *opaque
, void *buf
, int size
);
61 void (*destroy
) (void *opaque
);
65 void (*info
) (void *opaque
);
66 void (*destroy
) (void *opaque
);
69 typedef struct CaptureState
{
71 struct capture_ops ops
;
72 QLIST_ENTRY (CaptureState
) entries
;
75 typedef struct SWVoiceOut SWVoiceOut
;
76 typedef struct CaptureVoiceOut CaptureVoiceOut
;
77 typedef struct SWVoiceIn SWVoiceIn
;
79 typedef struct QEMUSoundCard
{
81 QLIST_ENTRY (QEMUSoundCard
) entries
;
84 typedef struct QEMUAudioTimeStamp
{
88 void AUD_vlog (const char *cap
, const char *fmt
, va_list ap
) GCC_FMT_ATTR(2, 0);
89 void AUD_log (const char *cap
, const char *fmt
, ...) GCC_FMT_ATTR(2, 3);
92 void AUD_register_card (const char *name
, QEMUSoundCard
*card
);
93 void AUD_remove_card (QEMUSoundCard
*card
);
94 CaptureVoiceOut
*AUD_add_capture (
95 struct audsettings
*as
,
96 struct audio_capture_ops
*ops
,
99 void AUD_del_capture (CaptureVoiceOut
*cap
, void *cb_opaque
);
101 SWVoiceOut
*AUD_open_out (
105 void *callback_opaque
,
106 audio_callback_fn callback_fn
,
107 struct audsettings
*settings
110 void AUD_close_out (QEMUSoundCard
*card
, SWVoiceOut
*sw
);
111 int AUD_write (SWVoiceOut
*sw
, void *pcm_buf
, int size
);
112 int AUD_get_buffer_size_out (SWVoiceOut
*sw
);
113 void AUD_set_active_out (SWVoiceOut
*sw
, int on
);
114 int AUD_is_active_out (SWVoiceOut
*sw
);
116 void AUD_init_time_stamp_out (SWVoiceOut
*sw
, QEMUAudioTimeStamp
*ts
);
117 uint64_t AUD_get_elapsed_usec_out (SWVoiceOut
*sw
, QEMUAudioTimeStamp
*ts
);
119 void AUD_set_volume_out (SWVoiceOut
*sw
, int mute
, uint8_t lvol
, uint8_t rvol
);
120 void AUD_set_volume_in (SWVoiceIn
*sw
, int mute
, uint8_t lvol
, uint8_t rvol
);
122 SWVoiceIn
*AUD_open_in (
126 void *callback_opaque
,
127 audio_callback_fn callback_fn
,
128 struct audsettings
*settings
131 void AUD_close_in (QEMUSoundCard
*card
, SWVoiceIn
*sw
);
132 int AUD_read (SWVoiceIn
*sw
, void *pcm_buf
, int size
);
133 void AUD_set_active_in (SWVoiceIn
*sw
, int on
);
134 int AUD_is_active_in (SWVoiceIn
*sw
);
136 void AUD_init_time_stamp_in (SWVoiceIn
*sw
, QEMUAudioTimeStamp
*ts
);
137 uint64_t AUD_get_elapsed_usec_in (SWVoiceIn
*sw
, QEMUAudioTimeStamp
*ts
);
139 static inline void *advance (void *p
, int incr
)
146 #define audio_MIN(a, b) ( __extension__ ({ \
147 __typeof (a) ta = a; \
148 __typeof (b) tb = b; \
149 ((ta)>(tb)?(tb):(ta)); \
152 #define audio_MAX(a, b) ( __extension__ ({ \
153 __typeof (a) ta = a; \
154 __typeof (b) tb = b; \
155 ((ta)<(tb)?(tb):(ta)); \
158 #define audio_MIN(a, b) ((a)>(b)?(b):(a))
159 #define audio_MAX(a, b) ((a)<(b)?(b):(a))
162 int wav_start_capture (CaptureState
*s
, const char *path
, int freq
,
163 int bits
, int nchannels
);