Re: [gnome-cyr] Re: [gnome-cyr] Патч к esound на подключение к arts аудиосерверу
- From: Igor Mokrushin <igor avtomir ru>
- To: gnome-cyr gnome org
- Subject: Re: [gnome-cyr] Re: [gnome-cyr] =?koi8-r?b?8MHU3iDLIGVzb3VuZCDOwSDQz8TLzMDexc7JxSDLIGFydHM=?==?koi8-r?b?IMHVxMnP08XS18XS1Q==?=
- Date: Mon, 13 May 2002 17:10:51 +0400
13 Май 2002 15:51, Igor Mokrushin написал:
> P.S. Патч почти закончен, остается тщательная проверка, как закончу, так
> сразу пошлю новый...
А вот и сам патч...
diff -ruN esound-0.2.26.orig/audio.c esound-0.2.26/audio.c
--- esound-0.2.26.orig/audio.c Tue Apr 23 13:33:07 2002
+++ esound-0.2.26/audio.c Mon May 13 16:26:10 2002
@@ -100,3 +100,61 @@
return;
}
#endif
+
+/* aRts sound server support for EsounD
+ 13.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+int dlarts()
+{
+handle = dlopen ("libartsc.so.0", RTLD_LAZY);
+
+if (!handle) {
+
+trigger = 1;
+err_arts = -1;
+
+} else {
+arts_init = dlsym(handle, "arts_init");
+arts_free = dlsym(handle, "arts_free");
+arts_read = dlsym(handle, "arts_read");
+arts_write = dlsym(handle, "arts_write");
+arts_play_stream = dlsym(handle, "arts_play_stream");
+arts_record_stream = dlsym(handle, "arts_record_stream");
+arts_close_stream = dlsym(handle, "arts_close_stream");
+arts_stream_set = dlsym(handle, "arts_stream_set");
+}
+}
+
+int arts_start()
+{
+ int channelss;
+ int bits;
+
+ channelss = ( ( ( 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, channelss, "esd");
+ } else {
+ stream = arts_play_stream(esd_audio_rate, bits, channelss, "esd");
+ }
+
+ arts_stream_set(stream, ARTS_P_BUFFER_TIME, 500);
+
+ esd_audio_fd = 0;
+ return esd_audio_fd;
+
+}
+
+int arts_end()
+{
+ arts_close_stream(stream);
+ arts_free();
+ dlclose(handle);
+ return;
+}
+#endif
+
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 Mon May 13 16:30:44 2002
@@ -12,6 +12,13 @@
# include <sys/soundlib.h>
#endif
+/* aRts sound server support for EsounD
+ 13.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+#include "esdarts.h"
+#endif
+
#if (SND_LIB_MINOR > 4)
# define ALSA_5_API
#endif
@@ -61,6 +68,16 @@
int esd_audio_open()
{
+#ifdef DRIVER_ARTS
+dlarts();
+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 +101,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 +338,35 @@
#else
return ( esd_audio_fd = snd_pcm_file_descriptor(alsa_sound_handle) );
#endif
-
+#ifdef DRIVER_ARTS
+} else {
+arts_start();
+}
+#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_end();
+ }
+#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 +375,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 +429,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 +441,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 Mon May 13 16:29:58 2002
@@ -25,7 +25,14 @@
int alsadbg = 0;
#include <alsa/asoundlib.h>
-
+/* aRts sound server support for EsounD
+ 13.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+#include "esdarts.h"
+#endif
+
+
/* FULL DUPLEX => two handlers */
static snd_pcm_t *alsa_playback_handle = NULL;
@@ -195,13 +202,23 @@
int esd_audio_open()
{
-
+
int channels;
int format;
+#ifdef DRIVER_ARTS
+ dlarts();
+ 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 +265,20 @@
print_state();
return 0;
+#ifdef DRIVER_ARTS
+ } else {
+ arts_start();
+ }
+#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 +290,27 @@
snd_pcm_close(alsa_capture_handle);
alsa_playback_handle = NULL;
alsa_capture_handle = NULL;
+#ifdef DRIVER_ARTS
+ } else {
+ arts_end();
+ }
+#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 +355,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 +409,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 +432,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 Mon May 13 16:51:54 2002
@@ -16,21 +16,43 @@
#define SNDCTL_DSP_SETDUPLEX DSP_CAP_DUPLEX
#endif
+/* aRts sound server support for EsounD
+ 13.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+#include "esdarts.h"
+#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
+ dlarts();
+
+ 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;
@@ -137,12 +159,59 @@
/* value = test = buf_size; */
esd_audio_fd = afd;
return afd;
+#ifdef DRIVER_ARTS
+ } else {
+ arts_start();
+ }
+#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_end();
+ }
+}
+
+#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 Mon May 13 16:47:09 2002
@@ -209,6 +209,16 @@
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 use arts if available [default=yes]], , with_arts=yes)
+
+ if test "x$with_arts" = "xyes"; then
+ CFLAGS="$CFLAGS -rdynamic"
+ LIBS="$LIBS -ldl"
+ AC_DEFINE(DRIVER_ARTS)
+ fi
+
+
else
AC_DEFINE(DRIVER_NONE)
fi
diff -ruN esound-0.2.26.orig/esdarts.h esound-0.2.26/esdarts.h
--- esound-0.2.26.orig/esdarts.h Thu Jan 1 03:00:00 1970
+++ esound-0.2.26/esdarts.h Mon May 13 16:41:00 2002
@@ -0,0 +1,63 @@
+/* aRts sound server support for EsounD
+ * 13.05.2002 Igor Mokrushin (igor avtomir ru)
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ */
+
+#ifndef ESDARTS_H
+#define ESDARTS_H
+#include <dlfcn.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+enum arts_parameter_t_enum {
+ ARTS_P_BUFFER_SIZE = 1,
+ ARTS_P_BUFFER_TIME = 2,
+ ARTS_P_BUFFER_SPACE = 3,
+ ARTS_P_SERVER_LATENCY = 4,
+ ARTS_P_TOTAL_LATENCY = 5,
+ ARTS_P_BLOCKING = 6,
+ ARTS_P_PACKET_SIZE = 7,
+ ARTS_P_PACKET_COUNT = 8,
+ ARTS_P_PACKET_SETTINGS = 9
+};
+
+typedef void *arts_stream_t;
+typedef enum arts_parameter_t_enum arts_parameter_t;
+
+void *handle;
+
+int (*arts_init)(void);
+void (*arts_free)(void);
+int (*arts_read)(arts_stream_t sst, void *bbuffer, int ccount);
+int (*arts_write)(arts_stream_t sst, const void *bbuffer, int ccount);
+void (*arts_close_stream)(arts_stream_t sst);
+int (*arts_stream_set)(arts_stream_t sst, arts_parameter_t pparam, int vvalue);
+
+arts_stream_t (*arts_play_stream)(int rrate, int bbits, int cch, const char *nn);
+arts_stream_t (*arts_record_stream)(int rrate, int bbits, int cch, const char *nn);
+
+arts_stream_t stream;
+int err_arts = -1;
+int trigger = 0;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* #ifndef ESDARTS_H */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]