Skip to content

Reusing discord.Sink subclasses throws AudioData is already finished writing #2926

@Icebluewolf

Description

@Icebluewolf

Summary

The audio_recording.py and audio_recording_merged.py examples reuse the same sink instances for multiple recordings. This throws an error. It is unclear if this is an issue with the sinks code or the examples.

Reproduction Steps

  1. Run one of the examples mentioned above.
  2. Join a voice channel
  3. Run /start
  4. Make some noise
  5. Run /stop
  6. Stay in the voice channel
  7. Run /start and make some noise
  8. Observe the error in the console
  9. If you run /stop at this point the console will be spammed with "Decoder Process Killed" indefinitely.

Minimal Reproducible Code

Expected Results

No error

Actual Results

Exception in thread DecodeManager:
Traceback (most recent call last):
  File "Python312\Lib\threading.py", line 1073, in _bootstrap_inner
    self.run()
  File "pycord\discord\opus.py", line 556, in run
    self.client.recv_decoded_audio(data)
  File "pycord\discord\voice_client.py", line 943, in recv_decoded_audio
    self._process_audio_packet(data)
  File "pycord\discord\voice_client.py", line 994, in _process_audio_packet
    self.sink.write(data.decoded_data, self.ws.ssrc_map[data.ssrc]["user_id"])
  File "pycord\discord\sinks\core.py", line 84, in _filter
    return func(self, data, user)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "pycord\discord\sinks\core.py", line 232, in write
    file.write(data)
  File "pycord\discord\sinks\core.py", line 154, in write
    raise SinkException("The AudioData is already finished writing.")
discord.sinks.errors.SinkException: The AudioData is already finished writing.

Intents

default

System Information

  • Python v3.12.4-final
  • py-cord v2.7.None-candidate
    • py-cord importlib.metadata: v2.7.0rc2.dev62+g3b8b79f20.d20250914
  • aiohttp v3.10.5
  • system info: Windows 11 10.0.26100

Checklist

  • I have searched the open issues for duplicates.
  • I have shown the entire traceback, if possible.
  • I have removed my token from display, if visible.

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    unconfirmed bugA bug report that needs triaging

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions