Volume obtained is 100% in multimedia sink for sounds from app

Bug #1485522 reported by Xavi Garcia
114
This bug affects 32 people
Affects Status Importance Assigned to Milestone
Canonical System Image
Fix Released
Critical
Pat McGowan
pulseaudio (Ubuntu)
Invalid
Undecided
Unassigned
qtmultimedia-opensource-src (Ubuntu)
Fix Released
Undecided
Timo Jyrinki
qtmultimedia-opensource-src (Ubuntu RTM)
Fix Released
Undecided
Timo Jyrinki
qtubuntu-media (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

I'm not sure 100% this is a bug but it is related to https://bugs.launchpad.net/canonical-devices-system-image/+bug/1478506

When the "Marron in trouble" games launches a sound the multimedia sink it's updated and when reading the volume it's always 100%.

I'ts not 100% for other applications using the multimedia role, like the music app or other games/apps. The volume in that case is in sync with the volume that was previously set for it.

This is the code from the indicator-sound where we get the 100% volume.

var props_variant = yield _pconn.call ("org.PulseAudio.Ext.StreamRestore1.RestoreEntry",
      sink_input_objp, "org.freedesktop.DBus.Properties", "Get",
      new Variant ("(ss)", "org.PulseAudio.Ext.StreamRestore1.RestoreEntry", "Volume"),
      null, DBusCallFlags.NONE, -1);
    Variant tmp;
    props_variant.get ("(v)", out tmp);
    uint32 type = 0, volume = 0;
    VariantIter iter = tmp.iterator ();
    iter.next ("(uu)", &type, &volume);

I did a workaround branch in the indicator-sound that reads the volume at initilaization for every role and stores any change When the sink is updated I read the volume in it that is already stored instead of reading the volume from pulse.

I'm not convinced of that, and would like to know why I get 100% volume only for this particular game.

Tags: volume
Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

Note:
As commented here: https://bugs.launchpad.net/canonical-devices-system-image/+bug/1478506/comments/11 and I've observed in other apps the problem seems to be in the QML component for playing sounds.

Revision history for this message
Matthew Paul Thomas (mpt) wrote :

In bug 1478506 I had already identified this problem as bug 1418210. This looks like a duplicate to me.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in pulseaudio (Ubuntu):
status: New → Confirmed
Changed in canonical-devices-system-image:
assignee: nobody → John McAleely (john.mcaleely)
Revision history for this message
David Henningsson (diwic) wrote :

I've researched why the "Dinosaur" game always have sound effects at 100% volume.

Starting with the pa_stream_connect_playback API, the documentation says:

"It is strongly recommended to pass NULL in both dev and volume and to set neither PA_STREAM_START_MUTED nor PA_STREAM_START_UNMUTED – unless these options are directly dependent on user input or configuration. If you follow this rule then the sound server will have the full flexibility to choose the device, volume and mute status automatically, based on server-side policies, heuristics and stored information from previous uses. "

Yet, in QPulseAudioOutput::open ( package: qtmultimedia-opensource-src, file: src/plugins/pulseaudio/qaudiooutput_pulse.cpp ), the volume is always set, despite PA recommending otherwise. In addition, the QPulseAudioOutput constructor defaults the volume to 1.0 (maximum).

I think the QPulseAudioOutput component should default to not set the volume at all, i e, leaving "NULL" as the volume in the call to pa_stream_connect_playback.

Revision history for this message
David Henningsson (diwic) wrote :

Actually, this seems to already be fixed... https://github.com/qtproject/qtmultimedia/commit/5f33d7bea3fd3dd441aff499576826a02e8e5be2 ...which is in 5.4.1, so should be on touch too. So forget about the previous comment; that said, I do see a message in PulseAudio saying that the stream volume is explicitly changed, so it's somewhere up the stack...

Revision history for this message
David Henningsson (diwic) wrote :

Hmm, in src/multimedia/audio/qsoundeffect_qaudio_p.cpp - PrivateSoundSource::sampleReady() seems to always call

m_audioOutput->setVolume(m_volume); - with m_volume defaulting to 1.0...maybe that could be the cause of error here?

Revision history for this message
David Henningsson (diwic) wrote :

Okay, some more research done today, and I also talked to Juho @ Jolla/Sailfish about it, because they would probably suffer from the same problem.

It's somewhat of a misdesign or broken thinking, I believe. In short, Qt allows the app to set the volume of its sounds. This is an important feature; it allows e g, if you have two sound effects, for them to be at different volumes. Then it opens two streams and set the stream volume accordingly.

Ubuntu phone / PulseAudio however comes from the other direction and sets stream volume based on role. The problem comes when the app then overrides this volume.
I believe we need to multiply both volumes somehow instead of just letting the app override it.

Changed in canonical-devices-system-image:
importance: Undecided → High
status: New → Confirmed
milestone: none → backlog
Revision history for this message
John McAleely (john.mcaleely) wrote :

@pmcgowan I've added qtubuntu as a task, but maybe there is a better proxy for QT?

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in qtubuntu (Ubuntu):
status: New → Confirmed
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

This is blocking silo 51 and several fixes including for bug #1382548, can it get additional attention near term?

Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

@timo think we can pass this by the folks at Qt?

Changed in canonical-devices-system-image:
assignee: John McAleely (john.mcaleely) → Pat McGowan (pat-mcgowan)
Changed in qtbase-opensource-src (Ubuntu):
assignee: nobody → Timo Jyrinki (timo-jyrinki)
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

affects: qtbase-opensource-src (Ubuntu) → qtmultimedia-opensource-src (Ubuntu)
Changed in qtmultimedia-opensource-src (Ubuntu):
status: New → Confirmed
affects: qtubuntu (Ubuntu) → qtubuntu-media (Ubuntu)
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

I've contacted upstream if they have anything to possibly improve on their side. Xenial now has Qt 5.5, but I don't see any pulseaudio changes in 5.6 or dev either so I doubt the behavior is different there.

On our side, the likely components are qtubuntu-media and media-hub.

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in qtmultimedia-opensource-src (Ubuntu):
status: New → Confirmed
Changed in canonical-devices-system-image:
importance: High → Critical
milestone: backlog → ww08-2016
tags: added: volume
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

No reply from our upstream contact, e-mail was sent on Dec 16th.

Revision history for this message
Yoann Lopes (yoann-lopes) wrote :

You can find more information about this problem in Qt at https://bugreports.qt.io/browse/QTBUG-36511
This was about QMediaPlayer, but the problem still exists for QAudioOutput and QSoundEffect.

A possible fix in Qt would be to check if the sink has flat volumes enabled and if it does, do software-based attenuation (in Qt).
That way, QSoundEffect and QAudioOutput volumes would always be relative to the stream role's volume.

Revision history for this message
Yoann Lopes (yoann-lopes) wrote :
Revision history for this message
Pat McGowan (pat-mcgowan) wrote :

@timo seems the patch was recently merged upstream at least to staging

Changed in canonical-devices-system-image:
status: Confirmed → In Progress
Changed in canonical-devices-system-image:
milestone: ww08-2016 → 11
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

Silo 010 has now the fix from upstream included. It needed some rebasing to apply to 5.4 and 5.5, but nothing seemed worrying.

Could you test the silo on vivid+overlay? (also xenial is included in the PPA)

Revision history for this message
Xavi Garcia (xavi-garcia-mena) wrote :

I've tested this adding some debug statements to the sound indicator to see if the incoming volumes are changing from Pulse.

Now the Qml game (I've tested with Maroon in trouble) is not changing the volume, so the issue seems to be fixed! :)

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

I tested eg Machines vs Machines successfully.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

It seems both the duplicate bug #1478506 (volume control increasing from 0) and this (volume always at 100) go away with the bug fix.

There is a remaining perceived bug of any sound playing app's volume being controlled only if the app is playing something at the time of volume control. If that's not the case, ringtone volume is controlled instead.

Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

(the remaining problem being documented in bug #1498466)

Revision history for this message
Łukasz Zemczak (sil2100) wrote :

This bug was fixed in the package qtmultimedia-opensource-src 5.4.1-1ubuntu19~overlay4 in https://launchpad.net/~ci-train-ppa-service/+archive/ubuntu/stable-phone-overlay

---------------

qtmultimedia-opensource-src (5.4.1-1ubuntu19~overlay4) vivid; urgency=medium

  * debian/patches/PulseAudio-change-the-way-volume-is-applied.patch:
    - Backport from 5.6, change Pulseaudio volume control (LP: #1485522)

 -- Timo Jyrinki <email address hidden> Wed, 13 Apr 2016 10:43:58 +0000

Changed in qtmultimedia-opensource-src (Ubuntu RTM):
status: New → Fix Released
Revision history for this message
Timo Jyrinki (timo-jyrinki) wrote :

I believe there is nothing to fix in pulseaudio or qtubuntu-media for now, but please correct if I'm wrong.

Changed in qtubuntu-media (Ubuntu):
status: Confirmed → Invalid
Changed in pulseaudio (Ubuntu):
status: Confirmed → Invalid
Changed in qtmultimedia-opensource-src (Ubuntu RTM):
assignee: nobody → Timo Jyrinki (timo-jyrinki)
Changed in qtmultimedia-opensource-src (Ubuntu):
status: Confirmed → Fix Committed
Changed in canonical-devices-system-image:
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package qtmultimedia-opensource-src - 5.5.1-4ubuntu3

---------------
qtmultimedia-opensource-src (5.5.1-4ubuntu3) xenial; urgency=medium

  * debian/patches/PulseAudio-change-the-way-volume-is-applied.patch:
    - Backport from 5.6, change Pulseaudio volume control (LP: #1485522)

 -- Timo Jyrinki <email address hidden> Wed, 13 Apr 2016 10:41:46 +0000

Changed in qtmultimedia-opensource-src (Ubuntu):
status: Fix Committed → Fix Released
Changed in canonical-devices-system-image:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.