神秘的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/)订阅本文的回复。评论和引用于此时均已关闭。

相似文章

模拟器调试:Area 5150 的 Lake Effect

Lobsters Hottest

本文详细介绍了在MartyPC模拟器上调试Area5150演示中“Lake”效应的过程,解释了需要特定标题hack的原因,以及通过总线嗅探和动态时钟实现周期精确CGA模拟的后续修复方法。