* [Qemu-devel] Re: esd audio output patch and debuging.
2006-08-30 15:45 [Qemu-devel] " Frederick Reeve
@ 2006-08-31 11:46 ` malc
2006-08-31 17:19 ` Leonardo E. Reiter
0 siblings, 1 reply; 10+ messages in thread
From: malc @ 2006-08-31 11:46 UTC (permalink / raw)
To: qemu-devel
Frederick Reeve <cylix <at> solace.info> writes:
>
> Hello.
>
> Attached you will find a patch for esd audio support in QEMU. It is more or
less a large modification of
> audio/wavaudio.c. The patch will apply against the latest tarball release
> http://fabrice.bellard.free.fr/qemu/qemu-0.8.2.tar.gz (0.8.2 at the time of
this writing). You
> will of course need libesd to compile this. To apply and test on linux/*nix
simply:
>
> $ cd qemu-src-dir
> $ patch -Np1 -i path/to/patch/file
> $ ./configure --enable-esd
> $ make
> $ sudo make install
> $ export QEMU_AUDIO_DRV=esd
> $ qemu (your options here) -soundhw es1370
>
[..snip..]
There are several problems with this patch:
a. esd_play_stream returns negative values on error (not zero)
b. esd_play_stream can return with EINTR
c. no error checking whatsoever on write to the socket
d. the socket is most likely opened in blocking mode
e. i don't think it's wise to use anything other than esd itself
as a audio-clock source
So basically the only way it can work (given the circumstances)
is to have a thread that would perform a blocking write to the
esd, and the rest as per coreaudio and sdladuio.
P.S. Oh yeah, mixing tabs and spaces is also not a great idea.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: esd audio output patch and debuging.
2006-08-31 11:46 ` [Qemu-devel] " malc
@ 2006-08-31 17:19 ` Leonardo E. Reiter
2006-09-01 19:02 ` malc
0 siblings, 1 reply; 10+ messages in thread
From: Leonardo E. Reiter @ 2006-08-31 17:19 UTC (permalink / raw)
To: qemu-devel
malc,
Other than the lack of error handling and blocking mode, what is the
problem with using QEMU's VM clock as the audio clock source? In my
experience from older projects using esd (not related to QEMU), it is
almost impossible to get reliable timing from ESD, especially if you are
transporting over a network. The timing will certainly not be accurate
enough for example for Windows guests using Windows Media Player, etc.
Plus, you have to factor in socket buffering and underruns due to
network latency if you expect anything synchronous on the socket. So
what is the reason for objecting to the QEMU vm clock, much like the
mute audio driver uses? I just want to know your reasoning for it just
to further my own understanding.
Thank you,
Leo Reiter
P.S. I can attest that using the mute audio driver you used, if the host
clock resolution is well above 100Hz such as on Linux and FreeBSD,
Windows Media Player guests have no problem with multimedia streams. I
keep referring to WMP because it is extremely picky about timing in
general, more so than other applications even. It seems that QEMU's vm
clock is accurate enough for this task, just FYI.
malc wrote:
<snip>
> There are several problems with this patch:
>
> a. esd_play_stream returns negative values on error (not zero)
> b. esd_play_stream can return with EINTR
> c. no error checking whatsoever on write to the socket
> d. the socket is most likely opened in blocking mode
> e. i don't think it's wise to use anything other than esd itself
> as a audio-clock source
>
> So basically the only way it can work (given the circumstances)
> is to have a thread that would perform a blocking write to the
> esd, and the rest as per coreaudio and sdladuio.
>
> P.S. Oh yeah, mixing tabs and spaces is also not a great idea.
>
>
>
>
> _______________________________________________
> Qemu-devel mailing list
> Qemu-devel@nongnu.org
> http://lists.nongnu.org/mailman/listinfo/qemu-devel
--
Leonardo E. Reiter
Vice President of Product Development, CTO
Win4Lin, Inc.
Virtual Computing that means Business
Main: +1 512 339 7979
Fax: +1 512 532 6501
http://www.win4lin.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Re: esd audio output patch and debuging.
2006-08-31 17:19 ` Leonardo E. Reiter
@ 2006-09-01 19:02 ` malc
0 siblings, 0 replies; 10+ messages in thread
From: malc @ 2006-09-01 19:02 UTC (permalink / raw)
To: qemu-devel
Leonardo E. Reiter <lreiter <at> win4lin.com> writes:
>
> malc,
>
> Other than the lack of error handling and blocking mode, what is the
> problem with using QEMU's VM clock as the audio clock source? In my
> experience from older projects using esd (not related to QEMU), it is
> almost impossible to get reliable timing from ESD, especially if you are
> transporting over a network. The timing will certainly not be accurate
> enough for example for Windows guests using Windows Media Player, etc.
> Plus, you have to factor in socket buffering and underruns due to
> network latency if you expect anything synchronous on the socket. So
> what is the reason for objecting to the QEMU vm clock, much like the
> mute audio driver uses? I just want to know your reasoning for it just
> to further my own understanding.
Mute/wav rendering works by the virtue of having one clock source, i.e.
vm clock, furthermore the writes are non-blocking and instantaneous[1].
With esd one has to deal with two clock sources - one is vm clock other
is esds ability to consume the data. If vm clock is a bit lower w.r.t.
the audio clock esd uses - you will always starve the esd and in turn
audio subsystem it uses.
All in all real-time(in a loose sense) audio will only work if your
only constraint is the receivers ability to consume data. Given esds
interface the only safe way to do that is by emulating of a blocking
write, this in trun (given all other things into consideration) means
threads and interaction with QEMUs audio/main loop a'la sdlaudio or
coreaudio.
[1] Less so for wav due to I/O, but close enough for all intents and
purposes.
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Re: esd audio output patch and debuging.
@ 2006-09-03 22:33 malc
2006-09-04 8:56 ` Peter Oberndorfer
0 siblings, 1 reply; 10+ messages in thread
From: malc @ 2006-09-03 22:33 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 935 bytes --]
Frederick Reeve <cylix <at> solace.info> writes:
>
> Hello.
>
[..snip..]
>
> Now, I would not have you thinking this patch is a ready to go. I
> am writing this email because I am having a little trouble with
> this. It outputs sound fine but it produces artafacts. I'm not
> sure of the cause. Though I think it may have to do with frame
> alignment or with the conversion process (see code). It sounds like
> its clipping at high sample volume but this is the first time I have
> done anything with audio programing. I had planed to submit a
> completed patch but... anyway if anyone can point me in the right
> direction I would appreciate it. Alternately if you just want to
> fix it that would be great to.
Implemented the ideas described in previous post, latency is no good
(something to be expected) but the quality seems to be fine now.
Fabrice: i think this can be safely applied.
--
mailto:malc@pulsesoft.com
[-- Attachment #2: Type: TEXT/PLAIN, Size: 15297 bytes --]
Index: Makefile.target
===================================================================
RCS file: /home/malc/cvsroot/bellard/qemu/Makefile.target,v
retrieving revision 1.1.1.10
retrieving revision 1.1.1.1.2.11
diff -u -r1.1.1.10 -r1.1.1.1.2.11
--- Makefile.target 4 Aug 2006 23:49:02 -0000 1.1.1.10
+++ Makefile.target 3 Sep 2006 21:56:08 -0000 1.1.1.1.2.11
@@ -315,6 +315,10 @@
AUDIODRV += dsoundaudio.o
LIBS += -lole32 -ldxguid
endif
+ifdef CONFIG_ESD
+AUDIODRV += esdaudio.o
+LIBS += -lesd
+endif
ifdef CONFIG_FMOD
AUDIODRV += fmodaudio.o
audio.o fmodaudio.o: DEFINES := -I$(CONFIG_FMOD_INC) $(DEFINES)
@@ -539,7 +543,7 @@
endif
ifeq (1, 0)
-audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \
+audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o esdaudio.o \
fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \
CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare
endif
Index: configure
===================================================================
RCS file: /home/malc/cvsroot/bellard/qemu/configure,v
retrieving revision 1.1.1.8
retrieving revision 1.1.1.1.2.6
diff -u -r1.1.1.8 -r1.1.1.1.2.6
--- configure 27 Jun 2006 11:05:10 -0000 1.1.1.8
+++ configure 3 Sep 2006 21:56:15 -0000 1.1.1.1.2.6
@@ -81,6 +81,7 @@
dsound="no"
coreaudio="no"
alsa="no"
+esd="no"
fmod="no"
fmod_lib=""
fmod_inc=""
@@ -207,6 +208,8 @@
;;
--enable-dsound) dsound="yes"
;;
+ --enable-esd) esd="yes"
+ ;;
--enable-fmod) fmod="yes"
;;
--fmod-lib=*) fmod_lib="$optarg"
@@ -282,6 +285,7 @@
echo " --enable-adlib enable Adlib emulation"
echo " --enable-coreaudio enable Coreaudio audio driver"
echo " --enable-alsa enable ALSA audio driver"
+echo " --enable-esd enable esd audio"
echo " --enable-fmod enable FMOD audio driver"
echo " --enabled-dsound enable DirectSound audio driver"
echo " --enable-system enable all system emulation targets"
@@ -545,6 +549,7 @@
echo "CoreAudio support $coreaudio"
echo "ALSA support $alsa"
echo "DSound support $dsound"
+echo "ESD support $esd"
if test "$fmod" = "yes"; then
if test -z $fmod_lib || test -z $fmod_inc; then
echo
@@ -694,6 +699,10 @@
echo "CONFIG_DSOUND=yes" >> $config_mak
echo "#define CONFIG_DSOUND 1" >> $config_h
fi
+if test "$esd" = "yes" ; then
+ echo "CONFIG_ESD=yes" >> $config_mak
+ echo "#define CONFIG_ESD 1" >> $config_h
+fi
if test "$fmod" = "yes" ; then
echo "CONFIG_FMOD=yes" >> $config_mak
echo "CONFIG_FMOD_LIB=$fmod_lib" >> $config_mak
Index: audio/audio.c
===================================================================
RCS file: /home/malc/cvsroot/bellard/qemu/audio/audio.c,v
retrieving revision 1.1.1.8
retrieving revision 1.1.1.1.2.20
diff -u -r1.1.1.8 -r1.1.1.1.2.20
--- audio/audio.c 4 Aug 2006 23:49:09 -0000 1.1.1.8
+++ audio/audio.c 3 Sep 2006 21:57:03 -0000 1.1.1.1.2.20
@@ -46,6 +46,9 @@
#ifdef CONFIG_DSOUND
&dsound_audio_driver,
#endif
+#ifdef CONFIG_ESD
+ &esd_audio_driver,
+#endif
#ifdef CONFIG_FMOD
&fmod_audio_driver,
#endif
@@ -605,11 +608,11 @@
}
if (info->sign) {
- memset (buf, 0x00, len << info->shift);
+ memset (buf, len << info->shift, 0x00);
}
else {
if (info->bits == 8) {
- memset (buf, 0x80, len << info->shift);
+ memset (buf, len << info->shift, 0x80);
}
else {
int i;
Index: audio/audio_int.h
===================================================================
RCS file: /home/malc/cvsroot/bellard/qemu/audio/audio_int.h,v
retrieving revision 1.1.1.7
retrieving revision 1.1.1.1.2.7
diff -u -r1.1.1.7 -r1.1.1.1.2.7
--- audio/audio_int.h 4 Aug 2006 23:49:09 -0000 1.1.1.7
+++ audio/audio_int.h 3 Sep 2006 21:57:09 -0000 1.1.1.1.2.7
@@ -200,6 +200,7 @@
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 esd_audio_driver;
extern struct audio_driver coreaudio_audio_driver;
extern struct audio_driver dsound_audio_driver;
extern volume_t nominal_volume;
Index: audio/esdaudio.c
===================================================================
RCS file: audio/esdaudio.c
diff -N audio/esdaudio.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ audio/esdaudio.c 3 Sep 2006 21:57:19 -0000 1.1.2.1
@@ -0,0 +1,404 @@
+/*
+ * QEMU ESD audio driver
+ *
+ * Copyright (c) 2006 Frederick Reeve (brushed up malc)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#include <esd.h>
+#include <pthread.h>
+
+#include "vl.h"
+
+#define AUDIO_CAP "esd"
+#include "audio_int.h"
+
+typedef struct ESDVoiceOut {
+ HWVoiceOut hw;
+ int done;
+ int live;
+ int decr;
+ int rpos;
+ void *pcm_buf;
+ int fd;
+ pthread_t thread;
+ pthread_cond_t cond;
+ pthread_mutex_t mutex;
+} ESDVoiceOut;
+
+static struct {
+ int samples;
+} conf = {
+ 1024
+};
+
+static void GCC_FMT_ATTR (2, 3) esd_logerr (int err, const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start (ap, fmt);
+ AUD_vlog (AUDIO_CAP, fmt, ap);
+ va_end (ap);
+
+ AUD_log (AUDIO_CAP, "Reason: %s\n", strerror (err));
+}
+
+static int esd_mlock (ESDVoiceOut *esd, const char *caller)
+{
+ int err;
+
+ err = pthread_mutex_lock (&esd->mutex);
+ if (err) {
+ esd_logerr (err, "pthread_mutex_lock failed for %s", caller);
+ return -1;
+ }
+ return 0;
+}
+
+static int esd_munlock (ESDVoiceOut *esd, const char *caller)
+{
+ int err;
+
+ err = pthread_mutex_unlock (&esd->mutex);
+ if (err) {
+ esd_logerr (err, "pthread_mutex_unlock failed for %s", caller);
+ return -1;
+ }
+ return 0;
+}
+
+static int esd_cwait (ESDVoiceOut *esd, const char *caller)
+{
+ int err;
+
+ err = pthread_cond_wait (&esd->cond, &esd->mutex);
+ if (err) {
+ esd_logerr (err, "pthread_cond_wait failed for %s", caller);
+ return -1;
+ }
+ return 0;
+}
+
+static int esd_munlock_and_csignal (ESDVoiceOut *esd, const char *caller)
+{
+ int err;
+
+ err = pthread_mutex_unlock (&esd->mutex);
+ if (err) {
+ esd_logerr (err, "[us] pthread_mutex_unlock failed for %s", caller);
+ return -1;
+ }
+
+ err = pthread_cond_signal (&esd->cond);
+ if (err) {
+ esd_logerr (err, "[us] pthread_cond_signal failed for %s", caller);
+ return -1;
+ }
+ return 0;
+}
+
+static void *esd_thread (void *arg)
+{
+ ESDVoiceOut *esd = arg;
+ HWVoiceOut *hw = &esd->hw;
+
+ for (;;) {
+ int decr, to_mix, rpos;
+
+ if (esd->done) {
+ break;
+ }
+
+ if (esd_cwait (esd, AUDIO_FUNC)) {
+ if (esd->done) {
+ break;
+ }
+ }
+
+ if (esd->live < hw->samples / 2) {
+ continue;
+ }
+
+ decr = to_mix = esd->live;
+ rpos = hw->rpos;
+
+ if (esd_munlock (esd, AUDIO_FUNC)) {
+ return NULL;
+ }
+
+ while (to_mix) {
+ ssize_t written;
+ int chunk = audio_MIN (to_mix, hw->samples - rpos);
+ st_sample_t *src = hw->mix_buf + rpos;
+
+ hw->clip (esd->pcm_buf, src, chunk);
+
+ again:
+ written = write (esd->fd, esd->pcm_buf, chunk << hw->info.shift);
+ if (written == -1) {
+ if (errno == EINTR || errno == EAGAIN) {
+ goto again;
+ }
+ esd_logerr (errno, "write failed");
+ return NULL;
+ }
+
+ if (written != chunk << hw->info.shift) {
+ int wsamples = written >> hw->info.shift;
+ int wbytes = wsamples << hw->info.shift;
+ if (wbytes != written) {
+ dolog ("warning: Misaligned write %d (requested %d), "
+ "alignment %d\n",
+ wbytes, written, hw->info.align + 1);
+ }
+ to_mix -= wsamples;
+ rpos = (rpos + wsamples) % hw->samples;
+ break;
+ }
+
+ rpos = (rpos + chunk) % hw->samples;
+ to_mix -= chunk;
+ }
+
+ if (esd_mlock (esd, AUDIO_FUNC))
+ return NULL;
+
+ esd->rpos = rpos;
+ esd->live = 0;
+ esd->decr += decr;
+ }
+
+ esd_munlock (esd, AUDIO_FUNC);
+ return NULL;
+}
+
+static int esd_run_out (HWVoiceOut *hw)
+{
+ int live, decr;
+ ESDVoiceOut *esd = (ESDVoiceOut *) hw;
+
+ if (esd_mlock (esd, AUDIO_FUNC)) {
+ return 0;
+ }
+
+ live = audio_pcm_hw_get_live_out (hw);
+ decr = audio_MIN (live, esd->decr);
+ esd->decr -= decr;
+ esd->live = live - decr;
+ hw->rpos = esd->rpos;
+ if (esd->live > 0) {
+ esd_munlock_and_csignal (esd, AUDIO_FUNC);
+ }
+ else {
+ esd_munlock (esd, AUDIO_FUNC);
+ }
+ return decr;
+}
+
+static int esd_write_out (SWVoiceOut *sw, void *buf, int len)
+{
+ return audio_pcm_sw_write (sw, buf, len);
+}
+
+static int esd_init_out (HWVoiceOut *hw, audsettings_t *as)
+{
+ int i, err;
+ ESDVoiceOut *esd = (ESDVoiceOut *) hw;
+ audsettings_t obt_as = *as;
+ int esdfmt = ESD_STREAM | ESD_PLAY;
+
+ err = pthread_mutex_init (&esd->mutex, NULL);
+ if (err) {
+ esd_logerr (err, "%s: pthread_mutex_init failed", AUDIO_FUNC);
+ goto fail0;
+ }
+
+ err = pthread_cond_init (&esd->cond, NULL);
+ if (err) {
+ esd_logerr (err, "%s: pthread_cond_init failed", AUDIO_FUNC);
+ goto fail1;
+ }
+
+ esdfmt = as->nchannels == 2 ? ESD_STEREO : ESD_MONO;
+ switch (as->fmt) {
+ case AUD_FMT_S8:
+ case AUD_FMT_U8:
+ esdfmt |= ESD_BITS8;
+ obt_as.fmt = AUD_FMT_U8;
+ break;
+
+ case AUD_FMT_S16:
+ case AUD_FMT_U16:
+ esdfmt |= ESD_BITS16;
+ obt_as.fmt = AUD_FMT_S16;
+ break;
+ }
+ obt_as.endianness = 0;
+
+ audio_pcm_init_info (&hw->info, &obt_as);
+
+ hw->samples = conf.samples;
+ esd->pcm_buf = audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->info.shift);
+ if (!esd->pcm_buf) {
+ dolog ("Could not allocate buffer (%d bytes)\n",
+ hw->samples << hw->info.shift);
+ return -1;
+ }
+
+ esd->fd = -1;
+ for (i = 0; i < 10000; i++) {
+ esd->fd = esd_play_stream (esdfmt, as->freq, NULL, NULL);
+ if (esd->fd < 0) {
+ if (errno == EINTR) {
+ continue;
+ }
+ esd_logerr (errno, "esd_play_stream failed");
+ goto fail2;
+ }
+ break;
+ }
+
+ if (esd->fd < 0) {
+ esd_logerr (errno, "esd_play_stream failed");
+ goto fail2;
+ }
+
+ err = pthread_create (&esd->thread, NULL, esd_thread, esd);
+ if (err) {
+ esd_logerr (err, "%s: pthred_create failed", AUDIO_FUNC);
+ goto fail3;
+ }
+
+ return 0;
+
+ fail3:
+ if (close (esd->fd)) {
+ esd_logerr (errno, "%s: close on esd socket(%d) failed",
+ AUDIO_FUNC, esd->fd);
+ }
+ esd->fd = -1;
+
+ fail2:
+ qemu_free (esd->pcm_buf);
+ esd->pcm_buf = NULL;
+
+ err = pthread_cond_destroy (&esd->cond);
+ if (err) {
+ esd_logerr (err, "%s: pthread_cond_destroy failed", AUDIO_FUNC);
+ }
+
+ fail1:
+ err = pthread_mutex_destroy (&esd->mutex);
+ if (err) {
+ esd_logerr (err, "%s: pthread_mutex_destroy failed", AUDIO_FUNC);
+ }
+
+ fail0:
+ return -1;
+}
+
+static void esd_fini_out (HWVoiceOut *hw)
+{
+ int err;
+ void *ret;
+ ESDVoiceOut *esd = (ESDVoiceOut *) hw;
+
+ esd_mlock (esd, AUDIO_FUNC);
+ esd->done = 1;
+ esd_munlock_and_csignal (esd, AUDIO_FUNC);
+
+ err = pthread_join (esd->thread, &ret);
+ if (err) {
+ esd_logerr (err, "%s: pthread_join failed", AUDIO_FUNC);
+ }
+
+ if (esd->fd >= 0) {
+ if (close (esd->fd)) {
+ esd_logerr (errno, "failed to close esd socket");
+ }
+ esd->fd = -1;
+ }
+
+ err = pthread_cond_destroy (&esd->cond);
+ if (err) {
+ esd_logerr (err, "%s: pthread_cond_destroy failed", AUDIO_FUNC);
+ }
+
+ err = pthread_mutex_destroy (&esd->mutex);
+ if (err) {
+ esd_logerr (err, "%s: pthread_mutex_destroy failed", AUDIO_FUNC);
+ }
+
+ qemu_free (esd->pcm_buf);
+ esd->pcm_buf = NULL;
+}
+
+static int esd_ctl_out (HWVoiceOut *hw, int cmd, ...)
+{
+ (void) hw;
+ (void) cmd;
+ return 0;
+}
+
+static void *esd_audio_init (void)
+{
+ return &conf;
+}
+
+static void esd_audio_fini (void *opaque)
+{
+ (void) opaque;
+ ldebug ("esd_fini");
+}
+
+struct audio_option esd_options[] = {
+ {"SAMPLES", AUD_OPT_INT, &conf.samples,
+ "buffer size in samples", NULL, 0},
+
+ {NULL, 0, NULL, NULL, NULL, 0}
+};
+
+struct audio_pcm_ops esd_pcm_ops = {
+ esd_init_out,
+ esd_fini_out,
+ esd_run_out,
+ esd_write_out,
+ esd_ctl_out,
+
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+struct audio_driver esd_audio_driver = {
+ INIT_FIELD (name = ) "esd",
+ INIT_FIELD (descr = )
+ "http://en.wikipedia.org/wiki/Esound",
+ INIT_FIELD (options = ) esd_options,
+ INIT_FIELD (init = ) esd_audio_init,
+ INIT_FIELD (fini = ) esd_audio_fini,
+ INIT_FIELD (pcm_ops = ) &esd_pcm_ops,
+ INIT_FIELD (can_be_default = ) 0,
+ INIT_FIELD (max_voices_out = ) 1,
+ INIT_FIELD (max_voices_in = ) 0,
+ INIT_FIELD (voice_size_out = ) sizeof (ESDVoiceOut),
+ INIT_FIELD (voice_size_in = ) 0
+};
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Qemu-devel] Re: esd audio output patch and debuging.
@ 2006-09-04 0:07 malc
2006-09-04 5:33 ` Frederick Reeve
0 siblings, 1 reply; 10+ messages in thread
From: malc @ 2006-09-04 0:07 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 73 bytes --]
Attached patch fixes a couple of problems.
--
mailto:malc@pulsesoft.com
[-- Attachment #2: Type: TEXT/PLAIN, Size: 2505 bytes --]
Index: esdaudio.c
===================================================================
RCS file: /home/malc/cvsroot/bellard/qemu/audio/Attic/esdaudio.c,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 esdaudio.c
--- esdaudio.c 3 Sep 2006 21:57:19 -0000 1.1.2.1
+++ esdaudio.c 3 Sep 2006 23:58:29 -0000
@@ -1,7 +1,7 @@
/*
* QEMU ESD audio driver
*
- * Copyright (c) 2006 Frederick Reeve (brushed up malc)
+ * Copyright (c) 2006 Frederick Reeve (brushed up by malc)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -44,8 +44,10 @@
static struct {
int samples;
+ int divisor;
} conf = {
- 1024
+ 1024,
+ 2
};
static void GCC_FMT_ATTR (2, 3) esd_logerr (int err, const char *fmt, ...)
@@ -117,22 +119,25 @@
{
ESDVoiceOut *esd = arg;
HWVoiceOut *hw = &esd->hw;
+ int threshold;
+
+ threshold = conf.divisor ? hw->samples / conf.divisor : 0;
for (;;) {
int decr, to_mix, rpos;
- if (esd->done) {
- break;
- }
-
- if (esd_cwait (esd, AUDIO_FUNC)) {
+ for (;;) {
if (esd->done) {
+ goto exit;
+ }
+
+ if (esd->live > threshold) {
break;
}
- }
- if (esd->live < hw->samples / 2) {
- continue;
+ if (esd_cwait (esd, AUDIO_FUNC)) {
+ goto exit;
+ }
}
decr = to_mix = esd->live;
@@ -176,14 +181,16 @@
to_mix -= chunk;
}
- if (esd_mlock (esd, AUDIO_FUNC))
+ if (esd_mlock (esd, AUDIO_FUNC)) {
return NULL;
+ }
esd->rpos = rpos;
- esd->live = 0;
+ esd->live -= decr;
esd->decr += decr;
}
+ exit:
esd_munlock (esd, AUDIO_FUNC);
return NULL;
}
@@ -235,7 +242,7 @@
goto fail1;
}
- esdfmt = as->nchannels == 2 ? ESD_STEREO : ESD_MONO;
+ esdfmt |= (as->nchannels == 2) ? ESD_STEREO : ESD_MONO;
switch (as->fmt) {
case AUD_FMT_S8:
case AUD_FMT_U8:
@@ -371,6 +378,9 @@
{"SAMPLES", AUD_OPT_INT, &conf.samples,
"buffer size in samples", NULL, 0},
+ {"DIVISOR", AUD_OPT_INT, &conf.divisor,
+ "threshold divisor", NULL, 0},
+
{NULL, 0, NULL, NULL, NULL, 0}
};
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: esd audio output patch and debuging.
2006-09-04 0:07 malc
@ 2006-09-04 5:33 ` Frederick Reeve
0 siblings, 0 replies; 10+ messages in thread
From: Frederick Reeve @ 2006-09-04 5:33 UTC (permalink / raw)
To: qemu-devel
On Mon, 4 Sep 2006 04:07:51 +0400 (MSD)
malc <malc@pulsesoft.com> wrote:
> Attached patch fixes a couple of problems.
I just want to say a big thanks to you for this. I have really had my hands full the last couple of days and have been putting in 12+ hour days at the schools trying to be ready. I was trying to figure out where to sneek in the time to fix this. This is really great. Even if you didn't do it for me I thank you none the less.
Big thanks! :-)
Frederick.
P.S. how long till a qemu release with the patches applied?
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: esd audio output patch and debuging.
2006-09-03 22:33 [Qemu-devel] Re: esd audio output patch and debuging malc
@ 2006-09-04 8:56 ` Peter Oberndorfer
2006-09-04 12:01 ` Christophe Fillot
2006-09-04 12:02 ` malc
0 siblings, 2 replies; 10+ messages in thread
From: Peter Oberndorfer @ 2006-09-04 8:56 UTC (permalink / raw)
To: qemu-devel; +Cc: malc
On Monday 04 September 2006 00:33, malc wrote:
> Frederick Reeve <cylix <at> solace.info> writes:
>
> >
> > Hello.
> >
>
> [..snip..]
>
> >
> > Now, I would not have you thinking this patch is a ready to go. I
> > am writing this email because I am having a little trouble with
> > this. It outputs sound fine but it produces artafacts. I'm not
> > sure of the cause. Though I think it may have to do with frame
> > alignment or with the conversion process (see code). It sounds like
> > its clipping at high sample volume but this is the first time I have
> > done anything with audio programing. I had planed to submit a
> > completed patch but... anyway if anyone can point me in the right
> > direction I would appreciate it. Alternately if you just want to
> > fix it that would be great to.
>
> Implemented the ideas described in previous post, latency is no good
> (something to be expected) but the quality seems to be fine now.
>
> Fabrice: i think this can be safely applied.
>
> --
> mailto:malc@pulsesoft.com
if (info->sign) {
- memset (buf, 0x00, len << info->shift);
+ memset (buf, len << info->shift, 0x00);
}
else {
if (info->bits == 8) {
- memset (buf, 0x80, len << info->shift);
+ memset (buf, len << info->shift, 0x80);
}
This part looks wrong (swapped parameters)
Greetings Peter
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: esd audio output patch and debuging.
2006-09-04 8:56 ` Peter Oberndorfer
@ 2006-09-04 12:01 ` Christophe Fillot
2006-09-04 14:04 ` Peter Oberndorfer
2006-09-04 12:02 ` malc
1 sibling, 1 reply; 10+ messages in thread
From: Christophe Fillot @ 2006-09-04 12:01 UTC (permalink / raw)
To: qemu-devel
Peter Oberndorfer a e'crit :
>
>
> if (info->sign) {
> - memset (buf, 0x00, len << info->shift);
> + memset (buf, len << info->shift, 0x00);
> }
> else {
> if (info->bits == 8) {
> - memset (buf, 0x80, len << info->shift);
> + memset (buf, len << info->shift, 0x80);
> }
>
>
> This part looks wrong (swapped parameters)
>
Hello,
No, this is correct:
#include <string.h>
void *memset(void *s, int c, size_t n);
Best regards.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: esd audio output patch and debuging.
2006-09-04 8:56 ` Peter Oberndorfer
2006-09-04 12:01 ` Christophe Fillot
@ 2006-09-04 12:02 ` malc
1 sibling, 0 replies; 10+ messages in thread
From: malc @ 2006-09-04 12:02 UTC (permalink / raw)
To: Peter Oberndorfer; +Cc: qemu-devel
[-- Attachment #1: Type: TEXT/PLAIN, Size: 682 bytes --]
On Mon, 4 Sep 2006, Peter Oberndorfer wrote:
> On Monday 04 September 2006 00:33, malc wrote:
>> Frederick Reeve <cylix <at> solace.info> writes:
>>
>>>
>>> Hello.
>>>
>>
>> [..snip..]
>>
> if (info->sign) {
> - memset (buf, 0x00, len << info->shift);
> + memset (buf, len << info->shift, 0x00);
> }
> else {
> if (info->bits == 8) {
> - memset (buf, 0x80, len << info->shift);
> + memset (buf, len << info->shift, 0x80);
> }
>
>
> This part looks wrong (swapped parameters)
Yes, that was fixed in CVS a while ago i just never updated my own
repository.
--
mailto:malc@pulsesoft.com
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Qemu-devel] Re: esd audio output patch and debuging.
2006-09-04 12:01 ` Christophe Fillot
@ 2006-09-04 14:04 ` Peter Oberndorfer
0 siblings, 0 replies; 10+ messages in thread
From: Peter Oberndorfer @ 2006-09-04 14:04 UTC (permalink / raw)
To: qemu-devel
On Monday 04 September 2006 14:01, Christophe Fillot wrote:
> Peter Oberndorfer a e'crit :
> >
> >
> > if (info->sign) {
> > - memset (buf, 0x00, len << info->shift);
> > + memset (buf, len << info->shift, 0x00);
> > }
> > else {
> > if (info->bits == 8) {
> > - memset (buf, 0x80, len << info->shift);
> > + memset (buf, len << info->shift, 0x80);
> > }
> >
> >
> > This part looks wrong (swapped parameters)
> >
>
> Hello,
>
> No, this is correct:
>
> #include <string.h>
>
> void *memset(void *s, int c, size_t n);
"The memset() function fills the first n bytes of the memory area pointed to by s with the constant byte c."
But isn't a size of 0x00 bytes a bit pointless?
Or is this a reverse patch? (doesn't look like one)
>
> Best regards.
Greetings Peter
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-09-04 13:59 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-09-03 22:33 [Qemu-devel] Re: esd audio output patch and debuging malc
2006-09-04 8:56 ` Peter Oberndorfer
2006-09-04 12:01 ` Christophe Fillot
2006-09-04 14:04 ` Peter Oberndorfer
2006-09-04 12:02 ` malc
-- strict thread matches above, loose matches on Subject: below --
2006-09-04 0:07 malc
2006-09-04 5:33 ` Frederick Reeve
2006-08-30 15:45 [Qemu-devel] " Frederick Reeve
2006-08-31 11:46 ` [Qemu-devel] " malc
2006-08-31 17:19 ` Leonardo E. Reiter
2006-09-01 19:02 ` malc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).