Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [solved] QAudioOutput works in example project, doesn't work in my project
Forum Updated to NodeBB v4.3 + New Features

[solved] QAudioOutput works in example project, doesn't work in my project

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 2.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    billconan
    wrote on last edited by
    #1

    hello,

    I'm facing a very weird issue. I want to add audio play to my project, so I first tried Qt's AudioOutput example. it compiles and works well. so I copied the same code to my project (same QAudioFormat):

    @
    m_format.setSampleRate(48000);
    m_format.setChannelCount(2);
    m_format.setSampleSize(16);
    m_format.setCodec("audio/pcm");
    m_format.setByteOrder(QAudioFormat::LittleEndian);
    m_format.setSampleType(QAudioFormat::SignedInt);

        QAudioDeviceInfo info(QAudioDeviceInfo::defaultOutputDevice());
        if (!info.isFormatSupported(m_format)) {
            qWarning() << "Default format not supported - trying to use nearest";
            LOG(ERROR, MISC, 0, "Default format not supported - trying to use nearest");
            m_format = info.nearestFormat(m_format);
        }
    

    @

    however, in my project, QAudioDeviceInfo::defaultOutputDevice() always return null device.

    I couldn't see any issue at all. so I copied the same code again to a completely new project's main function, and it worked.

    it just won't work in a specific project. I start to think maybe my .pro settings are wrong or something. I can't figure this out.

    [edit: Added missing coding tags @ SGaist]

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Did you compare the working project and your pro file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #3

        If you have the time, you can look up SFML
        http://www.sfml-dev.org/
        really easy to integrate with Qt and it's easier to use that all Audio classes in Qt IMO

        Good luck!


        Free Indoor Cycling Software - https://maximumtrainer.com

        1 Reply Last reply
        0
        • B Offline
          B Offline
          billconan
          wrote on last edited by
          #4

          Thank you

          Our project is quite large, it is not easy to strip it down and make it compile.

          I will debug Qt instead. I feel that it might have something to do with the lib, flags used by the project.

          [quote author="SGaist" date="1423781265"]Hi,

          Did you compare the working project and your pro file ?[/quote]

          1 Reply Last reply
          0
          • B Offline
            B Offline
            billconan
            wrote on last edited by
            #5

            will certainly try this!

            Thanks
            [quote author="maximus" date="1423782750"]If you have the time, you can look up SFML
            http://www.sfml-dev.org/
            really easy to integrate with Qt and it's easier to use that all Audio classes in Qt IMO

            Good luck![/quote]

            1 Reply Last reply
            0
            • B Offline
              B Offline
              billconan
              wrote on last edited by
              #6

              after debugging Qt, I realized that the issue is
              QFactoryLoader can't load the audio plugin for my project even the inputs I provide seem to be the same between the working case and the failed case.

              I'm still debugging QFactoryLoader to see how it works.

              1 Reply Last reply
              0
              • B Offline
                B Offline
                billconan
                wrote on last edited by
                #7

                Ok, so the root cause is in the failed case, we called:
                QCoreApplication::setLibraryPaths(QStringList(QCoreApplication::applicationDirPath()));

                before setting up audio. This path doesn't contain the default Qt plugins, so it can't find the audio plugin dll for windows.

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  Why are you making this call ?

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • B Offline
                    B Offline
                    billconan
                    wrote on last edited by
                    #9

                    this is a joint project with many people. I don't why and who added this code.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved