Skip to content

Commit

Permalink
tplgtool2: adjust print order and alignment of PCM attributes
Browse files Browse the repository at this point in the history
print_pcm_info() will show pcm ID before its name.

Also adjust alignment:
- id: 2 characters, right alignment.
- name: left alignment to the longest PCM name.
- type (playback/capture/duplex): 8 characters, left alignment.
- rate: 6 characters, right alignment, for highest rate '192000'.

Strings longer than the alignment won't be cut.

Signed-off-by: Mengdong Lin <[email protected]>
  • Loading branch information
mengdonglin authored and Chao Song committed Sep 19, 2023
1 parent 70558b1 commit bbae502
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/tplgtool2.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,10 @@ def is_dynamic_pipeline(self, pipeline_id: str):
def print_pcm_info(self):
r"""Print pcm info, like::
pcm=Speaker;id=2;type=playback;rate_min=48000;rate_max=48000;ch_min=2;ch_max=2;fmts=S16_LE S32_LE
pcm_id=2;name=Speaker;type=playback;rate_min=48000;rate_max=48000;ch_min=2;ch_max=2;fmts=S16_LE S32_LE
"""
max_name_len=max(len(pcm["pcm_name"]) for pcm in self.pcm_list)

for pcm in self.pcm_list:
name = pcm["pcm_name"]
pcm_id = pcm["pcm_id"]
Expand All @@ -734,8 +736,8 @@ def print_pcm_info(self):
rate_max = cap["rate_max"]
ch_min = cap["channels_min"]
ch_max = cap["channels_max"]
print(f"pcm={name};id={pcm_id};type={pcm_type};"
f"rate_min={rate_min};rate_max={rate_max};ch_min={ch_min};ch_max={ch_max};"
print(f"pcm_id={pcm_id:>2};name={name.ljust(max_name_len, ' ')};type={pcm_type:<8};"
f"rate_min={rate_min:>6};rate_max={rate_max:>6};ch_min={ch_min};ch_max={ch_max};"
f"fmts={fmts}")

@cached_property
Expand Down

0 comments on commit bbae502

Please sign in to comment.