aboutsummaryrefslogtreecommitdiff
path: root/discord/player.py
diff options
context:
space:
mode:
authorRapptz <[email protected]>2017-04-18 22:20:40 -0400
committerRapptz <[email protected]>2017-04-18 22:20:40 -0400
commitefd6d11e9a3ee0c9dbbdfe52c3377e2321cea928 (patch)
tree1eeadf620e527f080fd5ab0ee3cc0d90fc2a0b5b /discord/player.py
parentClean cache when TimeoutError occurs. (diff)
downloaddiscord.py-efd6d11e9a3ee0c9dbbdfe52c3377e2321cea928.tar.xz
discord.py-efd6d11e9a3ee0c9dbbdfe52c3377e2321cea928.zip
Fix static cut-off when playing.
Diffstat (limited to 'discord/player.py')
-rw-r--r--discord/player.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/discord/player.py b/discord/player.py
index cfddd2c4..3ed7fb7d 100644
--- a/discord/player.py
+++ b/discord/player.py
@@ -92,7 +92,10 @@ class PCMAudio(AudioSource):
self.stream = stream
def read(self):
- return self.stream.read(OpusEncoder.FRAME_SIZE)
+ ret = self.stream.read(OpusEncoder.FRAME_SIZE)
+ if len(ret) != OpusEncoder.FRAME_SIZE:
+ return b''
+ return ret
class FFmpegPCMAudio(AudioSource):
"""An audio source from FFmpeg (or AVConv).
@@ -155,7 +158,10 @@ class FFmpegPCMAudio(AudioSource):
raise ClientException('Popen failed: {0.__class__.__name__}: {0}'.format(e)) from e
def read(self):
- return self._stdout.read(OpusEncoder.FRAME_SIZE)
+ ret = self._stdout.read(OpusEncoder.FRAME_SIZE)
+ if len(ret) != OpusEncoder.FRAME_SIZE:
+ return b''
+ return ret
def cleanup(self):
proc = self._process