[PATCH] esd jack output
- From: Reza Jelveh <reza jelveh tu-harburg de>
- To: gnome-multimedia gnome org <gnome-multimedia gnome org>
- Subject: [PATCH] esd jack output
- Date: Tue, 3 Aug 2004 14:41:37 +0200
hi,
this should add jack to esd you need to have libbio2jack and jack installed and bio2jack.h in /{exec_prefix}/include/jack.
however there is still a problem. even tho libbio2jack should handle the blocking write esd_audio_write gets called so often that esd has 99% cpu useage while playing audio i really dont yet know how to fix it :/.
if you can help me. also this is initial so framerate conversion must still be done i think if esd and jack run in different configurations(i think? worked here with std esd.conf)
after patching dont forget
autoheader; autoconf ; automake
to enable jack output ./configure --disable-alsa --enable-jack
regards,
reza jelveh
--- audio_jack.c 1970-01-01 01:00:00.000000000 +0100
+++ audio_jack.c-new 2004-08-03 14:38:47.723464416 +0200
@@ -0,0 +1,126 @@
+/* JACK support for esound
+ 2004 Reza Jelveh <reza jelveh tuhh de>
+*/
+#include "esd.h"
+
+#include <jack/bio2jack.h>
+
+#define OUTFILE stderr
+
+/* debugging messages for audio device */
+#define TRACE_ENABLE 1
+#if TRACE_ENABLE
+ #define TRACE(...) fprintf(OUTFILE, "%s:", __FUNCTION__), \
+ fprintf(OUTFILE, __VA_ARGS__), \
+ fflush(OUTFILE);
+#else
+ #define TRACE(...) do{}while(0)
+#endif
+
+ #define ERR(...) fprintf(OUTFILE, "ERR: %s:", __FUNCTION__),\
+ fprintf(OUTFILE, __VA_ARGS__), \
+ fflush(OUTFILE);
+
+
+/* so that EsounD can use other cards besides the first */
+/* some identifiers changed names */
+
+#define ARCH_esd_audio_open
+
+int esd_audio_open()
+{
+ int retval;
+
+ TRACE (" entering esd_audio_open() \n");
+
+ JACK_Init(); /* initialize the driver */
+
+ /* open the jack device with true jack's rate, return 0 upon failure */
+ unsigned long rate = esd_audio_rate;
+ int bits= ((esd_audio_format & ESD_MASK_BITS) == ESD_BITS16) ? 16 : 8 ;
+
+ int channels =( ( esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO ) ? 2 : 1;
+
+ if((retval = JACK_Open(&esd_audio_fd, bits , &rate,
+ channels)))
+ {
+ ERR("failed to open jack with JACK_Open(), error %d\n", retval);
+ esd_audio_fd = -1;
+ return ( -1 );
+ }
+ TRACE( "success!!\n");
+
+
+ return esd_audio_fd ;
+
+}
+
+#define ARCH_esd_audio_close
+void esd_audio_close()
+{
+ int errval;
+ TRACE (" entering esd_audio_close() \n");
+ JACK_Reset(esd_audio_fd); /* flush buffers, reset position and set state to STOPPED */
+ TRACE("resetting driver, not closing now, destructor will close for us\n");
+ TRACE("calling JACK_Close()\n");
+ if((errval = JACK_Close(esd_audio_fd)))
+ {
+ ERR("error closing device, errval of %d\n", errval);
+ }
+ return errval;
+
+
+}
+
+#define ARCH_esd_audio_pause
+void esd_audio_pause()
+{
+ TRACE (" entering esd_audio_pause() \n");
+ if(JACK_GetState(esd_audio_fd) == PAUSED)
+ JACK_SetState(esd_audio_fd, PLAYING);
+ else
+ JACK_SetState(esd_audio_fd, PAUSED);
+
+}
+
+#define ARCH_esd_audio_read
+int esd_audio_read( void *buffer, int buf_size )
+{
+ TRACE (" entering esd_audio_read() \n");
+ return 0;
+}
+
+
+#define ARCH_esd_audio_write
+int esd_audio_write( void *buffer, int buf_size )
+{
+ int i=0;
+ int written;
+int length =buf_size;
+
+ TRACE (" entering esd_audio_write() \n");
+ while(length > 0)
+ {
+ TRACE("writing %d bytes\n", length);
+ written = JACK_Write(esd_audio_fd, buffer, length);
+ i+=written;
+ length-=written;
+ ((char *)buffer) += written;
+ }
+ TRACE("finished\n");
+
+
+ return (i);
+
+// return length;
+}
+
+#define ARCH_esd_audio_flush
+void esd_audio_flush()
+{
+ TRACE (" entering esd_audio_flush() \n");
+ JACK_Reset(esd_audio_fd); /* flush buffers and set state to STOPPED */
+
+ JACK_SetState(esd_audio_fd, PLAYING);
+
+}
--- audio.c.old 2004-08-03 14:36:38.699079104 +0200
+++ audio.c 2004-08-03 14:19:22.918541680 +0200
@@ -25,6 +25,8 @@
# include "audio_alsa.c"
#elif defined(DRIVER_ALSA_09)
#include "audio_alsa09.c"
+#elif defined(DRIVER_JACK)
+# include "audio_jack.c"
#elif defined(DRIVER_OSS)
# include "audio_oss.c"
#elif defined(DRIVER_AIX)
@@ -44,7 +46,7 @@
#elif defined(DRIVER_COREAUDIO)
# include "audio_coreaudio.c"
#else
-# include "audio_none.c"
+# include "audio_null.c"
#endif
/*******************************************************************/
--- Makefile.am 2004-08-03 14:36:23.300420056 +0200
+++ Makefile.am-new 2004-08-03 00:38:08.000000000 +0200
@@ -48,6 +48,7 @@
audio_alsa09.c \
audio_coreaudio.c \
audio_dart.c \
+ audio_jack.c \
audio_hpux.c \
audio_mklinux.c \
audio_irix.c \
--- configure.in 2004-08-03 14:36:10.070431320 +0200
+++ configure.in-new 2004-08-03 14:19:55.740551976 +0200
@@ -248,6 +248,24 @@
fi
fi
+ AC_ARG_ENABLE(jack,[ --enable-jack use JACK if available [default=no]], , enable_jack=no)
+
+
+ if test "x$enable_jack" = "xyes"; then
+ AC_CHECK_HEADER(jack/bio2jack.h,
+ [
+ arts_libjack_include=yes
+ ])
+ if test "x$arts_libjack_include" = "xyes"; then
+ AC_CHECK_LIB(bio2jack,JACK_Init,[
+ SOUND_LIBS="$SOUND_LIBS -lbio2jack -ljack"
+ AC_DEFINE(DRIVER_JACK, 1,
+ [Define if you have libjack (required if you want JACK support)])
+ ],,-ljack)
+ fi
+
+ fi
+
if test "${ac_cv_header_CoreAudio_CoreAudio_h}" = "yes"; then
found_sound=yes
AC_DEFINE(DRIVER_COREAUDIO)
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]