From ea48fd7dc3ffd2b3223c792227c7850e6e9e7185 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Sun, 12 Jun 2016 13:02:21 -0700 Subject: [PATCH] Fix #32: ffmpeg interference with stdin stream --- README.rst | 4 ++++ audioread/ffdec.py | 7 ++++++- setup.py | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index fe577fa..0c968d7 100644 --- a/README.rst +++ b/README.rst @@ -65,6 +65,10 @@ convert compressed audio files to WAV files. Version History --------------- +2.1.4 + Fix a bug in the FFmpeg backend where, after closing a file, the program's + standard input stream would be "broken" and wouldn't receive any input. + 2.1.3 Avoid some warnings in the GStreamer backend when using modern versions of GLib. We now require at least GLib 2.32. diff --git a/audioread/ffdec.py b/audioread/ffdec.py index b6e0c4f..622f31d 100644 --- a/audioread/ffdec.py +++ b/audioread/ffdec.py @@ -21,6 +21,7 @@ import re import threading import time +import os try: import queue except ImportError: @@ -117,10 +118,13 @@ def __init__(self, filename, block_size=4096): ) try: + self.devnull = open(os.devnull) self.proc = popen_multiple( COMMANDS, ['-i', filename, '-f', 's16le', '-'], - stdout=subprocess.PIPE, stderr=subprocess.PIPE, + stdout=subprocess.PIPE, + stderr=subprocess.PIPE, + stdin=self.devnull, ) except OSError: @@ -258,6 +262,7 @@ def close(self): if hasattr(self, 'proc') and self.proc.returncode is None: self.proc.kill() self.proc.wait() + self.devnull.close() def __del__(self): self.close() diff --git a/setup.py b/setup.py index 06875f5..1d3aa58 100644 --- a/setup.py +++ b/setup.py @@ -22,7 +22,7 @@ def _read(fn): setup(name='audioread', - version='2.1.3', + version='2.1.4', description='multi-library, cross-platform audio decoding', author='Adrian Sampson', author_email='adrian@radbox.org',