]> git.rkrishnan.org Git - pihpsdr.git/commitdiff
fixed buffer size on rate change with new protocol
authorJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Sat, 20 Aug 2016 10:54:52 +0000 (10:54 +0000)
committerJohn Melton - G0ORX/N6LYT <john.d.melton@googlemail.com>
Sat, 20 Aug 2016 10:54:52 +0000 (10:54 +0000)
new_protocol.c
pihpsdr
release/pihpsdr.tar
release/pihpsdr/pihpsdr
wdsp_init.c

index 3c134cc49fad50c294a2b3255f958917078485b7..537b64d2288c2701880b43f16df5fe82ad17724a 100644 (file)
@@ -156,6 +156,29 @@ static void* new_protocol_timer_thread(void* arg);
 static void full_rx_buffer();
 static void full_tx_buffer();
 
+static void new_protocol_calc_buffers() {
+  switch(sample_rate) {
+    case 48000:
+      outputsamples=BUFFER_SIZE;
+      break;
+    case 96000:
+      outputsamples=BUFFER_SIZE/2;
+      break;
+    case 192000:
+      outputsamples=BUFFER_SIZE/4;
+      break;
+    case 384000:
+      outputsamples=BUFFER_SIZE/8;
+      break;
+    case 768000:
+      outputsamples=BUFFER_SIZE/16;
+      break;
+    case 1536000:
+      outputsamples=BUFFER_SIZE/32;
+      break;
+  }
+}
+
 void schedule_high_priority(int source) {
 fprintf(stderr,"new_protocol: schedule_high_priority: source=%d\n",source);
     sem_wait(&send_high_priority_sem);
@@ -201,6 +224,8 @@ void new_protocol_init(int rx,int pixels) {
       }
     }
 
+    new_protocol_calc_buffers();
+
     rc=sem_init(&response_sem, 0, 0);
     rc=sem_init(&send_high_priority_sem, 0, 1);
     rc=sem_init(&send_general_sem, 0, 1);
@@ -216,7 +241,7 @@ void new_protocol_init(int rx,int pixels) {
 void new_protocol_new_sample_rate(int rate) {
   new_protocol_high_priority(0,0,0);
   sample_rate=rate;
-  old_protocol_calc_buffers();
+  new_protocol_calc_buffers();
   wdsp_new_sample_rate(rate);
   new_protocol_high_priority(1,0,drive);
 }
diff --git a/pihpsdr b/pihpsdr
index 9feeac72aee2b3058071e2dede2424e3af66704a..b39d2e390f605127a3ce8391057608039f9adb16 100755 (executable)
Binary files a/pihpsdr and b/pihpsdr differ
index dc835a6978891e987ea2f41f2f434b589c43b2ec..c69d382f42a9b2c6cc43a6dcb3813d720646202b 100644 (file)
Binary files a/release/pihpsdr.tar and b/release/pihpsdr.tar differ
index 9feeac72aee2b3058071e2dede2424e3af66704a..b39d2e390f605127a3ce8391057608039f9adb16 100755 (executable)
Binary files a/release/pihpsdr/pihpsdr and b/release/pihpsdr/pihpsdr differ
index 70a2b60f14884493a269f5a7cb32efad29192173..92325a6219018a46cf679cca9006a7204e622c04 100644 (file)
@@ -80,19 +80,24 @@ static int SPECTRUM_UPDATES_PER_SECOND=10;
 static void initAnalyzer(int channel,int buffer_size);
 
 static void calc_tx_buffer_size() {
-  switch(sample_rate) {
-    case 48000:
-      tx_buffer_size=BUFFER_SIZE;
-      break;
-    case 96000:
-      tx_buffer_size=BUFFER_SIZE/2;
-      break;
-    case 192000:
-      tx_buffer_size=BUFFER_SIZE/4;
-      break;
-    case 384000:
-      tx_buffer_size=BUFFER_SIZE/8;
-      break;
+  if(protocol==ORIGINAL_PROTOCOL) {
+    switch(sample_rate) {
+      case 48000:
+        tx_buffer_size=BUFFER_SIZE;
+        break;
+      case 96000:
+        tx_buffer_size=BUFFER_SIZE/2;
+        break;
+      case 192000:
+        tx_buffer_size=BUFFER_SIZE/4;
+        break;
+      case 384000:
+        tx_buffer_size=BUFFER_SIZE/8;
+        break;
+    }
+  } else {
+    tx_buffer_size=BUFFER_SIZE*4;
+    // input always 48K -- output always 192K
   }
 }
 
@@ -398,11 +403,14 @@ void wdsp_init(int rx,int pixels,int protocol) {
 }
 
 void wdsp_new_sample_rate(int rate) {
-  SetChannelState(CHANNEL_TX,0,0);
-  calc_tx_buffer_size();
-  initAnalyzer(CHANNEL_TX,tx_buffer_size);
-  SetInputSamplerate(CHANNEL_TX,rate);
-  SetChannelState(CHANNEL_TX,1,0);
+
+  if(protocol==ORIGINAL_PROTOCOL) {
+    SetChannelState(CHANNEL_TX,0,0);
+    calc_tx_buffer_size();
+    initAnalyzer(CHANNEL_TX,tx_buffer_size);
+    SetInputSamplerate(CHANNEL_TX,rate);
+    SetChannelState(CHANNEL_TX,1,0);
+  }
 
   SetChannelState(receiver,0,0);
   SetInputSamplerate(receiver,rate);