summaryrefslogtreecommitdiff
path: root/ALSASound.c
diff options
context:
space:
mode:
authorDave Hibberd <d@vehibberd.com>2023-09-12 21:38:19 +0100
committerDave Hibberd <d@vehibberd.com>2023-09-12 21:38:19 +0100
commit51667f3056f13acc54229843121ac37093e5c4fa (patch)
treef307ba57caaddce0bfce270fcd5f54865881bc2c /ALSASound.c
parentcc152664115edea852d18f9a1505db6914dce569 (diff)
parent3cdcbeea3e2891f4a10c79b272da144f37ff24f3 (diff)
Update upstream source from tag 'upstream/0.67'
Update to upstream version '0.67' with Debian dir d407fa05796b5e411553bba52531842bd913bb88
Diffstat (limited to 'ALSASound.c')
-rw-r--r--ALSASound.c36
1 files changed, 32 insertions, 4 deletions
diff --git a/ALSASound.c b/ALSASound.c
index d6739a4..3507e9f 100644
--- a/ALSASound.c
+++ b/ALSASound.c
@@ -93,6 +93,22 @@ extern BOOL UseKISS; // Enable Packet (KISS) interface
extern short * DMABuffer;
+#define MaxReceiveSize 2048 // Enough for 9600
+#define MaxSendSize 4096
+
+short buffer[2][MaxSendSize * 2]; // Two Transfer/DMA buffers of 0.1 Sec (x2 for Stereo)
+short inbuffer[MaxReceiveSize * 2]; // Input Transfer/ buffers of 0.1 Sec (x2 for Stereo)
+
+
+extern short * DMABuffer;
+extern int Number;
+
+int ReceiveSize = 512;
+int SendSize = 1024;
+int using48000 = 0;
+
+int SampleRate = 12000;
+
BOOL UseLeft = TRUE;
BOOL UseRight = TRUE;
@@ -123,8 +139,6 @@ void Sleep(int mS)
// Windows and ALSA work with signed samples +- 32767
// STM32 and Teensy DAC uses unsigned 0 - 4095
-short buffer[2][1200 * 2]; // Two Transfer/DMA buffers of 0.1 Sec
-short inbuffer[1200 * 2]; // Two Transfer/DMA buffers of 0.1 Sec
BOOL Loopback = FALSE;
//BOOL Loopback = TRUE;
@@ -967,7 +981,7 @@ int SoundCardWrite(short * input, int nSamples)
// Debugprintf("Tosend %d Avail %d", nSamples, (int)avail);
- while (avail < nSamples || (MaxAvail - avail) > 12000) // Limit to 1 sec of audio
+ while (avail < nSamples || (MaxAvail - avail) > SampleRate) // Limit to 1 sec of audio
{
txSleep(10);
avail = snd_pcm_avail_update(playhandle);
@@ -1203,15 +1217,29 @@ void GetSoundDevices()
int InitSound(BOOL Quiet)
{
+ if (using48000)
+ {
+ ReceiveSize = 2048;
+ SendSize = 4096; // 100 mS for now
+ SampleRate = 48000;
+ }
+ else
+ {
+ ReceiveSize = 512;
+ SendSize = 1024;
+ SampleRate = 12000;
+ }
+
GetSoundDevices();
switch (SoundMode)
{
case 0: // ALSA
- if (!OpenSoundCard(CaptureDevice, PlaybackDevice, 12000, 12000, Quiet))
+ if (!OpenSoundCard(CaptureDevice, PlaybackDevice, SampleRate, SampleRate, Quiet))
return FALSE;
+
break;
case 1: // OSS