*/
#include <fmod.h>
#include <fmod_errors.h>
-#include "vl.h"
+#include "qemu-common.h"
+#include "audio.h"
#define AUDIO_CAP "fmod"
#include "audio_int.h"
{
va_list ap;
- AUD_log (AUDIO_CAP, "Can not initialize %s\n", typ);
+ AUD_log (AUDIO_CAP, "Could not initialize %s\n", typ);
va_start (ap, fmt);
AUD_vlog (AUDIO_CAP, fmt, ap);
int src_len1 = dst_len;
int src_len2 = 0;
int pos = hw->rpos + dst_len;
- st_sample_t *src1 = hw->mix_buf + hw->rpos;
- st_sample_t *src2 = NULL;
+ struct st_sample *src1 = hw->mix_buf + hw->rpos;
+ struct st_sample *src2 = NULL;
if (pos > hw->samples) {
src_len1 = hw->samples - hw->rpos;
if (src_len1) {
hw->clip (dst, src1, src_len1);
- mixeng_clear (src1, src_len1);
}
if (src_len2) {
dst = advance (dst, src_len1 << hw->info.shift);
hw->clip (dst, src2, src_len2);
- mixeng_clear (src2, src_len2);
}
hw->rpos = pos % hw->samples;
}
}
-static int fmod_init_out (HWVoiceOut *hw, int freq, int nchannels, audfmt_e fmt)
+static int fmod_init_out (HWVoiceOut *hw, struct audsettings *as)
{
int bits16, mode, channel;
FMODVoiceOut *fmd = (FMODVoiceOut *) hw;
+ struct audsettings obt_as = *as;
- mode = aud_to_fmodfmt (fmt, nchannels == 2 ? 1 : 0);
+ mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0);
fmd->fmod_sample = FSOUND_Sample_Alloc (
FSOUND_FREE, /* index */
conf.nb_samples, /* length */
mode, /* mode */
- freq, /* freq */
+ as->freq, /* freq */
255, /* volume */
128, /* pan */
255 /* priority */
fmd->channel = channel;
/* FMOD always operates on little endian frames? */
- audio_pcm_init_info (&hw->info, freq, nchannels, fmt,
- audio_need_to_swap_endian (0));
+ obt_as.endianness = 0;
+ audio_pcm_init_info (&hw->info, &obt_as);
bits16 = (mode & FSOUND_16BITS) != 0;
- hw->bufsize = conf.nb_samples << (nchannels == 2) << bits16;
+ hw->samples = conf.nb_samples;
return 0;
}
return 0;
}
-static int fmod_init_in (HWVoiceIn *hw, int freq, int nchannels, audfmt_e fmt)
+static int fmod_init_in (HWVoiceIn *hw, struct audsettings *as)
{
int bits16, mode;
FMODVoiceIn *fmd = (FMODVoiceIn *) hw;
+ struct audsettings obt_as = *as;
if (conf.broken_adc) {
return -1;
}
- mode = aud_to_fmodfmt (fmt, nchannels == 2 ? 1 : 0);
+ mode = aud_to_fmodfmt (as->fmt, as->nchannels == 2 ? 1 : 0);
fmd->fmod_sample = FSOUND_Sample_Alloc (
FSOUND_FREE, /* index */
conf.nb_samples, /* length */
mode, /* mode */
- freq, /* freq */
+ as->freq, /* freq */
255, /* volume */
128, /* pan */
255 /* priority */
}
/* FMOD always operates on little endian frames? */
- audio_pcm_init_info (&hw->info, freq, nchannels, fmt,
- audio_need_to_swap_endian (0));
+ obt_as.endianness = 0;
+ audio_pcm_init_info (&hw->info, &obt_as);
bits16 = (mode & FSOUND_16BITS) != 0;
- hw->bufsize = conf.nb_samples << (nchannels == 2) << bits16;
+ hw->samples = conf.nb_samples;
return 0;
}
new_pos = FSOUND_Record_GetPosition ();
if (new_pos < 0) {
- fmod_logerr ("Can not get recording position\n");
+ fmod_logerr ("Could not get recording position\n");
return 0;
}
if (drv) {
int found = 0;
- for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
if (!strcmp (drv, drvtab[i].name)) {
output_type = drvtab[i].type;
found = 1;
if (!found) {
dolog ("Unknown FMOD driver `%s'\n", drv);
dolog ("Valid drivers:\n");
- for (i = 0; i < sizeof (drvtab) / sizeof (drvtab[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE (drvtab); i++) {
dolog (" %s\n", drvtab[i].name);
}
}