Skip to content

Commit

Permalink
player: Close ffmpeg stdin during streaming
Browse files Browse the repository at this point in the history
A `stdin` of `None` means the ffmpeg subprocess input inherits from the
parent process, which may cause undesired control from a terminal (e.g.
`C` causes ffmpeg to prompt for a command).  It also closes the parent's
stdin when the subprocess exits.

This commit switches to `subprocess.DEVNULL`, which provides a separate
pre-closed stdin for ffmpeg subprocesses.
  • Loading branch information
Terrance authored and Rapptz committed May 24, 2020
1 parent 755ab28 commit 017591d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions discord/player.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ class FFmpegPCMAudio(FFmpegAudio):

def __init__(self, source, *, executable='ffmpeg', pipe=False, stderr=None, before_options=None, options=None):
args = []
subprocess_kwargs = {'stdin': source if pipe else None, 'stderr': stderr}
subprocess_kwargs = {'stdin': source if pipe else subprocess.DEVNULL, 'stderr': stderr}

if isinstance(before_options, str):
args.extend(shlex.split(before_options))
Expand Down Expand Up @@ -293,7 +293,7 @@ def __init__(self, source, *, bitrate=128, codec=None, executable='ffmpeg',
pipe=False, stderr=None, before_options=None, options=None):

args = []
subprocess_kwargs = {'stdin': source if pipe else None, 'stderr': stderr}
subprocess_kwargs = {'stdin': source if pipe else subprocess.DEVNULL, 'stderr': stderr}

if isinstance(before_options, str):
args.extend(shlex.split(before_options))
Expand Down

0 comments on commit 017591d

Please sign in to comment.