Statistics
| Branch: | Revision:

root / audio / audio_int.h @ fb065187

History | View | Annotate | Download (4.4 kB)

1
/*
2
 * QEMU Audio subsystem header
3
 * 
4
 * Copyright (c) 2003-2004 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_INT_H
25
#define QEMU_AUDIO_INT_H
26

    
27
#include "vl.h"
28

    
29
struct pcm_ops;
30

    
31
typedef struct HWVoice {
32
    int active;
33
    int enabled;
34
    int pending_disable;
35
    int valid;
36
    int freq;
37

    
38
    f_sample *clip;
39
    audfmt_e fmt;
40
    int nchannels;
41

    
42
    int align;
43
    int shift;
44

    
45
    int rpos;
46
    int bufsize;
47

    
48
    int bytes_per_second;
49
    st_sample_t *mix_buf;
50

    
51
    int samples;
52
    int64_t old_ticks;
53
    int nb_voices;
54
    struct SWVoice **pvoice;
55
    struct pcm_ops *pcm_ops;
56
} HWVoice;
57

    
58
extern struct pcm_ops oss_pcm_ops;
59
extern struct audio_output_driver oss_output_driver;
60

    
61
extern struct pcm_ops sdl_pcm_ops;
62
extern struct audio_output_driver sdl_output_driver;
63

    
64
extern struct pcm_ops wav_pcm_ops;
65
extern struct audio_output_driver wav_output_driver;
66

    
67
extern struct pcm_ops fmod_pcm_ops;
68
extern struct audio_output_driver fmod_output_driver;
69

    
70
struct audio_output_driver {
71
    const char *name;
72
    void *(*init) (void);
73
    void (*fini) (void *);
74
    struct pcm_ops *pcm_ops;
75
    int can_be_default;
76
    int max_voices;
77
    int voice_size;
78
};
79

    
80
typedef struct AudioState {
81
    int fixed_format;
82
    int fixed_freq;
83
    int fixed_channels;
84
    int fixed_fmt;
85
    int nb_hw_voices;
86
    int voice_size;
87
    int64_t ticks_threshold;
88
    int freq_threshold;
89
    void *opaque;
90
    struct audio_output_driver *drv;
91
} AudioState;
92
extern AudioState audio_state;
93

    
94
struct SWVoice {
95
    int freq;
96
    audfmt_e fmt;
97
    int nchannels;
98

    
99
    int shift;
100
    int align;
101

    
102
    t_sample *conv;
103

    
104
    int left;
105
    int pos;
106
    int bytes_per_second;
107
    int64_t ratio;
108
    st_sample_t *buf;
109
    void *rate;
110

    
111
    int wpos;
112
    int live;
113
    int active;
114
    int64_t old_ticks;
115
    HWVoice *hw;
116
    char *name;
117
};
118

    
119
struct pcm_ops {
120
    int  (*init)  (HWVoice *hw, int freq, int nchannels, audfmt_e fmt);
121
    void (*fini)  (HWVoice *hw);
122
    void (*run)   (HWVoice *hw);
123
    int  (*write) (SWVoice *sw, void *buf, int size);
124
    int  (*ctl)   (HWVoice *hw, int cmd, ...);
125
};
126

    
127
void      pcm_sw_free_resources (SWVoice *sw);
128
int       pcm_sw_alloc_resources (SWVoice *sw);
129
void      pcm_sw_fini (SWVoice *sw);
130
int       pcm_sw_init (SWVoice *sw, HWVoice *hw, int freq,
131
                       int nchannels, audfmt_e fmt);
132

    
133
void      pcm_hw_clear (HWVoice *hw, void *buf, int len);
134
HWVoice * pcm_hw_find_any (HWVoice *hw);
135
HWVoice * pcm_hw_find_any_active (HWVoice *hw);
136
HWVoice * pcm_hw_find_any_passive (HWVoice *hw);
137
HWVoice * pcm_hw_find_specific (HWVoice *hw, int freq,
138
                                int nchannels, audfmt_e fmt);
139
HWVoice * pcm_hw_add (int freq, int nchannels, audfmt_e fmt);
140
int       pcm_hw_add_sw (HWVoice *hw, SWVoice *sw);
141
int       pcm_hw_del_sw (HWVoice *hw, SWVoice *sw);
142
SWVoice * pcm_create_voice_pair (int freq, int nchannels, audfmt_e fmt);
143

    
144
void      pcm_hw_free_resources (HWVoice *hw);
145
int       pcm_hw_alloc_resources (HWVoice *hw);
146
void      pcm_hw_fini (HWVoice *hw);
147
void      pcm_hw_gc (HWVoice *hw);
148
int       pcm_hw_get_live (HWVoice *hw);
149
int       pcm_hw_get_live2 (HWVoice *hw, int *nb_active);
150
void      pcm_hw_dec_live (HWVoice *hw, int decr);
151
int       pcm_hw_write (SWVoice *sw, void *buf, int len);
152

    
153
int         audio_get_conf_int (const char *key, int defval);
154
const char *audio_get_conf_str (const char *key, const char *defval);
155

    
156
struct audio_output_driver;
157

    
158
#define VOICE_ENABLE 1
159
#define VOICE_DISABLE 2
160

    
161
#endif /* audio_int.h */