Get sound from jack with QMediaPlayer or omxplayer system calls?
-
Goodmorning,
I've downloaded meta-boot2qt and built for Raspberrypi3.
I'm trying to get audio from raspberry jack output.
At the current state I can play songs from terminal with "omxplayer -o local music.mp3" getting sound from jack, on the other side with commands like "omxplayer -o alsa " or omxplayer -o hdmi", I get audio from hdmi.
I succeded to play music with QMediaPlayer (both in c++ or qml), but I'm not able to get it from jack.
Below the code used in c++:QList<QAudioDeviceInfo> devices = QAudioDeviceInfo::availableDevices(QAudio::AudioOutput); foreach (QAudioDeviceInfo i, devices){ qDebug()<<i.deviceName()<<endl; } QMediaPlayer *playMusicObj = new QMediaPlayer(); playMusicObj->setMedia(QUrl::fromLocalFile("/home/davide/music.mp3")); QMediaService *svc = playMusicObj->service(); if (svc != nullptr) { QAudioOutputSelectorControl *out = qobject_cast<QAudioOutputSelectorControl *> (svc->requestControl(QAudioOutputSelectorControl_iid)); if (out != nullptr) { out->setActiveOutput(devices.at(0).deviceName()); svc->releaseControl(out); } } playMusicObj->setVolume(1); playMusicObj->play();
Whatever devicesName I use, the audio always comes from hdmi.
I also tested the example multimedia-> audioutput among the qt example code, but the result is the same, the audio always come from hdmi.I wonder if omxplayer is the only solution as they did in the following link:
http://www.raspberry-projects.com/pi/programming-in-c/audio/playing-audioI'd prefer to stay with QMediaPlayer because it offers much more possibilities than system calls.
Can you help me?Than you for the attention
-
Found the solution for I2S, maybe it can work for jack output here:
https://forum.qt.io/topic/117721/getting-sound-from-jack-with-alsa-instead-of-pulseaudio/2 -
Hi!!
Did you solve your problem?
I also met same problem. If you solved it, please share your solutions.Thanks,
-
Hi @davidino, @Kernel-KIM
Did you solve your problem?
I also met same problem.
I use debian stretch and Qt 5.11. Even after setting up all possible flags on rpi3, I can't get the sound out from the jack in my Qt app. Command line tests play sound through jack....AND : If I boot without HDMI cable, sound goes out from jack, even after pluging it into rasp and displaying qt app.
Thanks !
-
Hello @Kernel-KIM and @etiennedm ,
no, I haven't solved the problem. In my opinion the only solution that could work is extracting the I2S signal from HDMI, and get the sound from it.
After all, the raspberry cape use this approach.Regards,
Davidino -
Found the solution for I2S, maybe it can work for jack output here:
https://forum.qt.io/topic/117721/getting-sound-from-jack-with-alsa-instead-of-pulseaudio/2