A network audio transmission method and system

By utilizing interrupt processing and DMA technology in the audio processor, network audio transmission with strong real-time and high stability is realized, which solves the audio transmission delay and stability problems in traditional technology and ensures low delay and stable data. transmission.

CN118282969BActive Publication Date: 2024-09-20GUANGZHOU BAOLUN ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410368328.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-28
Publication Date
2024-09-20
Estimated Expiration
2044-03-28

AI Technical Summary

Technical Problem

Traditional Linux network audio transmission is prone to lags when task scheduling lags, and it is difficult to ensure low latency and stability, especially when using low-latency processors.

Method used

By using interrupts to process data in the audio processor, a network audio transmission method with strong real-time and high stability is realized, using DMA and interrupt mechanisms to trigger data transmission within preset time intervals, and adjusting the time of DMA acquisition interruption according to network fluctuations. interval to ensure the continuity and stability of data transmission.

Benefits of technology

Fast response and stable network audio transmission are achieved at the hardware level. Compared with software methods, the response speed is faster and the transmission is more stable. It can adapt to network fluctuations and avoid data loss and stability problems caused by too fast transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118282969B
    Figure CN118282969B
Patent Text Reader

Abstract

The present application provides a network audio transmission method and system, the method comprising: the audio processor triggers an acquisition interrupt at a preset time interval, collects audio data, triggers a data transmission interrupt, assembles the audio data into a data packet, and sends it to a second audio processor; after receiving the data packet, the second audio processor parses the data packet and stores it; in response to a play instruction, the data packet is parsed, and the continuity of the data packet in the transmission buffer is detected, and a network fluctuation signal is returned to the first audio processor; the first audio processor receives the network fluctuation signal and adjusts the time interval of the DMA acquisition interrupt. This solution uses interrupts to realize network audio transmission and adjusts the transmission rate with network fluctuations, thereby realizing the transmission of network data at the hardware level. Compared with the existing software method, it has a faster response speed and is more stable while ensuring low latency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data transmission, and in particular to a network audio transmission method and system. Background Art

[0002] The data of traditional Linux network audio transmission needs to be processed by the audio ALSA layer, network layer, and application layer before the data can be sent out. Due to the multi-layer task scheduling, when the current task scheduling is stuck, the audio transmission will also be stuck. The low-latency and real-time network audio processors on the market basically use high-performance processors. If the Linux system is used, it is difficult to ensure that the audio transmission task stack scheduling will not conflict based on the low latency of the task itself, resulting in transmission jams. Therefore, there is a need for a data transmission method that is adapted to low-latency audio processors to ensure low latency and stability of network audio transmission. Summary of the invention

[0003] In order to solve the above problems, the present invention provides a network audio transmission method and system, which has the advantages of strong real-time performance and high stability by utilizing the method of interruption processing data.

[0004] To achieve the above object, the present invention provides the following technical solutions:

[0005] A network audio transmission method is applied to an audio processor, including a first audio processor and a second audio processor, wherein the audio processor is provided with a sound card, a network card, a DMA, a receiving buffer, and a sending buffer, and the method includes:

[0006] The first audio processor and the second audio processor both trigger a DMA acquisition interrupt at a preset time interval, store the audio data in the DMA into a receiving buffer, and end the DMA acquisition interrupt;

[0007] After the first audio processor ends the DMA acquisition interrupt each time, it triggers the data transmission interrupt, assembles the audio data in the receiving buffer into a data packet, sends the data packet to the second audio processor, and ends the data transmission interrupt;

[0008] After receiving the data packet, the second audio processor parses the data packet and stores the parsed data packet into a sending buffer of the second audio processor;

[0009] The second audio processor triggers an audio playback interrupt in response to the play instruction, detects whether there is a data packet in the send buffer, and if not, ends the audio playback interrupt. If so, parses the data packet, stores the audio data in the data packet into the DMA of the second audio processor, and detects whether the data packet in the send buffer is continuous. If not, returns a network fluctuation signal to the first audio processor;

[0010] The first audio processor receives the network fluctuation signal, adjusts the time interval of the DMA acquisition interruption, and uses the adjusted time interval as the new preset time interval.

[0011] Furthermore, the first audio processor and the second audio processor are both provided with a sound card, and the calculation formula of the preset time interval is:

[0012]

[0013] Among them, T is the time interval, C is the DMA capacity, R is the number of sound card channels, B is the number of sound card bits, and S is the sampling rate of the sound card.

[0014] Furthermore, the data sending interrupt includes: detecting whether there is audio data in the receiving buffer, and ending the data sending interrupt when there is no audio data in the receiving buffer; when there is audio data in the receiving buffer, assembling the audio data in the receiving buffer into data packets, assembling the data packets into network packets, and putting the network packets into the network card sending queue, triggering the network card sending interrupt of the first audio processor.

[0015] Furthermore, the first audio processor and the second audio processor are both provided with a network card, and the network card sending interrupt comprises: the network card in the first audio processor reads the network packet according to the network card sending queue, and sends the network packet to the port of the network card of the second audio processor.

[0016] Furthermore, the network packet includes: a frame header, a data size, a packet type, a data packet count, a packet to be sent, a cyclic redundancy check code and a frame tail, and the data packet count is a number, and when the first audio processor assembles a data packet each time, the data packet count is incremented by one.

[0017] Further, in step S4, the detection of the continuity of the data packets in the sending buffer specifically includes: checking whether the data packet count in the last parsed network packet is increased by one to be the data packet count in the current network packet; if they are the same, saving the current data packet count for the next data packet count check, and ending the audio playback interruption.

[0018] Furthermore, when the data packets in the sending buffer are discontinuous, a network fluctuation signal is returned to the first audio processor. The specific implementation includes: increasing the time interval for each time the second audio processor triggers a DMA acquisition interrupt, and assembling the increased time interval into a control packet, assembling the control packet into a network packet, sending the network packet to the port of the network card of the first audio processor, and adding a network fluctuation count in the sending buffer of the second audio processor, and setting the network fluctuation count according to the increased time interval.

[0019] Further, in step S4, after detecting the continuity of the data packets in the sending buffer, it also includes: when the data packets are continuous, detecting whether there is a network fluctuation count in the sending buffer of the second audio processor, when there is a network fluctuation count, the network fluctuation count is reduced by one, and when the network fluctuation count is reduced by one and becomes zero, restoring the time interval for each DMA acquisition interrupt triggered by the second audio processor to a preset time interval, deleting the network fluctuation count, and sending a control packet assembled into a network packet to the port of the network card of the first audio processor, notifying the first audio processor to restore the time interval for triggering the DMA acquisition interrupt to the preset time interval.

[0020] Furthermore, when the port of the network card of the first audio processor receives the network packet sent by the second processor, the packet type in the received network packet is parsed. When the network packet is a control packet, the instructions in the control packet are parsed and executed to adjust the interval time for triggering the DMA acquisition interrupt.

[0021] Through the above technical scheme, the present invention realizes network audio transmission by utilizing interruptions, and sets up network fluctuation detection, and adjusts the transmission rate according to network fluctuations, thereby realizing network data transmission at the hardware level. Compared with the existing software method, it has a faster response speed and is more stable while ensuring low latency. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Figure 1 A schematic diagram of the overall process of a network audio transmission method provided in an embodiment of the present application.

[0023] Figure 2 A schematic diagram of the structure of a network audio transmission system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0024] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0025] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the present invention is further described in detail below with reference to the accompanying drawings and specific embodiments.

[0026] Example 1

[0027] See also Figure 1A network audio transmission method is applied to an audio processor, including a first audio processor and a second audio processor, wherein the audio processor is provided with a sound card, a network card, a DMA, a receiving buffer, and a sending buffer, and the method includes:

[0028] The first audio processor and the second audio processor both trigger a DMA acquisition interrupt at a preset time interval, store the audio data in the DMA into a receiving buffer, and end the DMA acquisition interrupt;

[0029] After the first audio processor ends the DMA acquisition interrupt each time, it triggers the data transmission interrupt, assembles the audio data in the receiving buffer into a data packet, sends the data packet to the second audio processor, and ends the data transmission interrupt;

[0030] After receiving the data packet, the second audio processor parses the data packet and stores the parsed data packet into a sending buffer of the second audio processor;

[0031] The second audio processor triggers an audio playback interrupt in response to the play instruction, detects whether there is a data packet in the send buffer, and if not, ends the audio playback interrupt. If so, parses the data packet, stores the audio data in the data packet into the DMA of the second audio processor, and detects whether the data packet in the send buffer is continuous. If not, returns a network fluctuation signal to the first audio processor;

[0032] The first audio processor receives the network fluctuation signal, adjusts the time interval of the DMA acquisition interruption, and uses the adjusted time interval as the new preset time interval.

[0033] An interruption means that when some unexpected situation occurs during the operation of the processor and the processor needs to intervene, the processor can automatically stop the running program and switch to the program to handle the new situation. After the processing is completed, the processor returns to the original suspended program to continue running.

[0034] Interrupts can improve operating efficiency. The operating speed of the processor is much higher than that of the peripheral devices. Interrupts can coordinate the work between them. When the peripheral device needs to exchange information with the processor, the peripheral device sends an interrupt request to the processor, and the processor responds and processes it in time. In addition, interrupts can meet real-time processing requirements. Various monitoring and control devices randomly send interrupt requests to the processor, and the processor responds and processes them at any time.

[0035] DMA stands for direct memory access, which is used to provide high-speed data transfer between peripherals and memory or between memory and memory. The device can move data from DMA without the need for processor operation. Therefore, storing data in DMA can save processor resources while facilitating data reading and writing.

[0036] In this embodiment, when receiving a play instruction, the second audio processor will store the received audio data in the DMA according to the play address of the DMA, and the playback device will read the audio data in the DMA according to the play address of the DMA and play it.

[0037] The receiving buffer and the sending buffer are buffers with a first-in-first-out structure. Since the response speed of the processor is higher than that of other devices, the above buffers are set up to temporarily store the sent and received data. When the processor needs to read these data, it will read them from the buffer.

[0038] In an optional embodiment, the first audio processor and the second audio processor are both provided with a sound card, and the calculation formula of the preset time interval is:

[0039]

[0040] Among them, T is the time interval, C is the DMA capacity, R is the number of sound card channels, B is the number of sound card bits, and S is the sampling rate of the sound card.

[0041] In an optional embodiment, the data sending interrupt includes: detecting whether there is audio data in the receiving buffer, and ending the data sending interrupt when there is no audio data in the receiving buffer; when there is audio data in the receiving buffer, assembling the audio data in the receiving buffer into data packets, assembling the data packets into network packets, and putting the network packets into the network card sending queue, triggering the network card sending interrupt of the first audio processor.

[0042] In an optional embodiment, the first audio processor and the second audio processor are both provided with a network card, and the network card sending interrupt includes: the network card in the first audio processor reads the network packet according to the network card sending queue, and sends the network packet to the port of the network card of the second audio processor.

[0043] By building a queue to read and send network packets, the data is sent to another port in order, ensuring the integrity of the data.

[0044] In an optional embodiment, the network packet includes: a frame header, a data size, a packet type, a data packet count, a packet to be sent, a cyclic redundancy check code and a frame tail, and the data packet count is a number. When the first audio processor assembles a data packet each time, the data packet count is incremented by one.

[0045] Packet counting is used to detect network fluctuations and verify that the data packets received by the receiving end are complete. When the packet count is discontinuous, that is, there are fluctuations in the network and data packets are lost, the receiving end can respond to the packet loss.

[0046] In an optional embodiment, in step S4, the detection of the continuity of the data packets in the sending buffer specifically includes: checking whether the data packet count in the last parsed network packet is increased by one to be the data packet count in the current network packet; if they are the same, saving the current data packet count for the next data packet count check, and ending the audio playback interruption.

[0047] Each time an audio playback interruption is triggered, the second audio processor will check whether the data packet count in the current data packet is continuous with the previous data packet. Discontinuity means that there is a network fluctuation that causes packet loss. The second audio processor will also check the cyclic redundancy check code in the network packet to verify whether there is any data loss in the network packet.

[0048] In an optional embodiment, when the data packets in the sending buffer are discontinuous, a network fluctuation signal is returned to the first audio processor. The specific implementation includes: increasing the time interval for each time the second audio processor triggers a DMA acquisition interrupt, and assembling the increased time interval into a control packet, assembling the control packet into a network packet, sending the network packet to the port of the network card of the first audio processor, and adding a network fluctuation count in the sending buffer of the second audio processor, and setting the network fluctuation count according to the increased time interval.

[0049] Data packet loss is generally caused by network environment failure or data transmission blockage. Therefore, this solution uses the method of slowing down the transmission rate to adaptively adjust the data packet loss problem. When data transmission is blocked, the rate is slowed down to adapt to the processing speed of data reception. When the packet loss situation has not been restored, the transmission rate is gradually slowed down until the transmission environment is restored, and then the transmission rate is restored to improve the stability of audio transmission.

[0050] In this embodiment, whenever the data packets received in the sending buffer are discontinuous, the time interval for the second audio processor to trigger the DMA acquisition interrupt is increased to twice the current time interval, and the first audio processor is notified to increase the time interval as well. The frequency of data transmission is slowed down by increasing the acquisition interrupt to avoid data loss caused by over-fast transmission and to adapt to fluctuations in audio data transmission.

[0051] A network fluctuation count is set up to reflect the current network situation. Subsequently, the change of the network fluctuation check bit is verified to confirm whether the current transmission environment is restored and whether the DMA acquisition interrupt interval is effective. In this embodiment, the network fluctuation count is set to 2 / the interval of the current triggering DMA acquisition interrupt.

[0052] In an optional embodiment, in step S4, after detecting the continuity of the data packets in the sending buffer, it also includes: when the data packets are continuous, detecting whether there is a network fluctuation count in the sending buffer of the second audio processor, when there is a network fluctuation count, the network fluctuation count is reduced by one, and when the network fluctuation count is reduced by one and becomes zero, restoring the time interval for each DMA acquisition interrupt triggered by the second audio processor to a preset time interval, deleting the network fluctuation count, and sending a control packet assembled into a network packet to the port of the network card of the first audio processor, notifying the first audio processor to restore the time interval for triggering the DMA acquisition interrupt to the preset time interval.

[0053] When the data packets are continuous, the current network fluctuation count is checked. If there is a network fluctuation, it means that there is a network fluctuation, and the continuous data packets mean that the network packet transmission has returned to normal, so the network fluctuation count is -1, and when the network fluctuation count is 0, the first audio processor and the second audio processor are notified to restore the preset collection time interval. By reducing the network fluctuation count every time the network is normal, the network status is monitored in real time and adjusted according to the network status. When the network returns to normal, the default transmission rate is restored to ensure the transmission efficiency and improve the transmission stability of network audio data.

[0054] In an optional embodiment, when the port of the network card of the first audio processor receives a network packet sent by the second processor, the packet type in the received network packet is parsed. When the network packet is a control packet, the instructions in the control packet are parsed and executed to adjust the interval time for triggering the DMA acquisition interrupt.

[0055] Example 2

[0056] See also Figure 2 A network audio transmission system includes a first audio processor and a second audio processor, wherein the audio processor is provided with a sound card, a network card, a DMA, a receiving buffer, and a sending buffer, and the system includes:

[0057] The audio acquisition module is used to enable the first audio processor and the second audio processor to trigger a DMA acquisition interrupt at a preset time interval, store the audio data in the DMA into a receiving buffer, and end the DMA acquisition interrupt;

[0058] The audio sending module is used to trigger a data sending interrupt after the first audio processor ends the DMA acquisition interrupt each time, assemble the audio data in the receiving buffer into a data packet, send the data packet to the second audio processor, and end the data sending interrupt;

[0059] The audio receiving module is used to enable the second audio processor to parse the data packet after receiving the data packet, and store the parsed data packet into the sending buffer of the second audio processor;

[0060] An audio playback module, used to enable the second audio processor to respond to the playback instruction, trigger the audio playback interrupt, detect whether there is a data packet in the sending buffer, if not, end the audio playback interrupt, if so, parse the data packet, store the audio data in the data packet into the DMA of the second audio processor, and detect whether the data packet in the sending buffer is continuous, if not, return a network fluctuation signal to the first audio processor;

[0061] The fluctuation adjustment module is used to enable the first audio processor to receive the network fluctuation signal and adjust the time interval of the DMA acquisition interruption, and the adjusted time interval is used as the new preset time interval.

[0062] The embodiment disclosed in this specification is only an example of a unilateral feature of the present invention, and the protection scope of the present invention is not limited to this embodiment, and any other functionally equivalent embodiments fall within the protection scope of the present invention. For those skilled in the art, various other corresponding changes and deformations can be made according to the technical solutions and concepts described above, and all of these changes and deformations should fall within the protection scope of the claims of the present invention.

Claims

1. A network audio transmission method, applied to an audio processor, characterized in that: The method comprises a first audio processor and a second audio processor, both of which are provided with DMA, a receiving buffer and a sending buffer. The method comprises: The first audio processor and the second audio processor both trigger a DMA acquisition interrupt at a preset time interval, store the audio data in the DMA into a receiving buffer, and end the DMA acquisition interrupt; After the first audio processor ends the DMA acquisition interrupt each time, it triggers the data transmission interrupt, assembles the audio data in the receiving buffer into a data packet, sends the data packet to the second audio processor, and ends the data transmission interrupt; After receiving the data packet, the second audio processor parses the data packet and stores the parsed data packet into a sending buffer of the second audio processor; The second audio processor triggers an audio playback interrupt in response to the play instruction, detects whether there is a data packet in the send buffer, and if not, ends the audio playback interrupt. If so, parses the data packet, stores the audio data in the data packet into the DMA of the second audio processor, and detects whether the data packet in the send buffer is continuous. If not, returns a network fluctuation signal to the first audio processor; The first audio processor receives the network fluctuation signal, adjusts the time interval of the DMA acquisition interruption, and uses the adjusted time interval as the new preset time interval.

2. A network audio transmission method according to claim 1, characterized in that: The first audio processor and the second audio processor are both provided with a sound card, and the calculation formula of the preset time interval is: Among them, T is the time interval, C is the DMA capacity, R is the number of sound card channels, B is the number of sound card bits, and S is the sampling rate of the sound card.

3. A network audio transmission method according to claim 2, characterized in that: The data sending interruption includes: detecting whether there is audio data in the receiving buffer, and ending the data sending interruption when there is no audio data in the receiving buffer; when there is audio data in the receiving buffer, assembling the audio data in the receiving buffer into data packets, assembling the data packets into network packets, and putting the network packets into the network card sending queue, triggering the network card sending interruption of the first audio processor.

4. A network audio transmission method according to claim 3, characterized in that: The first audio processor and the second audio processor are both provided with a network card, and the network card sending interrupt comprises: the network card in the first audio processor reads a network packet according to a network card sending queue, and sends the network packet to a port of the network card of the second audio processor.

5. A network audio transmission method according to claim 4, characterized in that: The network packet includes: a frame header, a data size, a packet type, a data packet count, a packet to be sent, a cyclic redundancy check code and a frame tail. The data packet count is a number. When the first audio processor assembles a data packet each time, the data packet count is incremented by one.

6. A network audio transmission method according to claim 5, characterized in that: In step S4, the continuity of the data packets in the sending buffer is detected, specifically including: checking whether the data packet count in the last parsed network packet is the same as the data packet count in the current network packet after being increased by one. If they are the same, the current data packet count is saved for the next data packet count check, and the audio playback interruption is ended.

7. A network audio transmission method according to claim 6, characterized in that: When the data packets in the sending buffer are discontinuous, a network fluctuation signal is returned to the first audio processor. The specific implementation includes: increasing the time interval for each time the second audio processor triggers a DMA acquisition interrupt, assembling the increased time interval into a control packet, assembling the control packet into a network packet, sending the network packet to the port of the network card of the first audio processor, adding a network fluctuation count in the sending buffer of the second audio processor, and setting the network fluctuation count according to the increased time interval.

8. A network audio transmission method according to claim 7, characterized in that: In step S4, after detecting the continuity of the data packets in the sending buffer, it also includes: when the data packets are continuous, detecting whether there is a network fluctuation count in the sending buffer of the second audio processor, when there is a network fluctuation count, the network fluctuation count is reduced by one, and when the network fluctuation count is reduced by one and becomes zero, restoring the time interval for each DMA acquisition interrupt triggered by the second audio processor to a preset time interval, deleting the network fluctuation count, and sending a control packet assembled into a network packet to the port of the network card of the first audio processor, notifying the first audio processor to restore the time interval for triggering the DMA acquisition interrupt to the preset time interval.

9. A network audio transmission method according to claim 8, characterized in that: When the port of the network card of the first audio processor receives the network packet sent by the second processor, the packet type in the received network packet is parsed. When the network packet is a control packet, the instructions in the control packet are parsed and executed to adjust the interval time for triggering the DMA acquisition interrupt.

10. A network audio transmission system, characterized in that: The system comprises a first audio processor and a second audio processor, both of which are provided with DMA, a receiving buffer and a sending buffer. The system comprises: The audio acquisition module is used to enable the first audio processor and the second audio processor to trigger a DMA acquisition interrupt at a preset time interval, store the audio data in the DMA into a receiving buffer, and end the DMA acquisition interrupt; The audio sending module is used to trigger a data sending interrupt after the first audio processor ends the DMA acquisition interrupt each time, assemble the audio data in the receiving buffer into a data packet, send the data packet to the second audio processor, and end the data sending interrupt; The audio receiving module is used to enable the second audio processor to parse the data packet after receiving the data packet, and store the parsed data packet into the sending buffer of the second audio processor; An audio playback module, used to enable the second audio processor to respond to the playback instruction, trigger the audio playback interrupt, detect whether there is a data packet in the sending buffer, if not, end the audio playback interrupt, if so, parse the data packet, store the audio data in the data packet into the DMA of the second audio processor, and detect whether the data packet in the sending buffer is continuous, if not, return a network fluctuation signal to the first audio processor; The fluctuation adjustment module is used to enable the first audio processor to receive the network fluctuation signal and adjust the time interval of the DMA acquisition interruption, and the adjusted time interval is used as the new preset time interval.