root / audio / audio_int.h @ 6cc721cf
History | View | Annotate | Download (4.5 kB)
1 | fb065187 | bellard | /*
|
---|---|---|---|
2 | fb065187 | bellard | * QEMU Audio subsystem header
|
3 | fb065187 | bellard | *
|
4 | fb065187 | bellard | * Copyright (c) 2003-2004 Vassili Karpov (malc)
|
5 | fb065187 | bellard | *
|
6 | fb065187 | bellard | * Permission is hereby granted, free of charge, to any person obtaining a copy
|
7 | fb065187 | bellard | * of this software and associated documentation files (the "Software"), to deal
|
8 | fb065187 | bellard | * in the Software without restriction, including without limitation the rights
|
9 | fb065187 | bellard | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
10 | fb065187 | bellard | * copies of the Software, and to permit persons to whom the Software is
|
11 | fb065187 | bellard | * furnished to do so, subject to the following conditions:
|
12 | fb065187 | bellard | *
|
13 | fb065187 | bellard | * The above copyright notice and this permission notice shall be included in
|
14 | fb065187 | bellard | * all copies or substantial portions of the Software.
|
15 | fb065187 | bellard | *
|
16 | fb065187 | bellard | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
17 | fb065187 | bellard | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
18 | fb065187 | bellard | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
19 | fb065187 | bellard | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20 | fb065187 | bellard | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
21 | fb065187 | bellard | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
22 | fb065187 | bellard | * THE SOFTWARE.
|
23 | fb065187 | bellard | */
|
24 | fb065187 | bellard | #ifndef QEMU_AUDIO_INT_H
|
25 | fb065187 | bellard | #define QEMU_AUDIO_INT_H
|
26 | fb065187 | bellard | |
27 | fb065187 | bellard | #include "vl.h" |
28 | fb065187 | bellard | |
29 | fb065187 | bellard | struct pcm_ops;
|
30 | fb065187 | bellard | |
31 | fb065187 | bellard | typedef struct HWVoice { |
32 | fb065187 | bellard | int active;
|
33 | fb065187 | bellard | int enabled;
|
34 | fb065187 | bellard | int pending_disable;
|
35 | fb065187 | bellard | int valid;
|
36 | fb065187 | bellard | int freq;
|
37 | fb065187 | bellard | |
38 | fb065187 | bellard | f_sample *clip; |
39 | fb065187 | bellard | audfmt_e fmt; |
40 | fb065187 | bellard | int nchannels;
|
41 | fb065187 | bellard | |
42 | fb065187 | bellard | int align;
|
43 | fb065187 | bellard | int shift;
|
44 | fb065187 | bellard | |
45 | fb065187 | bellard | int rpos;
|
46 | fb065187 | bellard | int bufsize;
|
47 | fb065187 | bellard | |
48 | fb065187 | bellard | int bytes_per_second;
|
49 | fb065187 | bellard | st_sample_t *mix_buf; |
50 | fb065187 | bellard | |
51 | fb065187 | bellard | int samples;
|
52 | fb065187 | bellard | int64_t old_ticks; |
53 | fb065187 | bellard | int nb_voices;
|
54 | fb065187 | bellard | struct SWVoice **pvoice;
|
55 | fb065187 | bellard | struct pcm_ops *pcm_ops;
|
56 | fb065187 | bellard | } HWVoice; |
57 | fb065187 | bellard | |
58 | 7372f88d | bellard | extern struct pcm_ops no_pcm_ops; |
59 | 7372f88d | bellard | extern struct audio_output_driver no_output_driver; |
60 | 7372f88d | bellard | |
61 | fb065187 | bellard | extern struct pcm_ops oss_pcm_ops; |
62 | fb065187 | bellard | extern struct audio_output_driver oss_output_driver; |
63 | fb065187 | bellard | |
64 | fb065187 | bellard | extern struct pcm_ops sdl_pcm_ops; |
65 | fb065187 | bellard | extern struct audio_output_driver sdl_output_driver; |
66 | fb065187 | bellard | |
67 | fb065187 | bellard | extern struct pcm_ops wav_pcm_ops; |
68 | fb065187 | bellard | extern struct audio_output_driver wav_output_driver; |
69 | fb065187 | bellard | |
70 | fb065187 | bellard | extern struct pcm_ops fmod_pcm_ops; |
71 | fb065187 | bellard | extern struct audio_output_driver fmod_output_driver; |
72 | fb065187 | bellard | |
73 | fb065187 | bellard | struct audio_output_driver {
|
74 | fb065187 | bellard | const char *name; |
75 | fb065187 | bellard | void *(*init) (void); |
76 | fb065187 | bellard | void (*fini) (void *); |
77 | fb065187 | bellard | struct pcm_ops *pcm_ops;
|
78 | fb065187 | bellard | int can_be_default;
|
79 | fb065187 | bellard | int max_voices;
|
80 | fb065187 | bellard | int voice_size;
|
81 | fb065187 | bellard | }; |
82 | fb065187 | bellard | |
83 | fb065187 | bellard | typedef struct AudioState { |
84 | fb065187 | bellard | int fixed_format;
|
85 | fb065187 | bellard | int fixed_freq;
|
86 | fb065187 | bellard | int fixed_channels;
|
87 | fb065187 | bellard | int fixed_fmt;
|
88 | fb065187 | bellard | int nb_hw_voices;
|
89 | fb065187 | bellard | int64_t ticks_threshold; |
90 | fb065187 | bellard | int freq_threshold;
|
91 | fb065187 | bellard | void *opaque;
|
92 | fb065187 | bellard | struct audio_output_driver *drv;
|
93 | fb065187 | bellard | } AudioState; |
94 | fb065187 | bellard | extern AudioState audio_state;
|
95 | fb065187 | bellard | |
96 | fb065187 | bellard | struct SWVoice {
|
97 | fb065187 | bellard | int freq;
|
98 | fb065187 | bellard | audfmt_e fmt; |
99 | fb065187 | bellard | int nchannels;
|
100 | fb065187 | bellard | |
101 | fb065187 | bellard | int shift;
|
102 | fb065187 | bellard | int align;
|
103 | fb065187 | bellard | |
104 | fb065187 | bellard | t_sample *conv; |
105 | fb065187 | bellard | |
106 | fb065187 | bellard | int left;
|
107 | fb065187 | bellard | int pos;
|
108 | fb065187 | bellard | int bytes_per_second;
|
109 | fb065187 | bellard | int64_t ratio; |
110 | fb065187 | bellard | st_sample_t *buf; |
111 | fb065187 | bellard | void *rate;
|
112 | fb065187 | bellard | |
113 | fb065187 | bellard | int wpos;
|
114 | fb065187 | bellard | int live;
|
115 | fb065187 | bellard | int active;
|
116 | fb065187 | bellard | int64_t old_ticks; |
117 | fb065187 | bellard | HWVoice *hw; |
118 | fb065187 | bellard | char *name;
|
119 | fb065187 | bellard | }; |
120 | fb065187 | bellard | |
121 | fb065187 | bellard | struct pcm_ops {
|
122 | fb065187 | bellard | int (*init) (HWVoice *hw, int freq, int nchannels, audfmt_e fmt); |
123 | fb065187 | bellard | void (*fini) (HWVoice *hw);
|
124 | fb065187 | bellard | void (*run) (HWVoice *hw);
|
125 | fb065187 | bellard | int (*write) (SWVoice *sw, void *buf, int size); |
126 | fb065187 | bellard | int (*ctl) (HWVoice *hw, int cmd, ...); |
127 | fb065187 | bellard | }; |
128 | fb065187 | bellard | |
129 | fb065187 | bellard | void pcm_sw_free_resources (SWVoice *sw);
|
130 | fb065187 | bellard | int pcm_sw_alloc_resources (SWVoice *sw);
|
131 | fb065187 | bellard | void pcm_sw_fini (SWVoice *sw);
|
132 | fb065187 | bellard | int pcm_sw_init (SWVoice *sw, HWVoice *hw, int freq, |
133 | fb065187 | bellard | int nchannels, audfmt_e fmt);
|
134 | fb065187 | bellard | |
135 | fb065187 | bellard | void pcm_hw_clear (HWVoice *hw, void *buf, int len); |
136 | fb065187 | bellard | HWVoice * pcm_hw_find_any (HWVoice *hw); |
137 | fb065187 | bellard | HWVoice * pcm_hw_find_any_active (HWVoice *hw); |
138 | fb065187 | bellard | HWVoice * pcm_hw_find_any_passive (HWVoice *hw); |
139 | fb065187 | bellard | HWVoice * pcm_hw_find_specific (HWVoice *hw, int freq,
|
140 | fb065187 | bellard | int nchannels, audfmt_e fmt);
|
141 | fb065187 | bellard | HWVoice * pcm_hw_add (int freq, int nchannels, audfmt_e fmt); |
142 | fb065187 | bellard | int pcm_hw_add_sw (HWVoice *hw, SWVoice *sw);
|
143 | fb065187 | bellard | int pcm_hw_del_sw (HWVoice *hw, SWVoice *sw);
|
144 | fb065187 | bellard | SWVoice * pcm_create_voice_pair (int freq, int nchannels, audfmt_e fmt); |
145 | fb065187 | bellard | |
146 | fb065187 | bellard | void pcm_hw_free_resources (HWVoice *hw);
|
147 | fb065187 | bellard | int pcm_hw_alloc_resources (HWVoice *hw);
|
148 | fb065187 | bellard | void pcm_hw_fini (HWVoice *hw);
|
149 | fb065187 | bellard | void pcm_hw_gc (HWVoice *hw);
|
150 | fb065187 | bellard | int pcm_hw_get_live (HWVoice *hw);
|
151 | fb065187 | bellard | int pcm_hw_get_live2 (HWVoice *hw, int *nb_active); |
152 | fb065187 | bellard | void pcm_hw_dec_live (HWVoice *hw, int decr); |
153 | fb065187 | bellard | int pcm_hw_write (SWVoice *sw, void *buf, int len); |
154 | fb065187 | bellard | |
155 | fb065187 | bellard | int audio_get_conf_int (const char *key, int defval); |
156 | fb065187 | bellard | const char *audio_get_conf_str (const char *key, const char *defval); |
157 | fb065187 | bellard | |
158 | fb065187 | bellard | struct audio_output_driver;
|
159 | fb065187 | bellard | |
160 | fb065187 | bellard | #define VOICE_ENABLE 1 |
161 | fb065187 | bellard | #define VOICE_DISABLE 2 |
162 | fb065187 | bellard | |
163 | fb065187 | bellard | #endif /* audio_int.h */ |