Re: [gnome-cyr] о проталкивании патча к esd в офиц. пакет



Hi All!

Высылаю свой окончательный патч с изменениями.
Следуя пожеланиям дописал поддержку arts для
остальных звуковых систем, кроме HP-UX....
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	Fri May 17 18:35:16 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", 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;
+
+    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, 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_aix.c esound-0.2.26/audio_aix.c
--- esound-0.2.26.orig/audio_aix.c	Tue Sep 26 21:00:25 2000
+++ esound-0.2.26/audio_aix.c	Fri May 17 18:47:15 2002
@@ -5,9 +5,28 @@
 
 #include <sys/audio.h>
 
+/* aRts sound server support for EsounD
+   17.05.2002 Igor Mokrushin (igor avtomir ru)
+*/
+#ifdef DRIVER_ARTS
+#include "esdarts.h"
+#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
+			    
    audio_init a_init;
    audio_change a_change;
    audio_control a_control;
@@ -15,9 +34,12 @@
    int mode = O_WRONLY;
    int flag;
    static const char device[] = "/dev/paud0/1";
-   
+#ifdef DRIVER_ARTS
+   trigger = 1;
+#endif
+       
    if ((esd_audio_format & ESD_MASK_FUNC) == ESD_RECORD) {
-       fprintf(stderr, "No idea how to record audio on solaris, FIXME\n");
+       fprintf(stderr, "No idea how to record audio on AIX, FIXME\n");
        esd_audio_fd = -1;
        return -1;
    }
@@ -81,4 +103,42 @@
    
    esd_audio_fd = afd;
    return afd;
+#ifdef DRIVER_ARTS
+    } else {
+        arts_start();
+    }
+#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/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_irix.c esound-0.2.26/audio_irix.c
--- esound-0.2.26.orig/audio_irix.c	Tue Jun 15 01:36:09 1999
+++ esound-0.2.26/audio_irix.c	Fri May 17 19:03:20 2002
@@ -11,6 +11,13 @@
 #include <assert.h>
 #include <dmedia/audio.h>
 
+/* aRts sound server support for EsounD
+   17.05.2002 Igor Mokrushin (igor avtomir ru)
+ */
+#ifdef DRIVER_ARTS
+#include "esdarts.h"
+#endif
+   
 ALport outaudioport = (ALport) 0;
 ALport inaudioport = (ALport) 0;
 
@@ -19,9 +26,24 @@
 #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
+				    
     ALconfig audioconfig;
     audioconfig = ALnewconfig();
-  
+#ifdef DRIVER_ARTS
+    trigger = 1;
+#endif
+
 	rate_params[1] = esd_audio_rate;
 	rate_params[3] = esd_audio_rate;
 
@@ -128,11 +150,19 @@
 
     }
     return esd_audio_fd;
+#ifdef DRIVER_ARTS
+    } else {
+        arts_start();
+    }
+#endif
 }
 
 #define ARCH_esd_audio_close
 void esd_audio_close()
 {
+#ifdef DRIVER_ARTS
+    if (err_arts < 0) {
+#endif
     /*
      * I guess this chunk of code is meant to make sure that
      * everything that was sent to the output got written
@@ -157,11 +187,19 @@
       ALcloseport(inaudioport);
       inaudioport = (ALport) 0;
     }
+#ifdef DRIVER_ARTS
+    } else {
+        arts_end();
+    }
+#endif
 }
 
 #define ARCH_esd_audio_write
 int esd_audio_write(void *buffer, int buf_size)
 {
+#ifdef DRIVER_ARTS
+    if (err_arts < 0) {
+#endif
 	ALsetparams(AL_DEFAULT_DEVICE, rate_params, 2);
     if (ALwritesamps(outaudioport, buffer, buf_size / 2) == 0) {
 	ALsetfillpoint(outaudioport, ESD_BUF_SIZE);
@@ -169,11 +207,19 @@
     }
     else
 	return 0;    
+#ifdef DRIVER_ARTS
+    } else {
+        return (arts_write( stream, buffer, buf_size ));
+    }
+#endif
 }
 
 #define ARCH_esd_audio_read
 int esd_audio_read(void *buffer, int buf_size)
 {
+#ifdef DRIVER_ARTS
+    if (err_arts < 0) {
+#endif
 	ALsetparams(AL_DEFAULT_DEVICE, (rate_params + 2), 2);
     if (ALreadsamps(inaudioport, buffer, buf_size / 2) == 0) {
 	ALsetfillpoint(inaudioport, ESD_BUF_SIZE);
@@ -181,6 +227,11 @@
     }
     else
 	return 0;
+#ifdef DRIVER_ARTS
+    } else {
+        return (arts_read( stream, buffer, buf_size ));
+    }
+#endif
 }
 
 #define ARCH_esd_audio_flush
diff -ruN esound-0.2.26.orig/audio_mklinux.c esound-0.2.26/audio_mklinux.c
--- esound-0.2.26.orig/audio_mklinux.c	Mon Aug 10 00:25:56 1998
+++ esound-0.2.26/audio_mklinux.c	Fri May 17 19:21:00 2002
@@ -8,14 +8,35 @@
 #  endif
 #endif
 
+/* aRts sound server support for EsounD
+   17.05.2002 Igor Mokrushin (igor avtomir ru)
+ */
+#ifdef DRIVER_ARTS
+#include "esdarts.h"
+#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 = "/dev/dsp";
 
     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;
@@ -107,18 +128,34 @@
     esd_audio_fd = afd;
     sleep(1); /* give the driver a chance to wake up, it's kinda finicky that way... */
     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
 }
 
 #define ARCH_esd_audio_write
 int esd_audio_write( void *buffer, int buf_size ) {
+#ifdef DRIVER_ARTS
+    if (err_arts < 0) {
+#endif
   int stereo =  ( esd_audio_format & ESD_MASK_CHAN) == ESD_STEREO;
   int bits = (esd_audio_format & ESD_MASK_BITS) == ESD_BITS16;
   int i;
@@ -130,4 +167,34 @@
       ((char*)buffer)[i] = ((unsigned char*)buffer)[i] ^ 0x80;
  
   return write( esd_audio_fd, buffer, buf_size );
+#ifdef DRIVER_ARTS
+    } else {
+    return (arts_write( stream, buffer, buf_size ));
+    }
+#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_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
+			    
+				    
\ No newline at end of file
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/audio_solaris.c esound-0.2.26/audio_solaris.c
--- esound-0.2.26.orig/audio_solaris.c	Sat Jul  7 07:41:49 2001
+++ esound-0.2.26/audio_solaris.c	Fri May 17 19:38:22 2002
@@ -15,6 +15,13 @@
 #include <errno.h>
 #include <alloca.h>
 
+/* aRts sound server support for EsounD
+   17.05.2002 Igor Mokrushin (igor avtomir ru)
+ */
+#ifdef DRIVER_ARTS
+#include "esdarts.h"
+#endif
+
 
 /* if you want to confirm proper device setup, uncomment the following line */
 /* #define ESDBG_DRIVER */
@@ -129,7 +136,11 @@
     return my_ports + 2;
 
 hell:
+#ifdef DRIVER_ARTS
+    return "speaker, lineout, headphone or sound server aRts";
+#else
     return "speaker, lineout, headphone";
+#endif
 }
 
 
@@ -237,6 +248,17 @@
 #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
+				    
     int afd = -1, cafd = -1;
     audio_device_t adev;
     char *device, *devicectl;
@@ -249,7 +271,10 @@
      * it can't be very large and it will allow us to just return and not
      * care about freeing the memory.  -- dave arsdigita com
      */
-
+#ifdef DRIVER_ARTS
+    trigger = 1;
+#endif
+   
     if ((device = getenv("AUDIODEV")) == NULL)
 	device = default_device;
     devicectl = alloca(strlen(device) + 4);
@@ -515,12 +540,21 @@
     
     esd_audio_fd = afd;
     return afd;
+#ifdef DRIVER_ARTS
+    } else {
+        arts_start();
+    }
+#endif
 }
 
 #define ARCH_esd_audio_flush
 void
 esd_audio_flush()
 {
+#ifdef DRIVER_ARTS
+    if (err_arts < 0) {
+#endif
+    
     if (esd_audio_format & (ESD_PLAY | ESD_RECORD) == ESD_PLAY | ESD_RECORD)
 	ioctl(esd_audio_fd, I_FLUSH, FLUSHRW);
     else
@@ -529,12 +563,48 @@
 	else
 	    if (esd_audio_format & ESD_RECORD == ESD_RECORD)
 		ioctl(esd_audio_fd, I_FLUSH, FLUSHR);
+#ifdef DRIVER_ARTS
+    } else {
+        fsync( esd_audio_fd );
+        return;
+    }
+#endif
 }
 
 #define ARCH_esd_audio_close
 void
 esd_audio_close()
 {
+#ifdef DRIVER_ARTS
+    if (err_arts < 0) {
+#endif
     /* esd_audio_flush();  Should we flush here or not? */
     close(esd_audio_fd);
+#ifdef DRIVER_ARTS
+    } else {
+        arts_end();
+    }
+#endif
 }
+
+#ifdef DRIVER_ARTS
+#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]