Skip to content

PortAudioError: Unanticipated host error [PaErrorCode -9999]: 'No space left on device' [ALSA error -28] #624

@ammarkh95

Description

@ammarkh95

Platform/OS: Raspberry Pi 4B, Linux raspberrypi4b 6.12.62+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.62-1+rpt1 (2025-12-18) aarch64 GNU/Linux
Python 3.13.5

I am using sounddevice Version: 0.5.5 with PortAudio version ('PortAudio V19.6.0-devel, revision 396fe4b6699ae929d3a685b3ef8a7e97396139a4') to play a wav file to a USB Audio device.

When I try to play audio via sd.play function I get the following error:
PortAudioError: Error opening OutputStream: Unanticipated host error [PaErrorCode -9999]: 'No space left on device' [ALSA error -28]

(venv) rpi4b@raspberrypi4b:~/tmp_auracast $ ipython
Python 3.13.5 (main, Jun 25 2025, 18:55:22) [GCC 14.2.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 9.10.0 -- An enhanced Interactive Python. Type '?' for help.
Tip: You can use `files = !ls *.png`

In [1]: import soundfile

In [2]: import sounddevice as sd

In [3]: sd.query_devices()
Out[3]:
  0 bcm2835 Headphones: - (hw:0,0), ALSA (0 in, 8 out)
> 1 UT02C Aura: USB Audio (hw:3,0), ALSA (1 in, 2 out)
  2 UT02C Aura: USB Audio (hw:4,0), ALSA (1 in, 2 out)
  3 UT02C Aura: USB Audio (hw:5,0), ALSA (1 in, 2 out)
  4 UT02C Aura: USB Audio (hw:6,0), ALSA (1 in, 2 out)
  5 sysdefault, ALSA (0 in, 128 out)
< 6 default, ALSA (0 in, 128 out)
  7 dmix, ALSA (0 in, 2 out)

In [4]: data, _ = soundfile.read("../Downloads/1000-Hz-Tone.wav")

In [5]: sd.play(data, device=1)
Expression 'r' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2097
Expression 'PaAlsaStreamComponent_FinishConfigure( &self->playback, hwParamsPlayback, outParams, self->primeBuffers, realSr, outputLatency )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2737
Expression 'PaAlsaStream_Configure( stream, inputParameters, outputParameters, sampleRate, framesPerBuffer, &inputLatency, &outputLatency, &hostBufferSizeMode )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', l
ine: 2842
---------------------------------------------------------------------------
PortAudioError                            Traceback (most recent call last)
Cell In[5], line 1
----> 1 sd.play(data, device=1)

File ~/tmp_auracast/venv/lib/python3.13/site-packages/sounddevice.py:183, in play(data, samplerate, mapping, blocking, loop, **kwargs)
    180     ctx.write_outdata(outdata)
    181     ctx.callback_exit()
--> 183 ctx.start_stream(OutputStream, samplerate, ctx.output_channels,
    184                  ctx.output_dtype, callback, blocking,
    185                  prime_output_buffers_using_stream_callback=False,
    186                  **kwargs)

File ~/tmp_auracast/venv/lib/python3.13/site-packages/sounddevice.py:2664, in _CallbackContext.start_stream(self, StreamClass, samplerate, channels, dtype, callback, blocking, **kwargs)
   2661 def start_stream(self, StreamClass, samplerate, channels, dtype, callback,
   2662                  blocking, **kwargs):
   2663     stop()  # Stop previous playback/recording
-> 2664     self.stream = StreamClass(samplerate=samplerate,
   2665                               channels=channels,
   2666                               dtype=dtype,
   2667                               callback=callback,
   2668                               finished_callback=self.finished_callback,
   2670     self.stream.start()
   2671     global _last_callback

File ~/tmp_auracast/venv/lib/python3.13/site-packages/sounddevice.py:1532, in OutputStream.__init__(self, samplerate, blocksize, device, channels, dtype, latency, extra_settings, callback, finished_callback, c
lip_off, dither_off, never_drop_input, prime_output_buffers_using_stream_callback)
   1500 def __init__(self, samplerate=None, blocksize=None,
   1501              device=None, channels=None, dtype=None, latency=None,
   1502              extra_settings=None, callback=None, finished_callback=None,
   1503              clip_off=None, dither_off=None, never_drop_input=None,
   1504              prime_output_buffers_using_stream_callback=None):
   1505     """PortAudio output stream (using NumPy).
   1506
   1507     This has the same methods and attributes as `Stream`, except
   (...)   1530
   1531     """
-> 1532     _StreamBase.__init__(self, kind='output', wrap_callback='array',
   1533                          **_remove_self(locals()))

File ~/tmp_auracast/venv/lib/python3.13/site-packages/sounddevice.py:914, in _StreamBase.__init__(self, kind, samplerate, blocksize, device, channels, dtype, latency, extra_settings, callback, finished_callbac
k, clip_off, dither_off, never_drop_input, prime_output_buffers_using_stream_callback, userdata, wrap_callback)
    912     userdata = _ffi.NULL
    913 self._ptr = _ffi.new('PaStream**')
--> 914 _check(_lib.Pa_OpenStream(self._ptr, iparameters, oparameters,
    915                           samplerate, blocksize, stream_flags,
    916                           callback_ptr, userdata),
    917        f'Error opening {self.__class__.__name__}')
    919 # dereference PaStream** --> PaStream*
    920 self._ptr = self._ptr[0]

File ~/tmp_auracast/venv/lib/python3.13/site-packages/sounddevice.py:2836, in _check(err, msg)
   2834     hosterror_text = _ffi_string(info.errorText).decode()
   2835     hosterror_info = host_api, info.errorCode, hosterror_text
-> 2836     raise PortAudioError(errormsg, err, hosterror_info)
   2838 raise PortAudioError(errormsg, err)

PortAudioError: Error opening OutputStream: Unanticipated host error [PaErrorCode -9999]: 'No space left on device' [ALSA error -28]

I get a similar problem when calling sd.check_output_settings(device=1)

I checked which applications are using the audio devices and looks like pipewire, wirepluber audio services are involved but this should not be a problem I guess ?

(venv) rpi4b@raspberrypi4b:~/tmp_auracast $ fuser -v /dev/snd/*
                     USER        PID ACCESS COMMAND
/dev/snd/controlC0:  rpi4b      1220 F.... wireplumber
/dev/snd/controlC3:  rpi4b      1220 F.... wireplumber
/dev/snd/seq:        rpi4b      1217 F.... pipewire

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions