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
1diff --git a/bin/audio_test.py b/bin/audio_test.py
2index 2a56df4..4b3f89c 100755
3--- a/bin/audio_test.py
4+++ b/bin/audio_test.py
5@@ -24,10 +24,6 @@ except ImportError:
6 print((sys.version), file=sys.stderr)
7 sys.exit(127)
8
9-try:
10- from collections.abc import Callable
11-except ImportError:
12- from collections import Callable # backward compatible
13
14 # Frequency bands for FFT
15 BINS = 256
16@@ -115,22 +111,16 @@ class PIDController(object):
17 class PAVolumeController(object):
18 pa_types = {'input': 'source', 'output': 'sink'}
19
20- def __init__(self, type, method=None, logger=None):
21+ def __init__(self, type, logger=None):
22 """Initializes the volume controller.
23
24 Arguments:
25 type: either input or output
26- method: a method that will run a command and return pulseaudio
27- information in the described format, as a single string with
28- line breaks (to be processed with str.splitlines())
29
30 """
31 self.type = type
32 self._volume = None
33 self.identifier = None
34- self.method = method
35- if not isinstance(method, Callable):
36- self.method = self._pactl_output
37 self.logger = logger
38
39 def set_volume(self, volume):
40@@ -142,8 +132,7 @@ class PAVolumeController(object):
41 'set-%s-volume' % (self.pa_types[self.type]),
42 str(self.identifier[0]),
43 str(int(volume)) + "%"]
44- if not self.method(command):
45- return False
46+ self._pactl_output(command)
47 self._volume = volume
48 return True
49
50@@ -160,8 +149,7 @@ class PAVolumeController(object):
51 'set-%s-mute' % (self.pa_types[self.type]),
52 str(self.identifier[0]),
53 mute]
54- if not self.method(command):
55- return False
56+ self._pactl_output(command)
57 return True
58
59 def get_identifier(self):
60@@ -192,7 +180,7 @@ class PAVolumeController(object):
61 # <ID>\t<NAME>\t<MODULE>\t<SAMPLE_SPEC_WITH_SPACES>\t<STATE>
62 # What we need to return is the ID for the first element on this list
63 # that does not contain auto_null or monitor.
64- pa_info = self.method(command)
65+ pa_info = self._pactl_output(command)
66 valid_elements = None
67
68 if pa_info:
69@@ -221,7 +209,8 @@ class PAVolumeController(object):
70 universal_newlines=True)
71 except (subprocess.CalledProcessError):
72 time.sleep(5)
73- return False
74+ self.logger.error("Fail to execute: {}".format(command))
75+ sys.exit(1)
76
77
78 class FileDumper(object):
79@@ -369,7 +358,7 @@ class GStreamerMessageHandler(object):
80 # we can't control it :(
81 current_volume = volume_controller.get_volume()
82 if current_volume is None:
83- self.logger.error("Unable to control recording volume."
84+ self.logger.error("Unable to control recording volume. "
85 "Test results may be wrong")
86 return
87 self.current_level = level

Subscribers

People subscribed via source and target branches