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

KTD-S0057-I
Page 103 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
if (err < 0)
{
printf ("Start error: %s\n", snd_strerror (err));
exit
(EXIT_FAILURE);
}
}
else
{
err = snd_pcm_wait (handle, -1);
if (err < 0)
{
if ((err = xrun_recovery (handle, err)) < 0)
{
printf ("snd_pcm_wait error: %s\n", snd_strerror (err));
exit (EXIT_FAILURE);
}
first = 1;
}
}
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, &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;
}
}
}