Updated the S/PDIF test code.

This commit is contained in:
Jaroslav Kysela 2000-12-22 14:03:15 +00:00
parent 66608d67ea
commit 652941f76e

View file

@ -86,6 +86,8 @@ static int verbose = 0;
static int buffer_pos = 0; static int buffer_pos = 0;
static size_t bits_per_sample, bits_per_frame; static size_t bits_per_sample, bits_per_frame;
static size_t buffer_bytes; static size_t buffer_bytes;
static int digtype = SND_CONTROL_TYPE_NONE;
static snd_digital_audio_t diga;
static int count; static int count;
static int vocmajor, vocminor; static int vocmajor, vocminor;
@ -303,6 +305,7 @@ int main(int argc, char *argv[])
rhwparams.format = SND_PCM_FORMAT_U8; rhwparams.format = SND_PCM_FORMAT_U8;
rhwparams.rate = DEFAULT_SPEED; rhwparams.rate = DEFAULT_SPEED;
rhwparams.channels = 1; rhwparams.channels = 1;
memset(&diga, 0, sizeof(diga));
while ((c = getopt_long(argc, argv, short_options, long_options, &option_index)) != -1) { while ((c = getopt_long(argc, argv, short_options, long_options, &option_index)) != -1) {
switch (c) { switch (c) {
@ -403,10 +406,24 @@ int main(int argc, char *argv[])
interleaved = 0; interleaved = 0;
break; break;
case 'C': case 'C':
// digital = SND_PCM_DIG_AES_IEC958C; digtype = SND_CONTROL_TYPE_IEC958;
diga.aes.status[0] = SND_PCM_AES0_NONAUDIO |
SND_PCM_AES0_CON_EMPHASIS_NONE;
diga.aes.status[1] = SND_PCM_AES1_CON_ORIGINAL |
SND_PCM_AES1_CON_PCM_CODER;
diga.aes.status[2] = 0;
diga.aes.status[3] = SND_PCM_AES3_CON_FS_48000;
break; break;
case 'P': case 'P':
// digital = SND_PCM_DIG_AES_IEC958P; digtype = SND_CONTROL_TYPE_IEC958;
diga.aes.status[0] = SND_PCM_AES0_PROFESSIONAL |
SND_PCM_AES0_NONAUDIO |
SND_PCM_AES0_PRO_EMPHASIS_NONE |
SND_PCM_AES0_PRO_FS_48000;
diga.aes.status[1] = SND_PCM_AES1_PRO_MODE_NOTID |
SND_PCM_AES1_PRO_USERBITS_NOTID;
diga.aes.status[2] = SND_PCM_AES2_PRO_WORDLEN_NOTID;
diga.aes.status[3] = 0;
break; break;
default: default:
fprintf(stderr, "Try `%s --help' for more information.\n", command); fprintf(stderr, "Try `%s --help' for more information.\n", command);
@ -420,32 +437,40 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
#if 1 memset(&info, 0, sizeof(info));
#warning "The S/PDIF code needs to be recoded.." if ((err = snd_pcm_info(handle, &info)) < 0) {
#else error("info error: %s", snd_strerror(err));
if (digital != SND_PCM_DIG_NONE) { return 1;
snd_pcm_dig_params_t dig; }
memset(&dig, 0, sizeof(dig));
dig.group = 0; if (digtype != SND_CONTROL_TYPE_NONE) {
dig.val.aes.status[0] = SND_PCM_AES0_NONAUDIO; snd_control_t ctl;
dig.type = digital; snd_ctl_t *ctl_handle;
switch (digital) { char ctl_name[12];
case SND_PCM_DIG_AES_IEC958P: int ctl_card;
dig.val.aes.status[0] |= SND_PCM_AES0_PROFESSIONAL; memset(&ctl, 0, sizeof(ctl));
dig.val.aes.status[0] |= SND_PCM_AES0_PRO_FS_48000; ctl.id.numid = 0;
break; ctl.id.iface = SND_CONTROL_IFACE_PCM;
case SND_PCM_DIG_AES_IEC958C: ctl.id.device = info.device;
dig.type = SND_PCM_DIG_AES_IEC958C; ctl.id.subdevice = info.subdevice;
dig.val.aes.status[3] |= SND_PCM_AES3_CON_FS_48000; strcpy(ctl.id.name, "IEC958 (S/PDIF) Stream");
break; ctl_card = snd_pcm_card(handle);
} if (ctl_card < 0) {
err = snd_pcm_dig_params(handle, &dig); error("Unable to setup the IEC958 (S/PDIF) interface - PCM has no assigned card");
if (err < 0) { goto __diga_end;
error("dig_params setting error: %s", snd_strerror(err)); }
return 1; sprintf(ctl_name, "hw:%d", ctl_card);
} if ((err = snd_ctl_open(&ctl_handle, ctl_name)) < 0) {
error("Unable to open the control interface '%s': %s", ctl_name, snd_strerror(err));
goto __diga_end;
}
if ((err = snd_ctl_cwrite(ctl_handle, &ctl)) < 0) {
error("Unable to update the IEC958 control: %s", snd_strerror(err));
goto __diga_end;
}
snd_ctl_close(ctl_handle);
__diga_end:
} }
#endif
if (nonblock) { if (nonblock) {
err = snd_pcm_nonblock(handle, 1); err = snd_pcm_nonblock(handle, 1);
@ -454,11 +479,6 @@ int main(int argc, char *argv[])
return 1; return 1;
} }
} }
memset(&info, 0, sizeof(info));
if ((err = snd_pcm_info(handle, &info)) < 0) {
error("info error: %s", snd_strerror(err));
return 1;
}
buffer_size = 1024; buffer_size = 1024;
hwparams = rhwparams; hwparams = rhwparams;