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. Why can't I open my default audio input?
Forum Updated to NodeBB v4.3 + New Features

Why can't I open my default audio input?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 567 Views 2 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.
  • C Offline
    C Offline
    CodeCat
    wrote on 3 Jun 2022, 04:59 last edited by
    #1

    Using Qt 5.15 on Windows 10 Pro, this code

    const auto deviceInfos = QAudioDeviceInfo::availableDevices(QAudio::AudioInput);
    for (const QAudioDeviceInfo &deviceInfo : deviceInfos)
    qDebug() << "Device name: " << deviceInfo.deviceName();
    qDebug()<< "Default audio input is " << QAudioDeviceInfo::defaultInputDevice().deviceName();
    QAudioFormat format;
    format.setCodec("audio/pcm");
    format.setChannelCount(2);
    format.setSampleRate(44100);
    format.setSampleType(QAudioFormat::SignedInt);
    format.setSampleSize(16);
    format.setByteOrder(QAudioFormat::LittleEndian);
    QAudioDeviceInfo info(QAudioDeviceInfo::defaultInputDevice());
    if (info.isFormatSupported(format))
    qDebug() << "Format IS supported";
    else
    qDebug() << "Format is NOT supported";
    QAudioInput *audio = new QAudioInput(format, this);
    Q_ASSERT(audio);

    produces
    Device name: "Line In (Realtek(R) Audio)"
    Default audio input is "Default Input Device"
    Format IS supported

    but when I add
    QIODevice *dev = audio->start();

    it produces
    avcore\audiocore\client\audioclient\audioclientcore.cpp(1501)\AUDIOSES.DLL!00...
    QAudioInput: failed to open audio device

    Am I doing something wrong?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 3 Jun 2022, 18:56 last edited by
      #2

      Hi and welcome to devnet,

      Might be a silly question but do you have any other application that might be using it ?

      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
      • C Offline
        C Offline
        CodeCat
        wrote on 4 Jun 2022, 03:32 last edited by
        #3

        Ha! I didn't find anyone else using it, but I did find that my privacy settings were set to not allow access by desktop apps. After I changed that, my Qt code was able to open the audio input.

        Thanks for the tip!

        1 Reply Last reply
        2

        1/3

        3 Jun 2022, 04:59

        • Login

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