view sw/mcsi-rxtx/record.c @ 16:f422d19c0118 default tip

fc-mcsi-rxtx: fix bug in PCM sample Rx
author Mychaela Falconia <falcon@freecalypso.org>
date Tue, 29 Oct 2024 01:41:33 +0000
parents 315428573a25
children
line wrap: on
line source

/*
 * Here we implement the functionality of recording MCSI Rx streams
 * into robe files.
 */

#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>

extern u_short rx_pcm_samples[160];

static FILE *record_file;

void
record_process()
{
	unsigned n, samp;

	if (!record_file)
		return;
	for (n = 0; n < 160; n++) {
		samp = rx_pcm_samples[n];
		putc(samp >> 8, record_file);
		putc(samp, record_file);
	}
}

void
record_auto_stop()
{
	if (!record_file)
		return;
	fclose(record_file);
	record_file = 0;
}

void
cmd_record(argc, argv)
	char **argv;
{
	if (record_file) {
		printf("error: recording already in progress\n");
		return;
	}
	record_file = fopen(argv[1], "w");
	if (!record_file)
		perror(argv[1]);
}

void
cmd_record_stop()
{
	if (!record_file) {
		printf("error: no recording in progress\n");
		return;
	}
	fclose(record_file);
	record_file = 0;
}