kopia lustrzana https://github.com/F5OEO/PiFmRds
Safely exits when it is impossible to seek back in the audio file
rodzic
c67306ea9b
commit
9a819e5001
|
@ -176,7 +176,10 @@ int fm_mpx_get_samples(float *mpx_buffer) {
|
|||
return -1;
|
||||
}
|
||||
if(audio_len == 0) {
|
||||
sf_seek(inf, 0, SEEK_SET);
|
||||
if( sf_seek(inf, 0, SEEK_SET) < 0 ) {
|
||||
fprintf(stderr, "Could not rewind in audio file, terminating\n");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -483,7 +483,9 @@ int tx(uint32_t carrier_freq, char *audio_file, uint16_t pi, char *ps, char *rt,
|
|||
while (free_slots >= SUBSIZE) {
|
||||
// get more baseband samples if necessary
|
||||
if(data_len == 0) {
|
||||
fm_mpx_get_samples(data);
|
||||
if( fm_mpx_get_samples(data) < 0 ) {
|
||||
terminate(0);
|
||||
}
|
||||
data_len = DATA_SIZE;
|
||||
data_index = 0;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <sndfile.h>
|
||||
#include <strings.h>
|
||||
|
||||
#include "rds.h"
|
||||
#include "fm_mpx.h"
|
||||
|
@ -38,7 +39,7 @@
|
|||
int main(int argc, char **argv) {
|
||||
if(argc < 4) {
|
||||
fprintf(stderr, "Error: missing argument.\n");
|
||||
fprintf(stderr, "Syntax: rds_wav <in_file> <out.wav> <text>\n");
|
||||
fprintf(stderr, "Syntax: rds_wav <in_audio.wav> <out_mpx.wav> <text>\n");
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -77,7 +78,7 @@ int main(int argc, char **argv) {
|
|||
float mpx_buffer[LENGTH];
|
||||
|
||||
for(int j=0; j<40; j++) {
|
||||
fm_mpx_get_samples(mpx_buffer);
|
||||
if( fm_mpx_get_samples(mpx_buffer) < 0 ) break;
|
||||
|
||||
// scale samples
|
||||
for(int i=0; i<LENGTH; i++) {
|
||||
|
|
Ładowanie…
Reference in New Issue