Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

sound sometimes breaks up



  • I am creating a QML application that plays sound by clicking "Play Sound Button".
    I use "QSoundEffect"
    and this application have function.
    function has hard work.

    I click button then do function.
    sound breaks up.

    code like this.

    MouseArea {
    onClicked: {
    QSoundEffect effect;
    effect.setSource(QUrl::fromLocalFile("engine.wav"));
    effect.setLoopCount(QSoundEffect::Infinite);
    effect.setVolume(0.25f);
    effect.play();
    }
    }
    function() {
    //hard work( TCP/IP communication)
    waitRecieveSomething()
    }

    I'd like to here clear sound.
    How should I do?

    thanks.


  • Lifetime Qt Champion

    Hi,

    Shouldn't that "hard working" function be moved in its own thread to avoid blocking the main thread and likely the sound effect ?



  • Thanks for reply!
    I think you are right. but it's so difficult.
    Because this application so big and it has many "hard work".

    I'd like to keep sound in "hard work".
    it's impossible?


  • Moderators

    @nishiokas
    Why don't you move your SoundEffects in its own thread instead?


Log in to reply