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

Page 115

Advertising
background image

KTD-S0057-I

Page 111 Linux® Programming Examples (DebianTM)


KTAM3874/pITX Software Guide


if ((err = snd_pcm_hw_params_any (capture_handle, hw_params)) < 0)

{

fprintf (stderr, "Cannot initialize hardware parameter structure (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

if ((err = snd_pcm_hw_params_set_access (capture_handle, hw_params,

SND_PCM_ACCESS_RW_INTERLEAVED))

<

0)

{

fprintf (stderr, "Cannot set access type (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

if ((err = snd_pcm_hw_params_set_format (capture_handle, hw_params, SND_PCM_FORMAT_S16_LE)) < 0)

{

fprintf (stderr, "Cannot set sample format (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

rrate = RATE_44kHz;

if ((err = snd_pcm_hw_params_set_rate_near (capture_handle, hw_params, &rrate, 0)) < 0)

{

fprintf (stderr, "Cannot set sample rate (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

if ((err = snd_pcm_hw_params_set_channels (capture_handle, hw_params, MONO)) < 0)

{

fprintf (stderr, "Cannot set channel count (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

if ((err = snd_pcm_hw_params (capture_handle, hw_params)) < 0)

{

fprintf (stderr, "Cannot set parameters (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

snd_pcm_hw_params_free

(hw_params);

if ((err = snd_pcm_prepare (capture_handle)) < 0)

{

fprintf (stderr, "Cannot prepare audio interface for use (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

if ((err = snd_pcm_readi (capture_handle, buf, BUFSIZE)) != BUFSIZE)

{

fprintf (stderr, "read from audio interface failed (%s)\n", snd_strerror (err));

return

EXIT_FAILURE;

}

snd_pcm_close

(capture_handle);

Advertising
This manual is related to the following products: