static char *command;
static snd_pcm_t *handle;
static struct {
- unsigned int format;
+ snd_pcm_format_t format;
unsigned int channels;
unsigned int rate;
} hwparams, rhwparams;
static int file_type = FORMAT_DEFAULT;
static unsigned int sleep_min = 0;
static int open_mode = 0;
-static int stream = SND_PCM_STREAM_PLAYBACK;
+static snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
static int mmap_flag = 0;
static int interleaved = 1;
static int nonblock = 0;
static void usage(char *command)
{
- int k;
+ snd_pcm_format_t k;
fprintf(stderr, "\
Usage: %s [OPTION]... [FILE]...
-C, --iec958c AES IEC958 consumer
", command);
fprintf(stderr, "Recognized sample formats are:");
- for (k = 0; k < 32; ++k) {
+ for (k = 0; k < SND_PCM_FORMAT_LAST; ++(unsigned long) k) {
const char *s = snd_pcm_format_name(k);
if (s)
fprintf(stderr, " %s", s);
fprintf(stderr, "card %i: %s [%s], device %i: %s [%s]\n",
card, info.id, info.name,
dev,
- snd_pcm_info_device_id(pcminfo),
- snd_pcm_info_device_name(pcminfo));
- count = snd_pcm_info_subdevices_count(pcminfo);
- fprintf(stderr, " Subdevices: %i/%i\n", snd_pcm_info_subdevices_avail(pcminfo), count);
+ snd_pcm_info_get_id(pcminfo),
+ snd_pcm_info_get_name(pcminfo));
+ count = snd_pcm_info_get_subdevices_count(pcminfo);
+ fprintf(stderr, " Subdevices: %i/%i\n", snd_pcm_info_get_subdevices_avail(pcminfo), count);
for (idx = 0; idx < count; idx++) {
snd_pcm_info_set_subdevice(pcminfo, idx);
if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
error("control digital audio playback info (%i): %s", card, snd_strerror(err));
} else {
- fprintf(stderr, " Subdevice #%i: %s\n", idx, snd_pcm_info_subdevice_name(pcminfo));
+ fprintf(stderr, " Subdevice #%i: %s\n", idx, snd_pcm_info_get_subdevice_name(pcminfo));
}
}
}
memset(&ctl, 0, sizeof(ctl));
ctl.id.numid = 0;
ctl.id.iface = SND_CONTROL_IFACE_PCM;
- ctl.id.device = snd_pcm_info_device(info);
- ctl.id.subdevice = snd_pcm_info_subdevice(info);
+ ctl.id.device = snd_pcm_info_get_device(info);
+ ctl.id.subdevice = snd_pcm_info_get_subdevice(info);
strcpy(ctl.id.name, "IEC958 (S/PDIF) Stream");
- ctl_card = snd_pcm_info_card(info);
+ ctl_card = snd_pcm_info_get_card(info);
if (ctl_card < 0) {
error("Unable to setup the IEC958 (S/PDIF) interface - PCM has no assigned card");
goto __diga_end;
exit(EXIT_FAILURE);
}
if (mmap_flag) {
- snd_mask_t *mask = alloca(snd_mask_sizeof());
- snd_mask_none(mask);
- snd_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
- snd_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
- snd_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX);
- err = snd_pcm_hw_param_mask(handle, params,
- SND_PCM_HW_PARAM_ACCESS, mask);
+ snd_pcm_access_mask_t *mask = alloca(snd_pcm_access_mask_sizeof());
+ snd_pcm_access_mask_none(mask);
+ snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_INTERLEAVED);
+ snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_NONINTERLEAVED);
+ snd_pcm_access_mask_set(mask, SND_PCM_ACCESS_MMAP_COMPLEX);
+ err = snd_pcm_hw_params_set_access_mask(handle, params,
+ SND_CHANGE, mask);
} else if (interleaved)
- err = snd_pcm_hw_param_set(handle, params,
- SND_PCM_HW_PARAM_ACCESS,
- SND_PCM_ACCESS_RW_INTERLEAVED, 0);
+ err = snd_pcm_hw_params_set_access(handle, params, SND_CHANGE,
+ SND_PCM_ACCESS_RW_INTERLEAVED);
else
- err = snd_pcm_hw_param_set(handle, params,
- SND_PCM_HW_PARAM_ACCESS,
- SND_PCM_ACCESS_RW_NONINTERLEAVED, 0);
+ err = snd_pcm_hw_params_set_access(handle, params, SND_CHANGE,
+ SND_PCM_ACCESS_RW_NONINTERLEAVED);
if (err < 0) {
error("Access type not available");
exit(EXIT_FAILURE);
}
- err = snd_pcm_hw_param_set(handle, params, SND_PCM_HW_PARAM_FORMAT,
- hwparams.format, 0);
+ err = snd_pcm_hw_params_set_format(handle, params, SND_CHANGE, hwparams.format);
if (err < 0) {
error("Sample format non available");
exit(EXIT_FAILURE);
}
- err = snd_pcm_hw_param_set(handle, params, SND_PCM_HW_PARAM_CHANNELS,
- hwparams.channels, 0);
+ err = snd_pcm_hw_params_set_channels(handle, params, SND_CHANGE, hwparams.channels);
if (err < 0) {
error("Channels count non available");
exit(EXIT_FAILURE);
}
#if 0
- err = snd_pcm_hw_param_min(handle, params,
- SND_PCM_HW_PARAM_PERIODS, 2);
+ err = snd_pcm_hw_params_set_periods_min(handle, params, SND_CHANGE, 2);
assert(err >= 0);
#endif
- err = snd_pcm_hw_param_near(handle, params,
- SND_PCM_HW_PARAM_RATE, hwparams.rate, 0);
+ err = snd_pcm_hw_params_set_rate_near(handle, params, hwparams.rate, 0);
assert(err >= 0);
if (buffer_time < 0)
buffer_time = 500000;
- buffer_time = snd_pcm_hw_param_near(handle, params,
- SND_PCM_HW_PARAM_BUFFER_TIME,
- buffer_time, 0);
+ buffer_time = snd_pcm_hw_params_set_buffer_time_near(handle, params,
+ buffer_time, 0);
assert(buffer_time >= 0);
if (period_time < 0)
period_time = buffer_time / 4;
- period_time = snd_pcm_hw_param_near(handle, params,
- SND_PCM_HW_PARAM_PERIOD_TIME,
- period_time, 0);
+ period_time = snd_pcm_hw_params_set_period_time_near(handle, params,
+ period_time, 0);
assert(period_time >= 0);
err = snd_pcm_hw_params(handle, params);
if (err < 0) {
snd_pcm_hw_params_dump(params, log);
exit(EXIT_FAILURE);
}
- chunk_size = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_PERIOD_SIZE, 0);
- buffer_size = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_BUFFER_SIZE, 0);
+ chunk_size = snd_pcm_hw_params_get_period_size(params, 0);
+ buffer_size = snd_pcm_hw_params_get_buffer_size(params);
snd_pcm_sw_params_current(handle, swparams);
- xfer_align = snd_pcm_sw_param_value(swparams, SND_PCM_SW_PARAM_XFER_ALIGN);
+ xfer_align = snd_pcm_sw_params_get_xfer_align(swparams);
if (sleep_min)
xfer_align = 1;
- err = snd_pcm_sw_param_set(handle, swparams,
- SND_PCM_SW_PARAM_SLEEP_MIN, sleep_min);
+ err = snd_pcm_sw_params_set_sleep_min(handle, swparams,
+ sleep_min);
assert(err >= 0);
if (avail_min < 0)
n = chunk_size;
else
- n = snd_pcm_hw_param_value(params, SND_PCM_HW_PARAM_RATE, 0) * (double) avail_min / 1000000;
- err = snd_pcm_sw_param_near(handle, swparams,
- SND_PCM_SW_PARAM_AVAIL_MIN, n);
+ n = snd_pcm_hw_params_get_rate(params, 0) * (double) avail_min / 1000000;
+ err = snd_pcm_sw_params_set_avail_min(handle, swparams, n);
- err = snd_pcm_sw_param_near(handle, swparams,
- SND_PCM_SW_PARAM_XFER_ALIGN, xfer_align);
+ err = snd_pcm_sw_params_set_xfer_align(handle, swparams, xfer_align);
assert(err >= 0);
if (snd_pcm_sw_params(handle, swparams) < 0) {
error("unable to install sw params:");
snd_pcm_sw_params_dump(swparams, log);
exit(EXIT_FAILURE);
}
- if (snd_pcm_prepare(handle) < 0) {
- error("unable to prepare PCM");
- exit(EXIT_FAILURE);
- }
if (verbose)
snd_pcm_dump(handle, log);
error("status error: %s", snd_strerror(res));
exit(EXIT_FAILURE);
}
- if (snd_pcm_status_state(status) == SND_PCM_STATE_XRUN) {
+ if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
struct timeval now, diff, tstamp;
gettimeofday(&now, 0);
- snd_pcm_status_trigger_tstamp(status, &tstamp);
+ snd_pcm_status_get_trigger_tstamp(status, &tstamp);
timersub(&now, &tstamp, &diff);
fprintf(stderr, "xrun!!! (at least %.3f ms long)\n", diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
if (verbose) {
u_short tmp2;
bits = 8;
- switch (hwparams.format) {
+ switch ((unsigned long) hwparams.format) {
case SND_PCM_FORMAT_U8:
bits = 8;
break;
ah.magic = AU_MAGIC;
ah.hdr_size = BE_INT(24);
ah.data_size = BE_INT(cnt);
- switch (hwparams.format) {
+ switch ((unsigned long) hwparams.format) {
case SND_PCM_FORMAT_MU_LAW:
ah.encoding = BE_INT(AU_FMT_ULAW);
break;