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 "config-host.h"
28 #include "qemu-queue.h"
30 typedef void (*audio_callback_fn
) (void *opaque
, int avail
);
41 #ifdef HOST_WORDS_BIGENDIAN
42 #define AUDIO_HOST_ENDIANNESS 1
44 #define AUDIO_HOST_ENDIANNESS 0
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
);
66 void (*info
) (void *opaque
);
67 void (*destroy
) (void *opaque
);
70 typedef struct CaptureState
{
72 struct capture_ops ops
;
73 QLIST_ENTRY (CaptureState
) entries
;
76 typedef struct SWVoiceOut SWVoiceOut
;
77 typedef struct CaptureVoiceOut CaptureVoiceOut
;
78 typedef struct SWVoiceIn SWVoiceIn
;
80 typedef struct QEMUSoundCard
{
82 QLIST_ENTRY (QEMUSoundCard
) entries
;
85 typedef struct QEMUAudioTimeStamp
{
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);
93 void AUD_register_card (const char *name
, QEMUSoundCard
*card
);
94 void AUD_remove_card (QEMUSoundCard
*card
);
95 CaptureVoiceOut
*AUD_add_capture (
96 struct audsettings
*as
,
97 struct audio_capture_ops
*ops
,
100 void AUD_del_capture (CaptureVoiceOut
*cap
, void *cb_opaque
);
102 SWVoiceOut
*AUD_open_out (
106 void *callback_opaque
,
107 audio_callback_fn callback_fn
,
108 struct audsettings
*settings
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
);
117 void AUD_init_time_stamp_out (SWVoiceOut
*sw
, QEMUAudioTimeStamp
*ts
);
118 uint64_t AUD_get_elapsed_usec_out (SWVoiceOut
*sw
, QEMUAudioTimeStamp
*ts
);
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
);
123 SWVoiceIn
*AUD_open_in (
127 void *callback_opaque
,
128 audio_callback_fn callback_fn
,
129 struct audsettings
*settings
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
);
137 void AUD_init_time_stamp_in (SWVoiceIn
*sw
, QEMUAudioTimeStamp
*ts
);
138 uint64_t AUD_get_elapsed_usec_in (SWVoiceIn
*sw
, QEMUAudioTimeStamp
*ts
);
140 static inline void *advance (void *p
, int incr
)
147 #define audio_MIN(a, b) ( __extension__ ({ \
148 __typeof (a) ta = a; \
149 __typeof (b) tb = b; \
150 ((ta)>(tb)?(tb):(ta)); \
153 #define audio_MAX(a, b) ( __extension__ ({ \
154 __typeof (a) ta = a; \
155 __typeof (b) tb = b; \
156 ((ta)<(tb)?(tb):(ta)); \
159 #define audio_MIN(a, b) ((a)>(b)?(b):(a))
160 #define audio_MAX(a, b) ((a)<(b)?(b):(a))
163 int wav_start_capture (CaptureState
*s
, const char *path
, int freq
,
164 int bits
, int nchannels
);