Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-83776

Audio of running app is muted when requesting QAudioDeviceInfo

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.1
    • 5.12.4
    • Multimedia
    • None
    • iOS/tvOS/watchOS
    • b5a55492a63cb2cda75d6f980acb7fc5ae8dfc22 (qt/qtmultimedia/dev) 956fbd3f352f8bba5b8bf985b1787fc7b71aff24 (qt/qtmultimedia/5.15)

    Description

      When I launch an empty Qt app while music is playing on my iOS device, the music continues to play in backgronud

      However, when I add the the following line to main.cpp, the music stops playing after starting the ap

       

      QAudioDeviceInfo m_deviceInfo = QAudioDEviceInfo::defaultInputDevice();

      I think this is because the default iOS AVAudioSession is used (as I found here https://code.woboq.org/qt5/qtmultimedia/src/plugins/coreaudio/coreaudiosessionmanager.mm.html)

      The default AVAudioSession has the following behavior (from https://developer.apple.com/documentation/avfoundation/avaudiosession)

      • When the app plays audio, it silences any other background audio.
      • In iOS, locking a device silences the app’s audio.

      The first item is what we observe in this issue (the second item implies that we can't run our app in background, not even when setting UIBackgroundMode to audio)

      Possible solution (not tested): configure the AVAudioSession by adding lines like

        [session setCategory:AVAudioSessionPlayAndRecord withOptions:AVAudioSessionCategoryOptionMixWithOthers error:nil]

        [session overrideOutputAudioPort:AVAudioSessionPortOverrideSpeaker error:nil]

       

      Attachments

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

        Activity

          People

            valentyn.doroshchuk Valentyn Doroshchuk
            vdaele vdaele
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes