Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual

Page 112

Advertising
background image

KTD-S0057-I

Page 108 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


if ((err = set_hwparams (handle, hwparams, transfer_methods[method].access)) < 0)

{

printf ("Setting of hwparams failed: %s\n", snd_strerror (err));

exit

(EXIT_FAILURE);

}

if ((err = set_swparams (handle, swparams)) < 0)

{

printf ("Setting of swparams failed: %s\n", snd_strerror (err));

exit

(EXIT_FAILURE);

}

if (verbose > 0)

snd_pcm_dump (handle, output);

samples = malloc ((period_size * channels * snd_pcm_format_physical_width (format)) / 8);

if (samples == NULL)

{

printf ("Not enough memory\n");

exit

(EXIT_FAILURE);

}

areas = calloc (channels, sizeof (snd_pcm_channel_area_t));

if (areas == NULL)

{

printf ("No enough memory\n");

exit

(EXIT_FAILURE);

}

for (chn = 0; chn < channels; chn++)

{

areas[chn].addr = samples;

areas[chn].first = chn * snd_pcm_format_physical_width (format);

areas[chn].step = channels * snd_pcm_format_physical_width (format);

}

err = transfer_methods[method].transfer_loop (handle, samples, areas);

if (err < 0)

printf ("Transfer failed: %s\n", snd_strerror (err));

free

(areas);

free

(samples);

snd_pcm_close

(handle);

return

0;

}


The most important PCM ALSA interfaces use the identifiers

plughw

and

hw

. For the

plughw

identifier you

need no information about the sound hardware - data will be automatically converted. In contrast you have
to check whether the

hw

interface supports your hardware configuration. The two statements after the

colon represent the card and the device number which can be reliably determined by

aplay -l

Advertising
This manual is related to the following products: