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 typedef void (*audio_callback_fn_t) (void *opaque, int avail);
36 typedef struct SWVoiceOut SWVoiceOut;
37 typedef struct SWVoiceIn SWVoiceIn;
39 typedef struct QEMUAudioTimeStamp {
43 void AUD_vlog (const char *cap, const char *fmt, va_list ap);
44 void AUD_log (const char *cap, const char *fmt, ...)
46 __attribute__ ((__format__ (__printf__, 2, 3)))
53 SWVoiceOut *AUD_open_out (
56 void *callback_opaque,
57 audio_callback_fn_t callback_fn,
62 void AUD_close_out (SWVoiceOut *sw);
63 int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size);
64 int AUD_get_buffer_size_out (SWVoiceOut *sw);
65 void AUD_set_active_out (SWVoiceOut *sw, int on);
66 int AUD_is_active_out (SWVoiceOut *sw);
67 void AUD_init_time_stamp_out (SWVoiceOut *sw,
68 QEMUAudioTimeStamp *ts);
69 uint64_t AUD_time_stamp_get_elapsed_usec_out (SWVoiceOut *sw,
70 QEMUAudioTimeStamp *ts);
72 SWVoiceIn *AUD_open_in (
75 void *callback_opaque,
76 audio_callback_fn_t callback_fn,
81 void AUD_close_in (SWVoiceIn *sw);
82 int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size);
83 void AUD_adjust_in (SWVoiceIn *sw, int leftover);
84 void AUD_set_active_in (SWVoiceIn *sw, int on);
85 int AUD_is_active_in (SWVoiceIn *sw);
86 void AUD_init_time_stamp_in (SWVoiceIn *sw,
87 QEMUAudioTimeStamp *ts);
88 uint64_t AUD_time_stamp_get_elapsed_usec_in (SWVoiceIn *sw,
89 QEMUAudioTimeStamp *ts);
91 static inline void *advance (void *p, int incr)
97 uint32_t popcount (uint32_t u);
98 inline uint32_t lsbindex (uint32_t u);
101 #define audio_MIN(a, b) ( __extension__ ({ \
102 __typeof (a) ta = a; \
103 __typeof (b) tb = b; \
104 ((ta)>(tb)?(tb):(ta)); \
107 #define audio_MAX(a, b) ( __extension__ ({ \
108 __typeof (a) ta = a; \
109 __typeof (b) tb = b; \
110 ((ta)<(tb)?(tb):(ta)); \
113 #define audio_MIN(a, b) ((a)>(b)?(b):(a))
114 #define audio_MAX(a, b) ((a)<(b)?(b):(a))