]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
evil line of code strikes again\!
authorAnthony Minessale <anthony.minessale@gmail.com>
Sat, 24 Jan 2009 00:39:37 +0000 (00:39 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Sat, 24 Jan 2009 00:39:37 +0000 (00:39 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@11475 d0543943-73ff-0310-b7d9-9358b9ac24b2

libs/portaudio/test/patest1.c
libs/portaudio/test/patest_sine.c
libs/portaudio/test/patest_sine8.c
libs/portaudio/test/patest_sine_formats.c
src/switch_core_io.c

index 0d42f17a6eee8976d137e8c832d945d5fe4ab1f9..cee23bcdb253b6e94cfde7dc05de445ca6607f7b 100644 (file)
@@ -49,7 +49,7 @@
 #define M_PI (3.14159265)
 #endif
 
-#define SAMPLE_RATE (44100)
+#define SAMPLE_RATE (8000)
 
 typedef struct
 {
index 70eebc5d5b2f49b9f4086d29da06c2cd78d2e4d7..32476cc549503471eca3a1acd35bb6c3f2a9c98c 100644 (file)
@@ -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)
index 171d2ef3d86a859e3400f4635310218c7cda4139..5d830b38a133d67a42070d415b7b25bde3c1cb5d 100644 (file)
 #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
index 22bfa594f548df88318bc52b4fd9d1221625de81..f4bdb26a50e6d16723db6ceb110780d35ca9e64e 100644 (file)
 #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 @@ typedef float               SAMPLE_t;
 #endif
 
 
+static int fd = 0;
+
 typedef struct
 {
     double left_phase;
@@ -120,14 +123,26 @@ static int patestCallback( const void *inputBuffer,
     {
         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 @@ static int patestCallback( const void *inputBuffer,
         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 @@ int main(void)
 
 
     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;
index e3ca0bc807890f3dc3d4f13bc8303efeb6cb94cd..bcc24c589ffe920d3a6d1f84d2c2d124c1b91d3d 100644 (file)
@@ -616,7 +616,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_write_frame(switch_core_sess
        
 
        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);