Skip to content

Commit e97dfca

Browse files
committed
Merge pull request #68 from bastibe/issue-68
Allow pipe read/write
2 parents 5e92d73 + 00e3dda commit e97dfca

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

pysoundfile.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,6 +673,13 @@ def __init__(self, file, mode='r', samplerate=None, channels=None,
673673
# truncate the file, because SFM_RDWR doesn't:
674674
_os.close(_os.open(file, _os.O_WRONLY | _os.O_TRUNC))
675675
self._file = _snd.sf_open(file.encode(), mode_int, self._info)
676+
if mode_int == _snd.SFM_WRITE:
677+
# Due to a bug in libsndfile version <= 1.0.25, frames != 0
678+
# when opening a named pipe in SFM_WRITE mode.
679+
# See http://github.com/erikd/libsndfile/issues/77.
680+
self._info.frames = 0
681+
# This is not necessary for "normal" files (because
682+
# frames == 0 in this case), but it doesn't hurt, either.
676683
elif isinstance(file, int):
677684
self._file = _snd.sf_open_fd(file, mode_int, self._info, closefd)
678685
elif all(hasattr(file, a) for a in ('seek', 'read', 'write', 'tell')):

0 commit comments

Comments
 (0)