diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Freedv.java b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Freedv.java index c220c0d..70aef49 100644 --- a/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Freedv.java +++ b/codec2talkie/src/main/java/com/radio/codec2talkie/protocol/Freedv.java @@ -82,7 +82,7 @@ public class Freedv implements Protocol { //Log.i(TAG, "read " + bytesRead); long cntRead = Codec2.freedvRx(_freedv, _speechRxBuffer, buf); if (cntRead > 0) { - Log.i(TAG, "receive " + cntRead); + //Log.i(TAG, "receive " + cntRead); _parentProtocolCallback.onReceivePcmAudio(null, null, -1, Arrays.copyOf(_speechRxBuffer, (int) cntRead)); return true; } diff --git a/codec2talkie/src/main/java/com/radio/codec2talkie/transport/SoundModem.java b/codec2talkie/src/main/java/com/radio/codec2talkie/transport/SoundModem.java index 504a353..0e6eedc 100644 --- a/codec2talkie/src/main/java/com/radio/codec2talkie/transport/SoundModem.java +++ b/codec2talkie/src/main/java/com/radio/codec2talkie/transport/SoundModem.java @@ -28,8 +28,7 @@ public class SoundModem implements Transport, Runnable { private static final String TAG = SoundModem.class.getSimpleName(); - private static final int RECORD_DELAY_MS = 10; - private static final int SAMPLE_RATE = 8000; + private static final int SAMPLE_RATE = 8000; // TODO, need to get from freedv private String _name; @@ -45,7 +44,7 @@ public class SoundModem implements Transport, Runnable { private final ShortBuffer _recordAudioBuffer; - private boolean _isLoopback = false; + private boolean _isLoopback; public SoundModem(Context context) { _name = "SoundModem"; @@ -151,7 +150,7 @@ public class SoundModem implements Transport, Runnable { try { _recordAudioBuffer.put(sample); } catch (BufferOverflowException e) { - e.printStackTrace(); + // client is transmitting and cannot consume the buffer, just discard _recordAudioBuffer.clear(); } } @@ -181,11 +180,6 @@ public class SoundModem implements Transport, Runnable { int readSize = 32; short [] sampleBuf = new short[readSize]; while (_isRunning) { - try { - Thread.sleep(RECORD_DELAY_MS); - } catch (InterruptedException e) { - e.printStackTrace(); - } int readCnt = _systemAudioRecorder.read(sampleBuf, 0, readSize); if (readCnt != readSize) { Log.w(TAG, "" + readCnt + " != " + readSize); diff --git a/libcodec2-android/src/main/cpp/Codec2JNI.cpp b/libcodec2-android/src/main/cpp/Codec2JNI.cpp index cfaa5d5..f13d1cf 100644 --- a/libcodec2-android/src/main/cpp/Codec2JNI.cpp +++ b/libcodec2-android/src/main/cpp/Codec2JNI.cpp @@ -108,6 +108,7 @@ namespace Java_com_ustadmobile_codec2_Codec2 { conFreedv->modemSamples = static_cast(malloc( freedv_get_n_max_modem_samples(conFreedv->freeDv) * sizeof(short))); freedv_set_squelch_en(conFreedv->freeDv, 1); + freedv_set_snr_squelch_thresh(conFreedv->freeDv, -5.0); return reinterpret_cast(conFreedv); }