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. QAudioInput Device State Change
Forum Updated to NodeBB v4.3 + New Features

QAudioInput Device State Change

Scheduled Pinned Locked Moved Unsolved General and Desktop
qaudioinputqiodevicestate changesaudio device
1 Posts 1 Posters 446 Views
  • 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.
  • R Offline
    R Offline
    rtavakko
    wrote on 9 Oct 2019, 20:41 last edited by
    #1

    Hey guys,

    I've hit a bit of a roadblock with the QAudioInput class trying to figure how to handle state changes. This is certainly platform-specific but I'm trying to figure out a way to make some changes to my QAudioInput device pointer if the actual audio device is disabled.

    In windows 10, under input devices, you can enable or disable a device (let's say the Stereo Mix / sound card input). If I understand the documentation correctly, I should be able to use the stateChanged signal to make changes:

    https://doc.qt.io/qt-5/qaudioinput.html

    void AudioInputExample::handleStateChanged(QAudio::State newState)
    {
        switch (newState) {
            case QAudio::StoppedState:
                if (audio->error() != QAudio::NoError) {
                    // Error handling
                } else {
                    // Finished recording
                }
                break;
    
            case QAudio::ActiveState:
                // Started recording - read from IO device
                break;
    
            default:
                // ... other cases as appropriate
                break;
        }
    }
    

    So far when I disable the device I get this error:

    QAudioInput: failed to prepare block 0,err=6

    And there seems to be no way of deleting the QAudioInput object handling the device and recreating it since I never know when it's gone caput.

    I also tried messing around with QIODevice's aboutToClose() signal but that object is also the strong silent type...

    Anyone have experience doing this sort of thing on Windows or their own OS? Any thought would be appreciated.

    Thanks a bunch!

    1 Reply Last reply
    0

    1/1

    9 Oct 2019, 20:41

    • Login

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