On Mon, Dec 23, 2019 at 06:33:47PM +0900, Takashi Sakamoto wrote:
At present, when an element has callback function for TLV information, TLV read operation returns EPERM if the element is locked. On the other hand, the read operation is success when an element has allocated array for TLV information. In both cases, read operation is success for element value expectedly.
You can regenerate the issue by executing below Python 3 scripts: (Installation of alsa-gobject[1], PyGObject[2] and amixer(1) in alsa-utils is required.)
After element is locked, amixer reports EPERM for any read operation of TLV information.
``` #########after locked######### numid=28,iface=PCM,name='Playback Channel Map' ; type=INTEGER,access=r---lR--,values=6,min=0,max=36,step=0 : values=0,0,0,0,0,0 amixer: Control hw:1 element TLV read error: Operation not permitted ```
======== 8< -------- #!/usr/bin/env python3
from sys import argv,exit import subprocess
import gi gi.require_version('ALSACtl', '0.0') from gi.repository import ALSACtl
def lock_elems(card, targets, locked): for target in targets: card.lock_elem(target, locked)
def run_amixer(label, targets): print('{:#^30}'.format(label)) args = ['amixer', '-c', str(card_id), 'cget', '(placeholder)'] for target in targets: args[4] = "iface=PCM,name='{}'".format(target.get_name()) subprocess.run(args)
if len(argv) < 2: print('One argument is required for the numerical ID of soundcard.') exit(1) card_id = int(argv[1])
card = ALSACtl.Card.new() card.open(card_id)
targets = list(filter(lambda e: e.get_name().find("Channel Map") >= 0, card.get_elem_id_list())) run_amixer('before locked', targets)
lock_elems(card, targets, True) run_amixer('after locked', targets)
lock_elems(card, targets, False) run_amixer('after released', targets)
# The lock is surely released automatically when control character device is # released. Thus it's safe to terminate the above codes in its middle. ======== 8< --------
[1] https://github.com/alsa-project/alsa-gobject/ [2] https://pygobject.readthedocs.io/en/latest/