esd audio output patch and debuging.
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
You will also need to make sure esd is running when you do that of course. Sorry if that is insulting your intelegence. I just wanted to make everything very clear.
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. :-)
Just a note also on esd as far as I can tell it only supports 8 and 16 bit unsigned.
You may be wondering why with all the sound support options qemu has that I would want to write another one. Here is the logic. I am running an LTSP server setup. The servers I use have no sound card at all. Yet all the programs run on that server. The clients however have sound cards. None of QEMUs sound outputs will work without a sound card with the exeption of wav. None of QEMUs sound outputs can be broadcast over a network to clients but esd can. In short esd support allows me to run many QEMU copies on a server and output the audio to client terminals with out the server even having a sound card. esd is old but its about the only well supported option for network audio output in both linux distros and LTSP.
Background: I am maintaining LTSP servers for small elementy schools with "no budget". I currently maintain these networks for free to help with education though they may be offering me a job in the future. The teachers require a small few windows programs that do not run under wine. So I pipe qemu over the thin terms and use gdm so when they log into a qemu session it just pulls up windows full screen. Howerver they have resently needed sound and yes they actualy need it (though I whish I could say they didn't). School will be starting on september 4 and I am trying to be ready.
Anyway if you have any questions or I can help at all let me know.
If you can see what is wrong or have sugestions I welcome help. Also if you know of a better way that I would be happy to here it but after looking at our situation I think this sound module is the path of least resistance.
I thank you also for QEMU it has been a huge boon to the schools.
Thanks
Frederick
audio/audio.c +3 -0
@@ -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
audio/audio_int.h +1 -0
@@ -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;
audio/esdaudio.c +235 -0
235 lines not on this page · raw message
configure +9 -0
@@ -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
Makefile.target +5 -1
@@ -314,6 +314,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,6 +543,6 @@ ifeq (1, 0) audio.o sdlaudio.o dsoundaudio.o ossaudio.o wavaudio.o noaudio.o \ -fmodaudio.o alsaaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \ +fmodaudio.o alsaaudio.o esdaudio.o mixeng.o sb16.o es1370.o gus.o adlib.o: \ CFLAGS := $(CFLAGS) -Wall -Werror -W -Wsign-compare endif
Quoted 4 lines · 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
Quoted 2 lines
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
Quoted 1 line
will of course need libesd to compile this. To apply and test on linux/*nix
simply:
Quoted 9 lines
$ 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.
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>
Quoted 22 lines
There are several problems with this patch:
a.
esd_play_streamreturns negative values on error (not zero) b.esd_play_streamcan 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 sourceSo 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
[email protected]
http://lists.nongnu.org/mailman/listinfo/qemu-devel
Signature · 8 lines
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
Quoted 14 lines · 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.