• rkc@chromium.org's avatar
    Stop playing/recording when not needed. · 1ae6d05f
    rkc@chromium.org authored
    Currently when unpublishing or unsubscribing, we still keep playing or recording
    audio till it times out. We need to keep a track of which operations have
    requested playing or recording and once those operations are unpublished or
    unsubscribed, we need to appropriately stop the record/playback.
    
    To do this, the first change is to stop keeping a list of tokens, instead we
    just keep a list of operations. If we send our currently playing token to the
    server, it is guaraunteed to _not issue another token, unless our current token
    is going to expire in less time than is on the publish. In that case, we simply
    replace our currently playing token with the new one, making sure that we
    always just need to keep one token around.
    
    With this, the logic for playing/recording is completely changed. Now we just
    check if we have active transmit/receive, and if we do, we ensure that we are
    playing our current token (or keep recording); if we do not have an active
    transmit and we are playing, we stop playing. For all other cases our
    ProcessNextTransmit and ProcessNextReceive is a nop.
    
    The one ugliness in the code is that we have to keep the code for processing
    the audible and inaudible tokens in the same class, since the WhispernetClient
    can only give 'one' method tokens back. If two different classes call the
    WhispernetClient to encode tokens, the get samples callback from the second
    will overrite the callback for the first, hence the first class will never
    get its samples back. Once we find a way around this, we can just have two
    AudioDirectiveHandlers, one for audible and one for inaudible, but till then
    we need to keep this processing together in one AudioDirectiveHandler.
    
    
    R=xiyuan@chromium.org
    BUG=392028
    
    Review URL: https://codereview.chromium.org/461803003
    
    Cr-Commit-Position: refs/heads/master@{#289219}
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@289219 0039d316-1c4b-4281-b951-d872f2087c98
    1ae6d05f
rpc_handler.cc 19.5 KB