[PATCH v8] pipe-source: implement autosuspend option

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

 



On 02/20/2018 07:19 PM, Raman Shishniou wrote:
>>> +        if (chunk.length) {
If the source is running or idle, the chunk.length always will be 0.
if (PA_SOURCE_IS_OPENED(u->source->thread_info.state)) {
    ...
    chunk.length = 0;
}
guaranteed that.

>>> +            /* We have a pending data, let's stop polling pipe.
>>> +             * Setting up pollfd->events = 0 is not enough to stop
>>> +             * POLLHUP spam if all writers are closed pipe.
>>> +             * We need to stop polling pipe completely */
>>> +            if (rtpoll_item) {
Here rtpoll_item will be freed only once after source was suspended.
It will stay free until the source will be resumed.

>>> +                pa_rtpoll_item_free(rtpoll_item);
>>> +                rtpoll_item = NULL;
>>> +            }
>>> +        } else {
>>> +            /* We have no pending data, let's start polling pipe */
>>> +            if (rtpoll_item == NULL) {

Here rtpoll_item will be allocated only once after source was resumed and
processed all pending data.

>>> +                rtpoll_item = pa_rtpoll_item_new(u->rtpoll, PA_RTPOLL_NEVER, 1);
>>> +                pollfd = pa_rtpoll_item_get_pollfd(rtpoll_item, NULL);
>>> +                pollfd->events = POLLIN;
>>> +                pollfd->fd = u->fd;
>>> +            }
>>> +        }
>>
>> Your code will allocate/deallocate the rtpoll_item on each
>> iteration. This is unnecessary and CPU intensive (I was told).
>> I would still prefer my approach and I only see disadvantages
>> with your way.
>>
> 
> No, it's not like that.
> 
> rtpoll_item will be allocated:
> - On thread start
> - We just processed all pending data, i.e. source was just resumed.
> 
> rtpoll_item will be freed:
> - We were got any data from pipe, but source was just suspended.
> 
> So there will be only one free per suspend and one allocate per resume.
> 
> 

--
Raman


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

  Powered by Linux