Uploaded image for project: 'Qt for Python'
  1. Qt for Python
  2. PYSIDE-1983

Crash to desktop when using Custom QIODevice with QAudioSource

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • Not Evaluated
    • None
    • 6.3.1
    • PySide
    • None
    • Windows 11
    • Windows

    Description

      When using a custom device class inherited from QIODevice to capture raw PCM audio to, it captures a few frames then crashes to desktop with no error message. Doing the same thing in C++ works fine. The line that causes the crash is "audio_source.start(device)"

      The test code is:

      import sys from pathlib
      import Path from PySide6.QtCore
      import QIODevice from PySide6.QtMultimedia
      import QAudioSource, QAudioFormat from PySide6.QtGui
      import QGuiApplication from PySide6.QtQml
      import QQmlApplicationEngine from PySide6.QtQuickControls2
      import QQuickStyle
      
      class AudioCaptureDevice(QIODevice):
          def __init__(self) -> None:
              super().__init__()
          def readData(self, len) -> int:
              return len
          def writeData(self, data, len) -> int: 
              print(f"Received: {len} bytes")
              return len
      
      if __name__ == "__main__":
          app = QGuiApplication()
          QQuickStyle.setStyle("Material")
          engine = QQmlApplicationEngine()
      
          device = AudioCaptureDevice()
          device.open(QIODevice.WriteOnly)
          format = QAudioFormat()
          format.setSampleRate(16000)
          format.setChannelCount(1)
          format.setSampleFormat(QAudioFormat.Int16)
          audio_source = QAudioSource(format)
          audio_source.start(device)
      
          qml_file = Path(__file__).parent / "view.qml"
          engine.load(qml_file)
          if not engine.rootObjects():
              sys.exit(-1)
          sys.exit(app.exec())
      

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              crmaurei Cristian Maureira-Fredes
              sjpritchard Stephen Pritchard
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes