From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49107) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUy-0006jU-UG for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Z4TUv-0005z9-HE for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33554) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Z4TUu-0005yS-Vy for qemu-devel@nongnu.org; Mon, 15 Jun 2015 08:28:17 -0400 From: Gerd Hoffmann Date: Mon, 15 Jun 2015 14:27:52 +0200 Message-Id: <1434371291-6994-2-git-send-email-kraxel@redhat.com> In-Reply-To: <1434371291-6994-1-git-send-email-kraxel@redhat.com> References: <1434371291-6994-1-git-send-email-kraxel@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 01/20] audio: remove esd backend List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gerd Hoffmann , =?UTF-8?q?K=C5=91v=C3=A1g=C3=B3=2C=20Zolt=C3=A1n?= From: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n ESD is no longer developed and replaced by PulseAudio. Signed-off-by: K=C5=91v=C3=A1g=C3=B3, Zolt=C3=A1n Signed-off-by: Gerd Hoffmann --- audio/Makefile.objs | 1 - audio/audio_int.h | 1 - audio/esdaudio.c | 557 ----------------------------------------------= ------ configure | 18 +- 4 files changed, 6 insertions(+), 571 deletions(-) delete mode 100644 audio/esdaudio.c diff --git a/audio/Makefile.objs b/audio/Makefile.objs index 26a0ac9..5573ac1 100644 --- a/audio/Makefile.objs +++ b/audio/Makefile.objs @@ -6,7 +6,6 @@ common-obj-$(CONFIG_COREAUDIO) +=3D coreaudio.o common-obj-$(CONFIG_ALSA) +=3D alsaaudio.o common-obj-$(CONFIG_DSOUND) +=3D dsoundaudio.o common-obj-$(CONFIG_FMOD) +=3D fmodaudio.o -common-obj-$(CONFIG_ESD) +=3D esdaudio.o common-obj-$(CONFIG_PA) +=3D paaudio.o common-obj-$(CONFIG_WINWAVE) +=3D winwaveaudio.o common-obj-$(CONFIG_AUDIO_PT_INT) +=3D audio_pt_int.o diff --git a/audio/audio_int.h b/audio/audio_int.h index fd019a0..9dd6b7f 100644 --- a/audio/audio_int.h +++ b/audio/audio_int.h @@ -210,7 +210,6 @@ extern struct audio_driver fmod_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 struct audio_driver pa_audio_driver; extern struct audio_driver spice_audio_driver; extern struct audio_driver winwave_audio_driver; diff --git a/audio/esdaudio.c b/audio/esdaudio.c deleted file mode 100644 index eea9cce..0000000 --- a/audio/esdaudio.c +++ /dev/null @@ -1,557 +0,0 @@ -/* - * QEMU ESD audio driver - * - * 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 - * 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 includ= ed in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRE= SS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHA= LL - * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALING= S IN - * THE SOFTWARE. - */ -#include -#include "qemu-common.h" -#include "audio.h" - -#define AUDIO_CAP "esd" -#include "audio_int.h" -#include "audio_pt_int.h" - -typedef struct { - HWVoiceOut hw; - int done; - int live; - int decr; - int rpos; - void *pcm_buf; - int fd; - struct audio_pt pt; -} ESDVoiceOut; - -typedef struct { - HWVoiceIn hw; - int done; - int dead; - int incr; - int wpos; - void *pcm_buf; - int fd; - struct audio_pt pt; -} ESDVoiceIn; - -static struct { - int samples; - int divisor; - char *dac_host; - char *adc_host; -} conf =3D { - .samples =3D 1024, - .divisor =3D 2, -}; - -static void GCC_FMT_ATTR (2, 3) qesd_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)); -} - -/* playback */ -static void *qesd_thread_out (void *arg) -{ - ESDVoiceOut *esd =3D arg; - HWVoiceOut *hw =3D &esd->hw; - int threshold; - - threshold =3D conf.divisor ? hw->samples / conf.divisor : 0; - - if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) { - return NULL; - } - - for (;;) { - int decr, to_mix, rpos; - - for (;;) { - if (esd->done) { - goto exit; - } - - if (esd->live > threshold) { - break; - } - - if (audio_pt_wait (&esd->pt, AUDIO_FUNC)) { - goto exit; - } - } - - decr =3D to_mix =3D esd->live; - rpos =3D hw->rpos; - - if (audio_pt_unlock (&esd->pt, AUDIO_FUNC)) { - return NULL; - } - - while (to_mix) { - ssize_t written; - int chunk =3D audio_MIN (to_mix, hw->samples - rpos); - struct st_sample *src =3D hw->mix_buf + rpos; - - hw->clip (esd->pcm_buf, src, chunk); - - again: - written =3D write (esd->fd, esd->pcm_buf, chunk << hw->info.= shift); - if (written =3D=3D -1) { - if (errno =3D=3D EINTR || errno =3D=3D EAGAIN) { - goto again; - } - qesd_logerr (errno, "write failed\n"); - return NULL; - } - - if (written !=3D chunk << hw->info.shift) { - int wsamples =3D written >> hw->info.shift; - int wbytes =3D wsamples << hw->info.shift; - if (wbytes !=3D written) { - dolog ("warning: Misaligned write %d (requested %zd)= , " - "alignment %d\n", - wbytes, written, hw->info.align + 1); - } - to_mix -=3D wsamples; - rpos =3D (rpos + wsamples) % hw->samples; - break; - } - - rpos =3D (rpos + chunk) % hw->samples; - to_mix -=3D chunk; - } - - if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) { - return NULL; - } - - esd->rpos =3D rpos; - esd->live -=3D decr; - esd->decr +=3D decr; - } - - exit: - audio_pt_unlock (&esd->pt, AUDIO_FUNC); - return NULL; -} - -static int qesd_run_out (HWVoiceOut *hw, int live) -{ - int decr; - ESDVoiceOut *esd =3D (ESDVoiceOut *) hw; - - if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) { - return 0; - } - - decr =3D audio_MIN (live, esd->decr); - esd->decr -=3D decr; - esd->live =3D live - decr; - hw->rpos =3D esd->rpos; - if (esd->live > 0) { - audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC); - } - else { - audio_pt_unlock (&esd->pt, AUDIO_FUNC); - } - return decr; -} - -static int qesd_write (SWVoiceOut *sw, void *buf, int len) -{ - return audio_pcm_sw_write (sw, buf, len); -} - -static int qesd_init_out (HWVoiceOut *hw, struct audsettings *as) -{ - ESDVoiceOut *esd =3D (ESDVoiceOut *) hw; - struct audsettings obt_as =3D *as; - int esdfmt =3D ESD_STREAM | ESD_PLAY; - - esdfmt |=3D (as->nchannels =3D=3D 2) ? ESD_STEREO : ESD_MONO; - switch (as->fmt) { - case AUD_FMT_S8: - case AUD_FMT_U8: - esdfmt |=3D ESD_BITS8; - obt_as.fmt =3D AUD_FMT_U8; - break; - - case AUD_FMT_S32: - case AUD_FMT_U32: - dolog ("Will use 16 instead of 32 bit samples\n"); - /* fall through */ - case AUD_FMT_S16: - case AUD_FMT_U16: - deffmt: - esdfmt |=3D ESD_BITS16; - obt_as.fmt =3D AUD_FMT_S16; - break; - - default: - dolog ("Internal logic error: Bad audio format %d\n", as->fmt); - goto deffmt; - - } - obt_as.endianness =3D AUDIO_HOST_ENDIANNESS; - - audio_pcm_init_info (&hw->info, &obt_as); - - hw->samples =3D conf.samples; - esd->pcm_buf =3D audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->inf= o.shift); - if (!esd->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); - return -1; - } - - esd->fd =3D esd_play_stream (esdfmt, as->freq, conf.dac_host, NULL); - if (esd->fd < 0) { - qesd_logerr (errno, "esd_play_stream failed\n"); - goto fail1; - } - - if (audio_pt_init (&esd->pt, qesd_thread_out, esd, AUDIO_CAP, AUDIO_= FUNC)) { - goto fail2; - } - - return 0; - - fail2: - if (close (esd->fd)) { - qesd_logerr (errno, "%s: close on esd socket(%d) failed\n", - AUDIO_FUNC, esd->fd); - } - esd->fd =3D -1; - - fail1: - g_free (esd->pcm_buf); - esd->pcm_buf =3D NULL; - return -1; -} - -static void qesd_fini_out (HWVoiceOut *hw) -{ - void *ret; - ESDVoiceOut *esd =3D (ESDVoiceOut *) hw; - - audio_pt_lock (&esd->pt, AUDIO_FUNC); - esd->done =3D 1; - audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC); - audio_pt_join (&esd->pt, &ret, AUDIO_FUNC); - - if (esd->fd >=3D 0) { - if (close (esd->fd)) { - qesd_logerr (errno, "failed to close esd socket\n"); - } - esd->fd =3D -1; - } - - audio_pt_fini (&esd->pt, AUDIO_FUNC); - - g_free (esd->pcm_buf); - esd->pcm_buf =3D NULL; -} - -static int qesd_ctl_out (HWVoiceOut *hw, int cmd, ...) -{ - (void) hw; - (void) cmd; - return 0; -} - -/* capture */ -static void *qesd_thread_in (void *arg) -{ - ESDVoiceIn *esd =3D arg; - HWVoiceIn *hw =3D &esd->hw; - int threshold; - - threshold =3D conf.divisor ? hw->samples / conf.divisor : 0; - - if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) { - return NULL; - } - - for (;;) { - int incr, to_grab, wpos; - - for (;;) { - if (esd->done) { - goto exit; - } - - if (esd->dead > threshold) { - break; - } - - if (audio_pt_wait (&esd->pt, AUDIO_FUNC)) { - goto exit; - } - } - - incr =3D to_grab =3D esd->dead; - wpos =3D hw->wpos; - - if (audio_pt_unlock (&esd->pt, AUDIO_FUNC)) { - return NULL; - } - - while (to_grab) { - ssize_t nread; - int chunk =3D audio_MIN (to_grab, hw->samples - wpos); - void *buf =3D advance (esd->pcm_buf, wpos); - - again: - nread =3D read (esd->fd, buf, chunk << hw->info.shift); - if (nread =3D=3D -1) { - if (errno =3D=3D EINTR || errno =3D=3D EAGAIN) { - goto again; - } - qesd_logerr (errno, "read failed\n"); - return NULL; - } - - if (nread !=3D chunk << hw->info.shift) { - int rsamples =3D nread >> hw->info.shift; - int rbytes =3D rsamples << hw->info.shift; - if (rbytes !=3D nread) { - dolog ("warning: Misaligned write %d (requested %zd)= , " - "alignment %d\n", - rbytes, nread, hw->info.align + 1); - } - to_grab -=3D rsamples; - wpos =3D (wpos + rsamples) % hw->samples; - break; - } - - hw->conv (hw->conv_buf + wpos, buf, nread >> hw->info.shift)= ; - wpos =3D (wpos + chunk) % hw->samples; - to_grab -=3D chunk; - } - - if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) { - return NULL; - } - - esd->wpos =3D wpos; - esd->dead -=3D incr; - esd->incr +=3D incr; - } - - exit: - audio_pt_unlock (&esd->pt, AUDIO_FUNC); - return NULL; -} - -static int qesd_run_in (HWVoiceIn *hw) -{ - int live, incr, dead; - ESDVoiceIn *esd =3D (ESDVoiceIn *) hw; - - if (audio_pt_lock (&esd->pt, AUDIO_FUNC)) { - return 0; - } - - live =3D audio_pcm_hw_get_live_in (hw); - dead =3D hw->samples - live; - incr =3D audio_MIN (dead, esd->incr); - esd->incr -=3D incr; - esd->dead =3D dead - incr; - hw->wpos =3D esd->wpos; - if (esd->dead > 0) { - audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC); - } - else { - audio_pt_unlock (&esd->pt, AUDIO_FUNC); - } - return incr; -} - -static int qesd_read (SWVoiceIn *sw, void *buf, int len) -{ - return audio_pcm_sw_read (sw, buf, len); -} - -static int qesd_init_in (HWVoiceIn *hw, struct audsettings *as) -{ - ESDVoiceIn *esd =3D (ESDVoiceIn *) hw; - struct audsettings obt_as =3D *as; - int esdfmt =3D ESD_STREAM | ESD_RECORD; - - esdfmt |=3D (as->nchannels =3D=3D 2) ? ESD_STEREO : ESD_MONO; - switch (as->fmt) { - case AUD_FMT_S8: - case AUD_FMT_U8: - esdfmt |=3D ESD_BITS8; - obt_as.fmt =3D AUD_FMT_U8; - break; - - case AUD_FMT_S16: - case AUD_FMT_U16: - esdfmt |=3D ESD_BITS16; - obt_as.fmt =3D AUD_FMT_S16; - break; - - case AUD_FMT_S32: - case AUD_FMT_U32: - dolog ("Will use 16 instead of 32 bit samples\n"); - esdfmt |=3D ESD_BITS16; - obt_as.fmt =3D AUD_FMT_S16; - break; - } - obt_as.endianness =3D AUDIO_HOST_ENDIANNESS; - - audio_pcm_init_info (&hw->info, &obt_as); - - hw->samples =3D conf.samples; - esd->pcm_buf =3D audio_calloc (AUDIO_FUNC, hw->samples, 1 << hw->inf= o.shift); - if (!esd->pcm_buf) { - dolog ("Could not allocate buffer (%d bytes)\n", - hw->samples << hw->info.shift); - return -1; - } - - esd->fd =3D esd_record_stream (esdfmt, as->freq, conf.adc_host, NULL= ); - if (esd->fd < 0) { - qesd_logerr (errno, "esd_record_stream failed\n"); - goto fail1; - } - - if (audio_pt_init (&esd->pt, qesd_thread_in, esd, AUDIO_CAP, AUDIO_F= UNC)) { - goto fail2; - } - - return 0; - - fail2: - if (close (esd->fd)) { - qesd_logerr (errno, "%s: close on esd socket(%d) failed\n", - AUDIO_FUNC, esd->fd); - } - esd->fd =3D -1; - - fail1: - g_free (esd->pcm_buf); - esd->pcm_buf =3D NULL; - return -1; -} - -static void qesd_fini_in (HWVoiceIn *hw) -{ - void *ret; - ESDVoiceIn *esd =3D (ESDVoiceIn *) hw; - - audio_pt_lock (&esd->pt, AUDIO_FUNC); - esd->done =3D 1; - audio_pt_unlock_and_signal (&esd->pt, AUDIO_FUNC); - audio_pt_join (&esd->pt, &ret, AUDIO_FUNC); - - if (esd->fd >=3D 0) { - if (close (esd->fd)) { - qesd_logerr (errno, "failed to close esd socket\n"); - } - esd->fd =3D -1; - } - - audio_pt_fini (&esd->pt, AUDIO_FUNC); - - g_free (esd->pcm_buf); - esd->pcm_buf =3D NULL; -} - -static int qesd_ctl_in (HWVoiceIn *hw, int cmd, ...) -{ - (void) hw; - (void) cmd; - return 0; -} - -/* common */ -static void *qesd_audio_init (void) -{ - return &conf; -} - -static void qesd_audio_fini (void *opaque) -{ - (void) opaque; - ldebug ("esd_fini"); -} - -struct audio_option qesd_options[] =3D { - { - .name =3D "SAMPLES", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.samples, - .descr =3D "buffer size in samples" - }, - { - .name =3D "DIVISOR", - .tag =3D AUD_OPT_INT, - .valp =3D &conf.divisor, - .descr =3D "threshold divisor" - }, - { - .name =3D "DAC_HOST", - .tag =3D AUD_OPT_STR, - .valp =3D &conf.dac_host, - .descr =3D "playback host" - }, - { - .name =3D "ADC_HOST", - .tag =3D AUD_OPT_STR, - .valp =3D &conf.adc_host, - .descr =3D "capture host" - }, - { /* End of list */ } -}; - -static struct audio_pcm_ops qesd_pcm_ops =3D { - .init_out =3D qesd_init_out, - .fini_out =3D qesd_fini_out, - .run_out =3D qesd_run_out, - .write =3D qesd_write, - .ctl_out =3D qesd_ctl_out, - - .init_in =3D qesd_init_in, - .fini_in =3D qesd_fini_in, - .run_in =3D qesd_run_in, - .read =3D qesd_read, - .ctl_in =3D qesd_ctl_in, -}; - -struct audio_driver esd_audio_driver =3D { - .name =3D "esd", - .descr =3D "http://en.wikipedia.org/wiki/Esound", - .options =3D qesd_options, - .init =3D qesd_audio_init, - .fini =3D qesd_audio_fini, - .pcm_ops =3D &qesd_pcm_ops, - .can_be_default =3D 0, - .max_voices_out =3D INT_MAX, - .max_voices_in =3D INT_MAX, - .voice_size_out =3D sizeof (ESDVoiceOut), - .voice_size_in =3D sizeof (ESDVoiceIn) -}; diff --git a/configure b/configure index 409edf9..ee67ed1 100755 --- a/configure +++ b/configure @@ -575,13 +575,13 @@ MINGW32*) GNU/kFreeBSD) bsd=3D"yes" audio_drv_list=3D"oss" - audio_possible_drivers=3D"oss sdl esd pa" + audio_possible_drivers=3D"oss sdl pa" ;; FreeBSD) bsd=3D"yes" make=3D"${MAKE-gmake}" audio_drv_list=3D"oss" - audio_possible_drivers=3D"oss sdl esd pa" + audio_possible_drivers=3D"oss sdl pa" # needed for kinfo_getvmmap(3) in libutil.h LIBS=3D"-lutil $LIBS" netmap=3D"" # enable netmap autodetect @@ -591,14 +591,14 @@ DragonFly) bsd=3D"yes" make=3D"${MAKE-gmake}" audio_drv_list=3D"oss" - audio_possible_drivers=3D"oss sdl esd pa" + audio_possible_drivers=3D"oss sdl pa" HOST_VARIANT_DIR=3D"dragonfly" ;; NetBSD) bsd=3D"yes" make=3D"${MAKE-gmake}" audio_drv_list=3D"oss" - audio_possible_drivers=3D"oss sdl esd" + audio_possible_drivers=3D"oss sdl" oss_lib=3D"-lossaudio" HOST_VARIANT_DIR=3D"netbsd" ;; @@ -606,7 +606,7 @@ OpenBSD) bsd=3D"yes" make=3D"${MAKE-gmake}" audio_drv_list=3D"sdl" - audio_possible_drivers=3D"sdl esd" + audio_possible_drivers=3D"sdl" HOST_VARIANT_DIR=3D"openbsd" ;; Darwin) @@ -674,7 +674,7 @@ Haiku) ;; *) audio_drv_list=3D"oss" - audio_possible_drivers=3D"oss alsa sdl esd pa" + audio_possible_drivers=3D"oss alsa sdl pa" linux=3D"yes" linux_user=3D"yes" kvm=3D"yes" @@ -2630,12 +2630,6 @@ for drv in $audio_drv_list; do libs_softmmu=3D"$fmod_lib $libs_softmmu" ;; =20 - esd) - audio_drv_probe $drv esd.h -lesd 'return esd_play_stream(0, 0, "", 0= );' - libs_softmmu=3D"-lesd $libs_softmmu" - audio_pt_int=3D"yes" - ;; - pa) audio_drv_probe $drv pulse/mainloop.h "-lpulse" \ "pa_mainloop *m =3D 0; pa_mainloop_free (m); return 0;" --=20 1.8.3.1