Statistics
| Branch: | Revision:

root / audio / audio.h @ 1d14ffa9

History | View | Annotate | Download (3.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
typedef void (*audio_callback_fn_t) (void *opaque, int avail);
28

    
29
typedef enum {
30
  AUD_FMT_U8,
31
  AUD_FMT_S8,
32
  AUD_FMT_U16,
33
  AUD_FMT_S16
34
} audfmt_e;
35

    
36
typedef struct SWVoiceOut SWVoiceOut;
37
typedef struct SWVoiceIn SWVoiceIn;
38

    
39
typedef struct QEMUAudioTimeStamp {
40
    uint64_t old_ts;
41
} QEMUAudioTimeStamp;
42

    
43
void AUD_vlog (const char *cap, const char *fmt, va_list ap);
44
void AUD_log (const char *cap, const char *fmt, ...)
45
#ifdef __GNUC__
46
    __attribute__ ((__format__ (__printf__, 2, 3)))
47
#endif
48
    ;
49

    
50
void AUD_init (void);
51
void AUD_help (void);
52

    
53
SWVoiceOut  *AUD_open_out (
54
    SWVoiceOut *sw,
55
    const char *name,
56
    void *callback_opaque,
57
    audio_callback_fn_t callback_fn,
58
    int freq,
59
    int nchannels,
60
    audfmt_e fmt
61
    );
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);
71

    
72
SWVoiceIn   *AUD_open_in (
73
    SWVoiceIn *sw,
74
    const char *name,
75
    void *callback_opaque,
76
    audio_callback_fn_t callback_fn,
77
    int freq,
78
    int nchannels,
79
    audfmt_e fmt
80
    );
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);
90

    
91
static inline void *advance (void *p, int incr)
92
{
93
    uint8_t *d = p;
94
    return (d + incr);
95
}
96

    
97
uint32_t popcount (uint32_t u);
98
inline uint32_t lsbindex (uint32_t u);
99

    
100
#ifdef __GNUC__
101
#define audio_MIN(a, b) ( __extension__ ({      \
102
    __typeof (a) ta = a;                        \
103
    __typeof (b) tb = b;                        \
104
    ((ta)>(tb)?(tb):(ta));                      \
105
}))
106

    
107
#define audio_MAX(a, b) ( __extension__ ({      \
108
    __typeof (a) ta = a;                        \
109
    __typeof (b) tb = b;                        \
110
    ((ta)<(tb)?(tb):(ta));                      \
111
}))
112
#else
113
#define audio_MIN(a, b) ((a)>(b)?(b):(a))
114
#define audio_MAX(a, b) ((a)<(b)?(b):(a))
115
#endif
116

    
117
#endif  /* audio.h */