matzrm
Posts: 21
Joined: Tue Sep 03, 2019 9:15 am

QMediaPlayer and analog audio

Fri Oct 04, 2019 8:49 am

Hi,

I read a bit of old topics on this argument, but are all without an answer.
My raspi is well configured because omxplayer audio is going out from analog, but QMediaPlayer audio not.

Some one is able to play sound with QMediaPlayer using analog audio?

Thanks all.

User avatar
DougieLawson
Posts: 36089
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: QMediaPlayer and analog audio

Fri Oct 04, 2019 8:53 am

Why aren't you using vlc or omxplayer which are the best supported audio players on Raspbian? That is likely to be easier than trying to beat some other random piece of software to death.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

matzrm
Posts: 21
Joined: Tue Sep 03, 2019 9:15 am

Re: QMediaPlayer and analog audio

Fri Oct 04, 2019 8:58 am

Because my app is written in Qt and I need to control the playback status.

User avatar
DougieLawson
Posts: 36089
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: QMediaPlayer and analog audio

Fri Oct 04, 2019 9:02 am

matzrm wrote:
Fri Oct 04, 2019 8:58 am
Because my app is written in Qt and I need to control the playback status.
There's a DBus interface to omxplayer so you can write a QT front-end for that.

https://www.raspberrypi.org/forums/view ... hp?t=84780
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

matzrm
Posts: 21
Joined: Tue Sep 03, 2019 9:15 am

Re: QMediaPlayer and analog audio

Fri Oct 04, 2019 9:08 am

Thank you,

I'm already using it to control the video files, but I don't want use it to control small (few seconds) audio file playback, I think that Qt have a nice SLOT/SIGNAL interface, that are more handy then polling with DBUS interface.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7259
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: QMediaPlayer and analog audio

Fri Oct 04, 2019 1:14 pm

omxplayer bypasses ALSA etc and goes straight to the hardware so isn't a good test of what is working.

The default ALSA driver exposes a single device that can then be switched between the analog and HDMI outputs via a control. Run "amixer controls" and it should list out

Code: Select all

[email protected]:~ $ amixer controls
numid=3,iface=MIXER,name='PCM Playback Route'
numid=2,iface=MIXER,name='PCM Playback Switch'
numid=1,iface=MIXER,name='PCM Playback Volume'
numid=5,iface=PCM,name='IEC958 Playback Con Mask'
numid=4,iface=PCM,name='IEC958 Playback Default'
numid=3 is the one you want for redirecting the audio output. 1 is analog, and 2 is HDMI, (3 is HDMI1 on Pi4).

The volume control tool in Raspbian does exactly this when you switch the output. This should redirect the default audio output.

There is an alternate way to drive the audio hardware that exposes the different audio destinations as independent ALSA devices. See https://www.raspberrypi.org/forums/view ... 4#p1526690
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

matzrm
Posts: 21
Joined: Tue Sep 03, 2019 9:15 am

Re: QMediaPlayer and analog audio

Fri Oct 04, 2019 1:26 pm

Running amixer controls I get:

Code: Select all

numid=4,iface=MIXER,name='Master Playback Switch'
numid=3,iface=MIXER,name='Master Playback Volume'
numid=2,iface=MIXER,name='Capture Switch'
numid=1,iface=MIXER,name='Capture Volume'
But I don't understand how go ahead now.

Anyway, not also omxplayer is working but also aplay play the sound on analog audio.

Running my app with GST_DEBUG enabled I can read this:

Code: Select all

0:00:12.749753481 19958   0x45dc00 WARN                   pulse pulsesink.c:615:gst_pulseringbuffer_open_device:<audiosink-actual-sink-pulse> error: Failed to connect: Connection refused
0:00:13.876769235 19958   0x45dc00 WARN                 basesrc gstbasesrc.c:3583:gst_base_src_start_complete:<source> pad not activated yet
0:00:13.877895879 19958   0x45dc00 WARN                 basesrc gstbasesrc.c:3583:gst_base_src_start_complete:<source> pad not activated yet
Inizio messaggio vocale
Cannot read omxplayer dbus
Dbus not connected!
0:00:14.300507398 19958 0xac847580 FIXME                default gstutils.c:3981:gst_pad_create_stream_id_internal:<wavparse0:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id
0:00:14.301102349 19958 0xac847580 WARN                wavparse gstwavparse.c:1660:gst_wavparse_stream_headers:<wavparse0> Ignoring chunk PEAK
0:00:14.301384232 19958 0xac847580 WARN                wavparse gstwavparse.c:1660:gst_wavparse_stream_headers:<wavparse0> Ignoring chunk id3 
0:00:14.868534907 19958 0xaa01e8f0 WARN         audio-resampler audio-resampler.c:275:convert_taps_gint32_c: can't find exact taps
0:00:14.873584619 19958   0x63cb20 WARN               audiosink gstaudiosink.c:218:audioringbuffer_thread_func:<audiosink-actual-sink-omxhdmiaudio> failed to set thread priority
0:00:14.888018604 19958   0x45dc00 FIXME                    bin gstbin.c:4338:gst_bin_query: implement duration caching in GstBin again
Can this help?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7259
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: QMediaPlayer and analog audio

Fri Oct 04, 2019 2:50 pm

What does "aplay -l" return?
You don't appear to have the default audio driver loaded based on your amixer output. Have you got some other audio device connected to the system as there is no audio capture device present on a standard Pi?
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

matzrm
Posts: 21
Joined: Tue Sep 03, 2019 9:15 am

Re: QMediaPlayer and analog audio

Mon Oct 07, 2019 6:58 am

Sorry,

I have tested some settings in config.txt that have influecend the result of 'amixer controls'. Now that I putted back the default config.txt, the result is:

Code: Select all

numid=3,iface=MIXER,name='PCM Playback Route'                                                                                                                                                  
numid=2,iface=MIXER,name='PCM Playback Switch'                                                                                                                                                 
numid=1,iface=MIXER,name='PCM Playback Volume'                                                                                                                                                 
numid=5,iface=PCM,name='IEC958 Playback Con Mask'                                                                                                                                              
numid=4,iface=PCM,name='IEC958 Playback Default'  
I have tested 'amixer cset numid=3 1' with no result

matzrm
Posts: 21
Joined: Tue Sep 03, 2019 9:15 am

Re: QMediaPlayer and analog audio

Tue Oct 08, 2019 8:23 am

any hints?

matzrm
Posts: 21
Joined: Tue Sep 03, 2019 9:15 am

Re: QMediaPlayer and analog audio

Tue Oct 08, 2019 8:50 am

After some test I understood that without pulseaudio QtMultimedia play sound always through audiosink-actual-sink-omxhdmiaudio, while if pulseaudio is running, Qt play sound with the PCM Playback Route, and amixer cset numid=3 x (1 for analog or 2 for hdmi) have the desired effect of switch audio output.

Return to “Graphics programming”