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

QMediaDevices can't be accessed from an Android Service

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • P2: Important
    • None
    • 6.4.1
    • Multimedia
    • None
    • Developing on Linux Mint 20.2
    • Android
    • 2023wk06FOQtforAndroid, 2023wk10FOQtforAndroid

    Description

      I have a "Hello World" QML application with a dummy Android service and the following main.cpp.  The number of audio inputs is printed fine for the application but for the service part, the call to QMediaDevices::audioInputs seems to hang.

      Is this a bug?
      If so, is there a work-around to access the QAudioSource?

       

      int main(int argc, char *argv[])
      {
          if (argc > 1) {
              QAndroidService app(argc, argv);
              qInfo() << "Audio: Service: Number of inputs(1)";
              QList<QAudioDevice> audio = QMediaDevices::audioInputs();
              int n = audio.length();
              qInfo() << "Audio: Service: Number of inputs(2)";
              qInfo() << "Audio: Service: Number of inputs " << n << "#";
      
              return app.exec();
          } else {
              QGuiApplication app(argc, argv);
              QQmlApplicationEngine engine;
              const QUrl url(u"qrc:/testQt6/main.qml"_qs);
              QObject::connect(&engine, &QQmlApplicationEngine::objectCreated,
                               &app, [url](QObject *obj, const QUrl &objUrl) {
                  if (!obj && url == objUrl)
                      QCoreApplication::exit(-1);
              }, Qt::QueuedConnection);
              engine.load(url);
      
              QJniObject::callStaticMethod<void>(
                  "org/qtproject/example/QtAndroidService",
                  "startQtAndroidService",
                  "(Landroid/content/Context;)V",
                  QNativeInterface::QAndroidApplication::context());
      
              qInfo() << "Audio: App: Number of inputs(1)";
              QList<QAudioDevice> audio = QMediaDevices::audioInputs();
              int n = audio.length();
              qInfo() << "Audio: App: Number of inputs(2)";
              qInfo() << "Audio: App: Number of inputs " << n << "#";
      
              return app.exec();
          }
      }
      
      
       
      

      Attachments

        Issue Links

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

          Activity

            People

              bartlomiejmoskal Bartlomiej Moskal
              vdaele vdaele
              Votes:
              1 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes