Alsa Programming Examples
Hello to all ALSA developers!
I had compiled the examples of the Programming HOWTO succesfully!!! I saw many programming mistakes in these files. I don't think ANSI C supports polymorphism! So I had to take parts out of other running code and put it into the example.
But now, after a few changes I could run the program which starts to send Random PCM Data to the interface.
Now I have following problem:
Although the program compiled succesfully I get following output:
how1: pcm_params.c:2136: snd_pcm_hw_refine: Assertion && params failed. Canceled
What is the problem?
( My conditions:
CMI8738
ALSA 0.90 driver and library
)
Yours Philipp Vollmer
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
Quoted 9 lines · Philipp Vollmer
Hello to all ALSA developers!
I had compiled the examples of the Programming HOWTO succesfully!!! I saw many programming mistakes in these files. I don't think ANSI C supports polymorphism! So I had to take parts out of other running code and put it into the example.
But now, after a few changes I could run the program which starts to send Random PCM Data to the interface.
Quoted 7 lines
Now I have following problem:
Although the program compiled succesfully I get following output:how1: pcm_params.c:2136:
snd_pcm_hw_refine: Assertion && params failed. CanceledWhat is the problem?
$ man assert
it seems params == 0 when you're calling snd_pcm_hw_refine.
tim
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
Quoted 1 line
it seems params == 0 when you're calling
snd_pcm_hw_refine.
Hello,
Sorry but there is no codeline like snd_pcm_hw_refine in the example. I will send you the file as an attachment.
Best regards
Philipp Vollmer
[email protected]
#include <stdlib.h>
#include <alsa/asoundlib.h>
main (int argc, char *argv[])
{
int i;
char buf[4096];
snd_pcm_t *playback_handle;
snd_pcm_hw_params_t *hw_params;
if ((playback_handle = snd_pcm_open (&playback_handle, "default", SND_PCM_STREAM_PLAYBACK, 0)) < 0) {
fprintf (stderr, "cannot open audio device %s\n", argv[1]);
exit (1);
}
// snd_pcm_open (&playback_handle, pcm_name, SND_PCM_STREAM_PLAYBACK, 0)
snd_pcm_hw_params_malloc (&hw_params);
snd_pcm_hw_params_any (playback_handle, hw_params);
snd_pcm_hw_params_set_access (playback_handle, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
snd_pcm_hw_params_set_format (playback_handle, hw_params, SND_PCM_FORMAT_S16_LE);
snd_pcm_hw_params_set_rate_near (playback_handle, hw_params, 44100, 0);
//snd_pcm_hw_params_set_rate_near(playback_handle, hw_params, 44100, 0);
snd_pcm_hw_params_set_channels (playback_handle, hw_params, 2);
snd_pcm_hw_params (playback_handle, hw_params);
snd_pcm_hw_params_free (hw_params);
snd_pcm_prepare (playback_handle);
for (i = 0; i < 10; ++i) {
snd_pcm_writei (playback_handle, buf, sizeof (buf));
//snd_pcm_writei (playback_handle, buf, nframes);
}
snd_pcm_close (playback_handle);
exit (0);
}Quoted 5 lines · Philipp Vollmer
Quoted 1 line
it seems params == 0 when you're calling
snd_pcm_hw_refine.Hello,
Sorry but there is no codeline like
snd_pcm_hw_refinein the example. I will send you the file as an attachment.
in your file:
if ((playback_handle = snd_pcm_open (&playback_handle, "default",
SND_PCM_STREAM_PLAYBACK, 0)) < 0) {snd_pcm_open returns 0 on success, *not* the pcm handle. have you tried reading the docs yet ;) and haven't you wondered why you pass the address of 'playback_handle' to snd_pcm_open()?
gcc warns you about this:
$ gcc -c how1.c how1.c: In function `main': how1.c:11: warning: assignment makes pointer from integer without a cast
and if you had endeavoured to read the sources of alsa-lib, you'd have discovered that (alsa-lib/src/pcm/pcm.c):
int snd_pcm_hw_params_any(snd_pcm_t *pcm, snd_pcm_hw_params_t *params) {
_snd_pcm_hw_params_any(params);
return snd_pcm_hw_refine(pcm, params);
}
with all respect, i think you could have tried a little harder to find the error.
tim
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
Quoted 2 lines · Tim Goetze
with all respect, i think you could have tried a little harder to find the error.
There is a prominent link on
http://www.alsa-project.org/documentation.php3#0.9doc
Howto use the ALSA API - Paul Davis has also written a brief explanation.
http://www.op.net/~pbd/alsa-audio.html#captureex
You will find there:
if ((capture_handle = snd_pcm_open (argv[1], SND_PCM_STREAM_CAPTURE, 0)) <0) {
fprintf (stderr, "cannot open audio device %s\n", argv[1]);
exit (1);}
and many other errors.
While examples are the best for of developers documentation, broken examples are the worst form of misinformation.
I have written about a week ago to [email protected], no answer yet.
Best regards,
--
Tomasz Motylewski
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
Quoted 18 lines · tomasz motylewski
Quoted 2 lines · Tim Goetze
with all respect, i think you could have tried a little harder to find the error.
There is a prominent link on
http://www.alsa-project.org/documentation.php3#0.9docHowto use the ALSA API - Paul Davis has also written a brief explanation.
http://www.op.net/~pbd/alsa-audio.html#captureexYou will find there:
if ((capture_handle = snd_pcm_open (argv[1], SND_PCM_STREAM_CAPTURE, 0)) <0) { fprintf (stderr, "cannot open audio device %s\n", argv[1]); exit (1); }
Quoted 4 lines
and many other errors.
While examples are the best for of developers documentation, broken examples are the worst form of misinformation.
i offer my apologies, i had no idea this tutorial fails its purpose so badly.
tim
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
Quoted 5 lines
There is a prominent link on
http://www.alsa-project.org/documentation.php3#0.9docHowto use the ALSA API - Paul Davis has also written a brief explanation.
http://www.op.net/~pbd/alsa-audio.html#captureex
Right here, on this mailing list, and in private mail to Philipp, and in mail to LAD, I made it clear that the examples in my document are incomplete and incorrect.
The link is included because it was felt that the non-code material in my document was useful.
Quoted 2 lines
While examples are the best for of developers documentation, broken examples are the worst form of misinformation.
agreed. perhaps you can fix them, or produce a version of the document with them removed so that a better link can be used. If you would like to pay me to rearrange my time to get the code removed and/or fixed, thats fine. Otherwise, please accept the limited offering thats linked to right now.
Quoted 1 line
I have written about a week ago to [email protected], no answer yet.
thats not my email address, and its not listed as that on the web site. i get approximately 150 email messages per day connected with linux audio issues. i do not have time to answer them all.
--p
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink
Quoted 8 lines · Paul Davis
agreed. perhaps you can fix them, or produce a version of the document with them removed so that a better link can be used. If you would like to pay me to rearrange my time to get the code removed and/or fixed, thats fine. Otherwise, please accept the limited offering thats linked to right now.
If people send in a fix to that file I'll add it in and put up the revision on ALSA if Paul doesn't mind.
Signature · 11 lines
Patrick Shirkey - Boost Hardware Ltd. For the discerning hardware connoisseur Http://www.boosthardware.com Http://www.boosthardware.com/LAU/guide/ ======================================== _______________________________________________________________ Don't miss the 2002 Sprint PCS Application Developer's Conference August 25-28 in Las Vegas - http://devcon.sprintpcs.com/adp/index.cfm?source=osdntextlink