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

KTD-S0057-I
Page 100 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
first = 0;
err = snd_pcm_start (handle);
if (err < 0)
{
printf ("Start error: %s\n", snd_strerror (err));
exit
(EXIT_FAILURE);
}
}
else
break;
continue;
}
size = period_size;
while (size > 0)
{
frames = size;
err = snd_pcm_mmap_begin (handle, &my_areas, &offset, &frames);
if (err < 0)
{
if ((err = xrun_recovery (handle, err)) < 0)
{
printf ("MMAP begin avail error: %s\n", snd_strerror (err));
exit
(EXIT_FAILURE);
}
first = 1;
}
generate_sine (my_areas, offset, frames, &data->phase);
commitres = snd_pcm_mmap_commit (handle, offset, frames);
if (commitres < 0 || (snd_pcm_uframes_t) commitres != frames)
{
if ((err = xrun_recovery (handle, commitres >= 0 ? -EPIPE : commitres)) < 0)
{
printf ("MMAP commit error: %s\n", snd_strerror (err));
exit
(EXIT_FAILURE);
}
first = 1;
}
size -= frames;
}
}
}
static int async_direct_loop (snd_pcm_t *handle, signed short *samples ATTRIBUTE_UNUSED,
snd_pcm_channel_area_t
*areas
ATTRIBUTE_UNUSED)
{
struct async_private_data data;
snd_async_handler_t
*ahandler;
const snd_pcm_channel_area_t *my_areas;
snd_pcm_uframes_t offset, frames, size;
snd_pcm_sframes_t
commitres;
int err, count;