[Freeswitch-svn] [commit] r11475 - in freeswitch/trunk: libs/portaudio/test src

FreeSWITCH SVN anthm at freeswitch.org
Fri Jan 23 16:39:37 PST 2009


Author: anthm
Date: Fri Jan 23 18:39:37 2009
New Revision: 11475

Log:
evil line of code strikes again\!

Modified:
   freeswitch/trunk/libs/portaudio/test/patest1.c
   freeswitch/trunk/libs/portaudio/test/patest_sine.c
   freeswitch/trunk/libs/portaudio/test/patest_sine8.c
   freeswitch/trunk/libs/portaudio/test/patest_sine_formats.c
   freeswitch/trunk/src/switch_core_io.c

Modified: freeswitch/trunk/libs/portaudio/test/patest1.c
==============================================================================
--- freeswitch/trunk/libs/portaudio/test/patest1.c	(original)
+++ freeswitch/trunk/libs/portaudio/test/patest1.c	Fri Jan 23 18:39:37 2009
@@ -49,7 +49,7 @@
 #define M_PI (3.14159265)
 #endif
 
-#define SAMPLE_RATE (44100)
+#define SAMPLE_RATE (8000)
 
 typedef struct
 {

Modified: freeswitch/trunk/libs/portaudio/test/patest_sine.c
==============================================================================
--- freeswitch/trunk/libs/portaudio/test/patest_sine.c	(original)
+++ freeswitch/trunk/libs/portaudio/test/patest_sine.c	Fri Jan 23 18:39:37 2009
@@ -45,9 +45,9 @@
 #include <math.h>
 #include "portaudio.h"
 
-#define NUM_SECONDS   (5)
-#define SAMPLE_RATE   (44100)
-#define FRAMES_PER_BUFFER  (64)
+#define NUM_SECONDS   (1)
+#define SAMPLE_RATE   (8000)
+#define FRAMES_PER_BUFFER  (160)
 
 #ifndef M_PI
 #define M_PI  (3.14159265)

Modified: freeswitch/trunk/libs/portaudio/test/patest_sine8.c
==============================================================================
--- freeswitch/trunk/libs/portaudio/test/patest_sine8.c	(original)
+++ freeswitch/trunk/libs/portaudio/test/patest_sine8.c	Fri Jan 23 18:39:37 2009
@@ -45,15 +45,15 @@
 #include <math.h>
 #include "portaudio.h"
 
-#define NUM_SECONDS   (8)
+#define NUM_SECONDS   (1)
 #define SAMPLE_RATE   (44100)
 #define TABLE_SIZE    (200)
 #define TEST_UNSIGNED (0)
 
 #if TEST_UNSIGNED
-#define TEST_FORMAT   paUInt8
+#define TEST_FORMAT   paUInt16
 #else
-#define TEST_FORMAT   paInt8
+#define TEST_FORMAT   paInt16
 #endif
 
 #ifndef M_PI

Modified: freeswitch/trunk/libs/portaudio/test/patest_sine_formats.c
==============================================================================
--- freeswitch/trunk/libs/portaudio/test/patest_sine_formats.c	(original)
+++ freeswitch/trunk/libs/portaudio/test/patest_sine_formats.c	Fri Jan 23 18:39:37 2009
@@ -43,10 +43,11 @@
 #include <stdio.h>
 #include <math.h>
 #include "portaudio.h"
+#include <fcntl.h>
 
-#define NUM_SECONDS        (10)
-#define SAMPLE_RATE        (44100)
-#define FRAMES_PER_BUFFER  (512)
+#define NUM_SECONDS        (20)
+#define SAMPLE_RATE        (8000)
+#define FRAMES_PER_BUFFER  (80)
 #define LEFT_FREQ          (SAMPLE_RATE/256.0)  /* So we hit 1.0 */
 #define RIGHT_FREQ         (500.0)
 #define AMPLITUDE          (1.0)
@@ -91,6 +92,8 @@
 #endif
 
 
+static int fd = 0;
+
 typedef struct
 {
     double left_phase;
@@ -120,14 +123,26 @@
     {
         framesToCalc = data->framesToGo;
         data->framesToGo = 0;
-        finished = 1;
+        //finished = 1;
     }
     else
     {
         framesToCalc = framesPerBuffer;
         data->framesToGo -= framesPerBuffer;
     }
+	
+
+	if (!fd) {
+        fd = open("/root/sr8k.raw", O_RDONLY, 0);
+    }
+	
+	printf("WTF %d\n", framesToCalc);
 
+	i = read(fd, outputBuffer, framesToCalc * 2);
+	
+	if (!i) finished = 1;
+
+	/*
     for( i=0; i<framesToCalc; i++ )
     {
         data->left_phase += (LEFT_FREQ / SAMPLE_RATE);
@@ -138,12 +153,16 @@
         if( data->right_phase > 1.0) data->right_phase -= 1.0;
         *out++ = DOUBLE_TO_SAMPLE( AMPLITUDE * sin( (data->right_phase * M_PI * 2. )));
     }
+	*/
+
     /* zero remainder of final buffer */
+#if 0
     for( ; i<(int)framesPerBuffer; i++ )
     {
         *out++ = SAMPLE_ZERO; /* left */
         *out++ = SAMPLE_ZERO; /* right */
     }
+#endif
     return finished;
 }
 /*******************************************************************/
@@ -165,7 +184,7 @@
 
 
     outputParameters.device           = Pa_GetDefaultOutputDevice(); /* Default output device. */
-    outputParameters.channelCount     = 2;                           /* Stereo output */
+    outputParameters.channelCount     = 1;                           /* Stereo output */
     outputParameters.sampleFormat     = TEST_FORMAT;                 /* Selected above. */
     outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency;
     outputParameters.hostApiSpecificStreamInfo = NULL;

Modified: freeswitch/trunk/src/switch_core_io.c
==============================================================================
--- freeswitch/trunk/src/switch_core_io.c	(original)
+++ freeswitch/trunk/src/switch_core_io.c	Fri Jan 23 18:39:37 2009
@@ -616,7 +616,8 @@
 	
 
 	if ((session->write_codec && frame->codec && session->write_codec->implementation != frame->codec->implementation)) {
-		if (session->write_impl.microseconds_per_packet != frame->codec->implementation->microseconds_per_packet) {
+		if (session->write_impl.codec_id == frame->codec->implementation->codec_id || 
+			session->write_impl.microseconds_per_packet != frame->codec->implementation->microseconds_per_packet) {
 			ptime_mismatch = TRUE;
 			if (switch_test_flag(frame->codec, SWITCH_CODEC_FLAG_PASSTHROUGH) || switch_test_flag(session->read_codec, SWITCH_CODEC_FLAG_PASSTHROUGH)) {
 				status = perform_write(session, frame, flags, stream_id);



More information about the Freeswitch-svn mailing list