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

Page 105

Advertising
background image

KTD-S0057-I

Page 101 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


data.samples = NULL;

/* we do not require the global sample area for direct write */

data.areas = NULL;

/* we do not require the global areas for direct write */

data.phase = 0;

err = snd_async_add_pcm_handler (&ahandler, handle, async_direct_callback, &data);

if (err < 0)

{

printf ("Unable to register async handler\n");

exit

(EXIT_FAILURE);

}

for (count = 0; count < 2; count++)

{

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);

}

}

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);

}

}

size -= frames;

}

}

err = snd_pcm_start (handle);

if (err < 0)

{

printf ("Start error: %s\n", snd_strerror (err));

exit

(EXIT_FAILURE);

}

/* because all other work is done in the signal handler, suspend the process */

while

(1)

{

sleep(1);

}
}

Advertising
This manual is related to the following products: