2 * QEMU Audio subsystem header
4 * Copyright (c) 2003-2004 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
24 #ifndef QEMU_AUDIO_INT_H
25 #define QEMU_AUDIO_INT_H
31 typedef struct HWVoice
{
54 struct SWVoice
**pvoice
;
55 struct pcm_ops
*pcm_ops
;
58 extern struct pcm_ops no_pcm_ops
;
59 extern struct audio_output_driver no_output_driver
;
61 extern struct pcm_ops oss_pcm_ops
;
62 extern struct audio_output_driver oss_output_driver
;
64 extern struct pcm_ops sdl_pcm_ops
;
65 extern struct audio_output_driver sdl_output_driver
;
67 extern struct pcm_ops wav_pcm_ops
;
68 extern struct audio_output_driver wav_output_driver
;
70 extern struct pcm_ops fmod_pcm_ops
;
71 extern struct audio_output_driver fmod_output_driver
;
73 struct audio_output_driver
{
76 void (*fini
) (void *);
77 struct pcm_ops
*pcm_ops
;
83 typedef struct AudioState
{
90 int64_t ticks_threshold
;
93 struct audio_output_driver
*drv
;
95 extern AudioState audio_state
;
109 int bytes_per_second
;
123 int (*init
) (HWVoice
*hw
, int freq
, int nchannels
, audfmt_e fmt
);
124 void (*fini
) (HWVoice
*hw
);
125 void (*run
) (HWVoice
*hw
);
126 int (*write
) (SWVoice
*sw
, void *buf
, int size
);
127 int (*ctl
) (HWVoice
*hw
, int cmd
, ...);
130 void pcm_sw_free_resources (SWVoice
*sw
);
131 int pcm_sw_alloc_resources (SWVoice
*sw
);
132 void pcm_sw_fini (SWVoice
*sw
);
133 int pcm_sw_init (SWVoice
*sw
, HWVoice
*hw
, int freq
,
134 int nchannels
, audfmt_e fmt
);
136 void pcm_hw_clear (HWVoice
*hw
, void *buf
, int len
);
137 HWVoice
* pcm_hw_find_any (HWVoice
*hw
);
138 HWVoice
* pcm_hw_find_any_active (HWVoice
*hw
);
139 HWVoice
* pcm_hw_find_any_passive (HWVoice
*hw
);
140 HWVoice
* pcm_hw_find_specific (HWVoice
*hw
, int freq
,
141 int nchannels
, audfmt_e fmt
);
142 HWVoice
* pcm_hw_add (int freq
, int nchannels
, audfmt_e fmt
);
143 int pcm_hw_add_sw (HWVoice
*hw
, SWVoice
*sw
);
144 int pcm_hw_del_sw (HWVoice
*hw
, SWVoice
*sw
);
145 SWVoice
* pcm_create_voice_pair (int freq
, int nchannels
, audfmt_e fmt
);
147 void pcm_hw_free_resources (HWVoice
*hw
);
148 int pcm_hw_alloc_resources (HWVoice
*hw
);
149 void pcm_hw_fini (HWVoice
*hw
);
150 void pcm_hw_gc (HWVoice
*hw
);
151 int pcm_hw_get_live (HWVoice
*hw
);
152 int pcm_hw_get_live2 (HWVoice
*hw
, int *nb_active
);
153 void pcm_hw_dec_live (HWVoice
*hw
, int decr
);
154 int pcm_hw_write (SWVoice
*sw
, void *buf
, int len
);
156 int audio_get_conf_int (const char *key
, int defval
);
157 const char *audio_get_conf_str (const char *key
, const char *defval
);
159 struct audio_output_driver
;
161 #define VOICE_ENABLE 1
162 #define VOICE_DISABLE 2
164 #endif /* audio_int.h */