Merge ~lihow731/plainbox-provider-checkbox/+git/plainbox-provider-checkbox:master into plainbox-provider-checkbox:master

Proposed by Leon Liao
Status: Merged
Approved by: Sylvain Pineau
Approved revision: eaf611e91a68bd3ad4c09f181e17a5088f7d446f
Merged at revision: 27531c39b348727e42005344c2c252e5014c2e7a
Proposed branch: ~lihow731/plainbox-provider-checkbox/+git/plainbox-provider-checkbox:master
Merge into: plainbox-provider-checkbox:master
Diff against target: 87 lines (+7/-18)
1 file modified
bin/audio_test.py (+7/-18)
Reviewer Review Type Date Requested Status
Sylvain Pineau (community) Needs Fixing
Devices Certification Bot Needs Fixing
StanleyHuang Approve
Pierre Equoy Approve
Leon Liao (community) Needs Resubmitting
Rex Tsai Approve
Jonathan Cave (community) Approve
Review via email: mp+387916@code.launchpad.net

Commit message

Fix the "Unable to control recording volume..." bug

To post a comment you must log in.
Revision history for this message
Leon Liao (lihow731) wrote :

@Sylvain,

Could you help to view this MP?
Thank you.

Revision history for this message
Jonathan Cave (jocave) wrote :

I can't find any reference to this `self.default_method` attribute. Where does it come from?

review: Needs Information
Revision history for this message
Leon Liao (lihow731) wrote :

@Jonathan,

I correct the mistake.
Thank you.

Revision history for this message
Jonathan Cave (jocave) wrote :

LGTM

review: Approve
Revision history for this message
Rex Tsai (chihchun) wrote :

I think the fix is very wrong, it's not addressed the root cause of the issue.
Please refactor the design of _pactl_output.

review: Disapprove
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Could you link the corresponding bug to this MR please?

review: Needs Information
Revision history for this message
Leon Liao (lihow731) wrote :

@Rex,

Please review the new merge proposal.

@Sylvain,
The public bug 1890586 is linked.

review: Needs Resubmitting
Revision history for this message
Rex Tsai (chihchun) wrote :

I would prefer to see the _pactl_output can handle the failure of pactl when it can not query or change the volume from pulseuadio.

review: Needs Fixing
Revision history for this message
Rex Tsai (chihchun) wrote :

Add CE QA team as reviewer, as the QA will use this test job as well.

Revision history for this message
Leon Liao (lihow731) wrote :

The code is modified that implemented Rex's suggestion.

review: Needs Resubmitting
Revision history for this message
Rex Tsai (chihchun) :
review: Needs Fixing
Revision history for this message
Leon Liao (lihow731) wrote :

Resumbited.

review: Needs Resubmitting
Revision history for this message
Rex Tsai (chihchun) wrote :

Tested on focal and bionic, LGTM.

review: Approve
Revision history for this message
Pierre Equoy (pieq) wrote :

Thanks for fixing this!

A few comments inline (see below).

Also, regarding the commit title/message:

- Usually, the commit title includes the area that is impacted. In this case, you can prefix your commit title with `bin/audio_test.py: `
- Your commit message includes a lot of info (which is great!) but it has a few typos and I think "In get_volume() and mute(), the self.method(command) returns a zero-length string." is not correct: the `get_volume()` method does not access `self.method(command)` (I guess you meant `set_volume()`?)
- You can include `LP: #1890526` (for instance, at the very bottom of the commit message) to automatically link a merge request in Launchpad with a given Launchpad bug[1]. It's also a good thing to have in a project history.

[1] https://help.launchpad.net/Code/Git#Linking_to_bugs

review: Needs Fixing
Revision history for this message
Leon Liao (lihow731) wrote :

@Pierre,

I fixed and resubmit it.
Please review it.
Thanks again.

review: Needs Resubmitting
Revision history for this message
Leon Liao (lihow731) wrote :

About this line: self.logger.error("Unable to control recording volume. "

Original output message is:
 Unable to control recording volume.Test results may be wrong
                (There is no space ↑ )

New message:
 Unable to control recording volume. Test results may be wrong
             (There will be a space ↑ )

Revision history for this message
Pierre Equoy (pieq) wrote :

+1, thanks!

For the

self.logger.error("Unable to control recording volume. "
                               "Test results may be wrong")

line, I meant adding a period at the end of the sentence:

self.logger.error("Unable to control recording volume. "
                               "Test results may be wrong.")

But it's a nitpick. (and thanks for fixing the spae by the way :))

review: Approve
Revision history for this message
StanleyHuang (stanley31) wrote :

LGTM +1

review: Approve
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

LGTM

review: Approve
Revision history for this message
Devices Certification Bot (ce-certification-qa) wrote :

The merge was fine but running tests failed.

[xenial] [13:16:24] starting container
[bionic] [13:16:25] starting container
[focal] [13:16:25] starting container
Device project added to xenial-testing
Device project added to bionic-testing
Device project added to focal-testing
[xenial] [13:16:36] provisioning container
[bionic] [13:16:45] provisioning container
[focal] [13:16:45] provisioning container
[xenial] [13:16:48] Starting tests...
[xenial] Found a test script: ./requirements/container-tests-provider-checkbox
[bionic] [13:17:05] Starting tests...
[bionic] Found a test script: ./requirements/container-tests-provider-checkbox
[focal] [13:17:19] Starting tests...
[focal] Found a test script: ./requirements/container-tests-provider-checkbox
[xenial] [13:19:18] container-tests-provider-checkbox: FAIL
[xenial] output: https://paste.ubuntu.com/p/5CPFXWQnsh/
[xenial] [13:19:21] Fixing file permissions in source directory
[xenial] [13:19:22] Destroying container
[focal] [13:19:42] container-tests-provider-checkbox: FAIL
[focal] output: https://paste.ubuntu.com/p/D45PF8hkdZ/
[focal] [13:19:45] Fixing file permissions in source directory
[focal] [13:19:46] Destroying container
[bionic] [13:19:59] container-tests-provider-checkbox: FAIL
[bionic] output: https://paste.ubuntu.com/p/TxK4p4JJdx/
[bionic] [13:20:03] Fixing file permissions in source directory
[bionic] [13:20:03] Destroying container

review: Needs Fixing
Revision history for this message
Sylvain Pineau (sylvain-pineau) wrote :

Flake8 failed:

bin/audio_test.py:30:5: F401 'collections.Callable' imported but unused

review: Needs Fixing
Revision history for this message
Leon Liao (lihow731) wrote :

Updated the code to fix the Flake8 failed.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bin/audio_test.py b/bin/audio_test.py
index 2a56df4..4b3f89c 100755
--- a/bin/audio_test.py
+++ b/bin/audio_test.py
@@ -24,10 +24,6 @@ except ImportError:
24 print((sys.version), file=sys.stderr)24 print((sys.version), file=sys.stderr)
25 sys.exit(127)25 sys.exit(127)
2626
27try:
28 from collections.abc import Callable
29except ImportError:
30 from collections import Callable # backward compatible
3127
32# Frequency bands for FFT28# Frequency bands for FFT
33BINS = 25629BINS = 256
@@ -115,22 +111,16 @@ class PIDController(object):
115class PAVolumeController(object):111class PAVolumeController(object):
116 pa_types = {'input': 'source', 'output': 'sink'}112 pa_types = {'input': 'source', 'output': 'sink'}
117113
118 def __init__(self, type, method=None, logger=None):114 def __init__(self, type, logger=None):
119 """Initializes the volume controller.115 """Initializes the volume controller.
120116
121 Arguments:117 Arguments:
122 type: either input or output118 type: either input or output
123 method: a method that will run a command and return pulseaudio
124 information in the described format, as a single string with
125 line breaks (to be processed with str.splitlines())
126119
127 """120 """
128 self.type = type121 self.type = type
129 self._volume = None122 self._volume = None
130 self.identifier = None123 self.identifier = None
131 self.method = method
132 if not isinstance(method, Callable):
133 self.method = self._pactl_output
134 self.logger = logger124 self.logger = logger
135125
136 def set_volume(self, volume):126 def set_volume(self, volume):
@@ -142,8 +132,7 @@ class PAVolumeController(object):
142 'set-%s-volume' % (self.pa_types[self.type]),132 'set-%s-volume' % (self.pa_types[self.type]),
143 str(self.identifier[0]),133 str(self.identifier[0]),
144 str(int(volume)) + "%"]134 str(int(volume)) + "%"]
145 if not self.method(command):135 self._pactl_output(command)
146 return False
147 self._volume = volume136 self._volume = volume
148 return True137 return True
149138
@@ -160,8 +149,7 @@ class PAVolumeController(object):
160 'set-%s-mute' % (self.pa_types[self.type]),149 'set-%s-mute' % (self.pa_types[self.type]),
161 str(self.identifier[0]),150 str(self.identifier[0]),
162 mute]151 mute]
163 if not self.method(command):152 self._pactl_output(command)
164 return False
165 return True153 return True
166154
167 def get_identifier(self):155 def get_identifier(self):
@@ -192,7 +180,7 @@ class PAVolumeController(object):
192 # <ID>\t<NAME>\t<MODULE>\t<SAMPLE_SPEC_WITH_SPACES>\t<STATE>180 # <ID>\t<NAME>\t<MODULE>\t<SAMPLE_SPEC_WITH_SPACES>\t<STATE>
193 # What we need to return is the ID for the first element on this list181 # What we need to return is the ID for the first element on this list
194 # that does not contain auto_null or monitor.182 # that does not contain auto_null or monitor.
195 pa_info = self.method(command)183 pa_info = self._pactl_output(command)
196 valid_elements = None184 valid_elements = None
197185
198 if pa_info:186 if pa_info:
@@ -221,7 +209,8 @@ class PAVolumeController(object):
221 universal_newlines=True)209 universal_newlines=True)
222 except (subprocess.CalledProcessError):210 except (subprocess.CalledProcessError):
223 time.sleep(5)211 time.sleep(5)
224 return False212 self.logger.error("Fail to execute: {}".format(command))
213 sys.exit(1)
225214
226215
227class FileDumper(object):216class FileDumper(object):
@@ -369,7 +358,7 @@ class GStreamerMessageHandler(object):
369 # we can't control it :(358 # we can't control it :(
370 current_volume = volume_controller.get_volume()359 current_volume = volume_controller.get_volume()
371 if current_volume is None:360 if current_volume is None:
372 self.logger.error("Unable to control recording volume."361 self.logger.error("Unable to control recording volume. "
373 "Test results may be wrong")362 "Test results may be wrong")
374 return363 return
375 self.current_level = level364 self.current_level = level

Subscribers

People subscribed via source and target branches