aboutsummaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:43:59 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-02-10 15:43:59 -0800
commitc27f813900a3c114562efbb8df1065e94766fc48 (patch)
treed95919283707dcab61009e27007374a745c9541e /audio
parent0852ad57fa372f9b2854e4df685eaba8d8ef6790 (diff)
downloadexternal_qemu-c27f813900a3c114562efbb8df1065e94766fc48.zip
external_qemu-c27f813900a3c114562efbb8df1065e94766fc48.tar.gz
external_qemu-c27f813900a3c114562efbb8df1065e94766fc48.tar.bz2
auto import from //branches/cupcake/...@130745
Diffstat (limited to 'audio')
-rw-r--r--audio/alsaaudio.c39
-rw-r--r--audio/audio.c168
-rw-r--r--audio/audio.h9
-rw-r--r--audio/audio_int.h7
-rw-r--r--audio/audio_pt_int.c1
-rw-r--r--audio/audio_template.h4
-rw-r--r--audio/coreaudio.c3
-rw-r--r--audio/dsound_template.h9
-rw-r--r--audio/dsoundaudio.c24
-rw-r--r--audio/esdaudio.c5
-rw-r--r--audio/fmodaudio.c2
-rw-r--r--audio/mixeng.c97
-rw-r--r--audio/mixeng.h4
-rw-r--r--audio/noaudio.c2
-rw-r--r--audio/ossaudio.c1
-rw-r--r--audio/sdlaudio.c1
-rw-r--r--audio/wavaudio.c22
-rw-r--r--audio/wavcapture.c10
-rw-r--r--audio/winaudio.c4
19 files changed, 317 insertions, 95 deletions
diff --git a/audio/alsaaudio.c b/audio/alsaaudio.c
index cc43841..1cc4d6e 100644
--- a/audio/alsaaudio.c
+++ b/audio/alsaaudio.c
@@ -23,13 +23,13 @@
* THE SOFTWARE.
*/
#include <alsa/asoundlib.h>
-#include "vl.h"
+#include "audio.h"
#define AUDIO_CAP "alsa"
#include "audio_int.h"
#include <dlfcn.h>
#include <pthread.h>
-#include "android_debug.h"
+#include "qemu_debug.h"
#define DEBUG 1
@@ -59,6 +59,7 @@
DYNLINK_FUNC(size_t,snd_pcm_hw_params_sizeof,(void)) \
DYNLINK_FUNC(int,snd_pcm_hw_params_any,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params)) \
DYNLINK_FUNC(int,snd_pcm_hw_params_set_access,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_access_t _access)) \
+ DYNLINK_FUNC(int,snd_pcm_hw_params_get_format,(const snd_pcm_hw_params_t *params, snd_pcm_format_t *val)) \
DYNLINK_FUNC(int,snd_pcm_hw_params_set_format,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, snd_pcm_format_t val)) \
DYNLINK_FUNC(int,snd_pcm_hw_params_set_rate_near,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val, int *dir)) \
DYNLINK_FUNC(int,snd_pcm_hw_params_set_channels_near,(snd_pcm_t *pcm, snd_pcm_hw_params_t *params, unsigned int *val)) \
@@ -194,7 +195,7 @@ static int alsa_write (SWVoiceOut *sw, void *buf, int len)
return audio_pcm_sw_write (sw, buf, len);
}
-static int aud_to_alsafmt (audfmt_e fmt)
+static snd_pcm_format_t aud_to_alsafmt (audfmt_e fmt)
{
switch (fmt) {
case AUD_FMT_S8:
@@ -209,6 +210,12 @@ static int aud_to_alsafmt (audfmt_e fmt)
case AUD_FMT_U16:
return SND_PCM_FORMAT_U16_LE;
+ case AUD_FMT_S32:
+ return SND_PCM_FORMAT_S32_LE;
+
+ case AUD_FMT_U32:
+ return SND_PCM_FORMAT_U32_LE;
+
default:
dolog ("Internal logic error: Bad audio format %d\n", fmt);
#ifdef DEBUG_AUDIO
@@ -252,6 +259,26 @@ static int alsa_to_audfmt (snd_pcm_format_t alsafmt, audfmt_e *fmt,
*fmt = AUD_FMT_U16;
break;
+ case SND_PCM_FORMAT_S32_LE:
+ *endianness = 0;
+ *fmt = AUD_FMT_S32;
+ break;
+
+ case SND_PCM_FORMAT_U32_LE:
+ *endianness = 0;
+ *fmt = AUD_FMT_U32;
+ break;
+
+ case SND_PCM_FORMAT_S32_BE:
+ *endianness = 1;
+ *fmt = AUD_FMT_S32;
+ break;
+
+ case SND_PCM_FORMAT_U32_BE:
+ *endianness = 1;
+ *fmt = AUD_FMT_U32;
+ break;
+
default:
dolog ("Unrecognized audio format %d\n", alsafmt);
return -1;
@@ -468,6 +495,7 @@ static int alsa_open (int in, struct alsa_params_req *req,
}
err = FF(snd_pcm_hw_params_get_format)(hw_params, &obtfmt);
+ err = FF(snd_pcm_hw_params_get_format) (hw_params, &obtfmt);
if (err < 0) {
alsa_logerr2 (err, typ, "Failed to get format\n");
goto err;
@@ -499,6 +527,11 @@ static int alsa_open (int in, struct alsa_params_req *req,
case AUD_FMT_U16:
bytes_per_sec <<= 1;
break;
+
+ case AUD_FMT_S32:
+ case AUD_FMT_U32:
+ bytes_per_sec <<= 2;
+ break;
}
threshold = (conf.threshold * bytes_per_sec) / 1000;
diff --git a/audio/audio.c b/audio/audio.c
index 4ba1f7d..5a77dac 100644
--- a/audio/audio.c
+++ b/audio/audio.c
@@ -22,12 +22,17 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "vl.h"
+#include "hw/hw.h"
+#include "audio.h"
+#include "console.h"
+#include "qemu-timer.h"
+#include "sysemu.h"
#define AUDIO_CAP "audio"
#include "audio_int.h"
-#include "android_utils.h"
-#include "android.h"
+#include "android/utils/system.h"
+#include "qemu_debug.h"
+#include "android/android.h"
/* #define DEBUG_PLIVE */
/* #define DEBUG_LIVE */
@@ -161,7 +166,8 @@ static struct {
{
44100, /* freq */
2, /* nchannels */
- AUD_FMT_S16 /* fmt */
+ AUD_FMT_S16, /* fmt */
+ AUDIO_HOST_ENDIANNESS
}
},
@@ -172,7 +178,8 @@ static struct {
{
44100, /* freq */
2, /* nchannels */
- AUD_FMT_S16 /* fmt */
+ AUD_FMT_S16, /* fmt */
+ AUDIO_HOST_ENDIANNESS
}
},
@@ -189,8 +196,8 @@ volume_t nominal_volume = {
1.0,
1.0
#else
- UINT_MAX,
- UINT_MAX
+ 1ULL << 32,
+ 1ULL << 32
#endif
};
@@ -247,6 +254,25 @@ int audio_bug (const char *funcname, int cond)
}
#endif
+static inline int audio_bits_to_index (int bits)
+{
+ switch (bits) {
+ case 8:
+ return 0;
+
+ case 16:
+ return 1;
+
+ case 32:
+ return 2;
+
+ default:
+ audio_bug ("bits_to_index", 1);
+ AUD_log (NULL, "invalid bits %d\n", bits);
+ return 0;
+ }
+}
+
void *audio_calloc (const char *funcname, int nmemb, size_t size)
{
int cond;
@@ -294,7 +320,7 @@ static char *audio_alloc_prefix (const char *s)
return r;
}
-const char *audio_audfmt_to_string (audfmt_e fmt)
+static const char *audio_audfmt_to_string (audfmt_e fmt)
{
switch (fmt) {
case AUD_FMT_U8:
@@ -308,13 +334,20 @@ const char *audio_audfmt_to_string (audfmt_e fmt)
case AUD_FMT_S16:
return "S16";
+
+ case AUD_FMT_U32:
+ return "U32";
+
+ case AUD_FMT_S32:
+ return "S32";
}
dolog ("Bogus audfmt %d returning S16\n", fmt);
return "S16";
}
-audfmt_e audio_string_to_audfmt (const char *s, audfmt_e defval, int *defaultp)
+static audfmt_e audio_string_to_audfmt (const char *s, audfmt_e defval,
+ int *defaultp)
{
if (!strcasecmp (s, "u8")) {
*defaultp = 0;
@@ -324,6 +357,10 @@ audfmt_e audio_string_to_audfmt (const char *s, audfmt_e defval, int *defaultp)
*defaultp = 0;
return AUD_FMT_U16;
}
+ else if (!strcasecmp (s, "u32")) {
+ *defaultp = 0;
+ return AUD_FMT_U32;
+ }
else if (!strcasecmp (s, "s8")) {
*defaultp = 0;
return AUD_FMT_S8;
@@ -332,6 +369,10 @@ audfmt_e audio_string_to_audfmt (const char *s, audfmt_e defval, int *defaultp)
*defaultp = 0;
return AUD_FMT_S16;
}
+ else if (!strcasecmp (s, "s32")) {
+ *defaultp = 0;
+ return AUD_FMT_S32;
+ }
else {
dolog ("Bogus audio format `%s' using %s\n",
s, audio_audfmt_to_string (defval));
@@ -439,7 +480,7 @@ static void audio_print_options (const char *prefix,
const char *state = "default";
printf (" %s_%s: ", uprefix, opt->name);
- if (opt->overridenp && *opt->overridenp) {
+ if (opt->overriddenp && *opt->overriddenp) {
state = "current";
}
@@ -462,7 +503,7 @@ static void audio_print_options (const char *prefix,
{
audfmt_e *fmtp = opt->valp;
printf (
- "format, %s = %s, (one of: U8 S8 U16 S16)\n",
+ "format, %s = %s, (one of: U8 S8 U16 S16 U32 S32)\n",
state,
audio_audfmt_to_string (*fmtp)
);
@@ -569,10 +610,10 @@ static void audio_process_options (const char *prefix,
break;
}
- if (!opt->overridenp) {
- opt->overridenp = &opt->overriden;
+ if (!opt->overriddenp) {
+ opt->overriddenp = &opt->overridden;
}
- *opt->overridenp = !def;
+ *opt->overriddenp = !def;
qemu_free (optname);
}
}
@@ -626,6 +667,8 @@ static int audio_validate_settings (audsettings_t *as)
case AUD_FMT_U8:
case AUD_FMT_S16:
case AUD_FMT_U16:
+ case AUD_FMT_S32:
+ case AUD_FMT_U32:
break;
default:
invalid = 1;
@@ -651,6 +694,11 @@ static int audio_pcm_info_eq (struct audio_pcm_info *info, audsettings_t *as)
case AUD_FMT_U16:
bits = 16;
break;
+ case AUD_FMT_S32:
+ sign = 1;
+ case AUD_FMT_U32:
+ bits = 32;
+ break;
}
return info->freq == as->freq
&& info->nchannels == as->nchannels
@@ -661,7 +709,7 @@ static int audio_pcm_info_eq (struct audio_pcm_info *info, audsettings_t *as)
void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as)
{
- int bits = 8, sign = 0;
+ int bits = 8, sign = 0, shift = 0;
switch (as->fmt) {
case AUD_FMT_S8:
@@ -673,6 +721,14 @@ void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as)
sign = 1;
case AUD_FMT_U16:
bits = 16;
+ shift = 1;
+ break;
+
+ case AUD_FMT_S32:
+ sign = 1;
+ case AUD_FMT_U32:
+ bits = 32;
+ shift = 2;
break;
}
@@ -680,7 +736,7 @@ void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as)
info->bits = bits;
info->sign = sign;
info->nchannels = as->nchannels;
- info->shift = (as->nchannels == 2) + (bits == 16);
+ info->shift = (as->nchannels == 2) + shift;
info->align = (1 << info->shift) - 1;
info->bytes_per_second = info->freq << info->shift;
info->swap_endianness = (as->endianness != AUDIO_HOST_ENDIANNESS);
@@ -693,25 +749,52 @@ void audio_pcm_info_clear_buf (struct audio_pcm_info *info, void *buf, int len)
}
if (info->sign) {
- memset (buf, 0x80, len << info->shift);
+ memset (buf, 0x00, len << info->shift);
}
else {
- if (info->bits == 8) {
+ switch (info->bits) {
+ case 8:
memset (buf, 0x80, len << info->shift);
- }
- else {
- int i;
- uint16_t *p = buf;
- int shift = info->nchannels - 1;
- short s = INT16_MAX;
+ break;
- if (info->swap_endianness) {
- s = bswap16 (s);
+ case 16:
+ {
+ int i;
+ uint16_t *p = buf;
+ int shift = info->nchannels - 1;
+ short s = INT16_MAX;
+
+ if (info->swap_endianness) {
+ s = bswap16 (s);
+ }
+
+ for (i = 0; i < len << shift; i++) {
+ p[i] = s;
+ }
}
+ break;
- for (i = 0; i < len << shift; i++) {
- p[i] = s;
+ case 32:
+ {
+ int i;
+ uint32_t *p = buf;
+ int shift = info->nchannels - 1;
+ int32_t s = INT32_MAX;
+
+ if (info->swap_endianness) {
+ s = bswap32 (s);
+ }
+
+ for (i = 0; i < len << shift; i++) {
+ p[i] = s;
+ }
}
+ break;
+
+ default:
+ AUD_log (NULL, "audio_pcm_info_clear_buf: invalid bits %d\n",
+ info->bits);
+ break;
}
}
}
@@ -1508,7 +1591,7 @@ static void audio_run_capture (AudioState *s)
static void audio_timer (void *opaque)
{
- AudioState* s = opaque;
+ AudioState* s = opaque;
#if 0
#define MAX_DIFFS 1000
int64_t now = qemu_get_clock(vm_clock);
@@ -1586,7 +1669,7 @@ static struct audio_option audio_options[] = {
"(undocumented)", NULL, 0},
{"LOG_TO_MONITOR", AUD_OPT_BOOL, &conf.log_to_monitor,
- "print logging messages to montior instead of stderr", NULL, 0},
+ "print logging messages to monitor instead of stderr", NULL, 0},
{NULL, 0, NULL, NULL, NULL, 0}
};
@@ -2011,7 +2094,7 @@ CaptureVoiceOut *AUD_add_capture (
[hw->info.nchannels == 2]
[hw->info.sign]
[hw->info.swap_endianness]
- [hw->info.bits == 16];
+ [audio_bits_to_index (hw->info.bits)];
LIST_INSERT_HEAD (&s->cap_head, cap, entries);
LIST_INSERT_HEAD (&cap->cb_head, cb, entries);
@@ -2045,16 +2128,21 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
if (!cap->cb_head.lh_first) {
SWVoiceOut *sw = cap->hw.sw_head.lh_first, *sw1;
+
while (sw) {
+ SWVoiceCap *sc = (SWVoiceCap *) sw;
#ifdef DEBUG_CAPTURE
dolog ("freeing %s\n", sw->name);
#endif
+
sw1 = sw->entries.le_next;
if (sw->rate) {
st_rate_stop (sw->rate);
sw->rate = NULL;
}
LIST_REMOVE (sw, entries);
+ LIST_REMOVE (sc, entries);
+ qemu_free (sc);
sw = sw1;
}
LIST_REMOVE (cap, entries);
@@ -2064,3 +2152,21 @@ void AUD_del_capture (CaptureVoiceOut *cap, void *cb_opaque)
}
}
}
+
+void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol)
+{
+ if (sw) {
+ sw->vol.mute = mute;
+ sw->vol.l = nominal_volume.l * lvol / 255;
+ sw->vol.r = nominal_volume.r * rvol / 255;
+ }
+}
+
+void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol)
+{
+ if (sw) {
+ sw->vol.mute = mute;
+ sw->vol.l = nominal_volume.l * lvol / 255;
+ sw->vol.r = nominal_volume.r * rvol / 255;
+ }
+}
diff --git a/audio/audio.h b/audio/audio.h
index cc7aa04..2c347bf 100644
--- a/audio/audio.h
+++ b/audio/audio.h
@@ -25,6 +25,7 @@
#define QEMU_AUDIO_H
#include "config.h"
+#include "qemu-common.h"
#include "sys-queue.h"
typedef void (*audio_callback_fn_t) (void *opaque, int avail);
@@ -33,7 +34,9 @@ typedef enum {
AUD_FMT_U8,
AUD_FMT_S8,
AUD_FMT_U16,
- AUD_FMT_S16
+ AUD_FMT_S16,
+ AUD_FMT_U32,
+ AUD_FMT_S32
} audfmt_e;
#ifdef WORDS_BIGENDIAN
@@ -71,7 +74,6 @@ typedef struct CaptureState {
LIST_ENTRY (CaptureState) entries;
} CaptureState;
-typedef struct AudioState AudioState;
typedef struct SWVoiceOut SWVoiceOut;
typedef struct CaptureVoiceOut CaptureVoiceOut;
typedef struct SWVoiceIn SWVoiceIn;
@@ -125,6 +127,9 @@ int AUD_is_active_out (SWVoiceOut *sw);
void AUD_init_time_stamp_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
uint64_t AUD_get_elapsed_usec_out (SWVoiceOut *sw, QEMUAudioTimeStamp *ts);
+void AUD_set_volume_out (SWVoiceOut *sw, int mute, uint8_t lvol, uint8_t rvol);
+void AUD_set_volume_in (SWVoiceIn *sw, int mute, uint8_t lvol, uint8_t rvol);
+
SWVoiceIn *AUD_open_in (
QEMUSoundCard *card,
SWVoiceIn *sw,
diff --git a/audio/audio_int.h b/audio/audio_int.h
index 099bcbd..6677ec1 100644
--- a/audio/audio_int.h
+++ b/audio/audio_int.h
@@ -24,6 +24,8 @@
#ifndef QEMU_AUDIO_INT_H
#define QEMU_AUDIO_INT_H
+#include "audio/audio.h"
+
#ifdef CONFIG_COREAUDIO
#define FLOAT_MIXENG
/* #define RECIPROCAL */
@@ -44,8 +46,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 {
@@ -206,6 +208,7 @@ extern struct audio_driver esd_audio_driver;
extern struct audio_driver alsa_audio_driver;
extern struct audio_driver coreaudio_audio_driver;
extern struct audio_driver dsound_audio_driver;
+extern struct audio_driver esd_audio_driver;
extern volume_t nominal_volume;
void audio_pcm_init_info (struct audio_pcm_info *info, audsettings_t *as);
diff --git a/audio/audio_pt_int.c b/audio/audio_pt_int.c
index 3f01762..c753774 100644
--- a/audio/audio_pt_int.c
+++ b/audio/audio_pt_int.c
@@ -1,4 +1,3 @@
-#include "vl.h"
#include "audio.h"
#define AUDIO_CAP "audio-pt"
diff --git a/audio/audio_template.h b/audio/audio_template.h
index 4575a56..6f8e166 100644
--- a/audio/audio_template.h
+++ b/audio/audio_template.h
@@ -164,7 +164,7 @@ static int glue (audio_pcm_sw_init_, TYPE) (
[sw->info.nchannels == 2]
[sw->info.sign]
[sw->info.swap_endianness]
- [sw->info.bits == 16];
+ [audio_bits_to_index (sw->info.bits)];
sw->name = qemu_strdup (name);
err = glue (audio_pcm_sw_alloc_resources_, TYPE) (sw);
@@ -293,7 +293,7 @@ static HW *glue (audio_pcm_hw_add_new_, TYPE) (AudioState *s, audsettings_t *as)
[hw->info.nchannels == 2]
[hw->info.sign]
[hw->info.swap_endianness]
- [hw->info.bits == 16];
+ [audio_bits_to_index (hw->info.bits)];
if (glue (audio_pcm_hw_alloc_resources_, TYPE) (hw)) {
goto err1;
diff --git a/audio/coreaudio.c b/audio/coreaudio.c
index cf3eaf9..f23ebee 100644
--- a/audio/coreaudio.c
+++ b/audio/coreaudio.c
@@ -27,7 +27,7 @@
#include <string.h> /* strerror */
#include <pthread.h> /* pthread_X */
-#include "vl.h"
+#include "audio.h"
#define AUDIO_CAP "coreaudio"
#include "audio_int.h"
@@ -628,7 +628,6 @@ coreaudio_run_in (HWVoiceIn *hw)
if (coreaudio_voice_lock (core, "coreaudio_run_in")) {
return 0;
}
-
D("%s: core.decr=%d core.pos=%d\n", __FUNCTION__, core->decr, core->pos);
decr = core->decr;
core->decr -= decr;
diff --git a/audio/dsound_template.h b/audio/dsound_template.h
index 0896b04..9cc0b9d 100644
--- a/audio/dsound_template.h
+++ b/audio/dsound_template.h
@@ -23,16 +23,20 @@
*/
#ifdef DSBTYPE_IN
#define NAME "capture buffer"
+#define NAME2 "DirectSoundCapture"
#define TYPE in
#define IFACE IDirectSoundCaptureBuffer
#define BUFPTR LPDIRECTSOUNDCAPTUREBUFFER
#define FIELD dsound_capture_buffer
+#define FIELD2 dsound_capture
#else
#define NAME "playback buffer"
+#define NAME2 "DirectSound"
#define TYPE out
#define IFACE IDirectSoundBuffer
#define BUFPTR LPDIRECTSOUNDBUFFER
#define FIELD dsound_buffer
+#define FIELD2 dsound
#endif
static int glue (dsound_unlock_, TYPE) (
@@ -192,6 +196,11 @@ static int dsound_init_out (HWVoiceOut *hw, audsettings_t *as)
DSBCAPS bc;
#endif
+ if (!s->FIELD2) {
+ dolog ("Attempt to initialize voice without " NAME2 " object\n");
+ return -1;
+ }
+
err = waveformat_from_audio_settings (&wfx, as);
if (err) {
return -1;
diff --git a/audio/dsoundaudio.c b/audio/dsoundaudio.c
index 6104acb..8284067 100644
--- a/audio/dsoundaudio.c
+++ b/audio/dsoundaudio.c
@@ -26,12 +26,14 @@
* SEAL 1.07 by Carlos 'pel' Hasan was used as documentation
*/
-#include "vl.h"
+#include "audio.h"
#define AUDIO_CAP "dsound"
#include "audio_int.h"
+#define WIN32_LEAN_AND_MEAN
#include <windows.h>
+#include <mmsystem.h>
#include <objbase.h>
#include <dsound.h>
@@ -317,23 +319,22 @@ static int waveformat_from_audio_settings (WAVEFORMATEX *wfx, audsettings_t *as)
switch (as->fmt) {
case AUD_FMT_S8:
- wfx->wBitsPerSample = 8;
- break;
-
case AUD_FMT_U8:
wfx->wBitsPerSample = 8;
break;
case AUD_FMT_S16:
+ case AUD_FMT_U16:
wfx->wBitsPerSample = 16;
wfx->nAvgBytesPerSec <<= 1;
wfx->nBlockAlign <<= 1;
break;
- case AUD_FMT_U16:
- wfx->wBitsPerSample = 16;
- wfx->nAvgBytesPerSec <<= 1;
- wfx->nBlockAlign <<= 1;
+ case AUD_FMT_S32:
+ case AUD_FMT_U32:
+ wfx->wBitsPerSample = 32;
+ wfx->nAvgBytesPerSec <<= 2;
+ wfx->nBlockAlign <<= 2;
break;
default:
@@ -384,8 +385,13 @@ static int waveformat_to_audio_settings (WAVEFORMATEX *wfx, audsettings_t *as)
as->fmt = AUD_FMT_S16;
break;
+ case 32:
+ as->fmt = AUD_FMT_S32;
+ break;
+
default:
- dolog ("Invalid wave format, bits per sample is not 8 or 16, but %d\n",
+ dolog ("Invalid wave format, bits per sample is not "
+ "8, 16 or 32, but %d\n",
wfx->wBitsPerSample);
return -1;
}
diff --git a/audio/esdaudio.c b/audio/esdaudio.c
index 35d6b45..05c030f 100644
--- a/audio/esdaudio.c
+++ b/audio/esdaudio.c
@@ -24,7 +24,6 @@
*/
#include <esd.h>
-#include "vl.h"
#include "audio.h"
#include <signal.h>
@@ -33,7 +32,7 @@
#include "audio_pt_int.h"
#include <dlfcn.h>
-#include "android_debug.h"
+#include "qemu_debug.h"
#define DEBUG 1
@@ -494,14 +493,12 @@ static int qesd_init_in (HWVoiceIn *hw, audsettings_t *as)
esdfmt |= ESD_BITS16;
obt_as.fmt = AUD_FMT_S16;
break;
-#if 0
case AUD_FMT_S32:
case AUD_FMT_U32:
dolog ("Will use 16 instead of 32 bit samples\n");
esdfmt |= ESD_BITS16;
obt_as.fmt = AUD_FMT_S16;
break;
-#endif
}
obt_as.endianness = AUDIO_HOST_ENDIANNESS;
diff --git a/audio/fmodaudio.c b/audio/fmodaudio.c
index 5875ba1..e230e8b 100644
--- a/audio/fmodaudio.c
+++ b/audio/fmodaudio.c
@@ -23,7 +23,7 @@
*/
#include <fmod.h>
#include <fmod_errors.h>
-#include "vl.h"
+#include "audio.h"
#define AUDIO_CAP "fmod"
#include "audio_int.h"
diff --git a/audio/mixeng.c b/audio/mixeng.c
index 6308d41..34fc6df 100644
--- a/audio/mixeng.c
+++ b/audio/mixeng.c
@@ -22,7 +22,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "vl.h"
+#include "audio.h"
#define AUDIO_CAP "mixeng"
#include "audio_int.h"
@@ -82,6 +82,7 @@
#undef IN_T
#undef SHIFT
+/* Unsigned 16 bit */
#define IN_T uint16_t
#define IN_MIN 0
#define IN_MAX USHRT_MAX
@@ -101,26 +102,72 @@
#undef IN_T
#undef SHIFT
-t_sample *mixeng_conv[2][2][2][2] = {
+/* Signed 32 bit */
+#define IN_T int32_t
+#define IN_MIN INT32_MIN
+#define IN_MAX INT32_MAX
+#define SIGNED
+#define SHIFT 32
+#define ENDIAN_CONVERSION natural
+#define ENDIAN_CONVERT(v) (v)
+#include "mixeng_template.h"
+#undef ENDIAN_CONVERT
+#undef ENDIAN_CONVERSION
+#define ENDIAN_CONVERSION swap
+#define ENDIAN_CONVERT(v) bswap32 (v)
+#include "mixeng_template.h"
+#undef ENDIAN_CONVERT
+#undef ENDIAN_CONVERSION
+#undef SIGNED
+#undef IN_MAX
+#undef IN_MIN
+#undef IN_T
+#undef SHIFT
+
+/* Unsigned 16 bit */
+#define IN_T uint32_t
+#define IN_MIN 0
+#define IN_MAX UINT32_MAX
+#define SHIFT 32
+#define ENDIAN_CONVERSION natural
+#define ENDIAN_CONVERT(v) (v)
+#include "mixeng_template.h"
+#undef ENDIAN_CONVERT
+#undef ENDIAN_CONVERSION
+#define ENDIAN_CONVERSION swap
+#define ENDIAN_CONVERT(v) bswap32 (v)
+#include "mixeng_template.h"
+#undef ENDIAN_CONVERT
+#undef ENDIAN_CONVERSION
+#undef IN_MAX
+#undef IN_MIN
+#undef IN_T
+#undef SHIFT
+
+t_sample *mixeng_conv[2][2][2][3] = {
{
{
{
conv_natural_uint8_t_to_mono,
- conv_natural_uint16_t_to_mono
+ conv_natural_uint16_t_to_mono,
+ conv_natural_uint32_t_to_mono
},
{
conv_natural_uint8_t_to_mono,
- conv_swap_uint16_t_to_mono
+ conv_swap_uint16_t_to_mono,
+ conv_swap_uint32_t_to_mono,
}
},
{
{
conv_natural_int8_t_to_mono,
- conv_natural_int16_t_to_mono
+ conv_natural_int16_t_to_mono,
+ conv_natural_int32_t_to_mono
},
{
conv_natural_int8_t_to_mono,
- conv_swap_int16_t_to_mono
+ conv_swap_int16_t_to_mono,
+ conv_swap_int32_t_to_mono
}
}
},
@@ -128,46 +175,54 @@ t_sample *mixeng_conv[2][2][2][2] = {
{
{
conv_natural_uint8_t_to_stereo,
- conv_natural_uint16_t_to_stereo
+ conv_natural_uint16_t_to_stereo,
+ conv_natural_uint32_t_to_stereo
},
{
conv_natural_uint8_t_to_stereo,
- conv_swap_uint16_t_to_stereo
+ conv_swap_uint16_t_to_stereo,
+ conv_swap_uint32_t_to_stereo
}
},
{
{
conv_natural_int8_t_to_stereo,
- conv_natural_int16_t_to_stereo
+ conv_natural_int16_t_to_stereo,
+ conv_natural_int32_t_to_stereo
},
{
conv_natural_int8_t_to_stereo,
- conv_swap_int16_t_to_stereo
+ conv_swap_int16_t_to_stereo,
+ conv_swap_int32_t_to_stereo,
}
}
}
};
-f_sample *mixeng_clip[2][2][2][2] = {
+f_sample *mixeng_clip[2][2][2][3] = {
{
{
{
clip_natural_uint8_t_from_mono,
- clip_natural_uint16_t_from_mono
+ clip_natural_uint16_t_from_mono,
+ clip_natural_uint32_t_from_mono
},
{
clip_natural_uint8_t_from_mono,
- clip_swap_uint16_t_from_mono
+ clip_swap_uint16_t_from_mono,
+ clip_swap_uint32_t_from_mono
}
},
{
{
clip_natural_int8_t_from_mono,
- clip_natural_int16_t_from_mono
+ clip_natural_int16_t_from_mono,
+ clip_natural_int32_t_from_mono
},
{
clip_natural_int8_t_from_mono,
- clip_swap_int16_t_from_mono
+ clip_swap_int16_t_from_mono,
+ clip_swap_int32_t_from_mono
}
}
},
@@ -175,21 +230,25 @@ f_sample *mixeng_clip[2][2][2][2] = {
{
{
clip_natural_uint8_t_from_stereo,
- clip_natural_uint16_t_from_stereo
+ clip_natural_uint16_t_from_stereo,
+ clip_natural_uint32_t_from_stereo
},
{
clip_natural_uint8_t_from_stereo,
- clip_swap_uint16_t_from_stereo
+ clip_swap_uint16_t_from_stereo,
+ clip_swap_uint32_t_from_stereo
}
},
{
{
clip_natural_int8_t_from_stereo,
- clip_natural_int16_t_from_stereo
+ clip_natural_int16_t_from_stereo,
+ clip_natural_int32_t_from_stereo
},
{
clip_natural_int8_t_from_stereo,
- clip_swap_int16_t_from_stereo
+ clip_swap_int16_t_from_stereo,
+ clip_swap_int32_t_from_stereo
}
}
}
diff --git a/audio/mixeng.h b/audio/mixeng.h
index 9e3bac1..95b68df 100644
--- a/audio/mixeng.h
+++ b/audio/mixeng.h
@@ -37,8 +37,8 @@ typedef void (t_sample) (st_sample_t *dst, const void *src,
int samples, volume_t *vol);
typedef void (f_sample) (void *dst, const st_sample_t *src, int samples);
-extern t_sample *mixeng_conv[2][2][2][2];
-extern f_sample *mixeng_clip[2][2][2][2];
+extern t_sample *mixeng_conv[2][2][2][3];
+extern f_sample *mixeng_clip[2][2][2][3];
void *st_rate_start (int inrate, int outrate);
void st_rate_flow (void *opaque, st_sample_t *ibuf, st_sample_t *obuf,
diff --git a/audio/noaudio.c b/audio/noaudio.c
index 3567e9c..8788a41 100644
--- a/audio/noaudio.c
+++ b/audio/noaudio.c
@@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "vl.h"
+#include "qemu-timer.h"
#define AUDIO_CAP "noaudio"
#include "audio_int.h"
diff --git a/audio/ossaudio.c b/audio/ossaudio.c
index 17d676a..2ccaade 100644
--- a/audio/ossaudio.c
+++ b/audio/ossaudio.c
@@ -25,7 +25,6 @@
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/soundcard.h>
-#include "vl.h"
#define AUDIO_CAP "oss"
#include "audio_int.h"
diff --git a/audio/sdlaudio.c b/audio/sdlaudio.c
index eb353d7..ea5bccd 100644
--- a/audio/sdlaudio.c
+++ b/audio/sdlaudio.c
@@ -23,7 +23,6 @@
*/
#include <SDL.h>
#include <SDL_thread.h>
-#include "vl.h"
#ifndef _WIN32
#ifdef __sun__
diff --git a/audio/wavaudio.c b/audio/wavaudio.c
index 7d4fed1..8a500b9 100644
--- a/audio/wavaudio.c
+++ b/audio/wavaudio.c
@@ -22,10 +22,10 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "vl.h"
-
#define AUDIO_CAP "wav"
+#include "qemu-timer.h"
#include "audio_int.h"
+#include "qemu_file.h"
#define WAV_AUDIO_IN 1
@@ -46,7 +46,8 @@ static struct {
{
44100,
2,
- AUD_FMT_S16
+ AUD_FMT_S16,
+ 0
},
"qemu.wav"
};
@@ -136,6 +137,11 @@ static int wav_out_init (HWVoiceOut *hw, audsettings_t *as)
case AUD_FMT_U16:
bits16 = 1;
break;
+
+ case AUD_FMT_S32:
+ case AUD_FMT_U32:
+ dolog ("WAVE files can not handle 32bit formats\n");
+ return -1;
}
hdr[34] = bits16 ? 0x10 : 0x08;
@@ -156,7 +162,7 @@ static int wav_out_init (HWVoiceOut *hw, audsettings_t *as)
le_store (hdr + 28, hw->info.freq << (bits16 + stereo), 4);
le_store (hdr + 32, 1 << (bits16 + stereo), 2);
- wav->f = fopen (conf_out.wav_path, "wb");
+ wav->f = qemu_fopen (conf_out.wav_path, "wb");
if (!wav->f) {
dolog ("Failed to open wave file `%s'\nReason: %s\n",
conf_out.wav_path, strerror (errno));
@@ -190,7 +196,7 @@ static void wav_out_fini (HWVoiceOut *hw)
qemu_fseek (wav->f, 32, SEEK_CUR);
qemu_put_buffer (wav->f, dlen, 4);
- fclose (wav->f);
+ qemu_fclose (wav->f);
wav->f = NULL;
qemu_free (wav->pcm_buf);
@@ -247,7 +253,7 @@ wav_in_init (HWVoiceIn *hw, audsettings_t *as)
audsettings_t wav_as = *as;
int nchannels, freq, format, bits;
- wav->f = fopen (path, "rb");
+ wav->f = qemu_fopen (path, "rb");
if (wav->f == NULL) {
dolog("Failed to open wave file '%s'\nReason: %s\n", path,
strerror(errno));
@@ -316,7 +322,7 @@ wav_in_init (HWVoiceIn *hw, audsettings_t *as)
return 0;
Fail:
- fclose (wav->f);
+ qemu_fclose (wav->f);
wav->f = NULL;
return -1;
}
@@ -330,7 +336,7 @@ static void wav_in_fini (HWVoiceIn *hw)
return;
}
- fclose (wav->f);
+ qemu_fclose (wav->f);
wav->f = NULL;
qemu_free (wav->pcm_buf);
diff --git a/audio/wavcapture.c b/audio/wavcapture.c
index 748b580..d6f733e 100644
--- a/audio/wavcapture.c
+++ b/audio/wavcapture.c
@@ -1,4 +1,6 @@
-#include "vl.h"
+#include "audio/audio.h"
+#include "qemu_file.h"
+#include "console.h"
typedef struct {
QEMUFile *f;
@@ -46,7 +48,7 @@ static void wav_destroy (void *opaque)
qemu_fseek (wav->f, 32, SEEK_CUR);
qemu_put_buffer (wav->f, dlen, 4);
- fclose (wav->f);
+ qemu_fclose (wav->f);
if (wav->path) {
qemu_free (wav->path);
}
@@ -133,7 +135,7 @@ int wav_start_capture (CaptureState *s, const char *path, int freq,
le_store (hdr + 28, freq << shift, 4);
le_store (hdr + 32, 1 << shift, 2);
- wav->f = fopen (path, "wb");
+ wav->f = qemu_fopen (path, "wb");
if (!wav->f) {
term_printf ("Failed to open wave file `%s'\nReason: %s\n",
path, strerror (errno));
@@ -151,6 +153,8 @@ int wav_start_capture (CaptureState *s, const char *path, int freq,
cap = AUD_add_capture (NULL, &as, &ops, wav);
if (!cap) {
term_printf ("Failed to add audio capture\n");
+ qemu_free (wav->path);
+ qemu_fclose (wav->f);
qemu_free (wav);
return -1;
}
diff --git a/audio/winaudio.c b/audio/winaudio.c
index 63cd351..6e8daef 100644
--- a/audio/winaudio.c
+++ b/audio/winaudio.c
@@ -1,7 +1,7 @@
/*
* QEMU "simple" Windows audio driver
*
- * Copyright (c) 2007 The Android Open Source Project
+ * Copyright (c) 2007 The Android Open Source Project
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -21,8 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
-#include "vl.h"
-
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <mmsystem.h>