fixed bug, can now run soudn card1 at 44kHz
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 12 Nov 2012 04:30:48 +0000 (04:30 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Mon, 12 Nov 2012 04:30:48 +0000 (04:30 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@960 01035d8c-6547-0410-b346-abe4f91aad63

fdmdv2/src/fdmdv2_main.cpp

index 1624223a5f0cfd07f15c3baddc9014dea9623cd4..220c92b7cd55d241ca43ee6b9cd708325b7e7ee7 100644 (file)
@@ -1479,6 +1479,8 @@ int MainFrame::rxCallback(
     short           *wptr    = (short*)outputBuffer;
 
     // temp buffers re-used by tx and rx processing
+    // signals in in48k/out48k are at a maximum sample rate of 48k, could be 44.1kHz
+    // depending on sound hardware.
 
     short           in8k_short[2*N8];
     short           in48k_short[2*N48];
@@ -1526,11 +1528,13 @@ int MainFrame::rxCallback(
 
     // while we have enough input samples available ...
 
-    while (fifo_read(cbData->infifo1, in48k_short, N48) == 0)
+    int nsam = g_soundCard1SampleRate * (float)N8/FS;
+    assert(nsam <= N48);
+    while (fifo_read(cbData->infifo1, in48k_short, nsam) == 0)
     {
         int n8k;
 
-        n8k = resample(cbData->insrc1, in8k_short, in48k_short, FS, g_soundCard1SampleRate, N8, N48);
+        n8k = resample(cbData->insrc1, in8k_short, in48k_short, FS, g_soundCard1SampleRate, N8, nsam);
         fifo_write(cbData->rxinfifo, in8k_short, n8k);
 
         resample_for_plot(g_plotDemodInFifo, in8k_short, n8k);