VirtualBox

source: vbox/trunk/src/VBox/Devices/Audio/audio.h@ 1

最後變更 在這個檔案從1是 1,由 vboxsync 提交於 55 年 前

import

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 4.8 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#if defined __STDC_VERSION__ && __STDC_VERSION__ > 199901L
30#define FMTZ "z"
31#else
32#define FMTZ
33#endif
34
35typedef void (*audio_callback_fn_t) (void *opaque, int avail);
36
37typedef enum {
38 AUD_FMT_U8,
39 AUD_FMT_S8,
40 AUD_FMT_U16,
41 AUD_FMT_S16
42} audfmt_e;
43
44#define AUDIO_HOST_ENDIANNESS 0
45
46typedef struct {
47 int freq;
48 int nchannels;
49 audfmt_e fmt;
50 int endianness;
51} audsettings_t;
52
53typedef enum {
54 AUD_CNOTIFY_ENABLE,
55 AUD_CNOTIFY_DISABLE
56} audcnotification_e;
57
58struct 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);
62};
63
64struct capture_ops {
65 void (*info) (void *opaque);
66 void (*destroy) (void *opaque);
67};
68
69typedef struct CaptureState {
70 void *opaque;
71 struct capture_ops ops;
72 LIST_ENTRY (CaptureState) entries;
73} CaptureState;
74
75typedef struct AudioState AudioState;
76typedef struct SWVoiceOut SWVoiceOut;
77typedef struct CaptureVoiceOut CaptureVoiceOut;
78typedef struct SWVoiceIn SWVoiceIn;
79
80typedef struct QEMUSoundCard {
81 AudioState *audio;
82 char *name;
83 LIST_ENTRY (QEMUSoundCard) entries;
84} QEMUSoundCard;
85
86typedef struct QEMUAudioTimeStamp {
87 uint64_t old_ts;
88} QEMUAudioTimeStamp;
89
90void AUD_vlog (const char *cap, const char *fmt, va_list ap);
91void AUD_log (const char *cap, const char *fmt, ...)
92#ifdef __GNUC__
93 __attribute__ ((__format__ (__printf__, 2, 3)))
94#endif
95 ;
96
97void AUD_register_card (const char *name, QEMUSoundCard *card);
98void AUD_remove_card (QEMUSoundCard *card);
99
100CaptureVoiceOut *AUD_add_capture (
101 AudioState *s,
102 audsettings_t *as,
103 struct audio_capture_ops *ops,
104 void *opaque
105 );
106void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque);
107
108SWVoiceOut *AUD_open_out (
109 QEMUSoundCard *card,
110 SWVoiceOut *sw,
111 const char *name,
112 void *callback_opaque,
113 audio_callback_fn_t callback_fn,
114 audsettings_t *settings
115 );
116
117void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
118int AUD_write (SWVoiceOut *sw, void *pcm_buf, int size);
119int AUD_get_buffer_size_out (SWVoiceOut *sw);
120void AUD_set_active_out (SWVoiceOut *sw, int on);
121int AUD_is_active_out (SWVoiceOut *sw);
122
123void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
124uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
125
126SWVoiceIn *AUD_open_in (
127 QEMUSoundCard *card,
128 SWVoiceIn *sw,
129 const char *name,
130 void *callback_opaque,
131 audio_callback_fn_t callback_fn,
132 audsettings_t *settings
133 );
134
135void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
136int AUD_read (SWVoiceIn *sw, void *pcm_buf, int size);
137void AUD_set_active_in (SWVoiceIn *sw, int on);
138int AUD_is_active_in (SWVoiceIn *sw);
139
140void AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
141uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
142
143static inline void *advance (void *p, int incr)
144{
145#ifndef VBOX
146 uint8_t *d = p;
147#else
148 uint8_t *d = (uint8_t*)p;
149#endif
150 return (d + incr);
151}
152
153uint32_t popcount (uint32_t u);
154uint32_t lsbindex (uint32_t u);
155
156#ifdef __GNUC__
157#define audio_MIN(a, b) ( __extension__ ({ \
158 __typeof (a) ta = a; \
159 __typeof (b) tb = b; \
160 ((ta)>(tb)?(tb):(ta)); \
161}))
162
163#define audio_MAX(a, b) ( __extension__ ({ \
164 __typeof (a) ta = a; \
165 __typeof (b) tb = b; \
166 ((ta)<(tb)?(tb):(ta)); \
167}))
168#else
169#define audio_MIN(a, b) ((a)>(b)?(b):(a))
170#define audio_MAX(a, b) ((a)<(b)?(b):(a))
171#endif
172
173#endif /* audio.h */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette