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. QT audioinput example program, QAudioInput, AudioInfo, difference between emit(update) and connect-SLOT-SIGNAL(activated)

QT audioinput example program, QAudioInput, AudioInfo, difference between emit(update) and connect-SLOT-SIGNAL(activated)

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.9k 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
    btrwo
    wrote on last edited by
    #1

    Hi

    In my audio input-output program (based on QT multimedia example "audioinput" and "audiooutput") I'm trying to stop the audioinput data flow, resulting in run time problem. When using the orginal QT "audioinput" program I got same run time problem.

    Here is some code snippets from orginal QT "audioinput" with only 3 added lines, comments.

    In deviceChanged() there are two stops. The stops are working well in deviceChanged().

    If using the stops inside refreshDisplay(), ie. use first buffer/m_level from writeData() then stop the m_audioInfo and m_audioInput, via emit update(), problem arise.

    If only enabling "Adding 1" in code you got a lot of "QAudioInput: IOError" in QT Output.
    If only enabling "Adding 2" in code you got "QAudioInput: failed to prepare block 0,err=5" in QT Output.
    If only enabling "Adding 3" in code the audioinput data flow is actually suspended. But i want having it stopped of other reason.

    Have I missed something? Why can't you enable m_audioInfo->stop() and/or m_audioInput->stop() in refreshDisplay()?
    Why will m_audioInput->suspend() work?

    What is the major difference of signal [emit(update)] and emit signal from [connect-m_devicebox-SIGNAL(activated)-SLOT]?

    Thank You
    /Stefan

    @
    qint64 AudioInfo::writeData(const char *data, qint64 len)
    {
    ...
    ...
    maxValue = qMin(maxValue, m_maxAmplitude);
    m_level = qreal(maxValue) / m_maxAmplitude;
    }
    emit update();
    return len;
    }
    ...
    connect(m_audioInfo, SIGNAL(update()), SLOT(refreshDisplay()));
    connect(m_deviceBox, SIGNAL(activated(int)), SLOT(deviceChanged(int)));
    ...
    void InputTest::refreshDisplay()
    {
    m_canvas->setLevel(m_audioInfo->level());
    m_canvas->repaint();

    //m_audioInfo->stop();// Added 1
    //m_audioInput->stop(); // Added 2
    //m_audioInput->suspend(); // Added 3
    

    }

    void InputTest::deviceChanged(int index)
    {
    m_audioInfo->stop(); // Used here
    m_audioInput->stop(); // Used here
    m_audioInput->disconnect(this);
    delete m_audioInput;

    m_device = m_deviceBox->itemData(index).value<QAudioDeviceInfo>();
    createAudioInput();
    

    }@

    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