Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#39150 closed defect (fixed)

portaudio: patch to fix "Input overflowed" IOError

Reported by: cr@… Owned by: humem (humem)
Priority: Normal Milestone:
Component: ports Version: 2.1.3
Keywords: haspatch Cc:
Port: portaudio

Description

Symptoms

On Mac OS X 10.7.5 with CoreAudio 4.0.3, reading from the default audio source at non-standard framerates fails with an "Input overflowed" IOError:

$ cat bm.py 
#!/usr/bin/env python
import pyaudio
p = pyaudio.PyAudio()
s = p.open( format=pyaudio.paFloat32, channels=2, rate=24000, input=True, frames_per_buffer=256*4 )
while True: a = s.read( 256 )
$ ./bm.py 
Traceback (most recent call last):
  File "./bm.py", line 5, in <module>
    while True: a = s.read( 256 )
  File "/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyaudio.py", line 605, in read
    return pa.read_stream(self._stream, num_frames)
IOError: [Errno Input overflowed] -9981

Framerates tested:

96000: FAIL
88200: FAIL
48000: OK
44100: FAIL
32000: FAIL
24000: FAIL
22050: FAIL
16000: FAIL
12000: FAIL
11025: FAIL
8000:  FAIL

Preliminary analysis

The bug has been addressed upstream in mid-2012: https://www.assembla.com/spaces/portaudio/tickets/171#/activity/ticket

Contrary to what the developer stated in the ticket, the actual svn commit that fixed the issue was 1844:

------------------------------------------------------------------------
r1844 | philburk | 2012-06-25 03:12:29 +0200 (Mo, 25. Jun 2012) | 4 Zeilen

Fix ring buffer handling in pa_mac_core.c that caused many spurious paInputOverflow flags.
Fixed size bug when input underflow detected. Code was confused between bytes and elements.
Zero out the beginning of a recording when detecting pops to prevent start of audio from looking like a pop in qa loopback test.

While upgrading portaudio would probably be the better solution, there is no download archive that includes this revision, yet, except for the daily snapshot http://www.portaudio.com/archives/pa_snapshot.tgz . An alternative would be to switch to downloading from svn.

Solution

The patch from 1844 was added to the Portfile. Experiments show, that several frame rates now smoothly while others (possibly unsupported?) still fail. 1844 supposedly solves other spurious Input overflow failures, too.

Framerates tested:

96000: OK
88200: OK
48000: OK
44100: OK
32000: OK
24000: OK
22050: FAIL
16000: FAIL
12000: FAIL
11025: FAIL
8000:  FAIL

Attachments (1)

portaudio-IOError-patch.diff (11.4 KB) - added by cr@… 11 years ago.

Download all attachments as: .zip

Change History (4)

Changed 11 years ago by cr@…

comment:1 Changed 11 years ago by mf2k (Frank Schima)

Keywords: haspatch added
Owner: changed from macports-tickets@… to hum@…

In the future, please Cc the port maintainer(s).

comment:2 Changed 11 years ago by humem (humem)

Resolution: fixed
Status: newclosed

Thanks for your report and in-depth explanation. Committed in r106319.

comment:3 Changed 11 years ago by jmroot (Joshua Root)

Summary: portaudioportaudio: patch to fix "Input overflowed" IOError
Note: See TracTickets for help on using tickets.