]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
initial reworking for mod_portaudio multiple enpoint support
authorMoises Silva <moises.silva@gmail.com>
Fri, 18 Mar 2011 01:46:52 +0000 (21:46 -0400)
committerMoises Silva <moises.silva@gmail.com>
Fri, 18 Mar 2011 01:46:52 +0000 (21:46 -0400)
conf/autoload_configs/portaudio.conf.xml
src/mod/endpoints/mod_portaudio/mod_portaudio.c
src/mod/endpoints/mod_portaudio/pablio.h

index 1f758de89609b3e5a17ffee7b372e511c6abfb9a..7389bf49cd4310103222ff7fba36974a47beb86c 100644 (file)
@@ -5,12 +5,14 @@
         or the device number prefixed with # eg "#1" (or blank for default) -->
 
     <!-- device to use for input -->
-    <param name="indev" value=""/>
+    <param name="indev" value="Built-in Input"/>
     <!-- device to use for output -->
-    <param name="outdev" value=""/>
+    <!--<param name="outdev" value="Built-in Output"/>-->
+    <param name="outdev" value="#2"/>
 
     <!--device to use for inbound ring -->
-    <!--<param name="ringdev" value=""/>-->
+    <param name="ringdev" value="Built-in Output"/>
+
     <!--File to play as the ring sound -->
     <!--<param name="ring-file" value="/sounds/ring.wav"/>-->
     <!--Number of seconds to pause between rings -->
     <param name="cid-num" value="$${outbound_caller_id}"/>
 
     <!--audio sample rate and interval -->
-    <param name="sample-rate" value="48000"/>
+    <!--<param name="sample-rate" value="48000"/>-->
+    <param name="sample-rate" value="8000"/>
     <param name="codec-ms" value="20"/>
   </settings>
+
+  <shared-devices>
+       <device friendly-name="usb1" device="#2">
+               <param name="channels" value="2" />
+               <param name="sample-rate" value="8000" />
+               <param name="codec-ms" value="20" />
+       </device>
+  </shared-devices>
+
+  <endpoints>
+
+       <endpoint name="usbout-left">
+               <param name="outdev" value="usb1:0" />
+       </endpoint>
+
+       <endpoint name="usbout-right">
+               <param name="outdev" value="usb1:1" />
+       </endpoint>
+
+  </endpoints>
+
 </configuration>
+
index baa33d456ed0c4f3295474061a078e944ceb716c..d02a3ead07eb8092f59febbdab1832821b317495 100644 (file)
@@ -106,6 +106,34 @@ struct audio_stream {
 };
 typedef struct audio_stream audio_stream_t;
 
+typedef struct _pa_shared_device {
+       /*! Sampling rate */
+       int sample_rate;
+       /*! */
+       int codec_ms;
+       /*! Device number */
+       int devno;
+       /*! Running stream (if a stream is already running for devno) */
+       audio_stream_t *stream;
+       /*! The actual portaudio device number */
+       /*! It's a shared device after all */
+       switch_mutex_t *mutex;
+} pa_shared_device_t;
+
+typedef struct _pa_endpoint {
+       /*! Input device for this endpoint */
+       pa_shared_device_t *indev;
+
+       /*! Output device for this endpoint */
+       pa_shared_device_t *outdev;
+
+       /*! Channel index within the input device stream */
+       int inchan;
+
+       /*! Channel index within the input device stream */
+       int outchan;
+} pa_endpoint_t;
+
 static struct {
        int debug;
        int port;
index 0bd3c41e4635374bbe6e37fafa9af69bf0540d67..6d99d2f01203c77d3ee7d1852487d4ee388f7307 100644 (file)
@@ -56,17 +56,19 @@ extern "C" {
 
 #include <string.h>
 
-       typedef struct {
-               PaUtilRingBuffer inFIFO;
-               PaUtilRingBuffer outFIFO;
-               PaStream *istream;
-               PaStream *ostream;
-               PaStream *iostream;
-               int bytesPerFrame;
-               int do_dual;
-               int has_in;
-               int has_out;
-       } PABLIO_Stream;
+#define MAX_IO_CHANNELS 2
+typedef struct {
+       PaStream *istream;
+       PaStream *ostream;
+       PaStream *iostream;
+       int bytesPerFrame;
+       int do_dual;
+       int has_in;
+       int has_out;
+       PaUtilRingBuffer inFIFOs[2]
+       PaUtilRingBuffer outFIFOs[2]
+       int channelCount;
+} PABLIO_Stream;
 
 /* Values for flags for OpenAudioStream(). */
 #define PABLIO_READ     (1<<0)