Annotation of qemu/audio/audio.h, revision 1.1.1.4

1.1       root        1: /*
                      2:  * QEMU Audio subsystem header
1.1.1.2   root        3:  *
                      4:  * Copyright (c) 2003-2005 Vassili Karpov (malc)
                      5:  *
1.1       root        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: 
1.1.1.4 ! root       27: #include "config-host.h"
1.1.1.2   root       28: #include "sys-queue.h"
                     29: 
                     30: typedef void (*audio_callback_fn_t) (void *opaque, int avail);
1.1       root       31: 
                     32: typedef enum {
1.1.1.2   root       33:     AUD_FMT_U8,
                     34:     AUD_FMT_S8,
                     35:     AUD_FMT_U16,
1.1.1.4 ! root       36:     AUD_FMT_S16,
        !            37:     AUD_FMT_U32,
        !            38:     AUD_FMT_S32
1.1       root       39: } audfmt_e;
                     40: 
1.1.1.3   root       41: #ifdef WORDS_BIGENDIAN
                     42: #define AUDIO_HOST_ENDIANNESS 1
                     43: #else
                     44: #define AUDIO_HOST_ENDIANNESS 0
                     45: #endif
                     46: 
1.1.1.2   root       47: typedef struct {
                     48:     int freq;
                     49:     int nchannels;
                     50:     audfmt_e fmt;
1.1.1.3   root       51:     int endianness;
1.1.1.2   root       52: } audsettings_t;
                     53: 
1.1.1.3   root       54: typedef enum {
                     55:     AUD_CNOTIFY_ENABLE,
                     56:     AUD_CNOTIFY_DISABLE
                     57: } audcnotification_e;
                     58: 
                     59: struct audio_capture_ops {
                     60:     void (*notify) (void *opaque, audcnotification_e cmd);
                     61:     void (*capture) (void *opaque, void *buf, int size);
                     62:     void (*destroy) (void *opaque);
                     63: };
                     64: 
                     65: struct capture_ops {
                     66:     void (*info) (void *opaque);
                     67:     void (*destroy) (void *opaque);
                     68: };
                     69: 
                     70: typedef struct CaptureState {
                     71:     void *opaque;
                     72:     struct capture_ops ops;
                     73:     LIST_ENTRY (CaptureState) entries;
                     74: } CaptureState;
                     75: 
1.1.1.2   root       76: typedef struct SWVoiceOut SWVoiceOut;
1.1.1.3   root       77: typedef struct CaptureVoiceOut CaptureVoiceOut;
1.1.1.2   root       78: typedef struct SWVoiceIn SWVoiceIn;
                     79: 
                     80: typedef struct QEMUSoundCard {
                     81:     AudioState *audio;
                     82:     char *name;
                     83:     LIST_ENTRY (QEMUSoundCard) entries;
                     84: } QEMUSoundCard;
                     85: 
                     86: typedef struct QEMUAudioTimeStamp {
                     87:     uint64_t old_ts;
                     88: } QEMUAudioTimeStamp;
                     89: 
                     90: void AUD_vlog (const char *cap, const char *fmt, va_list ap);
                     91: void AUD_log (const char *cap, const char *fmt, ...)
                     92: #ifdef __GNUC__
                     93:     __attribute__ ((__format__ (__printf__, 2, 3)))
                     94: #endif
                     95:     ;
                     96: 
                     97: AudioState *AUD_init (void);
                     98: void AUD_help (void);
                     99: void AUD_register_card (AudioState *s, const char *name, QEMUSoundCard *card);
                    100: void AUD_remove_card (QEMUSoundCard *card);
1.1.1.3   root      101: CaptureVoiceOut *AUD_add_capture (
                    102:     AudioState *s,
                    103:     audsettings_t *as,
                    104:     struct audio_capture_ops *ops,
                    105:     void *opaque
                    106:     );
                    107: void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque);
1.1.1.2   root      108: 
                    109: SWVoiceOut *AUD_open_out (
                    110:     QEMUSoundCard *card,
                    111:     SWVoiceOut *sw,
                    112:     const char *name,
                    113:     void *callback_opaque,
                    114:     audio_callback_fn_t callback_fn,
1.1.1.3   root      115:     audsettings_t *settings
1.1.1.2   root      116:     );
                    117: 
                    118: void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
                    119: int  AUD_write (SWVoiceOut *sw, void *pcm_buf, int size);
                    120: int  AUD_get_buffer_size_out (SWVoiceOut *sw);
                    121: void AUD_set_active_out (SWVoiceOut *sw, int on);
                    122: int  AUD_is_active_out (SWVoiceOut *sw);
                    123: 
                    124: void     AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
                    125: uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
                    126: 
                    127: SWVoiceIn *AUD_open_in (
                    128:     QEMUSoundCard *card,
                    129:     SWVoiceIn *sw,
                    130:     const char *name,
                    131:     void *callback_opaque,
                    132:     audio_callback_fn_t callback_fn,
1.1.1.3   root      133:     audsettings_t *settings
1.1.1.2   root      134:     );
                    135: 
                    136: void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
                    137: int  AUD_read (SWVoiceIn *sw, void *pcm_buf, int size);
                    138: void AUD_set_active_in (SWVoiceIn *sw, int on);
                    139: int  AUD_is_active_in (SWVoiceIn *sw);
1.1       root      140: 
1.1.1.2   root      141: void     AUD_init_time_stamp_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
                    142: uint64_t AUD_get_elapsed_usec_in (SWVoiceIn *sw, QEMUAudioTimeStamp *ts);
1.1       root      143: 
                    144: static inline void *advance (void *p, int incr)
                    145: {
                    146:     uint8_t *d = p;
                    147:     return (d + incr);
                    148: }
                    149: 
                    150: uint32_t popcount (uint32_t u);
1.1.1.3   root      151: uint32_t lsbindex (uint32_t u);
1.1       root      152: 
1.1.1.2   root      153: #ifdef __GNUC__
                    154: #define audio_MIN(a, b) ( __extension__ ({      \
                    155:     __typeof (a) ta = a;                        \
                    156:     __typeof (b) tb = b;                        \
                    157:     ((ta)>(tb)?(tb):(ta));                      \
                    158: }))
                    159: 
                    160: #define audio_MAX(a, b) ( __extension__ ({      \
                    161:     __typeof (a) ta = a;                        \
                    162:     __typeof (b) tb = b;                        \
                    163:     ((ta)<(tb)?(tb):(ta));                      \
                    164: }))
                    165: #else
1.1       root      166: #define audio_MIN(a, b) ((a)>(b)?(b):(a))
                    167: #define audio_MAX(a, b) ((a)<(b)?(b):(a))
1.1.1.2   root      168: #endif
1.1       root      169: 
                    170: #endif  /* audio.h */

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.