A data transmission method, apparatus, device, and storage medium
By enabling zero-copy audio data exchange between Qemu and the embedded operating system, and utilizing a shared memory area to store the transmission process address queue of audio data, the problem of low audio data transmission efficiency between the virtual operating system and the embedded system is solved, achieving efficient audio data transmission.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- BEIJING ESWIN COMPUTING TECH CO LTD
- Filing Date
- 2022-12-02
- Publication Date
- 2026-06-19
AI Technical Summary
When using the virtual operating system simulator Qemu for embedded hardware simulation, the transmission efficiency of audio data is low, mainly because audio data interaction requires the use of an audio bus and memory devices, and communication between the embedded operating system and Qemu requires multiple mode switching and relays.
The audio component acquires a circular buffer and sends function commands to the sound card driver component. The sound card driver component acquires a shared memory area to configure the virtual sound card component. The shared memory area stores the transmission process associated address queue of audio data. The virtual sound card component acquires and transmits audio data based on the shared memory area, realizing zero-copy audio data interaction.
It improves the efficiency of audio data transmission, reduces virtual machine mode switching operations, and simplifies the audio data transmission process.
Smart Images

Figure CN115794023B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of hardware simulation of embedded systems, and more particularly to a data transmission method, apparatus, device, and storage medium. Background Technology
[0002] Typically, the virtual operating system simulator Qemu is used for embedded hardware simulation to support the development and debugging of basic functions such as audio in the early stages of embedded terminal development. In related technologies, since the virtual sound card is located in Qemu, the audio data interaction between it and the embedded operating system of the embedded terminal needs to be transmitted through audio buses and related memory devices, and the communication between the embedded operating system and Qemu also involves multiple mode switching and relays. As a result, the transmission efficiency of audio data is relatively low. Summary of the Invention
[0003] This application provides a data transmission technology solution.
[0004] The technical solution of this application embodiment is implemented as follows:
[0005] This application provides a data transmission method, the method comprising: using an audio component, acquiring a circular buffer for storing audio data, and sending a function instruction matching the audio component to a sound card driver component; using the sound card driver component in response to the function instruction, acquiring a shared memory area, configuring a virtual sound card component to obtain a configured virtual sound card component, and sending the function instruction to the configured virtual sound card component; wherein, the shared memory area is used to store an address queue constructed based on the address of the circular buffer and associated with the audio data transmission process; and using the configured virtual sound card component in response to the function instruction, acquiring and transmitting the audio data based on the shared memory area.
[0006] This application provides a data transmission device, comprising: an audio component, a sound card driver component, and a virtual sound card component. The audio component is configured to acquire a circular buffer for storing audio data and send a function command matching the audio component to the sound card driver component. The sound card driver component, in response to the function command, acquires a shared memory area, configures the virtual sound card component to obtain a configured virtual sound card component, and sends the function command to the configured virtual sound card component. The shared memory area stores an address queue constructed based on the address of the circular buffer and associated with the audio data transmission process. The virtual sound card component, after configuration, in response to the function command, acquires and transmits the audio data based on the shared memory area.
[0007] This application provides a computer device, which includes a memory and a processor. The memory stores computer-executable instructions, and the processor can implement any of the data transmission methods described above when it executes the computer-executable instructions in the memory.
[0008] This application provides a computer storage medium storing computer-executable instructions, which, when executed, can implement any of the data transmission methods described above.
[0009] This application provides a data transmission method, apparatus, device, and storage medium. First, an audio component is used to acquire a circular buffer for storing audio data, and a function command matching the audio component is sent to a sound card driver component. Second, in response to the function command, the sound card driver component acquires a shared memory area, configures a virtual sound card component to obtain a configured virtual sound card component, and sends the function command to the configured virtual sound card component. The shared memory area stores an address queue constructed based on the address of the circular buffer and associated with the audio data transmission process. The configured virtual sound card component responds to the function command. Based on the shared memory area, the audio data is acquired and transmitted. Thus, based on the configured virtual sound card component and the shared memory area storing address queues associated with audio data transmission (constructed using a circular buffer), the audio data to be processed by the audio component can be transmitted using shared memory addresses. This enables zero-copy audio data interaction between the virtual sound card component, the audio component, and the sound card driver component. In other words, it enables zero-copy audio data interaction between the virtual operating system where the virtual sound card component resides, the audio component, and the operating system where the sound card driver component resides, thereby improving the efficiency of audio data transmission. Attached Figure Description
[0010] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort, wherein:
[0011] Figure 1 A flowchart illustrating the first data transmission method provided in this application embodiment;
[0012] Figure 2 A flowchart illustrating the second data transmission method provided in this application embodiment;
[0013] Figure 3 A flowchart illustrating the third data transmission method provided in this application embodiment;
[0014] Figure 4 A flowchart illustrating the fourth data transmission method provided in this application embodiment.
[0015] Figure 5 A schematic diagram illustrating the principle of a terminal applying the data transmission method provided in the embodiments of this application during audio transmission.
[0016] Figure 6 A schematic diagram illustrating data transmission based on memory address sharing in the data transmission method provided in the embodiments of this application;
[0017] Figure 7 This is a schematic diagram of the composition structure of a data transmission device provided in an embodiment of this application;
[0018] Figure 8 This is a schematic diagram of the composition structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the specific technical solutions of the invention will be further described in detail below with reference to the accompanying drawings of the embodiments of this application. The following embodiments are used to illustrate the embodiments of this application, but are not intended to limit the scope of the embodiments of this application.
[0020] In the following description, references are made to “some embodiments,” which describe a subset of all possible embodiments. However, it is understood that “some embodiments” may be the same subset or different subsets of all possible embodiments and may be combined with each other without conflict.
[0021] In the following description, the terms "first, second, third" are used merely to distinguish similar objects and do not represent a specific ordering of objects. It is understood that "first, second, third" may be interchanged in a specific order or sequence where permitted, so that the embodiments of this application described herein can be implemented in an order other than that illustrated or described herein.
[0022] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which embodiments of this application belong. The terminology used herein is for descriptive purposes only and is not intended to limit the scope of embodiments of this application.
[0023] Before providing a further detailed description of the embodiments of this application, the nouns and terms involved in the embodiments of this application will be explained, and the nouns and terms involved in the embodiments of this application shall be interpreted as follows.
[0024] 1) Component: This refers to a simple encapsulation of data and methods; the component is an object. A component can have its own properties and methods; properties are simple accessors to the component's data, while methods are some simple and visible functionalities of the component.
[0025] 2) Thread: The smallest unit of computation that the operating system can schedule. It is contained within a process and is the actual unit of operation within a process.
[0026] 3) Driver: A computer software term referring to a program that drives the software in a computer. A driver, or device driver, is a special program added to the operating system that contains information about a hardware device. This information enables the computer to communicate with the corresponding device. Drivers are configuration files written by hardware manufacturers according to the operating system; without drivers, the hardware in a computer cannot function.
[0027] 4) Audio data: Digitalized sound data is audio data; the process of digitizing sound is actually the process of converting continuous analog audio signals from devices such as microphones into digital signals at a certain frequency to obtain audio data; playing digital sound is the process of converting audio data into analog signals for output.
[0028] The data transmission method provided in this application embodiment can be applied to computer devices. The function implemented by this method can be achieved by the processor in the computer device calling program code. Of course, the program code can be stored in the computer storage medium. It can be seen that the computer device includes at least a processor and a storage medium.
[0029] This application provides a data transmission method, such as... Figure 1 The diagram shown is a flowchart illustrating the first data transmission method provided in this application embodiment; combined with... Figure 1 Steps S101 to S103 shown in the figure will be explained as follows:
[0030] Step S101: Using the audio component, obtain a circular buffer for storing audio data, and send a function command matching the audio component to the sound card driver component.
[0031] Here, the audio component can be an application in any operating system; the operating system includes, but is not limited to, audio components, sound card driver components, controller driver components, etc.
[0032] The audio component can be either an audio playback component or an audio recording component.
[0033] Here, the size of the space corresponding to the circular buffer can be preset, and the specific data format and data size of the audio data are not limited in this embodiment.
[0034] Here, when the audio component is an audio playback component, in response to a startup operation, the audio playback component can request physical space from the operating system corresponding to the data transmission device where the audio playback component is located, namely a circular buffer for storing the audio data to be played, and send an audio playback command to the sound card driver component; similarly, when the audio component is an audio recording component, in response to a startup operation, the audio recording component can request physical space from the operating system corresponding to the data transmission device where the audio recording component is located, namely a circular buffer for temporarily storing the input recording data, and send an audio recording command to the sound card driver component.
[0035] Step S102: The sound card driver component responds to the function command, obtains the shared memory area, configures the virtual sound card component to obtain the configured virtual sound card component, and sends the function command to the configured virtual sound card component.
[0036] The shared memory area is used to store an address queue associated with the audio data transmission process, constructed based on the address of the circular buffer.
[0037] Here, after the sound card driver component receives the function command sent by the audio component, it configures the virtual sound card component to obtain the configured virtual sound card component, and sends the function command to the configured virtual sound card component; in addition, the sound card driver component also needs to obtain a shared memory area, which is used to store the address queue associated with the audio data transmission process based on the address of the circular buffer.
[0038] Here, the virtual sound card component can be an application within a related system emulator; or it can be an application within a virtual operating system in a data transmission device that runs the audio component.
[0039] Specifically, the sound card driver component responds to function commands, controls the relevant controller driver, and writes corresponding control information to the relevant area of the virtual controller component, so that the virtual controller component can configure the virtual sound card component based on the control information, thereby obtaining the configured virtual sound card component.
[0040] Here, the virtual controller component can be a device controller that transmits information based on a two-wire serial bus (Inter-Integrated Circuit, I2C).
[0041] Here, the sound card driver component responds to function instructions and can also request a physical address in the corresponding operating system, which is the shared memory area. Here, the shared memory area can be used to store the address queue associated with the audio data transmission process, which is built based on the address of the circular buffer, and can also be used to store the address of the circular buffer.
[0042] In the case of an audio playback instruction, the shared memory area stores an address queue associated with the audio data transmission process, which is constructed based on the address of the circular buffer. This queue may include a transmitted address queue and a pending address queue. The addresses in the transmitted address queue are the addresses of audio data that has been played and is waiting to be cleared in the circular buffer. Meanwhile, the addresses in the pending address queue are the addresses of memory blocks in the circular buffer that are to be played.
[0043] When the function instruction is an audio recording instruction, the shared memory area stores an address queue associated with the audio data transmission process, constructed based on the address of the circular buffer. This queue may include: a queue of stored addresses and a queue of addresses to be stored. The addresses in the queue of stored addresses are the addresses of audio data that has been stored in the circular buffer and loaded into the corresponding file. Meanwhile, the addresses in the queue of addresses to be stored are the addresses of memory blocks in the circular buffer that are empty and await loading audio data.
[0044] Step S103: The configured virtual sound card component responds to the function command and acquires and transmits the audio data based on the shared memory area.
[0045] Here, the configured virtual sound card component responds to the function instructions sent by the sound card driver component, and obtains the address queue associated with the audio data transmission process based on the shared memory area. This address is a partial address of the circular buffer storing audio data, and the corresponding audio data can be read based on this address so as to transmit the read audio data.
[0046] The configured virtual sound card component responds to function commands, acquires and transmits audio data to the relevant audio output component based on the shared memory area, so as to realize the audio data playback function. It can also acquire and transmit audio data input from the outside to the corresponding file, so as to realize the recording function of audio data input from the outside.
[0047] Here, when the audio component is an audio playback component, firstly, the audio playback component can acquire a circular buffer for storing the audio data to be played and send an audio playback command to the sound card driver component. Then, in response to the audio playback command, the sound card driver component acquires a shared memory area to store an address queue associated with the playback process of the audio data to be played, constructed based on the address of the circular buffer. It then configures the virtual sound card component for audio playback, resulting in a virtual sound card component with audio playback functionality. The audio playback command is also sent to this virtual sound card component. Finally, the virtual sound card component with audio playback functionality reads the address queue associated with the playback process of the audio data to be played from the shared memory area using a shared memory address method, and then obtains the audio data associated with the address in the address queue. Based on the audio playback command, the data is played. This allows the virtual sound card component, audio component, and sound card driver component to perform zero-copy audio data interaction using a shared memory address method, thus improving the efficiency of audio data transmission.
[0048] The data transmission method provided in this application embodiment firstly uses an audio component to obtain a circular buffer for storing audio data and sends a function instruction matching the audio component to a sound card driver component; secondly, the sound card driver component, in response to the function instruction, obtains a shared memory area, configures a virtual sound card component to obtain a configured virtual sound card component, and sends the function instruction to the configured virtual sound card component; wherein, the shared memory area is used to store an address queue associated with the audio data transmission process, constructed based on the address of the circular buffer; the configured virtual sound card component, in response to the function instruction, obtains a shared memory area, configures a virtual sound card component to obtain a configured virtual sound card component, and sends the function instruction to the configured virtual sound card component; wherein, the shared memory area is used to store an address queue constructed based on the address of the circular buffer, constructed based on the address of the circular buffer; the configured virtual sound card component, in response to the function instruction, obtains a shared memory area, configures a virtual sound card component to obtain ... and sends the function instruction to the configured virtual sound card component. The shared memory area acquires and transmits the audio data. Thus, based on the configured virtual sound card component and the shared memory area storing address queues associated with audio data transmission (constructed using a circular buffer), the audio data to be processed by the audio component can be transmitted in a shared memory manner. This enables zero-copy audio data interaction between the virtual sound card component, the audio component, and the sound card driver component. In other words, it enables zero-copy audio data interaction between the virtual operating system where the virtual sound card component resides, the audio component, and the operating system where the sound card driver component resides, thereby improving the efficiency of audio data transmission.
[0049] In some embodiments, the audio component responds to the startup operation by acquiring the corresponding circular buffer and synchronously generating a data loading thread; then, the audio component responds to the generation of the data loading thread by sending corresponding function instructions to the sound card driver component, so as to start the sound card driver component and provide a foundation for the subsequent normal transmission of audio data. That is, step S101 provided in the above embodiment can be implemented by the following steps S201 and S202; Figure 2 The diagram shown is a flowchart illustrating the second data transmission method provided in this application embodiment. Figure 1 and Figure 2 The steps shown are explained below:
[0050] Step S201: In response to the startup operation, the audio component obtains the circular buffer and generates a data loading thread.
[0051] Here, the audio component responds to the startup operation, that is, the audio component is started, and then the audio component will request a circular buffer in the corresponding embedded system and generate a data loading thread.
[0052] In the case where the audio component is an audio playback component, the audio playback component responds to the start operation by obtaining the audio data to be played and a first circular buffer for storing the audio data to be played, and starts a first data loading thread for loading the audio data to be played into the first circular buffer.
[0053] In the case where the audio component is an audio recording component, the audio recording component responds to the startup operation, that is, the audio recording component is started. Then, the audio recording component will request a second circular buffer with empty content in the corresponding embedded system, and at the same time generate a second data loading thread for loading data from the second circular buffer.
[0054] It should be noted that the first circular buffer and the second circular buffer can be the same or different.
[0055] Step S202: The audio component responds to the generation of the data loading thread by sending the function command to the sound card driver component.
[0056] Here, after the data loading thread is generated, the audio component can send corresponding function commands, such as audio playback commands or audio recording commands, to the sound card driver component.
[0057] Correspondingly, after the sound card driver component receives the function instruction sent by the audio component, it can also obtain a shared memory area for storing an address queue associated with the audio data transmission process, constructed based on the address of a circular buffer. This provides a foundation for subsequent audio data transmission based on memory address sharing. In addition, the sound card driver component synchronously configures the virtual sound card component to obtain the corresponding configured virtual sound card component, and sends the function instruction to the configured virtual sound card component. In this way, the configured virtual sound card component can transmit audio data in a memory address sharing manner based on the function instruction and the shared memory area. That is, step S102 provided in the above embodiment can be implemented by the following steps S203 and S204:
[0058] Step S203: The sound card driver component responds to the function command and controls the virtual controller component to configure the virtual sound card component, thereby obtaining the configured virtual sound card component.
[0059] Here, the sound card driver component responds to the audio playback command and controls the corresponding controller driver to write relevant function commands to the virtual controller component associated with the controller driver, so that the virtual controller component can configure the virtual sound card component, thereby obtaining the configured virtual sound card component.
[0060] Here, the virtual controller component and the virtual sound card component are virtual applications or modules provided in the relevant virtual operating system.
[0061] In some possible implementations, the virtual sound card component is configured using control information that matches the function instructions, resulting in a configured virtual sound card component with functional attributes that match the function instructions. This makes the configuration of the virtual sound card component more accurate. That is, the above step S203 can be implemented by the following steps S2031 and S2032 (not shown in the figure):
[0062] Step S2031: The sound card driver component responds to the function command, and the controller driver component obtains control information that matches the function command.
[0063] Here, the sound card driver component responds to the function amplifier command and controls the controller driver component, which is on the same operating system as it, to obtain control information that matches the function command; the control information may include, but is not limited to, control parameters such as audio playback frequency, audio playback speed, and audio playback gain.
[0064] Step S2032: Using the controller driver component, write the control information into the memory mapping area associated with the virtual controller component, so that the virtual controller component configures the virtual sound card component based on the control information, and obtains the configured virtual sound card component.
[0065] Here, a controller driver component can be used to write the control information into the memory-mapped area associated with its virtual controller component, so that the virtual controller component can configure the virtual sound card component based on the control information, and obtain the configured virtual sound card component.
[0066] Step S204: Use the sound card driver component to send the function command to the configured virtual sound card component, and obtain a shared memory area for storing an address queue associated with the transmission process of the audio data, constructed based on the address of the circular buffer.
[0067] Here, after the virtual sound card component is configured, the sound card driver component will simultaneously send audio playback commands to the configured virtual sound card component.
[0068] In the case where the function instruction is an audio playback instruction and the audio component is an audio playback component, the sound card driver component responds to the audio playback instruction and simultaneously requests a physical address in its operating system, namely a shared memory area. This shared memory area is used to store some address information, namely, the address queue associated with the audio data playback process, which is constructed from the address of the aforementioned circular buffer.
[0069] Here, the shared memory area can also store all the address information of the circular buffer, as well as the waiting address queue and the played address queue associated with the audio data playback process; among them, the data at the addresses in the waiting address queue is the audio data that has not been played, that is, the audio data waiting to be played or output, while the data at the addresses in the played address queue is the audio data that has been output.
[0070] In the case where the function instruction is an audio recording instruction and the audio component is an audio recording component, the sound card driver component responds to the audio recording instruction and simultaneously requests a physical address in its operating system, namely a shared memory area. This shared memory area is used to store some address information, namely, an address queue associated with the recording process, which is used to store the address of the aforementioned circular buffer.
[0071] Here, the shared memory area can also store all address information of the circular buffer, as well as the queue of addresses to be stored and the queue of addresses already stored associated with the recording process; among them, the data at the addresses in the queue of addresses to be stored are unrecorded, that is, audio data waiting to be stored or loaded, while the data at the addresses in the queue of addresses already stored are audio data that has been loaded into the corresponding recording file.
[0072] In some embodiments, when the function instruction includes an audio playback instruction, the audio data is stored in a shared memory area based on the memory address corresponding to the audio data. With the help of a virtual sound card service component, efficient transmission of audio data during audio playback can be achieved through memory address sharing. That is, step S103 can be implemented using steps S301 and S3022. (Refer to...) Figure 3 The diagram shown is a flowchart illustrating the third data transmission method provided in this application embodiment. Figures 1 to 3 The steps shown are explained below:
[0073] Step S301: In response to the audio playback command, the configured virtual sound card component obtains and sends the pre-play audio data to the service buffer associated with the virtual sound card service component based on the pending playback address queue associated with the playback process of the audio data in the shared memory area.
[0074] The address queue includes the address queue to be played.
[0075] Here, the configured virtual sound card component responds to the audio playback command by reading the address queue to be played from the shared memory area, obtaining the address in the address queue, and then obtaining the pre-playback audio data associated with that address; wherein, the pre-playback audio data is a portion of the audio data to be played.
[0076] Here, the circular buffer can include multiple buffers, which can split the audio data to be played into multiple audio data and store them in multiple buffers in a preset order.
[0077] It should be noted that the number of addresses in the queue of addresses to be played can be one, two or more, and there is no limit here.
[0078] The virtual sound card service component can be an application or module running in the relevant virtual operating system, and the service buffer associated with the virtual sound card service component is a virtual address in the virtual operating system.
[0079] Step S302: The audio output component associated with the configured virtual sound card component responds to the pre-playback audio data written in the service buffer and outputs the pre-playback audio data.
[0080] Here, the audio output component can be a speaker or loudspeaker; wherein, the enabling of the audio output component can be achieved in the process of using the sound card driver component to control the virtual controller component to configure the virtual sound card component in response to the audio playback command, thereby obtaining the configured virtual sound card component.
[0081] The configured virtual sound card component responds to audio playback commands. Since the memory address corresponding to the relevant audio data to be played is stored in the shared memory area, it can read the corresponding audio data from the shared memory area in a shared memory address manner and control the audio output component to output the audio data.
[0082] It should be noted that when data is written to the service buffer associated with the virtual sound card service component, the corresponding audio output component will read and output that data.
[0083] Correspondingly, if there is an address marked as the last in the queue of addresses to be played in the shared memory area, indicating that no new audio data needs to be played, then the circular buffer and the shared memory area are released. In this way, releasing the corresponding space facilitates the subsequent playback of audio data. Therefore, the data transmission method provided in this embodiment can also perform the following process:
[0084] The first step involves using the configured virtual sound card component to respond to the audio playback command. If an address marked as the last bit is found in the address queue to be played from the shared memory area, a space release command is generated and sent to the sound card driver component.
[0085] Here, in response to an audio playback command, the configured virtual sound card component reads from the shared memory area and finds an address marked as the last bit in the address queue to be played, indicating that there is no new audio data to be played. The configured virtual sound card component then generates a space release command and sends the space release command to the sound card driver component.
[0086] The second step involves the sound card driver component responding to the space release command, releasing the space of the shared memory area, and sending the space release command to the audio component.
[0087] Here, the sound card driver component responds to the space release command, releases the space in the shared memory area, and simultaneously sends the space release command to the audio component.
[0088] The third step involves using the audio component in response to the space release command to release the space of the circular buffer.
[0089] Here, the sound card driver component can also send the space release command to the controller driver component, so that the controller driver component can release the space of the memory-mapped area associated with the virtual controller component based on the space release command, that is, delete the control information written in it.
[0090] It should be noted that, if the shared memory area also includes a queue of played addresses associated with the audio data playback process, a sound card driver component can be used to respond to and send the queue of played addresses to the audio component, so that the audio component can clear the memory space corresponding to the addresses in the queue of played addresses, so that the addresses cleared from the memory can be reused in a cyclical manner.
[0091] In some embodiments, when the function includes an audio recording instruction, storing the audio data in a shared memory area based on the memory address corresponding to the audio data enables efficient transmission of the audio data to be recorded during the audio recording process using a shared memory address approach. That is, step S103 provided in the above embodiment can be implemented using steps S401 and S402. (Refer to...) Figure 4 The diagram shown is a schematic representation of the fourth type of data transmission provided in this application embodiment. Figure 1 , Figure 2 as well as Figure 4 The steps shown are explained below:
[0092] Step S401: Using the audio input component associated with the configured virtual sound card component, send the received audio data to the loading area.
[0093] The address queue includes the address queue to be stored; the area to be loaded is the region corresponding to the address in the address queue to be stored stored in the shared memory area.
[0094] Here, the audio input component can be a microphone; and the enabling of the audio input component can be achieved by using the sound card driver component to respond to the audio recording command, controlling the virtual controller component to configure the virtual sound card component, and obtaining the configured virtual sound card component.
[0095] The configured virtual sound card component responds to audio recording commands. Since the memory address corresponding to the relevant recording data is stored in the shared memory area, it can read the corresponding audio data to be stored, i.e., the audio data to be recorded, from the shared memory area in a shared memory address manner.
[0096] Here, an enabled audio input component is used to write the received audio data into a waiting area. The address of this waiting area is any address in the queue of waiting addresses stored in the shared memory area. There can be multiple waiting areas, and the memory size of each waiting area can be determined according to actual needs.
[0097] In some feasible implementations, based on relevant virtual components, externally input audio data is written to the loading area in a preset circular buffer. This provides a foundation for efficient transmission of audio data during the recording process based on memory address sharing. That is, the above step S401 can be implemented by the following steps S4011 and S4012 (not shown in the figure):
[0098] Step S4011: Using the audio input component, the received audio data is sent to the service buffer associated with the virtual sound card service component.
[0099] Step S4012: In response to the received audio data, the virtual sound card service component sends a write command to the configured virtual sound card component, so that the configured virtual sound card component writes the audio data from the service buffer to the loading area.
[0100] Step S402: The configured virtual sound card component responds to the audio recording command and stores the audio data based on the unloaded area where the audio data is written.
[0101] Here, the audio data is stored, which means that the audio data is recorded.
[0102] In some feasible implementations, firstly, the configured virtual sound card component responds to the audio recording command and the area to be loaded by sending a start command to the sound card driver component, so that the sound card driver component sends a start command to the audio recording component; then, the audio recording component responds to the start command by starting the relevant data loading thread, loading the audio input data in the area to be loaded and storing it in a preset file. That is, it can achieve efficient transmission of audio data in the recording process by sharing memory addresses. That is, the above step S402 can be implemented by the following steps S4021 and S4022 (not shown in the figure):
[0103] Step S4021: The configured virtual sound card component responds to the audio recording command and the unloaded area, generates and sends a startup command to the sound card driver component, so that the sound card driver component sends the startup command to the audio component.
[0104] Step S4022: The audio component responds to the start command by starting a data loading thread to load the audio data in the loading area and store it in a preset file.
[0105] Here, in response to the received start command, the audio component will start a thread to load data from the circular buffer, so as to load the audio input data in the loading area into a preset file to form a recording file.
[0106] It should be noted that when the audio component responds to an end operation, it will generate a space release command to release the space of the circular buffer and send the space release command to the sound card driver component so that the sound card driver component can release the space of the shared memory area. In addition, the sound card driver component can also send the space release command to the controller driver component so that the controller driver component can release the space of the memory-mapped area associated with the virtual controller component based on the space release command, that is, delete the control information written therein.
[0107] Here, if the shared memory area also includes a queue of stored addresses associated with the audio data recording process, a sound card driver component can be used to respond to and send the queue of stored addresses to the audio component, so that the audio component can clear the memory space corresponding to the addresses in the queue of recorded addresses, so that the addresses cleared from the memory can be reused in a cyclical manner.
[0108] The above data transmission method will be described below with reference to a specific embodiment. However, it is worth noting that this specific embodiment is only for better illustrating the embodiments of this application and does not constitute an improper limitation on the embodiments of this application.
[0109] With the development of the integration of computer technology and industry applications, embedded systems have gradually become the main players in the information industry. The development process of embedded terminals includes two parts: software development and hardware development. In the early stages of terminal development, since the hardware is not yet ready, audio, as a basic function, cannot be developed and debugged, which will affect the efficiency of terminal development.
[0110] Qemu, as an open-source software emulator, boasts high speed and cross-platform compatibility, making it suitable for embedded hardware simulation to support the early-stage development and debugging of audio functions in embedded terminals. However, in existing Qemu-based emulators, the virtual sound card resides within Qemu. Audio data interaction between Qemu and the embedded operating system may require the use of devices such as the Inter-IC Sound (I2S) and Direct Memory Access (DMA), increasing the workload during terminal development. Furthermore, communication between the embedded operating system and Qemu necessitates vm-exit and vm-entry operations, switching virtual machine modes, and relaying data via the kernel-based Virtual Machine (KVM). Each audio data interaction operation involves a long path and relatively low transmission efficiency.
[0111] To address the complexity of existing sound card emulation solutions, this application provides a data transmission method that eliminates the need for additional virtual modules such as I2S, DMA, and their corresponding drivers. By sharing memory addresses, it enables zero-copy audio data exchange between Qemu and the embedded operating system. This reduces the need to switch virtual machine modes, thereby improving audio data transmission efficiency.
[0112] like Figure 5 The diagram shown illustrates the principle block diagram of a terminal using the data transmission method provided in this application during audio transmission. The embedded terminal's corresponding embedded operating system includes a playback application 501, a recording application 502, a sound card driver 503, and a controller driver 504. The Qemu operating system running on the embedded terminal, i.e., the virtual operating system, includes a virtual sound card device 506, a virtual operation controller 505, and a host sound card service 507. Furthermore, there are a host speaker 509 and a microphone 508 associated with the host sound card service 507. Based on... Figure 5 As shown, the audio data transmission process during the recording stage will be explained as an example below:
[0113] First, click on the playback application 501. The playback application 501 will request a region corresponding to a physical address in the embedded operating system. This region can be a circular buffer. At the same time, it will start a thread to load the audio data to be played into the circular buffer. Here, at the same time as the thread starts, the playback application 501 will simultaneously send an audio playback request to the sound card driver 503.
[0114] Secondly, the sound card driver 503 uses the controller driver 504 to perform read and write operations on the address area mapped to the memory of the virtual controller 505 to realize the transmission of control information matching the audio playback request. This enables the virtual controller 505 to configure the virtual sound card device 506 based on the control information. At the same time, the sound card driver 503 requests a shared memory area from the embedded operating system to store the address of the circular buffer, the queue to be transmitted, and the queue of transmitted data, that is, the audio data corresponding to the memory sharing.
[0115] Then, as Figure 6 The diagram shows a data transmission method based on memory address sharing in the data transmission method provided in this application embodiment. When the virtual sound card device 506 receives an audio playback instruction, it obtains the address of the ring buffer to be played from the transmission queue 602, loads the audio data in the address into the virtual buffer of the host sound card service 507, and then plays it through the speaker 509.
[0116] Here, as Figure 6 As shown, 601 is the requested circular buffer, which includes multiple addresses. Figure 5 The recording application 501 loads the audio data to be played, i.e., the audio file, into the circular buffer. It can add the address of the buffer to be transmitted to the transmission queue 602 and the address of the buffer that has been transmitted to the transmitted queue 603. The virtual sound card device 506 identifies the addresses in the transmission queue 602 to determine if the audio file loading is complete (604). If an address marked as the last address exists in the transmission queue 602, the audio file is considered to have been loaded, and loading stops; otherwise, the relevant audio file continues to be loaded into the circular buffer.
[0117] Here, once the audio file has finished loading, the corresponding space in the circular buffer and shared memory area needs to be released.
[0118] It should be noted that during audio recording, the calls between the recording application 502 and the sound card driver 503 in the embedded operating system are similar to those during playback. Here, the virtual sound card device 506 will be set to the recording function. The audio data call flow during recording is the reverse of the call flow during audio playback, and will not be elaborated further here.
[0119] Based on this, the data transmission method provided in this application can effectively avoid the problem of software development and debugging being impossible due to asynchronous hardware development in the early stages of embedded terminal development; and without adding too much software development work, it supports the development and debugging of audio playback and recording functions in the early stages of embedded terminal development; at the same time, in the recording and audio playback stages, based on the memory address sharing method, zero-copy audio data interaction is enabled between the virtual operating system where the virtual sound card component resides, the audio component, and the operating system where the sound card driver component resides, that is, the cache address for storing audio data is obtained through zero-copy method, realizing efficient transmission of audio data in the recording and playback stages.
[0120] This application provides a data transmission device. Figure 7 This is a schematic diagram of the structural composition of the data transmission device provided in the embodiments of this application, as shown below. Figure 7 As shown, the data transmission device 700 includes: an audio component 701, a sound card driver component 702, and a virtual sound card component 703; wherein:
[0121] The audio component 701 is used to acquire a circular buffer for storing audio data and send a function command matching the audio component to the sound card driver component 702.
[0122] The sound card driver component 702 is used to respond to the function instruction, obtain the shared memory area, configure the virtual sound card component 703 to obtain the configured virtual sound card component, and send the function instruction to the configured virtual sound card component; wherein, the shared memory area is used to store an address queue associated with the audio data transmission process, constructed based on the address of the circular buffer.
[0123] The virtual sound card component 703, after configuration, is used to acquire and transmit the audio data based on the shared memory area in response to the function command.
[0124] In some embodiments, the audio playback component 701 is further configured to, in response to a startup operation, acquire the circular buffer and generate a data loading thread, and in response to the generation of the data loading thread, send the function instruction to the sound card driver component 702.
[0125] In some embodiments, the sound card driver component 702 is further configured to, in response to the function instruction, control the virtual controller component to configure the virtual sound card component 703 to obtain the configured virtual sound card component; and send the function instruction to the configured virtual sound card component, and obtain a shared memory area for storing an address queue associated with the transmission process of the audio data, constructed based on the address of the circular buffer.
[0126] In some embodiments, the sound card driver component 702 is further configured to, in response to the function instruction, control the controller driver component to obtain control information matching the function instruction; the controller driver component is further configured to write the control information into the memory-mapped area associated with the virtual controller component, so that the virtual controller component configures the virtual sound card component 603 based on the control information to obtain the configured virtual sound card component.
[0127] In some embodiments, the function instructions include audio playback instructions. The virtual sound card component 703 is further configured, after configuration, to obtain and send pre-playing audio data to the service buffer associated with the virtual sound card service component based on the pending playback address queue associated with the playback process of the audio data in the shared memory area, in response to the audio playback instructions; wherein, the address queue includes the pending playback address queue; the audio output component associated with the configured virtual sound card component is further configured to output the pre-playing audio data in response to the pre-playing audio data written to the service buffer.
[0128] In some embodiments, the virtual sound card component 703 is further configured to, after configuration, generate and send a space release instruction to the sound card driver component 702 in response to the audio playback instruction if an address marked as the last bit is found in the address queue to be played from the shared memory area; the sound card driver component 702 is further configured to, in response to the space release instruction, release the space of the shared memory area and send the space release instruction to the audio component 701; the audio component 701 is further configured to, in response to the space release instruction, release the space of the circular buffer.
[0129] In some embodiments, the function instructions include audio recording instructions, and the audio input component associated with the configured virtual sound card component is further configured to send the received audio data to a loading area; wherein, the loading area is the region corresponding to the address in the storage address queue stored in the memory shared area; the address queue includes a storage address queue; the virtual sound card component 703 is further configured, after configuration, in response to the audio recording instructions, to store the audio data based on the loading area where the audio data is written.
[0130] It should be noted that the description of the above device-side embodiments is similar to the description of the above method embodiments, and has similar beneficial effects. For technical details not disclosed in the device-side embodiments of this application, please refer to the description of the method embodiments of this application for understanding.
[0131] It should be noted that, in the embodiments of this application, if the above-described data transmission method is implemented as a software functional module and sold or used as an independent product, it can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the embodiments of this application, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a terminal, server, etc.) to execute all or part of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, mobile hard drives, read-only memory (ROM), magnetic disks, or optical disks. Thus, the embodiments of this application are not limited to any specific hardware and software combination.
[0132] Based on the same technical concept, this application provides a computer device for implementing the data transmission method described in the above method embodiments. Figure 8 This is a schematic diagram of the composition structure of a computer device provided in an embodiment of this application, such as... Figure 8 As shown, the computer device 800 includes: a processor 801, at least one communication bus 804, a communication interface 802, at least one external communication interface, and a memory 803. The communication interface 802 is configured to enable communication between these components. The communication interface 802 may include a display screen, and the external communication interface may include standard wired and wireless interfaces. The processor 801 is configured to execute a program in the memory to implement the data transmission method provided in the above embodiments.
[0133] Correspondingly, this application embodiment further provides a computer program product, which includes computer executable instructions. After the computer executable instructions are executed, they can implement the data transmission method provided in this application embodiment.
[0134] Accordingly, this application embodiment further provides a computer storage medium storing computer-executable instructions, which, when executed by a processor, implement the data transmission method provided in the above embodiment.
[0135] The descriptions of the data transmission apparatus and storage medium embodiments above are similar to those of the method embodiments above, and have similar technical descriptions and beneficial effects. Due to space limitations, please refer to the descriptions of the method embodiments above, and therefore will not be repeated here. For technical details not disclosed in the embodiments of the data transmission apparatus and storage medium provided in this application, please refer to the descriptions of the method embodiments of this application for understanding.
[0136] It should be understood that the phrase "an embodiment" or "one embodiment" throughout the specification means that a specific feature, structure, or characteristic related to the embodiment is included in at least one embodiment of the present application. Therefore, "in one embodiment" or "one embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. Furthermore, these specific features, structures, or characteristics can be combined in any suitable manner in one or more embodiments. It should be understood that in the various embodiments of the present application, the sequence number of the above-described processes does not imply the order of execution; the execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application. The sequence numbers of the above-described embodiments are merely for descriptive purposes and do not represent the superiority or inferiority of the embodiments. It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.
[0137] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods, such as: multiple units or components can be combined, or integrated into another system, or some features can be ignored or not executed. In addition, the coupling, direct coupling, or communication connection between the various components shown or discussed can be through some interfaces, and the indirect coupling or communication connection between devices or units can be electrical, mechanical, or other forms.
[0138] The units described above as separate components may or may not be physically separate. The components shown as units may or may not be physical units. They may be located in one place or distributed across multiple network units. Some or all of the units may be selected to achieve the purpose of this embodiment according to actual needs.
[0139] Furthermore, in the embodiments of this application, all functional units can be integrated into one processing unit, or each unit can be a separate unit, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units. Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When the program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROMs, magnetic disks, or optical disks.
[0140] Alternatively, if the integrated units described above in this application embodiment are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application embodiment, essentially or in other words, the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the methods described in the various embodiments of this application embodiment. The above descriptions are merely specific implementations of the embodiments of this application, but the protection scope of the embodiments of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the embodiments of this application should be included within the protection scope of the embodiments of this application. Therefore, the protection scope of the embodiments of this application should be determined by the protection scope of the claims.
Claims
1. A method of transferring audio data between an embedded operating system and a virtual operating system, characterized by, The method includes: An audio component is used to obtain a circular buffer for storing audio data in the embedded operating system, and a function instruction matching the audio component is sent to the sound card driver component in the embedded operating system. The sound card driver component responds to the function command and controls the virtual controller component to configure the virtual sound card component, thereby obtaining the configured virtual sound card component; wherein, the virtual controller component and the virtual sound card component run in the virtual operating system; The sound card driver component sends the function instruction to the configured virtual sound card component, and obtains a shared memory area in the embedded operating system for storing an address queue associated with the transmission process of the audio data, constructed based on the address of the circular buffer. The virtual sound card component configured as described responds to the function command and acquires and transmits the audio data based on the shared memory area.
2. The method of claim 1, wherein, The step of employing an audio component, acquiring a circular buffer for storing audio data in the embedded operating system, and sending a function instruction matching the audio component to the sound card driver component in the embedded operating system includes: The audio component responds to the startup operation by acquiring the circular buffer and generating a data loading thread; The audio component responds to the generation of the data loading thread by sending the function command to the sound card driver component.
3. The method of claim 1, wherein, The step of using the sound card driver component to respond to the function command and control the virtual controller component to configure the virtual sound card component to obtain the configured virtual sound card component includes: The sound card driver component responds to the function command, and the controller driver component obtains control information matching the function command; Using the controller driver component, the control information is written into the memory mapping area associated with the virtual controller component, so that the virtual controller component configures the virtual sound card component based on the control information, thereby obtaining the configured virtual sound card component.
4. The method of claim 1, wherein, The function instructions include audio playback instructions. The virtual sound card component, after configuration, responds to these function instructions by acquiring and transmitting the audio data based on the shared memory area, including: In response to the audio playback command, the configured virtual sound card component acquires and sends pre-playable audio data to the service buffer associated with the virtual sound card service component based on the pending playback address queue associated with the playback process of the audio data in the shared memory area; wherein, the address queue includes the pending playback address queue; The audio output component associated with the configured virtual sound card component responds to the pre-playback audio data written to the service buffer and outputs the pre-playback audio data.
5. The method of claim 4, wherein, The method further includes: In response to the audio playback command, the virtual sound card component with the above configuration generates and sends a space release command to the sound card driver component if it finds an address marked as the last bit in the address queue to be played from the shared memory area. The sound card driver component responds to the space release command by releasing the space in the shared memory area and sending the space release command to the audio component; The audio component responds to the space release command by releasing the space of the annular buffer.
6. The method of claim 1, wherein, The function instructions include audio recording instructions. The virtual sound card component, after configuration, responds to these function instructions by acquiring and transmitting the audio data based on the shared memory area, including: The audio input component associated with the configured virtual sound card component sends the received audio data to the loading area; wherein, the loading area is the region corresponding to the address in the address queue to be stored stored in the memory shared area; the address queue includes the address queue to be stored. The virtual sound card component with the above configuration responds to the audio recording command and stores the audio data based on the unloaded area where the audio data is written.
7. A device for transmitting audio data between an embedded operating system and a virtual operating system, characterized in that, The device includes: an audio component, a sound card driver component, and a virtual sound card component, wherein: The audio component is used to obtain a circular buffer for storing audio data in the embedded operating system and send functional instructions matching the audio component to the sound card driver component. The sound card driver component is used to respond to the function command and control the virtual controller component to configure the virtual sound card component to obtain the configured virtual sound card component; wherein, the virtual controller component and the virtual sound card component run in the virtual operating system; The sound card driver component is also used to send the function instructions to the configured virtual sound card component, and to obtain a shared memory area in the embedded operating system for storing an address queue associated with the transmission process of the audio data, constructed based on the address of the circular buffer. The virtual sound card component, after configuration, is used to acquire and transmit the audio data based on the shared memory area in response to the function command.
8. A computer device, comprising: The computer device includes a memory and a processor, the memory storing computer-executable instructions, and the processor, when executing the computer-executable instructions in the memory, is capable of implementing the method for transmitting audio data between an embedded operating system and a virtual operating system as described in any one of claims 1 to 6.
9. A computer storage medium, characterized in that The computer storage medium stores computer-executable instructions, which, when executed, enable the method for transmitting audio data between an embedded operating system and a virtual operating system as described in any one of claims 1 to 6.