kopia lustrzana https://github.com/OpenRTX/OpenRTX
Fixed a buffer management bug inside linux input stream driver
rodzic
086cb549c7
commit
a37e24c953
|
@ -1,8 +1,8 @@
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* Copyright (C) 2021 by Federico Amedeo Izzo IU2NUO, *
|
* Copyright (C) 2021 - 2022 by Federico Amedeo Izzo IU2NUO, *
|
||||||
* Niccolò Izzo IU2KIN *
|
* Niccolò Izzo IU2KIN *
|
||||||
* Frederik Saraci IU2NRO *
|
* Frederik Saraci IU2NRO *
|
||||||
* Silvano Seva IU2KWO *
|
* Silvano Seva IU2KWO *
|
||||||
* *
|
* *
|
||||||
* This program is free software; you can redistribute it and/or modify *
|
* This program is free software; you can redistribute it and/or modify *
|
||||||
* it under the terms of the GNU General Public License as published by *
|
* it under the terms of the GNU General Public License as published by *
|
||||||
|
@ -25,10 +25,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
stream_sample_t *buffer = NULL;
|
static stream_sample_t *buffer = NULL;
|
||||||
size_t bufferLength = 0;
|
static size_t bufferLength = 0;
|
||||||
bool first_half = true;
|
static bool first_half = true;
|
||||||
FILE *baseband_file = NULL;
|
static FILE *baseband_file = NULL;
|
||||||
|
|
||||||
streamId inputStream_start(const enum AudioSource source,
|
streamId inputStream_start(const enum AudioSource source,
|
||||||
const enum AudioPriority prio,
|
const enum AudioPriority prio,
|
||||||
|
@ -59,26 +59,32 @@ dataBlock_t inputStream_getData(streamId id)
|
||||||
(void) id;
|
(void) id;
|
||||||
|
|
||||||
dataBlock_t block;
|
dataBlock_t block;
|
||||||
block.len = bufferLength;
|
|
||||||
|
block.len = bufferLength / 2;
|
||||||
|
|
||||||
if (first_half)
|
if (first_half)
|
||||||
{
|
{
|
||||||
first_half = false;
|
first_half = false;
|
||||||
block.data = buffer;
|
block.data = buffer;
|
||||||
} else
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
first_half = true;
|
first_half = true;
|
||||||
block.data = buffer + bufferLength;
|
block.data = buffer + (bufferLength / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t read_items = fread(block.data, 2, block.len, baseband_file);
|
size_t read_items = fread(block.data, 2, block.len, baseband_file);
|
||||||
|
|
||||||
if (read_items != block.len)
|
if (read_items != block.len)
|
||||||
{
|
{
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
void inputStream_stop(streamId id)
|
void inputStream_stop(streamId id)
|
||||||
{
|
{
|
||||||
fclose(baseband_file);
|
|
||||||
(void) id;
|
(void) id;
|
||||||
|
fclose(baseband_file);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue