[gnome-cyr] Патч к esound на подключение к arts аудиосерверу
- From: Igor Mokrushin <igor avtomir ru>
- To: gnome-cyr gnome org
- Subject: [gnome-cyr] =?koi8-r?b?8MHU3iDLIGVzb3VuZCDOwSDQz8TLzMDexc7JxSDLIGFydHM=?==?koi8-r?b?IMHVxMnP08XS18XS1Q==?=
- Date: Wed, 8 May 2002 20:25:42 +0400
Hi All!
Сделал патч к esound версии 0.2.26, что бы он мог подключаться
к arts аудиосерверу, просто возникла необходимость использовать
esd в среде KDE из-за ряда программ и тем самым не подключаться
на прямую к /dev/dsp. Патч позволяет esd детектить, запущен ли artsd
или нет, если не запущен, то использует OSS или ALSA, т.е. как обычно.
После установки патча надо сделать ./autoconf, что бы перебилдить
./confugure. По умолчанию в configure стоит ключ --with-arts, который
ищет наличие arts в системе.
P.S. Я смог проверить эту реализацию в связке OSS+aRts, ALSA у
меня нет, так что пробуйте у кого есть. Проверял так же на запись,
esdrec'ом, вроде бы проблем небыло при воспроизведении esdcat'ом.
Есть правда одна неприятность, это сегфаулт при выходе esd,
впринципе, это виновата функция arts_init(), и похоже привязка
этого глюка идет к glibc-2.2.5. Вообщем пробуйте, и сообщайте...
diff -ruN esound-0.2.26.orig/audio_alsa.c esound-0.2.26/audio_alsa.c
--- esound-0.2.26.orig/audio_alsa.c Mon Oct 9 19:08:32 2000
+++ esound-0.2.26/audio_alsa.c Wed May 8 17:09:06 2002
@@ -12,6 +12,16 @@
# include <sys/soundlib.h>
#endif
+/* aRts sound server support for EsounD
+ 06.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+#include <artsc.h>
+arts_stream_t stream;
+int err_arts = -1;
+int trigger = 0;
+#endif
+
#if (SND_LIB_MINOR > 4)
# define ALSA_5_API
#endif
@@ -61,6 +71,15 @@
int esd_audio_open()
{
+#ifdef DRIVER_ARTS
+if ( trigger == 0) {
+ err_arts = arts_init();
+} else {
+ err_arts = -1;
+}
+if (err_arts < 0) {
+#endif
+
int mask, card=ALSACARD, device=ALSADEVICE;
int nbr_cards, ret;
char buf[256];
@@ -84,6 +103,10 @@
snd_ctl_t *ctl_handle;
+#ifdef DRIVER_ARTS
+ trigger = 1;
+#endif
+
if( driver_trace ) {
fprintf( stderr, "Using ALSA %s\n", SND_LIB_VERSION_STR );
}
@@ -317,18 +340,55 @@
#else
return ( esd_audio_fd = snd_pcm_file_descriptor(alsa_sound_handle) );
#endif
+#ifdef DRIVER_ARTS
+} else {
+ int channels;
+ int bits;
+
+ channels = ( ( ( esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO )
+ ? /* stereo */ 2 : /* mono */ 1 );
+ bits = ( (esd_audio_format & ESD_MASK_BITS) == ESD_BITS16 )
+ ? /* 16 bit */ 16 : /* 8 bit */ 8;
+
+ if ((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) {
+ stream = arts_record_stream(esd_audio_rate, bits, channels, "esd");
+ } else {
+ stream = arts_play_stream(esd_audio_rate, bits, channels, "esd");
+ }
+
+ arts_stream_set(stream, ARTS_P_BUFFER_TIME, 500);
+
+ esd_audio_fd = 0;
+ return esd_audio_fd;
+}
+#endif
+
}
#define ARCH_esd_audio_close
void esd_audio_close()
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
snd_pcm_close( alsa_sound_handle );
+#ifdef DRIVER_ARTS
+ } else {
+ arts_close_stream(stream);
+ arts_free();
+ return;
+ }
+#endif
}
#define ARCH_esd_audio_pause
void esd_audio_pause()
{
+#ifdef DRIVER_ARTS
+ if (err_arts >= 0)
+ return;
+#endif
/* apparently this gets rid of pending data, which isn't the effect
we're going for, namely, play the data in the buffers and stop */
/* snd_pcm_drain_playback( handle ); */
@@ -337,12 +397,23 @@
#define ARCH_esd_audio_read
int esd_audio_read( void *buffer, int buf_size )
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
return (snd_pcm_read( alsa_sound_handle, buffer, buf_size ));
+#ifdef DRIVER_ARTS
+ } else {
+ return (arts_read( stream, buffer, buf_size ));
+ }
+#endif
}
#define ARCH_esd_audio_write
int esd_audio_write( void *buffer, int buf_size )
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
int i=0;
#ifdef ALSA_5_API
@@ -380,6 +451,11 @@
#endif /* ALSA_5_API */
return (i);
+#ifdef DRIVER_ARTS
+ } else {
+ return (arts_write( stream, buffer, buf_size ));
+ }
+#endif
}
#define ARCH_esd_audio_flush
@@ -387,4 +463,8 @@
{
fsync( esd_audio_fd );
/*snd_pcm_flush_playback( handle );*/
+#ifdef DRIVER_ARTS
+ if (err_arts >= 0)
+ return;
+#endif
}
diff -ruN esound-0.2.26.orig/audio_alsa09.c esound-0.2.26/audio_alsa09.c
--- esound-0.2.26.orig/audio_alsa09.c Fri May 3 18:46:57 2002
+++ esound-0.2.26/audio_alsa09.c Wed May 8 17:10:28 2002
@@ -25,7 +25,17 @@
int alsadbg = 0;
#include <alsa/asoundlib.h>
-
+/* aRts sound server support for EsounD
+ 06.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+#include <artsc.h>
+arts_stream_t stream;
+int err_arts = -1;
+int trigger = 0;
+#endif
+
+
/* FULL DUPLEX => two handlers */
static snd_pcm_t *alsa_playback_handle = NULL;
@@ -195,13 +205,24 @@
int esd_audio_open()
{
-
+
int channels;
int format;
+#ifdef DRIVER_ARTS
+ int bits;
+
+ if ( trigger == 0) {
+ err_arts = arts_init();
+ } else {
+ err_arts = -1;
+ }
+
+ if (err_arts < 0) {
+ trigger = 1;
+#endif
if (alsadbg)
fprintf(stderr, "esd_audio_open\n");
-
if ((esd_audio_format & ESD_MASK_BITS) == ESD_BITS16)
format = SND_PCM_FORMAT_S16_LE;
@@ -248,11 +269,36 @@
print_state();
return 0;
+#ifdef DRIVER_ARTS
+ } else {
+
+ channels = ( ( ( esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO )
+ ? /* stereo */ 2 : /* mono */ 1 );
+ bits = ( (esd_audio_format & ESD_MASK_BITS) == ESD_BITS16 )
+ ? /* 16 bit */ 16 : /* 8 bit */ 8;
+
+
+ if ((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) {
+ stream = arts_record_stream(esd_audio_rate, bits, channels, "esd");
+ } else {
+ stream = arts_play_stream(esd_audio_rate, bits, channels, "esd");
+ }
+
+ arts_stream_set(stream, ARTS_P_BUFFER_TIME, 500);
+
+ esd_audio_fd = 0;
+ return esd_audio_fd;
+ }
+#endif
+
}
#define ARCH_esd_audio_close
void esd_audio_close()
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
if (alsadbg) {
fprintf(stderr, "esd_audio_close\n");
print_state();
@@ -264,18 +310,29 @@
snd_pcm_close(alsa_capture_handle);
alsa_playback_handle = NULL;
alsa_capture_handle = NULL;
+#ifdef DRIVER_ARTS
+ } else {
+ arts_close_stream(stream);
+ arts_free();
+ return;
+ }
+#endif
+
}
#define ARCH_esd_audio_pause
void esd_audio_pause()
{
-
+
return;
}
#define ARCH_esd_audio_read
int esd_audio_read( void *buffer, int buf_size )
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
int err;
int len = snd_pcm_bytes_to_frames(alsa_capture_handle, buf_size);
@@ -320,12 +377,20 @@
}
return ( snd_pcm_frames_to_bytes(alsa_capture_handle, err) );
+#ifdef DRIVER_ARTS
+ } else {
+ return (arts_read( stream, buffer, buf_size ));
+ }
+#endif
}
#define ARCH_esd_audio_write
int esd_audio_write( void *buffer, int buf_size )
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
int err;
int len = snd_pcm_bytes_to_frames(alsa_playback_handle, buf_size);
@@ -366,11 +431,19 @@
}
return ( snd_pcm_frames_to_bytes(alsa_playback_handle, err) );
+#ifdef DRIVER_ARTS
+ } else {
+ return (arts_write( stream, buffer, buf_size ));
+ }
+#endif
}
#define ARCH_esd_audio_flush
void esd_audio_flush()
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
if (alsadbg) {
fprintf(stderr, "esd_audio_flush\n");
@@ -381,6 +454,10 @@
if (alsadbg)
print_state();
-
-
+#ifdef DRIVER_ARTS
+ } else {
+ fsync( esd_audio_fd );
+ return;
+ }
+#endif
}
diff -ruN esound-0.2.26.orig/audio_oss.c esound-0.2.26/audio_oss.c
--- esound-0.2.26.orig/audio_oss.c Tue Jul 18 20:33:41 2000
+++ esound-0.2.26/audio_oss.c Wed May 8 17:10:08 2002
@@ -16,21 +16,44 @@
#define SNDCTL_DSP_SETDUPLEX DSP_CAP_DUPLEX
#endif
+/* aRts sound server support for EsounD
+ 06.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+#include <artsc.h>
+arts_stream_t stream;
+int err_arts = -1;
+int trigger = 0;
+#endif
+
#define ARCH_esd_audio_devices
const char *esd_audio_devices()
{
+#ifdef DRIVER_ARTS
+ return "/dev/dsp, /dev/dsp2, etc. or sound server aRts";
+#else
return "/dev/dsp, /dev/dsp2, etc.";
+#endif
}
-
#define ARCH_esd_audio_open
int esd_audio_open()
{
+#ifdef DRIVER_ARTS
+ if ( trigger == 0) {
+ err_arts = arts_init();
+ } else {
+ err_arts = -1;
+ }
+ if (err_arts < 0) {
+#endif
const char *device;
int afd = -1, value = 0, test = 0;
int mode = O_WRONLY;
-
+#ifdef DRIVER_ARTS
+ trigger = 1;
+#endif
/* if recording, set for full duplex mode */
if ( (esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD )
mode = O_RDWR;
@@ -41,7 +64,7 @@
device = esd_audio_device ? esd_audio_device : "/dev/dsp";
if ((afd = open(device, mode, 0)) == -1)
{ /* Opening device failed */
- perror(device);
+ /* perror(device); */
return( -2 );
}
@@ -137,12 +160,80 @@
/* value = test = buf_size; */
esd_audio_fd = afd;
return afd;
+#ifdef DRIVER_ARTS
+ } else {
+
+ int channels;
+ int bits;
+
+ channels = ( ( ( esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO )
+ ? /* stereo */ 2 : /* mono */ 1 );
+ bits = ( (esd_audio_format & ESD_MASK_BITS) == ESD_BITS16 )
+ ? /* 16 bit */ 16 : /* 8 bit */ 8;
+
+
+ if ((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) {
+ stream = arts_record_stream(esd_audio_rate, bits, channels, "esd");
+ } else {
+ stream = arts_play_stream(esd_audio_rate, bits, channels, "esd");
+ }
+
+ arts_stream_set(stream, ARTS_P_BUFFER_TIME, 500);
+
+ esd_audio_fd = 0;
+ return esd_audio_fd;
+ }
+#endif
+
}
#define ARCH_esd_audio_pause
void esd_audio_pause()
{
+#ifdef DRIVER_ARTS
+ if (err_arts < 0) {
+#endif
/* per oss specs */
ioctl( esd_audio_fd, SNDCTL_DSP_POST, 0 );
return;
+#ifdef DRIVER_ARTS
+ } else {
+ return;
+ }
+#endif
+}
+
+#ifdef DRIVER_ARTS
+#define ARCH_esd_audio_close
+void esd_audio_close()
+{
+ if (err_arts < 0) {
+ close( esd_audio_fd );
+ return;
+ } else {
+ arts_close_stream(stream);
+ arts_free();
+ return;
+ }
}
+
+#define ARCH_esd_audio_write
+int esd_audio_write( void *buffer, int buf_size )
+{
+ if (err_arts < 0) {
+ return write( esd_audio_fd, buffer, buf_size );
+ } else {
+ return (arts_write( stream, buffer, buf_size ));
+ }
+}
+
+#define ARCH_esd_audio_read
+int esd_audio_read( void *buffer, int buf_size )
+{
+ if (err_arts < 0) {
+ return read( esd_audio_fd, buffer, buf_size );
+ } else {
+ return (arts_read( stream, buffer, buf_size ));
+ }
+}
+#endif
diff -ruN esound-0.2.26.orig/config.h.in esound-0.2.26/config.h.in
--- esound-0.2.26.orig/config.h.in Tue Apr 23 13:35:04 2002
+++ esound-0.2.26/config.h.in Wed May 8 18:02:02 2002
@@ -44,6 +44,7 @@
#undef DRIVER_ALSA_09
#undef DRIVER_DART
#undef DRIVER_NONE
+#undef DRIVER_ARTS
#undef HAVE_INET_ATON
#undef HAVE_NANOSLEEP
#undef USE_LIBWRAP
diff -ruN esound-0.2.26.orig/configure.in esound-0.2.26/configure.in
--- esound-0.2.26.orig/configure.in Mon May 6 12:27:26 2002
+++ esound-0.2.26/configure.in Wed May 8 18:58:07 2002
@@ -209,6 +209,25 @@
AC_CHECK_FUNC(snd_cards,,[AC_CHECK_LIB(asound,snd_cards)])
AC_CHECK_FUNC(snd_pcm_pause,,[AC_CHECK_LIB(asound,snd_pcm_pause)])
fi
+
+ AC_ARG_WITH(arts,[ --with-arts with arts if available [default=yes]], , with_arts=yes)
+
+ if test "x$with_arts" = "xyes"; then
+ AC_PATH_PROG(ARTSC_CONFIG, artsc-config)
+ AM_CONDITIONAL(DRIVER_ARTS,test "x$ac_cv_path_ARTSC_CONFIG" != x)
+
+ if test "x$ac_cv_path_ARTSC_CONFIG" != x
+ then
+ ARTS_CFLAGS=`$ac_cv_path_ARTSC_CONFIG --cflags`
+ ARTS_LIBS=`$ac_cv_path_ARTSC_CONFIG --libs`
+ CFLAGS="$CFLAGS $ARTS_CFLAGS"
+ LIBS="$LIBS $ARTS_LIBS"
+ AC_DEFINE(DRIVER_ARTS)
+ fi
+
+ fi
+
+
else
AC_DEFINE(DRIVER_NONE)
fi
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]