Added support for con/pro distinction. Fixed pcm_name use

This commit is contained in:
Abramo Bagnara 2001-04-22 14:44:23 +00:00
parent 97a55787e6
commit e334ec438c
3 changed files with 36 additions and 20 deletions

View file

@ -50,7 +50,8 @@ static void help(void)
printf(" -D,--device=NAME select PCM by NAME\n"); printf(" -D,--device=NAME select PCM by NAME\n");
printf(" -4,--4ch four channels mode\n"); printf(" -4,--4ch four channels mode\n");
printf(" -6,--6ch six channels mode\n"); printf(" -6,--6ch six channels mode\n");
printf(" -I,--iec958 raw IEC958 (S/PDIF) mode\n"); printf(" -C,--iec958c raw IEC958 (S/PDIF) consumer mode\n");
printf(" -P,--iec958p raw IEC958 (S/PDIF) professional mode\n");
printf(" -q,--quit quit mode\n"); printf(" -q,--quit quit mode\n");
} }
@ -84,15 +85,15 @@ int main(int argc,char *argv[])
{"device", 1, NULL, 'D'}, {"device", 1, NULL, 'D'},
{"4ch", 0, NULL, '4'}, {"4ch", 0, NULL, '4'},
{"6ch", 0, NULL, '6'}, {"6ch", 0, NULL, '6'},
{"iec958", 0, NULL, 'I'}, {"iec958c", 0, NULL, 'C'},
{"spdif", 0, NULL, 'I'}, {"spdif", 0, NULL, 'C'},
{"iec958p", 0, NULL, 'P'},
{"quit", 0, NULL, 'q'}, {"quit", 0, NULL, 'q'},
{NULL, 0, NULL, 0}, {NULL, 0, NULL, 0},
}; };
ac3_config_t ac3_config; ac3_config_t ac3_config;
output_t out_config; output_t out_config;
int morehelp, loop = 0; int morehelp, loop = 0;
char *pcm_name = NULL;
bzero(&ac3_config, sizeof(ac3_config)); bzero(&ac3_config, sizeof(ac3_config));
ac3_config.fill_buffer_callback = fill_buffer; ac3_config.fill_buffer_callback = fill_buffer;
@ -103,13 +104,13 @@ int main(int argc,char *argv[])
out_config.bits = 16; out_config.bits = 16;
out_config.rate = 48000; out_config.rate = 48000;
out_config.channels = 2; out_config.channels = 2;
out_config.spdif = 0; out_config.spdif = SPDIF_NONE;
morehelp = 0; morehelp = 0;
while (1) { while (1) {
int c; int c;
if ((c = getopt_long(argc, argv, "hvD:46Iq", long_option, NULL)) < 0) if ((c = getopt_long(argc, argv, "hvD:46CPq", long_option, NULL)) < 0)
break; break;
switch (c) { switch (c) {
case 'h': case 'h':
@ -119,19 +120,23 @@ int main(int argc,char *argv[])
printf("ac3dec version " VERSION "\n"); printf("ac3dec version " VERSION "\n");
return 1; return 1;
case 'D': case 'D':
pcm_name = optarg; out_config.pcm_name = optarg;
break; break;
case '4': case '4':
if (!out_config.spdif) if (out_config.spdif != SPDIF_NONE)
ac3_config.num_output_ch = 4; ac3_config.num_output_ch = 4;
break; break;
case '6': case '6':
if (!out_config.spdif) if (out_config.spdif != SPDIF_NONE)
ac3_config.num_output_ch = 6; ac3_config.num_output_ch = 6;
break; break;
case 'I': case 'C':
ac3_config.num_output_ch = 2; ac3_config.num_output_ch = 2;
out_config.spdif = 1; out_config.spdif = SPDIF_CON;
break;
case 'P':
ac3_config.num_output_ch = 2;
out_config.spdif = SPDIF_PRO;
break; break;
case 'q': case 'q':
ac3_config.flags |= AC3_QUIET; ac3_config.flags |= AC3_QUIET;
@ -163,7 +168,7 @@ int main(int argc,char *argv[])
optind++; optind++;
loop++; loop++;
} }
if (!out_config.spdif) { if (out_config.spdif == SPDIF_NONE) {
ac3_frame_t *ac3_frame; ac3_frame_t *ac3_frame;
ac3_init(&ac3_config); ac3_init(&ac3_config);
ac3_frame = ac3_decode_frame(); ac3_frame = ac3_decode_frame();

View file

@ -131,7 +131,7 @@ int output_open(output_t *output)
goto __close; goto __close;
} }
if (output->spdif) { if (output->spdif != SPDIF_NONE) {
snd_pcm_info_t *info; snd_pcm_info_t *info;
snd_ctl_elem_value_t *ctl; snd_ctl_elem_value_t *ctl;
snd_ctl_t *ctl_handle; snd_ctl_t *ctl_handle;
@ -140,12 +140,23 @@ int output_open(output_t *output)
snd_aes_iec958_t spdif; snd_aes_iec958_t spdif;
memset(&spdif, 0, sizeof(spdif)); memset(&spdif, 0, sizeof(spdif));
spdif.status[0] = IEC958_AES0_NONAUDIO | if (output->spdif == SPDIF_PRO) {
IEC958_AES0_CON_EMPHASIS_NONE; spdif.status[0] = (IEC958_AES0_PROFESSIONAL |
spdif.status[1] = IEC958_AES1_CON_ORIGINAL | IEC958_AES0_NONAUDIO |
IEC958_AES1_CON_PCM_CODER; IEC958_AES0_PRO_EMPHASIS_NONE |
spdif.status[2] = 0; IEC958_AES0_PRO_FS_48000);
spdif.status[3] = IEC958_AES3_CON_FS_48000; spdif.status[1] = (IEC958_AES1_PRO_MODE_NOTID |
IEC958_AES1_PRO_USERBITS_NOTID);
spdif.status[2] = IEC958_AES2_PRO_WORDLEN_NOTID;
spdif.status[3] = 0;
} else {
spdif.status[0] = (IEC958_AES0_NONAUDIO |
IEC958_AES0_CON_EMPHASIS_NONE);
spdif.status[1] = (IEC958_AES1_CON_ORIGINAL |
IEC958_AES1_CON_PCM_CODER);
spdif.status[2] = 0;
spdif.status[3] = IEC958_AES3_CON_FS_48000;
}
snd_pcm_info_alloca(&info); snd_pcm_info_alloca(&info);
if ((err = snd_pcm_info(pcm, info)) < 0) { if ((err = snd_pcm_info(pcm, info)) < 0) {
fprintf(stderr, "pcm info error: %s", snd_strerror(err)); fprintf(stderr, "pcm info error: %s", snd_strerror(err));

View file

@ -29,8 +29,8 @@ typedef struct {
int bits; int bits;
int rate; int rate;
int channels; int channels;
int spdif: 1;
int quiet: 1; int quiet: 1;
enum {SPDIF_NONE = 0, SPDIF_CON, SPDIF_PRO} spdif;
} output_t; } output_t;
int output_open(output_t *output); int output_open(output_t *output);