[lsb-discuss] first attempt at "normal" t2c-alsa test

Stew Benedict stewb at linux-foundation.org
Thu Apr 22 05:45:25 PDT 2010


Andrey Ponomarenko wrote:
> On 04/22/2010 12:23 AM, Stew Benedict wrote:
>> I've attached modifications to test snd_pcm_open, following Alexey's
>> tutorial as best I could. Please review and comment. I'm still having
>> some trouble wrapping my head around things.
>>
>> Questions in my mind:
>>
>> 1) seems like I should have a snd_pcm_close() in there somewhere, but I
>> either ended up with segfaults or child exiting with signal 6 when I
>> tried to add it to the test
>> 2) the -1 in the sequence was intended to give me a <0 result to test
>> req-06.02, but it didn't really happen. I'm not sure how to force the
>> error condition
>>
>>   
>
> Hello,
> I've tried to run the same test on my work station (ALSA v1.0.22):
>
> ------------------code----------------------
> #include <alsa/asoundlib.h>
> int main(int argc, char *argv[ ])
> {
>     snd_pcm_t* pcm = 0;
>     int res = snd_pcm_open(
>         (snd_pcm_t**)&pcm,
>         "hw:0",
>         -1,
>         SND_PCM_NONBLOCK); //target call
>     printf("res=%d\n", res);
>     return 0;
> }
> ------------------/code----------------------
>
> And it reports:
>
> ALSA lib pcm_hw.c:1268:(snd_pcm_hw_open) invalid stream -1
> res=-22
>
> Also I have run test for snd_pcm_close:
>
> ------------------code----------------------
> #include <alsa/asoundlib.h>
> int main(int argc, char *argv[ ])
> {
>     snd_pcm_t* pcm = 0;
>     snd_pcm_open(
>         (snd_pcm_t**)&pcm,
>         "hw:0",
>         SND_PCM_STREAM_PLAYBACK,
>         SND_PCM_NONBLOCK); //target call
>    
>     int res = snd_pcm_close(pcm);
>     printf("res=%d\n", res);
>     return 0;
> }
> ------------------/code----------------------
>
> And it reports:
> res=0
>
> So snd_pcm_close and snd_pcm_open work as expected at least on my station.
>
> The signal 6 (ABRT) your received possibly means that your pcm is NULL
> (passed to snd_pcm_close and then aborted). Try to check it before
> passing to snd_pcm_close (standalone test without both tet and t2c):
>
Thanks. Silly me, I declared res, but never set res = snd_pcm_open().
Now things work as expected. I had snd_pcm_close(pcm) in the "success"
stanza before, which should have had a value for pcm. Putting it back
again, it now "just works". Not sure why it failed before.

It is interesting that one will get different results if the hardware is
in use (music player running, no pulseaudio), than when it's idle:

in use:

520|15 17 00017342 1 4|Checked requirement: {snd_pcm_open.06.02}
220|15 17 0 07:58:19|PASS
520|15 18 00017343 1 4|Checked requirement: {snd_pcm_open.06.01}
220|15 18 0 07:58:19|PASS
520|15 19 00017344 1 4|Checked requirement: {snd_pcm_open.06.02}
220|15 19 0 07:58:19|PASS

idle (had to actually close exaile):

520|15 17 00021044 1 4|Checked requirement: {snd_pcm_open.06.01}
220|15 17 0 08:03:43|PASS
520|15 18 00021045 1 4|Checked requirement: {snd_pcm_open.06.01}
220|15 18 0 08:03:43|PASS
520|15 19 00021046 1 4|Checked requirement: {snd_pcm_open.06.02}
220|15 19 0 08:03:43|PASS

So SND_PCM_STREAM_PLAYBACK drops into the res < 0 case as the hardware
is tied up. We still PASS, but follow a different sequence.

And on a VM with no sound hardware:

520|15 17 00002477 1 4|Checked requirement: {snd_pcm_open.06.02}
220|15 17 0 08:41:20|PASS
520|15 18 00002478 1 4|Checked requirement: {snd_pcm_open.06.02}
220|15 18 0 08:41:20|PASS
520|15 19 00002479 1 4|Checked requirement: {snd_pcm_open.06.02}
220|15 19 0 08:41:20|PASS

Nothing unexpected here with regards to snd_pcm_open behavior, just less
than consistent test results if I was trying to compare runs between
systems. Perhaps this doesn't matter.

-- 
Stew Benedict
Linux Foundation




More information about the lsb-discuss mailing list