Why tsched disabled when I use module-alsa-sink with 'mmap=0 tsched=1' parameters?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



03.01.2015 11:55, Raymond Yau wrote:
>
>  >>>
>  >>> Dear developers,
>  >>>
>  >>>
>  >>> I have question something about selecting logic between timer-based
>  >>> and IRQ scheduling.
>  >>>
>  >>> When I tried to load 'module-alsa-sink' with 'mmap=0 tsched=1'
>  >>> parameters, tsched(timer-based scheduling) becomes disabled by below
>  >>> codes.
>  >>>
>  >>> It seems tsched is allowed only mmap supported ALSA devices. Why
>  >>> tsched disabled while use non-mmap driven ALSA?
>  >>
>  >>
>  >> Because rewinding is not available in non-mmap mode. That is, it's not
>  >> possible to rewrite previously written data in non-mmap mode. In
>  >> timer-based scheduling mode PulseAudio uses bigger buffer size, which
>  >> causes problems if rewinding isn't available.
>  >
>  >
>  > Sorry, rewinding is actually available in non-mmap mode. And,
> pulseaudio can rewind even without tsched (i.e., tsched == 0 does not
> imply max_rewind == 0). So the reasoning must be different. But I don't
> know the answer.
>
> http://cgit.freedesktop.org/pulseaudio/pulseaudio/log/src/modules/alsa?qt=grep&q=tsched
>
> set latency range only in tsched mode
>
> don't enabled tsched on software ALSA devices
>
> pa_bool_t pa_alsa_pcm_is_hw(snd_pcm_t *pcm) {
> +    snd_pcm_info_t* info;
> +    snd_pcm_info_alloca(&info);
> +
> +    pa_assert(pcm);
> +
> +    if (snd_pcm_info(pcm, info) < 0)
> +        return FALSE;
> +
> +    return snd_pcm_info_get_card(info) >= 0;
>
> This patch seem strange since only those io plugin (e.g. a52) fail the
> test, most plugins pass the above test

Correct. This piece of code has already been discussed exactly due to 
this issue, and Tanu has already expressed his opinion (even though he 
mentions a different commit):

http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-April/020476.html

"""
 > In fact, if you look through the git history behind the uses of
 > pa_alsa_pcm_is_hw() function, you'll notice that one of them was added
 > because of the AC3 encoder which has the same limitation: no rewinding.
 >
 > In particular, "git show cb55b00ccd25d965b1222e74375aee05427a449b" shows
 > the commit that I am attempting to fix up for the DTS case, because the
 > existing check in pa_alsa_pcm_is_hw() does not catch it. If you are
 > still objecting to my commit, and think that the same objections don't
 > apply to cb55b00ccd25d965b1222e74375aee05427a449b, then I would like to
 > see why.
 >
 > See also d5f43bd4c6a7eecff7bc0c4ff1be9152b33cb1e0 and
 > e3f15104cf0386a0e0a782037e8c0323629be749.

Well, I think that some existing code should be replaced with code that
uses snd_pcm_rewindable, once we have confirmed that snd_pcm_rewindable
is actually working in the ALSA layer. The code that needs updating
probably includes the code added by commit cb55b00ccd25d ("alsa: disable
rewinds when using ALSA plugins").
"""

...except that we later agreed to use a new function for this test.

>
> alsa: don't make use of tsched related variables when tsched is disabled
>
> +    if (u->use_tsched) {
> +        *sleep_usec = pa_bytes_to_usec(left_to_play,
> &u->sink->sample_spec);
>
> -    if (*sleep_usec > process_usec)
> -        *sleep_usec -= process_usec;
> -    else
> +        if (*sleep_usec > process_usec)
> +            *sleep_usec -= process_usec;
> +        else
> +            *sleep_usec = 0;
> +    } else
>
> Does it mean it won't sleep for a period time but polling continuosly
> when timer scheduling is disabled

No. sleep_usec gets eventually copied to rtpoll_sleep:

                 rtpoll_sleep = PA_MIN(sleep_usec, cusec);

...and then used as follows:

         if (rtpoll_sleep > 0) {
             pa_rtpoll_set_timer_relative(u->rtpoll, rtpoll_sleep);
             real_sleep = pa_rtclock_now();
         }
         else
             pa_rtpoll_set_timer_disabled(u->rtpoll);

i.e. sleep_usec == 0 means "disable the timer". In this case, pulseaudio 
will wait on the file descriptors provided by snd_pcm_poll_descriptors().

-- 
Alexander E. Patrakov


[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux