Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite voice connection internals #9525

Merged
merged 51 commits into from
Sep 28, 2023
Merged

Commits on Sep 22, 2023

  1. Configuration menu
    Copy the full SHA
    f8d2d00 View commit details
    Browse the repository at this point in the history
  2. Porting progress

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    ec3de31 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    6febaf0 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    321c8b7 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    f2f7cf4 View commit details
    Browse the repository at this point in the history
  6. Read packets from the socket until we get the ip discovery packet

    If this isn't the initial connection, the socket fills up with rtp/rtcp
    packets, meaning you can't just read one when you reconnect.
    This has terrible implications for voice recv.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    fc3f9da View commit details
    Browse the repository at this point in the history
  7. Resend speaking state upon reconnect

    I finally found this bug.  Reconnecting sends a none speaking state, so
    we need to send speaking again to be heard.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    7ddcd13 View commit details
    Browse the repository at this point in the history
  8. Logging tweaks

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    fa3ddc1 View commit details
    Browse the repository at this point in the history
  9. Remove defunct code

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    099f552 View commit details
    Browse the repository at this point in the history
  10. Rename connection_state to _voice_state

    also add ws property
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    536b11a View commit details
    Browse the repository at this point in the history
  11. Configuration menu
    Copy the full SHA
    5b8c372 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    069f5bf View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    0f851ef View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    7931adc View commit details
    Browse the repository at this point in the history
  15. Configuration menu
    Copy the full SHA
    8a03951 View commit details
    Browse the repository at this point in the history
  16. run black

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    220a786 View commit details
    Browse the repository at this point in the history
  17. Fix grievances part 1

    Renamed VoiceClient._voice_state -> ._connection
    Renamed ConnectionStage -> ConnectionFlowState (tentatively)
    Renamed VoiceConnectionState._stage -> ._state
    Renamed VoiceConnectionState.stage -> .state
    Renamed parameters called stage -> state
    Renamed VoiceConnectionState._wait_for_stage -> ._wait_for_state
    Fix VoiceClient.wait_until_connected docstring
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    eb2c17a View commit details
    Browse the repository at this point in the history
  18. Fix grievances part 2

    Rework ConnectionFlowState from bitfields to normal int enum and fix
    relevant comparisons.
    Remove obsolete exact param from _wait_for_state
    Remove IntEnum typing hack
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    86b21d2 View commit details
    Browse the repository at this point in the history
  19. Fix reconnect state check

    Since we can only check absolute states now we need to be able to check
    for multiple in _wait_for_state
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    26fb0c1 View commit details
    Browse the repository at this point in the history
  20. Use single quotes

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    cc149b6 View commit details
    Browse the repository at this point in the history
  21. Try to avoid doing ip discovery if unnecessary

    One step towards trying to avoid a very annoying problem with reading
    packets from the socket as a shared resource (voice recv)
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    071d873 View commit details
    Browse the repository at this point in the history
  22. Configuration menu
    Copy the full SHA
    107921d View commit details
    Browse the repository at this point in the history
  23. Configuration menu
    Copy the full SHA
    726d243 View commit details
    Browse the repository at this point in the history
  24. Configuration menu
    Copy the full SHA
    6a6efab View commit details
    Browse the repository at this point in the history
  25. Configuration menu
    Copy the full SHA
    12d4bb2 View commit details
    Browse the repository at this point in the history
  26. Configuration menu
    Copy the full SHA
    0ee4954 View commit details
    Browse the repository at this point in the history
  27. Refactor socket connection code and work on state stability

    1. We're changing the socket from implicit connect using sendto to
       explicit connect with sock_connect, and making it use async
       functions while we're at it.
    
    2. We're adding a timeout to the websocket connection+handshake part,
       and also splitting _connect_websocket into two functions, that and
       _handshake_websocket.  Now the ws attribute gets assigned
       immediately after creation and not only after the handshake.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    6576d49 View commit details
    Browse the repository at this point in the history
  28. Fix voice_state_update disconnect state confusion

    Since there's no way to tell who or what a voice_state_update with
    channel=None came from, we have to remember if we were the ones who
    disconnected ourselves from the voice channel.  Hopefully this is sane
    enough to withstand the average discord eventual consistency.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    ed6379e View commit details
    Browse the repository at this point in the history
  29. disconnect() cleanup

    We switch to force=True by default, and now have a cleanup param to
    selectively run voice client cleanup.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    0f7cea7 View commit details
    Browse the repository at this point in the history
  30. Quotes and debug log

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    5b02238 View commit details
    Browse the repository at this point in the history
  31. Configuration menu
    Copy the full SHA
    0a0e646 View commit details
    Browse the repository at this point in the history
  32. Implement safe shared socket reading

    The voice socket is no longer directly read from by the voice websocket
    to get the ip discovery packet.  Now there is a socket reader thread
    object that handles this by using registered callbacks.  This way there
    is no longer any for the socket to be improperly shared between any
    potential readers.  In the base library this isn't important since the
    only thing the socket is read for is the ip discovery packet, but for
    *extensions implementing voice recv* its necessary.  The thread pauses
    when there are no listeners attached as not to waste cpu time.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    3d71f62 View commit details
    Browse the repository at this point in the history
  33. Configuration menu
    Copy the full SHA
    2471f6a View commit details
    Browse the repository at this point in the history
  34. Fix some stuff

    Clean up ip discovery future handling
    Rename _self_paused to _idle_paused
    Misc
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    dee6e3d View commit details
    Browse the repository at this point in the history
  35. Partially fix connection durability issues

    Fixing checks and timeouts mostly.  The change to move_to is mostly a
    band-aid fix.  It doesn't solve the underlying problem but it removes
    that vector for causing it.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    0b5e1a1 View commit details
    Browse the repository at this point in the history
  36. Maybe fully fix voice reconnection instability

    By moving connect() to a task we can cancel it and restart, making it
    easier to handle overlapping reconnects.  It seems to work from my
    testing but i'm not entirely sure its sound, specifically the whole
    'stopping the ws runner task' part.  If anything its racy but that
    remains to be seen.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    59f121e View commit details
    Browse the repository at this point in the history
  37. Configuration menu
    Copy the full SHA
    53992b6 View commit details
    Browse the repository at this point in the history
  38. Go over comments, logging, and minor changes

    There are a bunch of TODOs that need input or a decision on
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    6196016 View commit details
    Browse the repository at this point in the history
  39. Clean up TODOs

    Remove ip caching, didn't really serve a purpose
    Add timeout param to move_to()
    Change BlockingIOError to OSError in send_audio_packet()
    Change task types to Optional instead of MISSING
    Properly transfer connect params and voice state to connect() calls
    Remove some uncertain code path handling TODOs
    Fix reconnecting in the ws runner task
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    d0bc55f View commit details
    Browse the repository at this point in the history
  40. Configuration menu
    Copy the full SHA
    f9200d0 View commit details
    Browse the repository at this point in the history
  41. Configuration menu
    Copy the full SHA
    87bbf1a View commit details
    Browse the repository at this point in the history
  42. Fix issues

    Raise errors on connection problems
    Add default timeout to wait_until_connected
    Undocument wait_until_connected (its sync and only used internally once)
    Change some timeouts to 30s
    Floatify floats
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    e5bdd39 View commit details
    Browse the repository at this point in the history
  43. Configuration menu
    Copy the full SHA
    92e2bbb View commit details
    Browse the repository at this point in the history
  44. Remove todo comments

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    aaf15df View commit details
    Browse the repository at this point in the history
  45. And this one too

    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    db3a045 View commit details
    Browse the repository at this point in the history
  46. Configuration menu
    Copy the full SHA
    afdbb7d View commit details
    Browse the repository at this point in the history
  47. Add a factory for VoiceConnectionState

    Good thing I remembered to do this or fixing this in my voice recv code
    would have been a little annoying.
    imayhaveborkedit committed Sep 22, 2023
    Configuration menu
    Copy the full SHA
    014147a View commit details
    Browse the repository at this point in the history

Commits on Sep 28, 2023

  1. Configuration menu
    Copy the full SHA
    be55956 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    ce4cb2f View commit details
    Browse the repository at this point in the history
  3. Fix docstring

    imayhaveborkedit committed Sep 28, 2023
    Configuration menu
    Copy the full SHA
    719fdf1 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    515da08 View commit details
    Browse the repository at this point in the history