神秘的XF86AudioPlay问题

Lobsters Hottest 新闻

摘要

一篇博客文章,详细描述了在Emacs中调试重复出现的XF86AudioPlay按键事件,最终通过libinput和evtest追踪到头戴式耳机设备驱动的问题。

<p><a href="https://lobste.rs/s/tbizqg/mysterious_xf86audioplay_issue">评论</a></p>
查看原文
查看缓存全文

缓存时间: 2026/05/22 22:38

# mikas 博客 » 博文存档 来源:https://michael-prokop.at/blog/2026/05/20/the-mysterious-xf86audioplay-issue/ 我遇到 Emacs 的状态栏每 2-3 秒显示“is undefined”。除此之外没有任何异常或问题,也找不到相关的日志记录。它一直不停出现,但我不想为了验证重启能否修复而重启系统,这个问题快把我逼疯了。于是作为起点,我调整了 sway 配置,让它响应 XF86AudioPlay 按键事件: ``` bindsym XF86AudioPlay exec playerctl play-pause ``` 重新加载 sway 后,我的音乐播放器开始播放 2-3 秒,然后停止,接着又开始播放,如此循环。这并不是 Emacs 的 bug,确实是有什么东西每隔 2-3 秒发送了 XF86AudioPlay 按键事件。也不是我的 USB 键盘或某个按键卡住了,因为我拔掉键盘后问题依旧。所以是哪个设备在搞鬼呢? 来自 `libinput-tools`(https://packages.debian.org/search?keywords=libinput-tools)的 `libinput` 救了场: ``` % sudo libinput debug-events [...] -event12 KEYBOARD_KEY +0.000s KEY_PLAYPAUSE (164) pressed event12 KEYBOARD_KEY +0.000s KEY_PLAYPAUSE (164) released event12 KEYBOARD_KEY +2.887s KEY_PLAYPAUSE (164) pressed event12 KEYBOARD_KEY +2.887s KEY_PLAYPAUSE (164) released event12 KEYBOARD_KEY +5.773s KEY_PLAYPAUSE (164) pressed event12 KEYBOARD_KEY +5.774s KEY_PLAYPAUSE (164) released [...] ``` `event12` 设备在发送这个事件,它到底是个啥? ``` % sudo udevadm info /dev/input/event12 P: /devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0/input17/event12 M: event12 R: 12 J: c13:76 U: input D: c 13:76 N: input/event12 L: 0 S: input/by-path/pci-0000:00:1f.3-platform-skl_hda_dsp_generic-event E: DEVPATH=/devices/pci0000:00/0000:00:1f.3/skl_hda_dsp_generic/sound/card0/input17/event12 E: DEVNAME=/dev/input/event12 E: MAJOR=13 E: MINOR=76 E: SUBSYSTEM=input E: USEC_INITIALIZED=12468722 E: ID_INPUT=1 E: ID_INPUT_KEY=1 E: ID_INPUT_SWITCH=1 E: ID_PATH=pci-0000:00:1f.3-platform-skl_hda_dsp_generic E: ID_PATH_TAG=pci-0000_00_1f_3-platform-skl_hda_dsp_generic E: XKBMODEL=pc105 E: XKBLAYOUT=us E: XKBOPTIONS=lv3:ralt_switch,compose:rctrl E: BACKSPACE=guess E: LIBINPUT_DEVICE_GROUP=0/0/0:ALSA E: DEVLINKS=/dev/input/by-path/pci-0000:00:1f.3-platform-skl_hda_dsp_generic-event E: TAGS=:power-switch: E: CURRENT_TAGS=:power-switch: % sudo udevadm info -a /dev/input/event12 | grep -iE 'kernels|drivers|name' KERNELS=="input17" DRIVERS=="" ATTRS{name}=="sof-hda-dsp Headphone" KERNELS=="card0" DRIVERS=="" KERNELS=="skl_hda_dsp_generic" DRIVERS=="skl_hda_dsp_generic" KERNELS=="0000:00:1f.3" DRIVERS=="sof-audio-pci-intel-tgl" KERNELS=="pci0000:00" DRIVERS=="" ``` 这个 `event12` 背后是 `sof-hda-dsp Headphone`,而 `evtest`(https://packages.debian.org/search?keywords=evtest)也证实了这一点: ``` % sudo evtest No device specified, trying to scan all of /dev/input/event* Available devices: /dev/input/event0: AT Translated Set 2 keyboard /dev/input/event1: Sleep Button /dev/input/event10: ThinkPad Extra Buttons /dev/input/event11: sof-hda-dsp Mic /dev/input/event12: sof-hda-dsp Headphone /dev/input/event13: sof-hda-dsp HDMI/DP,pcm=3 /dev/input/event14: sof-hda-dsp HDMI/DP,pcm=4 /dev/input/event15: sof-hda-dsp HDMI/DP,pcm=5 /dev/input/event16: Yubico YubiKey OTP+FIDO+CCID /dev/input/event17: Apple Inc. Magic Keyboard with Numeric Keypad /dev/input/event18: Apple Inc. Magic Keyboard with Numeric Keypad [...] Select the device event number [0-24]: ^C ``` 我们甚至能获取更多信息: ``` % sudo evtest /dev/input/event12 Input driver version is 1.0.1 Input device ID: bus 0x0 vendor 0x0 product 0x0 version 0x0 Input device name: "sof-hda-dsp Headphone" Supported events: Event type 0 (EV_SYN) Event type 1 (EV_KEY) Event code 114 (KEY_VOLUMEDOWN) Event code 115 (KEY_VOLUMEUP) Event code 164 (KEY_PLAYPAUSE) Event code 582 (KEY_VOICECOMMAND) Event type 5 (EV_SW) Event code 2 (SW_HEADPHONE_INSERT) state 0 Properties: Testing ... (interrupt to exit) Event: time 1779295060.175766, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 1 Event: time 1779295060.175766, -------------- SYN_REPORT ------------ Event: time 1779295061.951168, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295061.951168, -------------- SYN_REPORT ------------ Event: time 1779295061.951194, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295061.951194, -------------- SYN_REPORT ------------ Event: time 1779295064.548671, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295064.548671, -------------- SYN_REPORT ------------ Event: time 1779295064.548689, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295064.548689, -------------- SYN_REPORT ------------ Event: time 1779295067.437172, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295067.437172, -------------- SYN_REPORT ------------ Event: time 1779295067.437187, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295067.437187, -------------- SYN_REPORT ------------ Event: time 1779295070.323775, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295070.323775, -------------- SYN_REPORT ------------ Event: time 1779295070.323790, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295070.323790, -------------- SYN_REPORT ------------ Event: time 1779295073.200350, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295073.200350, -------------- SYN_REPORT ------------ Event: time 1779295073.200373, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295073.200373, -------------- SYN_REPORT ------------ Event: time 1779295076.076228, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295076.076228, -------------- SYN_REPORT ------------ Event: time 1779295076.076250, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295076.076250, -------------- SYN_REPORT ------------ Event: time 1779295078.961740, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295078.961740, -------------- SYN_REPORT ------------ Event: time 1779295078.961754, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295078.961754, -------------- SYN_REPORT ------------ Event: time 1779295081.850156, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 1 Event: time 1779295081.850156, -------------- SYN_REPORT ------------ Event: time 1779295081.850175, type 1 (EV_KEY), code 164 (KEY_PLAYPAUSE), value 0 Event: time 1779295081.850175, -------------- SYN_REPORT ------------ Event: time 1779295083.306612, type 5 (EV_SW), code 2 (SW_HEADPHONE_INSERT), value 0 Event: time 1779295083.306612, -------------- SYN_REPORT ------------ ``` 因此,当我插入耳机时(参见 `SW_HEADPHONE_INSERT` 事件),异常行为开始出现;拔掉耳机问题就消失了。太好了!但完全出乎我意料的是:我的耳机是 Beyerdynamic DT-990 Pro,**并没有任何按键**。8-) 结果发现,耳机插孔似乎不太干净。插头的**模拟**侧触发了音频编解码器中的某种行为,它把波动的阻抗误判为耳机的播放按钮被反复按下。我清洁了耳机插头,XF86AudioPlay 的问题就消失了,结案。 本文由 mika(https://michael-prokop.at/)于 2026 年 5 月 20 日星期三 19:19 发布,归类于 Computer(https://michael-prokop.at/blog/category/computer/)、Debian(https://michael-prokop.at/blog/category/debian/)、English(https://michael-prokop.at/blog/category/english/)、Hardware(https://michael-prokop.at/blog/category/hardware/)。你可以通过 RSS 2.0(https://michael-prokop.at/blog/2026/05/20/the-mysterious-xf86audioplay-issue/feed/)订阅本文的回复。评论和引用于此时均已关闭。

相似文章

@jedisct1: epoll UAF

X AI KOLs Timeline

对 Linux 内核 epoll 子系统中的一个释放后使用(UAF)漏洞的详细分析,该漏洞通过切换到 RCU 修复,以及作者在现代设备上尝试利用该漏洞失败的经过。

机械键盘声音 – The Listening Museum

Hacker News Top

The Listening Museum 是一个基于网页的互动策展项目,包含36种机械键盘和轴体的声音映射,用户可以通过点击键盘和自行输入来聆听不同配置和录音条件下的音频样本。它更像是一个教育资源而非购买指南,强调录音方式如何影响感知到的键盘声音。

用户更改键盘布局时程序挂起的问题

The Old New Thing (Raymond Chen)

一个调试故事,讲述了当用户更改键盘布局(例如使用 Win+Space 快捷键)时,Windows 程序挂起的原因,是由于一个后台线程创建了窗口但没有泵送消息。修复方法是要么泵送消息,要么销毁窗口。