On 2020-01-23, R.Wieser wrote:
>> No. The value of dir is set by the function - that's why you pass
>> it the address of dir. It's returned value for the function
>> "snd_pcm_hw_params_set_rate_near" is
>
> Here at my end a "val" of 8000 with "dir" being given a positive number
> causes a seconds long delay, "val" returns 8001 and "dir" returns 0. Using
> a "dir" of zero doesn't cause a delay and "var" and "dir" stay unchanged.
> Using a negative "dir" doesn't causes a delay either, "val" returns 7999 and
> "dir" returns 0.
>
> In other words, here that "dir" argument goes, just like the "val" one, in
> BOTH directions. Interresting, no ? :-(
Ok instead of playing guessing games I briefly looked at the source code
for libasound, and you are right - it does interrogate the value, probably
to guide the finding of the best match to our given samplerate. I say
probable, because I didn't have the energy to follow the code through
completely. But interestingly you can pass a null pointer there. Given the
simple code you want I suggest you do that. You can always check the
returned value against a copy of the given value to find out if it is
> , < or = to what you wanted.
So with dir uninitialised you can get problems. My advice is to
ignore it, use a null pointer for that parameter, and let the code select
a samplerate close to what you requested.
>> I haven't edited the sample code you referenced - so 44100
>
> Can you do that now ? Maybe testing different a negative and positive
> value for "dir" too ?
>
>>> But I wondered if my, or rather Geany's calling of gcc missed
>>> a "clear declared variables" flag (which is why I specifically
>>> mentioned what I was using, and how).
>>
>> gcc -c simple_alsa_play.c
>> gcc -o simple_alsa_play simple_alsa_play.o -lasound
>
> Nope, no extra setting used.
>
> I think we can conclude that the ALSA version you are using on the PC seems
> to be different from mine on the RPi.
>
> Do you have an RPi that you can re-do the check on ? The result from that
> would mean a lot more.
>
> Regards,
> Rudy Wieser
>
>
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | FidoUsenet Gateway (3:770/3)
|