mirror of
https://github.com/steve-m/hsdaoh.git
synced 2025-12-10 07:44:41 +01:00
add aux/headswitch support
This commit is contained in:
parent
bb63558b9d
commit
642de0654d
2 changed files with 30 additions and 23 deletions
|
|
@ -236,6 +236,7 @@ void hsdaoh_unpack_pio_10bit_iq(hsdaoh_dev_t *dev, hsdaoh_data_info_t *data_info
|
||||||
|
|
||||||
void hsdaoh_unpack_pio_pcm1802_audio(hsdaoh_dev_t *dev, hsdaoh_data_info_t *data_info)
|
void hsdaoh_unpack_pio_pcm1802_audio(hsdaoh_dev_t *dev, hsdaoh_data_info_t *data_info)
|
||||||
{
|
{
|
||||||
|
unsigned int i;
|
||||||
uint32_t *in = (uint32_t *)data_info->buf;
|
uint32_t *in = (uint32_t *)data_info->buf;
|
||||||
size_t inlen = data_info->len / sizeof(uint32_t);
|
size_t inlen = data_info->len / sizeof(uint32_t);
|
||||||
|
|
||||||
|
|
@ -243,7 +244,7 @@ void hsdaoh_unpack_pio_pcm1802_audio(hsdaoh_dev_t *dev, hsdaoh_data_info_t *data
|
||||||
uint8_t *out = malloc(inlen * 3);
|
uint8_t *out = malloc(inlen * 3);
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < inlen; i += 2) {
|
for (i = 0; i < inlen; i += 2) {
|
||||||
out[j++] = in[i+1] & 0xff;
|
out[j++] = in[i+1] & 0xff;
|
||||||
out[j++] = (in[i+1] >> 8) & 0xff;
|
out[j++] = (in[i+1] >> 8) & 0xff;
|
||||||
out[j++] = (in[i+1] >> 16) & 0xff;
|
out[j++] = (in[i+1] >> 16) & 0xff;
|
||||||
|
|
@ -259,6 +260,19 @@ void hsdaoh_unpack_pio_pcm1802_audio(hsdaoh_dev_t *dev, hsdaoh_data_info_t *data
|
||||||
data_info->is_signed = true;
|
data_info->is_signed = true;
|
||||||
data_info->is_float = false;
|
data_info->is_float = false;
|
||||||
dev->cb(data_info);
|
dev->cb(data_info);
|
||||||
|
|
||||||
|
/* extract aux info/headswitch signal */
|
||||||
|
for (i = 0; i < inlen; i++)
|
||||||
|
out[i] = in[i] & (1 << 25) ? 0xff : 0;
|
||||||
|
|
||||||
|
data_info->stream_id += 2;
|
||||||
|
data_info->srate *= 2;
|
||||||
|
data_info->len = inlen;
|
||||||
|
data_info->bits_per_samp = 8;
|
||||||
|
data_info->nchans = 1;
|
||||||
|
data_info->is_signed = false;
|
||||||
|
dev->cb(data_info);
|
||||||
|
|
||||||
free(out);
|
free(out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,6 +24,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
@ -40,7 +41,7 @@
|
||||||
|
|
||||||
#include "hsdaoh.h"
|
#include "hsdaoh.h"
|
||||||
|
|
||||||
#define FD_NUMS 4
|
#define FD_NUMS 6
|
||||||
|
|
||||||
static bool do_exit = false;
|
static bool do_exit = false;
|
||||||
static hsdaoh_dev_t *dev = NULL;
|
static hsdaoh_dev_t *dev = NULL;
|
||||||
|
|
@ -65,7 +66,7 @@ void usage(void)
|
||||||
#ifdef FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK
|
#ifdef FLAC__STREAM_ENCODER_SET_NUM_THREADS_OK
|
||||||
"\t[-t number of threads for FLAC encoding (default: 4)]\n"
|
"\t[-t number of threads for FLAC encoding (default: 4)]\n"
|
||||||
#endif
|
#endif
|
||||||
"\t[-0 to -3 filename of stream 0 to stream 3 (a '-' dumps samples to stdout)]\n"
|
"\t[-0 to -5 filename of stream 0 to stream 5 (a '-' dumps samples to stdout)]\n"
|
||||||
"\tfilename (of stream 0) (a '-' dumps samples to stdout)\n\n"
|
"\tfilename (of stream 0) (a '-' dumps samples to stdout)\n\n"
|
||||||
"\tFilenames with the extension .flac will enable FLAC encoding\n\n");
|
"\tFilenames with the extension .flac will enable FLAC encoding\n\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
|
|
@ -232,7 +233,17 @@ int main(int argc, char **argv)
|
||||||
bool fname0_used = false;
|
bool fname0_used = false;
|
||||||
bool have_file = false;
|
bool have_file = false;
|
||||||
|
|
||||||
while ((opt = getopt(argc, argv, "0:1:2:3:d:b:l:t:")) != -1) {
|
while ((opt = getopt(argc, argv, "0:1:2:3:4:5:d:b:l:t:")) != -1) {
|
||||||
|
if (isdigit(opt)) {
|
||||||
|
int num = opt - 0x30;
|
||||||
|
have_file = true;
|
||||||
|
filenames[num] = optarg;
|
||||||
|
if (num == 0)
|
||||||
|
fname0_used = true;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
case 'd':
|
case 'd':
|
||||||
dev_index = (uint32_t)atoi(optarg);
|
dev_index = (uint32_t)atoi(optarg);
|
||||||
|
|
@ -246,23 +257,6 @@ int main(int argc, char **argv)
|
||||||
case 't':
|
case 't':
|
||||||
flac_nthreads = atoi(optarg);
|
flac_nthreads = atoi(optarg);
|
||||||
break;
|
break;
|
||||||
case '0':
|
|
||||||
fname0_used = true;
|
|
||||||
have_file = true;
|
|
||||||
filenames[0] = optarg;
|
|
||||||
break;
|
|
||||||
case '1':
|
|
||||||
have_file = true;
|
|
||||||
filenames[1] = optarg;
|
|
||||||
break;
|
|
||||||
case '2':
|
|
||||||
have_file = true;
|
|
||||||
filenames[2] = optarg;
|
|
||||||
break;
|
|
||||||
case '3':
|
|
||||||
have_file = true;
|
|
||||||
filenames[3] = optarg;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
usage();
|
usage();
|
||||||
break;
|
break;
|
||||||
|
|
@ -273,9 +267,8 @@ int main(int argc, char **argv)
|
||||||
if (argc <= optind) {
|
if (argc <= optind) {
|
||||||
if (!have_file)
|
if (!have_file)
|
||||||
usage();
|
usage();
|
||||||
} else {
|
} else
|
||||||
filenames[0] = argv[optind];
|
filenames[0] = argv[optind];
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dev_index < 0)
|
if (dev_index < 0)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue