Nominate our 2022 Qt Champions!

More sound simultaneously with QSoundEffect and alsa

  • Hi,
    I'm working on a custom ARM board and I should get sounds working in Qt5.5. At the beginning just one sound in one time could be played uing QSoundEffect and aplay. Then I've configured /etc/asound.cfg for using alsa mixer plugin dmix and that default output for alsa should be the mixer:

    pcm.dmixed {
        type dmix
        ipc_key 1024
        ipc_key_add_uid 0
        slave.pcm "hw:0,0"
    pcm.dsnooped {
        type dsnoop
        ipc_key 1025
        slave.pcm "hw:0,0"
    pcm.duplex {
        type asym
        playback.pcm "dmixed"
        capture.pcm "dsnooped"
    pcm.!default {
        type plug
        slave.pcm "duplex"
    ctl.!default {
      type hw
      card 0

    From this time can I play more aplay, however the QT app is able to play just one sound (on desktop linux more).

    Default device name: "sysdefault:CARD=DatAudio"

    Device Name: "sysdefault:CARD=DatAudio"
    Preferred Format: "audio/pcm"
    Device Name: "default"
    Preferred Format: "audio/pcm"

    I suppose the QT is using wrong output (not default). According the strace the /etc/asound.conf is read as well as alsa plugin /usr/lib/qt/plugins/audio/ (there is no other available)

    What can I do to change the output? Is that the right way? Thanks.

  • Lifetime Qt Champion


    I think the best thing to do would be to check the Alsa plugin source to see what it's doing and maybe modify it for your purpose.

    Hope it helps.

  • Ok it was a bug in qt5/qtmultimedia/src/plugins/alsa/qalsaaudiooutput.cpp method bool QAlsaAudioOutput::open() which is fixed in QT5.7

    The old version was explicitly opening alsa device hw:0 and the 5.7 version is using the proper "default" device as specified in /etc/asound.cfg

  • Lifetime Qt Champion

    Glad you found out and thanks for sharing ! :)

    Happy hacking !

Log in to reply