Skip to content

Commit

Permalink
Make audio violate POSIX less
Browse files Browse the repository at this point in the history
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5864 c046a42c-6fe2-441c-8c8c-71466251a162
  • Loading branch information
malc committed Dec 3, 2008
1 parent 8b0de43 commit 1ea879e
Show file tree
Hide file tree
Showing 31 changed files with 139 additions and 135 deletions.
12 changes: 6 additions & 6 deletions audio/alsaaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ static int alsa_run_out (HWVoiceOut *hw)
int rpos, live, decr;
int samples;
uint8_t *dst;
st_sample_t *src;
struct st_sample *src;
snd_pcm_sframes_t avail;

live = audio_pcm_hw_get_live_out (hw);
Expand Down Expand Up @@ -612,13 +612,13 @@ static void alsa_fini_out (HWVoiceOut *hw)
}
}

static int alsa_init_out (HWVoiceOut *hw, audsettings_t *as)
static int alsa_init_out (HWVoiceOut *hw, struct audsettings *as)
{
ALSAVoiceOut *alsa = (ALSAVoiceOut *) hw;
struct alsa_params_req req;
struct alsa_params_obt obt;
snd_pcm_t *handle;
audsettings_t obt_as;
struct audsettings obt_as;

req.fmt = aud_to_alsafmt (as->fmt);
req.freq = as->freq;
Expand Down Expand Up @@ -692,13 +692,13 @@ static int alsa_ctl_out (HWVoiceOut *hw, int cmd, ...)
return -1;
}

static int alsa_init_in (HWVoiceIn *hw, audsettings_t *as)
static int alsa_init_in (HWVoiceIn *hw, struct audsettings *as)
{
ALSAVoiceIn *alsa = (ALSAVoiceIn *) hw;
struct alsa_params_req req;
struct alsa_params_obt obt;
snd_pcm_t *handle;
audsettings_t obt_as;
struct audsettings obt_as;

req.fmt = aud_to_alsafmt (as->fmt);
req.freq = as->freq;
Expand Down Expand Up @@ -792,7 +792,7 @@ static int alsa_run_in (HWVoiceIn *hw)

for (i = 0; i < 2; ++i) {
void *src;
st_sample_t *dst;
struct st_sample *dst;
snd_pcm_sframes_t nread;
snd_pcm_uframes_t len;

Expand Down
26 changes: 13 additions & 13 deletions audio/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ struct fixed_settings {
int enabled;
int nb_voices;
int greedy;
audsettings_t settings;
struct audsettings settings;
};

static struct {
Expand Down Expand Up @@ -91,7 +91,7 @@ static struct {

static AudioState glob_audio_state;

volume_t nominal_volume = {
struct mixeng_volume nominal_volume = {
0,
#ifdef FLOAT_MIXENG
1.0,
Expand Down Expand Up @@ -513,7 +513,7 @@ static void audio_process_options (const char *prefix,
}
}

static void audio_print_settings (audsettings_t *as)
static void audio_print_settings (struct audsettings *as)
{
dolog ("frequency=%d nchannels=%d fmt=", as->freq, as->nchannels);

Expand Down Expand Up @@ -556,7 +556,7 @@ static void audio_print_settings (audsettings_t *as)
AUD_log (NULL, "\n");
}

static int audio_validate_settings (audsettings_t *as)
static int audio_validate_settings (struct audsettings *as)
{
int invalid;

Expand All @@ -580,7 +580,7 @@ static int audio_validate_settings (audsettings_t *as)
return invalid ? -1 : 0;
}

static int audio_pcm_info_eq (struct audio_pcm_info *info, audsettings_t *as)
static int audio_pcm_info_eq (struct audio_pcm_info *info, struct audsettings *as)
{
int bits = 8, sign = 0;

Expand Down Expand Up @@ -609,7 +609,7 @@ static int audio_pcm_info_eq (struct audio_pcm_info *info, audsettings_t *as)
&& info->swap_endianness == (as->endianness != AUDIO_HOST_ENDIANNESS);
}

void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as)
void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *as)
{
int bits = 8, sign = 0, shift = 0;

Expand Down Expand Up @@ -704,8 +704,8 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)
/*
* Capture
*/
static void noop_conv (st_sample_t *dst, const void *src,
int samples, volume_t *vol)
static void noop_conv (struct st_sample *dst, const void *src,
int samples, struct mixeng_volume *vol)
{
(void) src;
(void) dst;
Expand All @@ -715,7 +715,7 @@ static void noop_conv (st_sample_t *dst, const void *src,

static CaptureVoiceOut *audio_pcm_capture_find_specific (
AudioState *s,
audsettings_t *as
struct audsettings *as
)
{
CaptureVoiceOut *cap;
Expand Down Expand Up @@ -891,7 +891,7 @@ int audio_pcm_sw_read (SWVoiceIn *sw, void *buf, int size)
{
HWVoiceIn *hw = sw->hw;
int samples, live, ret = 0, swlim, isamp, osamp, rpos, total = 0;
st_sample_t *src, *dst = sw->buf;
struct st_sample *src, *dst = sw->buf;

rpos = audio_pcm_sw_get_rpos_in (sw) % hw->samples;

Expand Down Expand Up @@ -1442,7 +1442,7 @@ static void audio_run_capture (AudioState *s)
while (live) {
int left = hw->samples - rpos;
int to_capture = audio_MIN (live, left);
st_sample_t *src;
struct st_sample *src;
struct capture_callback *cb;

src = hw->mix_buf + rpos;
Expand Down Expand Up @@ -1812,7 +1812,7 @@ AudioState *AUD_init (void)

CaptureVoiceOut *AUD_add_capture (
AudioState *s,
audsettings_t *as,
struct audsettings *as,
struct audio_capture_ops *ops,
void *cb_opaque
)
Expand Down Expand Up @@ -1863,7 +1863,7 @@ CaptureVoiceOut *AUD_add_capture (
/* XXX find a more elegant way */
hw->samples = 4096 * 4;
hw->mix_buf = audio_calloc (AUDIO_FUNC, hw->samples,
sizeof (st_sample_t));
sizeof (struct st_sample));
if (!hw->mix_buf) {
dolog ("Could not allocate capture mix buffer (%d samples)\n",
hw->samples);
Expand Down
10 changes: 5 additions & 5 deletions audio/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@ typedef enum {
#define AUDIO_HOST_ENDIANNESS 0
#endif

typedef struct {
struct audsettings {
int freq;
int nchannels;
audfmt_e fmt;
int endianness;
} audsettings_t;
};

typedef enum {
AUD_CNOTIFY_ENABLE,
Expand Down Expand Up @@ -100,7 +100,7 @@ void AUD_register_card (AudioState *s, const char *name, QEMUSoundCard *card);
void AUD_remove_card (QEMUSoundCard *card);
CaptureVoiceOut *AUD_add_capture (
AudioState *s,
audsettings_t *as,
struct audsettings *as,
struct audio_capture_ops *ops,
void *opaque
);
Expand All @@ -112,7 +112,7 @@ SWVoiceOut *AUD_open_out (
const char *name,
void *callback_opaque,
audio_callback_fn_t callback_fn,
audsettings_t *settings
struct audsettings *settings
);

void AUD_close_out (QEMUSoundCard *card, SWVoiceOut *sw);
Expand All @@ -133,7 +133,7 @@ SWVoiceIn *AUD_open_in (
const char *name,
void *callback_opaque,
audio_callback_fn_t callback_fn,
audsettings_t *settings
struct audsettings *settings
);

void AUD_close_in (QEMUSoundCard *card, SWVoiceIn *sw);
Expand Down
20 changes: 10 additions & 10 deletions audio/audio_int.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct HWVoiceOut {
int rpos;
uint64_t ts_helper;

st_sample_t *mix_buf;
struct st_sample *mix_buf;

int samples;
LIST_HEAD (sw_out_listhead, SWVoiceOut) sw_head;
Expand All @@ -95,7 +95,7 @@ typedef struct HWVoiceIn {
int total_samples_captured;
uint64_t ts_helper;

st_sample_t *conv_buf;
struct st_sample *conv_buf;

int samples;
LIST_HEAD (sw_in_listhead, SWVoiceIn) sw_head;
Expand All @@ -107,14 +107,14 @@ struct SWVoiceOut {
struct audio_pcm_info info;
t_sample *conv;
int64_t ratio;
st_sample_t *buf;
struct st_sample *buf;
void *rate;
int total_hw_samples_mixed;
int active;
int empty;
HWVoiceOut *hw;
char *name;
volume_t vol;
struct mixeng_volume vol;
struct audio_callback callback;
LIST_ENTRY (SWVoiceOut) entries;
};
Expand All @@ -125,11 +125,11 @@ struct SWVoiceIn {
int64_t ratio;
void *rate;
int total_hw_samples_acquired;
st_sample_t *buf;
struct st_sample *buf;
f_sample *clip;
HWVoiceIn *hw;
char *name;
volume_t vol;
struct mixeng_volume vol;
struct audio_callback callback;
LIST_ENTRY (SWVoiceIn) entries;
};
Expand All @@ -149,13 +149,13 @@ struct audio_driver {
};

struct audio_pcm_ops {
int (*init_out)(HWVoiceOut *hw, audsettings_t *as);
int (*init_out)(HWVoiceOut *hw, struct audsettings *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, audsettings_t *as);
int (*init_in) (HWVoiceIn *hw, struct audsettings *as);
void (*fini_in) (HWVoiceIn *hw);
int (*run_in) (HWVoiceIn *hw);
int (*read) (SWVoiceIn *sw, void *buf, int size);
Expand Down Expand Up @@ -204,9 +204,9 @@ extern struct audio_driver coreaudio_audio_driver;
extern struct audio_driver dsound_audio_driver;
extern struct audio_driver esd_audio_driver;
extern struct audio_driver pa_audio_driver;
extern volume_t nominal_volume;
extern struct mixeng_volume nominal_volume;

void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as);
void audio_pcm_init_info (struct audio_pcm_info *info, struct audsettings *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);
Expand Down
20 changes: 11 additions & 9 deletions audio/audio_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static void glue (audio_pcm_hw_free_resources_, TYPE) (HW *hw)

static int glue (audio_pcm_hw_alloc_resources_, TYPE) (HW *hw)
{
HWBUF = audio_calloc (AUDIO_FUNC, hw->samples, sizeof (st_sample_t));
HWBUF = audio_calloc (AUDIO_FUNC, hw->samples, sizeof (struct st_sample));
if (!HWBUF) {
dolog ("Could not allocate " NAME " buffer (%d samples)\n",
hw->samples);
Expand Down Expand Up @@ -116,7 +116,7 @@ static int glue (audio_pcm_sw_alloc_resources_, TYPE) (SW *sw)
samples = ((int64_t) sw->hw->samples << 32) / sw->ratio;
#endif

sw->buf = audio_calloc (AUDIO_FUNC, samples, sizeof (st_sample_t));
sw->buf = audio_calloc (AUDIO_FUNC, samples, sizeof (struct st_sample));
if (!sw->buf) {
dolog ("Could not allocate buffer for `%s' (%d samples)\n",
SW_NAME (sw), samples);
Expand All @@ -140,7 +140,7 @@ static int glue (audio_pcm_sw_init_, TYPE) (
SW *sw,
HW *hw,
const char *name,
audsettings_t *as
struct audsettings *as
)
{
int err;
Expand Down Expand Up @@ -229,7 +229,7 @@ static HW *glue (audio_pcm_hw_find_any_enabled_, TYPE) (AudioState *s, HW *hw)
static HW *glue (audio_pcm_hw_find_specific_, TYPE) (
AudioState *s,
HW *hw,
audsettings_t *as
struct audsettings *as
)
{
while ((hw = glue (audio_pcm_hw_find_any_, TYPE) (s, hw))) {
Expand All @@ -240,7 +240,8 @@ static HW *glue (audio_pcm_hw_find_specific_, TYPE) (
return NULL;
}

static HW *glue (audio_pcm_hw_add_new_, TYPE) (AudioState *s, audsettings_t *as)
static HW *glue (audio_pcm_hw_add_new_, TYPE) (AudioState *s,
struct audsettings *as)
{
HW *hw;
struct audio_driver *drv = s->drv;
Expand Down Expand Up @@ -308,7 +309,8 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (AudioState *s, audsettings_t *as)
return NULL;
}

static HW *glue (audio_pcm_hw_add_, TYPE) (AudioState *s, audsettings_t *as)
static HW *glue (audio_pcm_hw_add_, TYPE) (AudioState *s,
struct audsettings *as)
{
HW *hw;

Expand All @@ -335,12 +337,12 @@ static HW *glue (audio_pcm_hw_add_, TYPE) (AudioState *s, audsettings_t *as)
static SW *glue (audio_pcm_create_voice_pair_, TYPE) (
AudioState *s,
const char *sw_name,
audsettings_t *as
struct audsettings *as
)
{
SW *sw;
HW *hw;
audsettings_t hw_as;
struct audsettings hw_as;

if (glue (conf.fixed_, TYPE).enabled) {
hw_as = glue (conf.fixed_, TYPE).settings;
Expand Down Expand Up @@ -405,7 +407,7 @@ SW *glue (AUD_open_, TYPE) (
const char *name,
void *callback_opaque ,
audio_callback_fn_t callback_fn,
audsettings_t *as
struct audsettings *as
)
{
AudioState *s;
Expand Down
4 changes: 2 additions & 2 deletions audio/coreaudio.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static OSStatus audioDeviceIOProc(
HWVoiceOut *hw = hwptr;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hwptr;
int rpos, live;
st_sample_t *src;
struct st_sample *src;
#ifndef FLOAT_MIXENG
#ifdef RECIPROCAL
const float scale = 1.f / UINT_MAX;
Expand Down Expand Up @@ -289,7 +289,7 @@ static int coreaudio_write (SWVoiceOut *sw, void *buf, int len)
return audio_pcm_sw_write (sw, buf, len);
}

static int coreaudio_init_out (HWVoiceOut *hw, audsettings_t *as)
static int coreaudio_init_out (HWVoiceOut *hw, struct audsettings *as)
{
OSStatus status;
coreaudioVoiceOut *core = (coreaudioVoiceOut *) hw;
Expand Down
6 changes: 3 additions & 3 deletions audio/dsound_template.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,16 +174,16 @@ static void dsound_fini_out (HWVoiceOut *hw)
}

#ifdef DSBTYPE_IN
static int dsound_init_in (HWVoiceIn *hw, audsettings_t *as)
static int dsound_init_in (HWVoiceIn *hw, struct audsettings *as)
#else
static int dsound_init_out (HWVoiceOut *hw, audsettings_t *as)
static int dsound_init_out (HWVoiceOut *hw, struct audsettings *as)
#endif
{
int err;
HRESULT hr;
dsound *s = &glob_dsound;
WAVEFORMATEX wfx;
audsettings_t obt_as;
struct audsettings obt_as;
#ifdef DSBTYPE_IN
const char *typ = "ADC";
DSoundVoiceIn *ds = (DSoundVoiceIn *) hw;
Expand Down
Loading

0 comments on commit 1ea879e

Please sign in to comment.