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

KTD-S0057-I
Page 91 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
phase += step;
if (phase >= max_phase)
phase -= max_phase;
}
*_phase = phase;
}
static int set_hwparams (snd_pcm_t *handle, snd_pcm_hw_params_t *params, snd_pcm_access_t access)
{
unsigned int rrate;
snd_pcm_uframes_t
size;
int err, dir;
/* choose all parameters */
err = snd_pcm_hw_params_any (handle, params);
if (err < 0)
{
printf ("Broken configuration for playback: no configurations available: %s\n", snd_strerror (err));
return
err;
}
/* set hardware resampling */
err = snd_pcm_hw_params_set_rate_resample (handle, params, resample);
if (err < 0)
{
printf ("Resampling setup failed for playback: %s\n", snd_strerror (err));
return
err;
}
/* set the interleaved read/write format */
err = snd_pcm_hw_params_set_access (handle, params, access);
if (err < 0)
{
printf ("Access type not available for playback: %s\n", snd_strerror (err));
return
err;
}
/* set the sample format */
err = snd_pcm_hw_params_set_format (handle, params, format);
if (err < 0)
{
printf ("Sample format not available for playback: %s\n", snd_strerror (err));
return
err;
}
/* set the count of channels */
err = snd_pcm_hw_params_set_channels (handle, params, channels);
if (err < 0)
{
printf ("Channels count (%i) not available for playbacks: %s\n", channels, snd_strerror (err));
return
err;
}