Skip to content

stream.time raises when the time is 0.0 (PortAudioError: Error getting stream time.. on RaspberyPI) #591

@RmStorm

Description

@RmStorm

When I run:

        self.stream = sd.InputStream(device=self.device, channels=1, samplerate=self.fs, blocksize=self.block_size, callback=cb)
        self.stream.start()
        self.stream.time

on my laptop it works.. but when I run it on a raspbery pi I get:

/home/monil/repos/silo/tools/scripts/.venv/lib/python3.12/site-packages/sounddevice.py:1078 in time                                                                                        │
│                                                                                                                                                                                            │
│   1075 │   │   """                                                                              ╭───────────────────────── locals ──────────────────────────╮                              │
│   1076 │   │   time = _lib.Pa_GetStreamTime(self._ptr)                                          │ self = <sounddevice.InputStream object at 0x7fff5eb3d040> │                              │
│   1077 │   │   if not time:                                                                     │ time = 0.0                                                │                              │
│ ❱ 1078 │   │   │   raise PortAudioError('Error getting stream time')                            ╰───────────────────────────────────────────────────────────╯                              │
│   1079 │   │   return time      

This probably happens because the raspberry is slow and the time is literally 0.0 which is falsy breaking this check.

I think that is the case because adding a tiny sleep(0.1) before reading the property fixes the issue..

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions