USB sound card loudspeaker audio output real-time detection method and device

CN122952253APending Publication Date: 2026-10-20BEIJING ICPC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611103176.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-23
Publication Date
2026-10-20

AI Technical Summary

Technical Problem

调用原生事件接口获取二进制原始音频报文;

Benefits of technology

[0011]本发明实施例提供的技术方案包括以下有益效果:1.检测零误判:依托 USB 底层硬件指纹永久绑定目标声卡,双层原生字段过滤彻底屏蔽板载声卡、HDMI、USB 麦克风干扰,仅目标声卡播放才触发“有声音”判定;2.算力大幅降低:前置双层过滤直接丢弃70% 以上无关音频报文,避免全量文本遍历匹配,适配低算力嵌入式工控设备;3.免人工运维:基于内核总线硬件识别不受上层Sink编号动态变化影响,热插拔自动更新匹配基准,无需修改程序配置;4.功能可拓展:同步采集 USB 端口、采样率等硬件参数,支持设备运维、故障上报拓展;5.系统兼容性强:完全适配现有Linux系统,兼容全品类USB外置音频输出声卡;6.逻辑低耦合:整套监测架构仅绑定目标 USB 硬件,可独立启停不与其他音频设备监测逻辑耦合。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure FT_1
    Figure FT_1
  • Figure FT_2
    Figure FT_2
  • Figure FT_3
    Figure FT_3
Patent Text Reader

Abstract

This application provides a method and apparatus for real-time detection of audio output from a USB sound card speaker. The method includes: generating a USB hardware fingerprint based on the original bus message; generating a mapping table between the USB hardware fingerprint and the sink number; retaining the USB audio output device entries in the mapping table to obtain a filtering benchmark; calling the native event interface to obtain the binary original audio message; generating a structured event tuple based on the binary original audio message; obtaining valid tuple information by checking the field status and whether the filtered structured event tuple exists in the filtering benchmark; caching the valid tuple information; using hierarchical judgment rules to judge the valid tuple information to determine whether audio output exists, and setting a global persistent state flag; pushing the result when the current judgment differs from the previous judgment. This application relies on the USB underlying hardware fingerprint to permanently bind to the target sound card, completely filtering and shielding interference; hot-plugging automatically updates the matching benchmark without modifying program configuration.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of audio recognition and processing technology, and in particular to a method and apparatus for real-time detection of audio output from a USB sound card speaker. Background Technology

[0002] Currently, industrial control terminals and embedded intelligent devices commonly run on the Linux operating system. The industry mainstream uses PulseAudio audio service to uniformly manage audio data streams, and various external USB sound cards are widely used as general-purpose audio output peripherals. During device operation, business systems need to determine in real time whether the USB sound card's accompanying speaker is outputting audio, in order to complete logic such as audio playback status reporting and business linkage. Conventional audio status detection relies on the global event subscription interface provided by the audio service. This interface pushes playback, volume change, and device plug-in / plug-out events generated by all audio devices within the system in real time, which is the common technical foundation in the current embedded audio monitoring field.

[0003] In related technologies, for USB sound card speaker output status monitoring scenarios, existing general monitoring solutions directly call the global event subscription interface without targeted filtering logic. The program continuously receives and parses all audio events. This solution does not have a binding and matching design for a single USB sound card, resulting in a large amount of overhead from parsing irrelevant events. At the same time, it cannot accurately distinguish the playback stream of the target USB sound card itself, which is prone to status misjudgment and cannot meet the business requirements of monitoring speaker output independently for USB sound cards.

[0004] Based on the above analysis, it can be seen that existing USB sound card audio monitoring solutions generally suffer from three major underlying shortcomings: 1. Relying solely on the temporary sink number of the PulseAudio upper layer to bind the device, the number randomly drifts after the USB sound card is plugged in or unplugged, causing the monitoring logic to fail and requiring manual configuration modification; 2. Using full-text keyword fuzzy matching for audio logs without parsing the underlying raw messages, the onboard sound card, HDMI virtual audio, and USB microphone are prone to status misjudgments. At the same time, global full parsing generates a large amount of invalid calculations, consuming the embedded device's CPU; 3. Simply determining whether audio is playing cannot simultaneously collect the underlying hardware parameters of the USB sound card, resulting in a lack of device maintenance data.

[0005] Based on the above analysis of the development status of this technology field, the existing technologies lack solutions that can automatically adapt to hot-plugging of USB sound cards, accurately filter non-target device events based on the underlying raw messages, and simultaneously collect hardware parameters for targeted real-time monitoring. Summary of the Invention

[0006] The purpose of this invention is to provide a method and apparatus for real-time detection of audio output from a USB sound card speaker, in order to solve the aforementioned problems in the prior art.

[0007] According to a first aspect of the present invention, a method for real-time detection of audio output from a USB sound card speaker is provided, comprising: A USB hardware fingerprint is generated based on the original bus message. A mapping table between the USB hardware fingerprint and the sink number is generated. The USB audio output device entries in the mapping table are retained to obtain the filtering benchmark. Call the native event interface to obtain the binary raw audio message; Structured event tuples are generated based on binary raw audio messages. Valid tuple information is obtained by filtering structured event tuples by checking field status and whether they exist in the filtering benchmark, and then cached. A hierarchical judgment rule is used to judge the valid tuple information to determine whether there is audio output, and a global persistent state flag is set. When the judgment in this round is different from the judgment in the previous round, the result is pushed.

[0008] According to a second aspect of the present invention, a real-time detection device for USB sound card speaker audio output is provided, comprising: The benchmark generation module is used to generate USB hardware fingerprints based on the original bus messages, generate a mapping table between USB hardware fingerprints and sink numbers, retain the USB audio output device entries in the mapping table, and obtain the filtering benchmark. The audio message acquisition module is used to call the native event interface to obtain the binary raw audio message; The structured event parsing module is used to generate structured event tuples based on binary raw audio messages, filter structured event tuples by field status and whether they exist in the filtering benchmark, obtain valid tuple information, and cache valid tuple information; The audio output judgment module uses a hierarchical judgment rule to judge the valid tuple information, determine whether there is audio output, and set a global persistent state flag. When the judgment in this round is different from the judgment in the previous round, the result is pushed.

[0009] According to a third aspect of the present invention, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the real-time detection method for USB sound card speaker audio output as provided in the first aspect of the present disclosure.

[0010] According to a fourth aspect of the present invention, a computer-readable storage medium is provided, on which an information transmission implementation program is stored, which, when executed by a processor, implements the steps of the real-time detection method for USB sound card speaker audio output provided in the first aspect of the present disclosure.

[0011] The technical solution provided by this invention includes the following beneficial effects: 1. Zero false positives: Relying on the USB underlying hardware fingerprint to permanently bind the target sound card, the dual-layer native field filtering completely blocks interference from the onboard sound card, HDMI, and USB microphone, and only the target sound card plays to trigger the "sound is present" judgment; 2. Significantly reduced computing power: The front-end dual-layer filtering directly discards more than 70% of irrelevant audio packets, avoiding full text traversal matching, and adapting to low-computing-power embedded industrial control equipment; 3. No manual maintenance required: Based on kernel bus hardware identification, it is not affected by the dynamic changes of the upper-layer Sink number, and hot-plugging automatically updates the matching benchmark without modifying the program configuration; 4. Expandable functions: Synchronously collects hardware parameters such as USB port and sampling rate, supporting device maintenance and fault reporting expansion; 5. Strong system compatibility: Fully adapts to existing Linux systems and is compatible with all types of USB external audio output sound cards; 6. Low logical coupling: The entire monitoring architecture is only bound to the target USB hardware and can be started and stopped independently without being coupled with the monitoring logic of other audio devices.

[0012] It should be understood that the above general description and the following detailed description are exemplary and explanatory only, and are not intended to limit this disclosure. Attached Figure Description

[0013] To more clearly illustrate the technical solutions in one or more embodiments of this specification or in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 This is a flowchart of a real-time detection method for USB sound card speaker audio output according to an embodiment of the present invention; Figure 2 This is a schematic diagram of a USB sound card speaker audio output real-time detection device according to an embodiment of the present invention; Figure 3 This is a schematic diagram of an electronic device according to an embodiment of the present invention. Detailed Implementation

[0015] To enable those skilled in the art to better understand the technical solutions in one or more embodiments of this specification, the technical solutions in one or more embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this specification, and not all of the embodiments. Based on one or more embodiments of this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of this document.

[0016] Method Implementation Examples According to an embodiment of the present invention, a method for real-time detection of audio output from a USB sound card speaker is provided. Figure 1 This is a flowchart of a real-time detection method for USB sound card speaker audio output according to an embodiment of the present invention, such as... Figure 1 As shown, the real-time detection method for USB sound card speaker audio output according to an embodiment of the present invention specifically includes: In step S110, a USB hardware fingerprint is generated based on the original bus message, a mapping table between the USB hardware fingerprint and the sink number is generated, and the USB audio output device entries in the mapping table are retained to obtain the filtering benchmark, specifically including: Create a netlink socket to subscribe to the kernel SUBSYSTEM=usb subsystem uevent raw message, filter USBAudio Class output devices, perform preliminary filtering of USB Audio Class according to the protocol, and filter keyboard and mouse, storage, microphone, and HDMI virtual devices to obtain the initial devices; The four-element inherent hardware information corresponding to the initial device is filtered from the original bus message. The four-element inherent hardware information includes the manufacturer VID, product PID, physical bus port, and device unique hardware serial number. The four-element inherent hardware information is hashed to generate a USB hardware fingerprint. The underlying native interface of PulseAudio is called to traverse all audio sinks, parse the kernel DEVPATH device path corresponding to each audio sink, obtain the USB hardware fingerprint that matches the kernel DEVPATH device path, and generate a mapping table by mapping the USB hardware fingerprint to the sink number, which can realize a bidirectional persistent mapping mechanism.

[0017] Only the USB audio output device mapping entries are retained as the sole basis for subsequent audio event filtering. The hardware entity in the USB device is further identified as the one in which the function occurs. The USB sound card speaker device is locked through dual filtering to avoid any omissions.

[0018] In step S120, the native event interface is called to obtain the binary raw audio message, specifically including: In this embodiment of the invention, the system-encapsulated text log is not read. Instead, the underlying D-Bus native event interface of PulseAudio is directly called to obtain the unsimplified binary raw audio message. The original fields of the message, such as ACTION action type, SINK destination number, STREAM playback stream number, and underlying device bus path, are retained to provide complete underlying data for structured parsing.

[0019] In step S130, a structured event tuple is generated based on the binary raw audio message. Valid tuple information is obtained by checking the field status and whether the filtered structured event tuple exists in the filtering benchmark. The valid tuple information is then cached. Specifically, this includes: The binary raw message fields are split, and the ACTION action type, SINK sink number and STREAM playback stream number are extracted independently from the binary raw audio message to generate structured event tuples; The first layer of filtering is performed by verifying the ACTION action type, retaining structured event tuples with valid states of ACTION action type three: new stream, change stream, and remove stream; and directly discarding interference packets with no business meaning such as volume adjustment, cache refresh, and device enumeration. A second layer of filtering is performed by comparing the SINK sink number with the sink number in the filtering benchmark, retaining structured event tuples with consistent numbers; only events matching the target USB sound card proceed to the next step, while other packets are discarded and not included in the judgment.

[0020] After the first and second layers of filtering, the valid tuple information is obtained and stored.

[0021] Preferably, the number of currently active playback streams from the USB sound card can be stored in real time.

[0022] In step S140, a hierarchical judgment rule is used to judge the valid tuple information to determine whether there is audio output, and a global persistent state flag is set. When the judgment in this round is different from the judgment in the previous round, the result is pushed. Specifically, this includes: Complete sound card hardware information is synchronously captured from the USB bus cache and structured tuples as sound card information, namely, the USB hardware fingerprint, USB physical port, number of audio channels, supported resolution and number of STREAM playback streams are obtained as sound card information. First-level rule: If the ACTION action type is new stream or change stream, and the number of STREAM playback streams is greater than 0, then the USB sound card speaker has audio output; Second-level rule: If the ACTION action type is stream destruction (remove), or the STREAM playback stream count is equal to 0, then the USB sound card speaker will not output audio. In the domain of determining whether audio output exists, the general situation is covered by the above-mentioned hierarchical judgment rules. If it does not belong to all the conditions in the hierarchical judgment rules, it may be an abnormal or invalid event. After double-layer filtering, it is highly unlikely that an abnormality or invalidity will occur. In the rare cases that may occur, preferably, the classification result can be output by a minimal finite state machine or a lightweight model.

[0023] The number of STREAM playback streams is event-driven, referring to the incremental snapshot carried in a single message, while the number of valid playback streams is state-driven, referring to the real-time inventory continuously maintained by the system. It has stronger real-time performance and can be updated and counted in real time through a local counter. Therefore, in this embodiment of the invention, the judgment can also be based on the number of valid playback streams; preferably, the first new event can be used as the activation point to start the statistics.

[0024] The setting result is a combination of sound card information and audio output status.

[0025] Set a global persistent state flag, and only output a combination of USB hardware information and audio output status when the current judgment is inconsistent with the previous one, so as to avoid repeatedly pushing the same data.

[0026] The method further includes: In step S150, a dual-threaded parallel monitoring event update is created: The first thread periodically traverses the underlying sink list of PulseAudio to detect the addition or removal of audio devices, while the second thread listens for raw bus messages for hot-plugging USB uevent in the kernel. When an event update is detected, the mapping table and structured event tuples are regenerated.

[0027] In other words, once a message is captured indicating that the USB sound card has been unplugged and reconnected, the system automatically re-collects the hardware quadruple, generates a new hardware fingerprint, updates the mapping table, and synchronously updates the event filtering benchmark. No manual modification of any configuration is required throughout the entire process, and the system continuously monitors the target USB sound card.

[0028] In this embodiment of the invention, all functional modules can be started and stopped individually.

[0029] The overall construction approach of this invention can be summarized as follows: A complete detection architecture is constructed, consisting of USB kernel hardware fingerprint mapping, layered parsing of underlying raw audio packets, and dual-threaded hot-plug adaptive detection. A unique hardware fingerprint is generated by subscribing to the USB bus uevent via netlink, extracting the VID / PID / port / serial number quadruple, and establishing a permanent binding mapping with the PulseAudio underlying sink. Unencapsulated binary raw audio packets are directly subscribed to, and native fields are split for double-layer filtering. USB sound card hardware parameters are captured synchronously, and speaker output status is determined only for the target sound card playback stream.

[0030] In summary, addressing the existing problems, this invention provides a real-time detection method for USB sound card speaker audio output, achieving the following: 1. Zero false positives: Utilizing a permanent hardware fingerprint of the USB interface to bind to the target sound card, dual-layer native field filtering completely blocks interference from the onboard sound card, HDMI, and USB microphone; only playback from the target sound card triggers a "sound present" detection. 2. Significantly reduced computing power: The front-end dual-layer filtering discards over 70% of irrelevant audio packets, avoiding full text traversal matching, making it suitable for low-computing-power embedded industrial control equipment. 3. No manual maintenance required: Based on kernel bus hardware identification, it is unaffected by dynamic changes in the upper-layer sink number; hot-plugging automatically updates the matching benchmark, requiring no program configuration modifications. 4. Expandable functionality: Synchronously collects hardware parameters such as USB port and sampling rate, supporting device maintenance and fault reporting expansion. 5. Strong system compatibility: Fully compatible with existing Linux systems and compatible with all types of USB external audio output sound cards. 6. Low logical coupling: The entire monitoring architecture is bound only to the target USB hardware and can be independently started and stopped without coupling with other audio device monitoring logic.

[0031] Device Examples According to an embodiment of the present invention, a real-time detection device for USB sound card speaker audio output is provided. Figure 2 This is a schematic diagram of a real-time audio output detection device for a USB sound card speaker according to an embodiment of the present invention, as shown below. Figure 2 As shown, the real-time audio output detection device for a USB sound card speaker according to an embodiment of the present invention specifically includes: The benchmark generation module 20 is used to generate a USB hardware fingerprint based on the original bus message, generate a mapping table between the USB hardware fingerprint and the sink number, retain the USB audio output device entries in the mapping table, and obtain the filtering benchmark, specifically for: Create a netlink socket to subscribe to the kernel SUBSYSTEM=usb subsystem uevent raw packets, filter USBAudio Class output devices and filter keyboard, mouse, storage, microphone, and HDMI virtual devices to obtain the initial device; The four-element inherent hardware information corresponding to the initial device is filtered from the original bus message. The four-element inherent hardware information includes the manufacturer VID, product PID, physical bus port, and device unique hardware serial number. The four-element inherent hardware information is hashed to generate a USB hardware fingerprint. The underlying native interface of PulseAudio is called to traverse all audio sinks, parse the kernel DEVPATH device path corresponding to each audio sink, obtain the USB hardware fingerprint that matches the kernel DEVPATH device path, and generate a mapping table between the USB hardware fingerprint and the sink number.

[0032] The audio message acquisition module 22 is used to call the native event interface to obtain the binary raw audio message. Specifically, it is used to call the PulseAudio underlying D-Bus native event interface to obtain the unsimplified binary raw audio message.

[0033] The structured event parsing module 24 is used to generate structured event tuples based on the binary raw audio message, filter structured event tuples by field status and whether they exist in the filtering benchmark, obtain valid tuple information, and cache the valid tuple information. Specifically, it is used for: Extract the ACTION action type, SINK sink number, and STREAM playback stream count from the binary raw audio message to generate a structured event tuple; The first layer of filtering is performed by verifying the ACTION action type, retaining structured event tuples with valid ACTION action types of three states: new stream, change stream, and remove stream. The second layer of filtering is performed by comparing the SINK sink number with the Sink number in the filtering benchmark, retaining structured event tuples with consistent numbers. After the first and second layers of filtering, valid tuple information is obtained.

[0034] The audio output judgment module 26 uses a hierarchical judgment rule to judge the valid tuple information, determine whether audio output exists, and set a global persistent state flag. When the judgment in this round is different from the judgment in the previous round, the result is pushed. Specifically, it is used for: Obtain USB hardware fingerprint, USB physical port, number of audio channels, supported resolution, and number of STREAM playback streams as sound card information; If the ACTION action type is "new" or "change", and the number of streams played by the STREAM is greater than 0, then the USB sound card speaker will have audio output; if the ACTION action type is "remove", or the number of streams played by the STREAM is equal to 0, then the USB sound card speaker will not have audio output. The setting result is a combination of sound card information and audio output status.

[0035] The device further includes: Real-time update module 28 is used to create a dual-threaded parallel monitoring system for event updates. The first thread periodically traverses the underlying sink list of PulseAudio to detect the addition or removal of audio devices, while the second thread listens for raw bus messages for hot-plugging USB uevent in the kernel. When an event update is detected, the mapping table and structured event tuples are regenerated.

[0036] In summary, addressing the existing problems, this invention provides a real-time detection device for USB sound card speaker audio output, achieving the following: 1. Zero false positives: Utilizing a permanent hardware fingerprint of the USB interface to bind to the target sound card, dual-layer native field filtering completely blocks interference from the onboard sound card, HDMI, and USB microphone; only playback from the target sound card triggers a "sound output" determination. 2. Significantly reduced computing power: The front-end dual-layer filtering discards over 70% of irrelevant audio packets, avoiding full text traversal matching, making it suitable for low-computing-power embedded industrial control equipment. 3. No manual maintenance required: Based on kernel bus hardware identification, it is unaffected by dynamic changes in the upper-layer sink number; hot-plugging automatically updates the matching benchmark, requiring no program configuration modifications. 4. Expandable functionality: Synchronously collects hardware parameters such as USB port and sampling rate, supporting device maintenance and fault reporting expansion. 5. Strong system compatibility: Fully compatible with existing Linux systems and compatible with all types of USB external audio output sound cards. 6. Low-coupling logic: The entire monitoring architecture is bound only to the target USB hardware and can be independently started and stopped without coupling with other audio device monitoring logic.

[0037] Electronic device examples Figure 3 This is a schematic diagram of an electronic device according to an embodiment of the present invention. The electronic device 300 may include at least one processor 310 and a memory 320. The processor 310 can execute instructions stored in the memory 320. The processor 310 is communicatively connected to the memory 320 via a data bus. In addition to the memory 320, the processor 310 can also be communicatively connected to an input device 330, an output device 340, and a communication device 350 via the data bus.

[0038] Processor 310 can be any conventional processor, such as a commercially available CPU. Processors may also include graphics processing units (GPUs), field-programmable gate arrays (FPGAs), systems-on-chips (SoCs), application-specific integrated circuits (ASICs), or combinations thereof.

[0039] The memory 320 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0040] In this embodiment of the present disclosure, the memory 320 stores executable instructions, and the processor 310 can read the executable instructions from the memory 320 and execute the instructions to implement all or part of the steps of the real-time detection method for USB sound card speaker audio output in any of the above exemplary embodiments.

[0041] Computer-readable storage medium embodiments In addition to the methods and apparatus described above, exemplary embodiments of this disclosure may also be a computer program product or a computer-readable storage medium storing the computer program product, wherein the computer program product includes computer program instructions that can be executed by a processor to implement all or part of the steps described in the real-time detection method for USB sound card speaker audio output of any of the exemplary embodiments described above.

[0042] Computer program products can be written in any combination of one or more programming languages ​​to perform the operations of the embodiments of this application. Programming languages ​​include object-oriented programming languages ​​such as Java and C++, as well as conventional procedural programming languages ​​such as C or similar languages, and scripting languages ​​(e.g., Python). The program code can be executed entirely on the user's computing device, partially on the user's device, as a standalone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server.

[0043] Computer-readable storage media may be any combination of one or more readable media. A readable medium may be a readable signal medium or a readable storage medium. A readable storage medium may be, for example,, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of readable storage media include: static random access memory (SRAM) having one or more electrically connected wires; electrically erasable programmable read-only memory (EEPROM); erasable programmable read-only memory (EPROM); programmable read-only memory (PROM); read-only memory (ROM); magnetic storage; flash memory; magnetic disk or optical disk; or any suitable combination thereof.

[0044] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for real-time detection of audio output from a USB sound card speaker, characterized in that, include: A USB hardware fingerprint is generated based on the original bus message. A mapping table between the USB hardware fingerprint and the sink number is generated. The USB audio output device entries in the mapping table are retained to obtain the filtering benchmark. Call the native event interface to obtain the binary raw audio message; A structured event tuple is generated based on the binary raw audio message. The structured event tuple is filtered by field status and whether it exists in the filtering benchmark to obtain valid tuple information. The valid tuple information is then cached. The effective tuple information is judged using a hierarchical judgment rule to determine whether there is audio output, and a global persistent state flag is set. When the judgment in this round is different from the judgment in the previous round, the result is pushed.

2. The method according to claim 1, characterized in that, The method further includes: Create a dual-threaded parallel monitoring system for event updates: The first thread periodically traverses the PulseAudio underlying sink list to detect the addition or removal of audio devices, while the second thread listens for raw bus messages for hot-plugging USB uevents in the kernel. When an event update is detected, the mapping table and the structured event tuple are regenerated.

3. The method according to claim 1, characterized in that, The process of generating a USB hardware fingerprint based on the original bus message, and generating a mapping table between the USB hardware fingerprint and the Sink number, specifically includes: Create a netlink socket to subscribe to the kernel SUBSYSTEM=usb subsystem uevent raw packets, filter USBAudioClass output devices and filter keyboard, mouse, storage, microphone, and HDMI virtual devices to obtain the initial device; The four-element inherent hardware information corresponding to the initial device is filtered from the original bus message. The four-element inherent hardware information includes the manufacturer VID, product PID, physical bus port, and device unique hardware serial number. A hash operation is performed on the four-element inherent hardware information to generate a USB hardware fingerprint. The underlying native interface of PulseAudio is called to traverse all audio sinks, parse the kernel DEVPATH device path corresponding to each audio sink, obtain the USB hardware fingerprint that matches the kernel DEVPATH device path, and generate the mapping table by associating the USB hardware fingerprint with the sink number.

4. The method according to claim 1, characterized in that, The specific steps of calling the native event interface to obtain the raw binary audio message include: calling the underlying D-Bus native event interface of PulseAudio to obtain the unsimplified raw binary audio message.

5. The method according to claim 1, characterized in that, The process of generating structured event tuples based on the binary raw audio message, and filtering the structured event tuples by field status and whether they exist in the filtering benchmark to obtain valid tuple information specifically includes: Extract the ACTION action type, SINK sink number, and STREAM playback stream count from the binary raw audio message to generate the structured event tuple; The first layer of filtering is performed by verifying the ACTION action type, retaining structured event tuples with valid states of ACTION action type: new stream, change stream, and remove stream; the second layer of filtering is performed by comparing the SINK sink number with the Sink number in the filtering benchmark, retaining structured event tuples with consistent numbers. After the first layer of filtering and the second layer of filtering, the effective tuple information is obtained.

6. The method according to claim 5, characterized in that, The step of using a hierarchical judgment rule to judge the valid tuple information and determine whether there is audio output specifically includes: Obtain USB hardware fingerprint, USB physical port, number of audio channels, supported resolution, and number of STREAM playback streams as sound card information; If the ACTION action type is "new" or "change", and the number of STREAM playback streams is greater than 0, then the USB sound card speaker will have audio output; if the ACTION action type is "remove", or the number of STREAM playback streams is equal to 0, then the USB sound card speaker will not have audio output. The setting result is a combination of the sound card information and the audio output status.

7. A real-time detection device for USB sound card speaker audio output, characterized in that, include: The benchmark generation module is used to generate a USB hardware fingerprint based on the original bus message, generate a mapping table between the USB hardware fingerprint and the sink number, retain the USB audio output device entries in the mapping table, and obtain the filtering benchmark. The audio message acquisition module is used to call the native event interface to obtain the binary raw audio message; The structured event parsing module is used to generate structured event tuples based on the binary raw audio message, filter the structured event tuples by field status and whether they exist in the filtering benchmark, obtain valid tuple information, and cache the valid tuple information. The audio output judgment module uses a hierarchical judgment rule to judge the valid tuple information to determine whether there is audio output, and sets a global persistent state flag. When the judgment in this round is different from the judgment in the previous round, the result is pushed.

8. The apparatus according to claim 7, characterized in that, The device further includes: The real-time update module is used to create a dual-threaded parallel monitoring system for event updates. The first thread periodically traverses the PulseAudio underlying sink list to detect the addition or removal of audio devices, while the second thread listens for raw bus messages for hot-plugging USB uevents in the kernel. When an event update is detected, the mapping table and the structured event tuple are regenerated.

9. An electronic device, characterized in that, include: The memory, the processor, and the computer program stored in the memory and executable on the processor, wherein the computer program, when executed by the processor, implements the steps of the real-time detection method for USB sound card speaker audio output as described in any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores an information transmission implementation program, which, when executed by a processor, implements the steps of the real-time detection method for USB sound card speaker audio output as described in any one of claims 1 to 6.