New '-bios' option, used to select an alternate BIOS image from bios_dir.
[qemu] / audio / audio_int.h
index 9d28829..cd22a30 100644 (file)
 #ifndef QEMU_AUDIO_INT_H
 #define QEMU_AUDIO_INT_H
 
-#include "sys-queue.h"
-
 #ifdef CONFIG_COREAUDIO
 #define FLOAT_MIXENG
 /* #define RECIPROCAL */
 #endif
 #include "mixeng.h"
 
-int audio_bug (const char *funcname, int cond);
-
 struct audio_pcm_ops;
 
 typedef enum {
@@ -48,8 +44,8 @@ struct audio_option {
     audio_option_tag_e tag;
     void *valp;
     const char *descr;
-    int *overridenp;
-    int overriden;
+    int *overriddenp;
+    int overridden;
 };
 
 struct audio_callback {
@@ -65,39 +61,37 @@ struct audio_pcm_info {
     int align;
     int shift;
     int bytes_per_second;
-    int swap_endian;
+    int swap_endianness;
 };
 
+typedef struct SWVoiceCap SWVoiceCap;
+
 typedef struct HWVoiceOut {
-    int active;
     int enabled;
     int pending_disable;
-    int valid;
     struct audio_pcm_info info;
 
     f_sample *clip;
 
     int rpos;
-    int bufsize;
     uint64_t ts_helper;
 
     st_sample_t *mix_buf;
 
     int samples;
     LIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
+    LIST_HEAD (sw_cap_listhead, SWVoiceCap) cap_head;
     struct audio_pcm_ops *pcm_ops;
     LIST_ENTRY (HWVoiceOut) entries;
 } HWVoiceOut;
 
 typedef struct HWVoiceIn {
     int enabled;
-    int active;
     struct audio_pcm_info info;
 
     t_sample *conv;
 
     int wpos;
-    int bufsize;
     int total_samples_captured;
     uint64_t ts_helper;
 
@@ -109,58 +103,6 @@ typedef struct HWVoiceIn {
     LIST_ENTRY (HWVoiceIn) entries;
 } HWVoiceIn;
 
-extern struct audio_driver no_audio_driver;
-extern struct audio_driver oss_audio_driver;
-extern struct audio_driver sdl_audio_driver;
-extern struct audio_driver wav_audio_driver;
-extern struct audio_driver fmod_audio_driver;
-extern struct audio_driver alsa_audio_driver;
-extern struct audio_driver coreaudio_audio_driver;
-extern struct audio_driver dsound_audio_driver;
-extern volume_t nominal_volume;
-
-struct audio_driver {
-    const char *name;
-    const char *descr;
-    struct audio_option *options;
-    void *(*init) (void);
-    void (*fini) (void *);
-    struct audio_pcm_ops *pcm_ops;
-    int can_be_default;
-    int max_voices_out;
-    int max_voices_in;
-    int voice_size_out;
-    int voice_size_in;
-};
-
-typedef struct AudioState {
-    int fixed_settings_out;
-    int fixed_freq_out;
-    int fixed_channels_out;
-    int fixed_fmt_out;
-    int nb_hw_voices_out;
-    int greedy_out;
-
-    int fixed_settings_in;
-    int fixed_freq_in;
-    int fixed_channels_in;
-    int fixed_fmt_in;
-    int nb_hw_voices_in;
-    int greedy_in;
-
-    void *opaque;
-    struct audio_driver *drv;
-
-    QEMUTimer *ts;
-    union {
-        int usec;
-        int64_t ticks;
-    } period;
-
-    int plive;
-} AudioState;
-extern AudioState audio_state;
-
 struct SWVoiceOut {
     struct audio_pcm_info info;
     t_sample *conv;
@@ -183,7 +125,7 @@ struct SWVoiceIn {
     int64_t ratio;
     void *rate;
     int total_hw_samples_acquired;
-    st_sample_t *conv_buf;
+    st_sample_t *buf;
     f_sample *clip;
     HWVoiceIn *hw;
     char *name;
@@ -192,22 +134,77 @@ struct SWVoiceIn {
     LIST_ENTRY (SWVoiceIn) entries;
 };
 
+struct audio_driver {
+    const char *name;
+    const char *descr;
+    struct audio_option *options;
+    void *(*init) (void);
+    void (*fini) (void *);
+    struct audio_pcm_ops *pcm_ops;
+    int can_be_default;
+    int max_voices_out;
+    int max_voices_in;
+    int voice_size_out;
+    int voice_size_in;
+};
+
 struct audio_pcm_ops {
-    int  (*init_out)(HWVoiceOut *hw, int freq, int nchannels, audfmt_e fmt);
+    int  (*init_out)(HWVoiceOut *hw, audsettings_t *as);
     void (*fini_out)(HWVoiceOut *hw);
     int  (*run_out) (HWVoiceOut *hw);
     int  (*write)   (SWVoiceOut *sw, void *buf, int size);
     int  (*ctl_out) (HWVoiceOut *hw, int cmd, ...);
 
-    int  (*init_in) (HWVoiceIn *hw, int freq, int nchannels, audfmt_e fmt);
+    int  (*init_in) (HWVoiceIn *hw, audsettings_t *as);
     void (*fini_in) (HWVoiceIn *hw);
     int  (*run_in)  (HWVoiceIn *hw);
     int  (*read)    (SWVoiceIn *sw, void *buf, int size);
     int  (*ctl_in)  (HWVoiceIn *hw, int cmd, ...);
 };
 
-void audio_pcm_init_info (struct audio_pcm_info *info, int freq,
-                          int nchannels, audfmt_e fmt, int swap_endian);
+struct capture_callback {
+    struct audio_capture_ops ops;
+    void *opaque;
+    LIST_ENTRY (capture_callback) entries;
+};
+
+struct CaptureVoiceOut {
+    HWVoiceOut hw;
+    void *buf;
+    LIST_HEAD (cb_listhead, capture_callback) cb_head;
+    LIST_ENTRY (CaptureVoiceOut) entries;
+};
+
+struct SWVoiceCap {
+    SWVoiceOut sw;
+    CaptureVoiceOut *cap;
+    LIST_ENTRY (SWVoiceCap) entries;
+};
+
+struct AudioState {
+    struct audio_driver *drv;
+    void *drv_opaque;
+
+    QEMUTimer *ts;
+    LIST_HEAD (card_listhead, QEMUSoundCard) card_head;
+    LIST_HEAD (hw_in_listhead, HWVoiceIn) hw_head_in;
+    LIST_HEAD (hw_out_listhead, HWVoiceOut) hw_head_out;
+    LIST_HEAD (cap_listhead, CaptureVoiceOut) cap_head;
+    int nb_hw_voices_out;
+    int nb_hw_voices_in;
+};
+
+extern struct audio_driver no_audio_driver;
+extern struct audio_driver oss_audio_driver;
+extern struct audio_driver sdl_audio_driver;
+extern struct audio_driver wav_audio_driver;
+extern struct audio_driver fmod_audio_driver;
+extern struct audio_driver alsa_audio_driver;
+extern struct audio_driver coreaudio_audio_driver;
+extern struct audio_driver dsound_audio_driver;
+extern volume_t nominal_volume;
+
+void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as);
 void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len);
 
 int  audio_pcm_sw_write (SWVoiceOut *sw, void *buf, int len);
@@ -217,6 +214,9 @@ int  audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int len);
 int  audio_pcm_hw_get_live_out (HWVoiceOut *hw);
 int  audio_pcm_hw_get_live_out2 (HWVoiceOut *hw, int *nb_live);
 
+int audio_bug (const char *funcname, int cond);
+void *audio_calloc (const char *funcname, int nmemb, size_t size);
+
 #define VOICE_ENABLE 1
 #define VOICE_DISABLE 2
 
@@ -225,19 +225,10 @@ static inline int audio_ring_dist (int dst, int src, int len)
     return (dst >= src) ? (dst - src) : (len - src + dst);
 }
 
-static inline int audio_need_to_swap_endian (int endianness)
-{
-#ifdef WORDS_BIGENDIAN
-    return endianness != 1;
-#else
-    return endianness != 0;
-#endif
-}
-
 #if defined __GNUC__
 #define GCC_ATTR __attribute__ ((__unused__, __format__ (__printf__, 1, 2)))
 #define INIT_FIELD(f) . f
-#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (printf, n, m)))
+#define GCC_FMT_ATTR(n, m) __attribute__ ((__format__ (__printf__, n, m)))
 #else
 #define GCC_ATTR /**/
 #define INIT_FIELD(f) /**/