Hi. I know this is an old thread but I just wanted to say that since that demo is still actually LIVE and people are still citing it.
And almost no decent demo's exist.
The following may well be the reason you didn't get your card working:
(I didn't do it all but you'll get the gist, and hopefully glean how to get other demo's working)
FROM THE DEMO: WITH EXTRA NOTES Added as ///:
/// Many devices don't support "near" - mine didn't.
/// However you can just use snd_pcm_hw_params_set_rate and pick a rate THAT IS supported by your hardware.
/// Selecting the plug, plughw, plughw:0, plughw:0,0 device provide automagic conversion but may not be what was intended
/// 44100 and 48000 are good choices here generally - as is snd_pcm_hw_params_set_rate if you have the luxury of programming for known HW
///
Code:
/* 44100 bits/second sampling rate (CD quality) */
val = 44100;
snd_pcm_hw_params_set_rate_near(handle, params,
&val, &dir);
/// Again this set and get period size construct was not supported
/// The program worked without them IIRC
/// Mine defaulted to 8 frames anyway with no params for this.
/// arecord -vv > test.wav throws out some stuff
/// Determine your default frame time some other way if this seggies
/// or just ignore it and comment out the code if it's not essential to operation
/* Set period size to 32 frames. */
frames = 32;
snd_pcm_hw_params_set_period_size_near(handle,
params, &frames, &dir);
/* Write the parameters to the driver */
rc = snd_pcm_hw_params(handle, params);
if (rc < 0) {
fprintf(stderr,
"unable to set hw parameters: %s\n",
snd_strerror(rc));
exit(1);
}
/// This seggied on me - 8 was my default size IIRC
/// Fudge it if you have to.
/* Use a buffer large enough to hold one period */
snd_pcm_hw_params_get_period_size(params, &frames,
&dir);
size = frames * 4; /* 2 bytes/sample, 2 channels */
buffer = (char *) malloc(size);
ELIDED....
Simply (ha!) work your way through the unsupported function replacing with similar things. set_near with set etc.
About 4 or 5 things don't work out-of-the-box on this, and other demo's, set_near is often a culprit.
Hope this helps relieve some frustration.
There are a few other decent demos out there.
Alan's demo here www . saunalahti . fi /~s7l/blog/2005/08/21/Full%20Duplex%20ALSA (remove the spaces) whilst incomplete is more discursive.
Hope that helps.