WO2017005010A1 - 音频处理方法及设备、计算机存储介质 - Google Patents

音频处理方法及设备、计算机存储介质 Download PDF

Info

Publication number
WO2017005010A1
WO2017005010A1 PCT/CN2016/076802 CN2016076802W WO2017005010A1 WO 2017005010 A1 WO2017005010 A1 WO 2017005010A1 CN 2016076802 W CN2016076802 W CN 2016076802W WO 2017005010 A1 WO2017005010 A1 WO 2017005010A1
Authority
WO
WIPO (PCT)
Prior art keywords
buffer
mix
dma
virtual sound
sound card
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Ceased
Application number
PCT/CN2016/076802
Other languages
English (en)
French (fr)
Inventor
杨爱民
于光海
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Sanechips Technology Co Ltd
Original Assignee
Sanechips Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Sanechips Technology Co Ltd filed Critical Sanechips Technology Co Ltd
Publication of WO2017005010A1 publication Critical patent/WO2017005010A1/zh
Anticipated expiration legal-status Critical
Ceased legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G10MUSICAL INSTRUMENTS; ACOUSTICS
    • G10LSPEECH ANALYSIS TECHNIQUES OR SPEECH SYNTHESIS; SPEECH RECOGNITION; SPEECH OR VOICE PROCESSING TECHNIQUES; SPEECH OR AUDIO CODING OR DECODING
    • G10L19/00Speech or audio signals analysis-synthesis techniques for redundancy reduction, e.g. in vocoders; Coding or decoding of speech or audio signals, using source filter models or psychoacoustic analysis

Definitions

  • the present invention relates to audio technologies in the field of embedded platforms, and in particular, to an audio processing method and device, and a computer storage medium.
  • the ear-back time (the time from the input of the microphone to the time of output from the TV) is above 120 milliseconds (ms), compared to the 40-second ear-back time of the iOS system.
  • the big ear return time affects the user experience.
  • the embodiment of the invention provides an audio processing method and device, and a computer storage medium, which can reduce the ear return time of the Android device.
  • An embodiment of the present invention provides an audio processing method, where the method includes:
  • DMA direct memory read
  • the play buffer address and the recording buffer address are obtained in the soft interrupt of the mix, the mix processing function is called to perform the mixing process, and the processed mixed data is saved in the mix play buffer.
  • the method further includes:
  • the address of the mix play buffer is used to support the DMA function from the address data of the mix play buffer to the first in first out (FIFO) queue of the virtual sound card.
  • the method further includes:
  • the data of the sound mixing buffer is copied into the sound recording buffer, and the sound recording buffer is used to support the application layer to read the sound by opening the virtual sound card. After the audio data.
  • the method before the allocation of the mix play buffer and the mix recording buffer in the memory space, the method further includes:
  • the method further includes:
  • a normal recording buffer is allocated to the DMA buffer, and the normal recording buffer is used to support the application layer to read the original audio data input by the microphone by opening the virtual sound card.
  • An embodiment of the present invention provides an audio processing device, where the device includes:
  • a buffer unit configured to allocate a memory space for the DMA buffer, where the DMA buffer includes a mix play buffer and a mix recording buffer;
  • a soft interrupt declaration unit configured to declare a name of a soft interrupt that handles the mix and a corresponding processing function
  • the soft interrupt processing unit is configured to acquire the play buffer address and the recording buffer address in the soft interrupt of the mix, call the mix processing function for mixing processing, and process the data after the mixing There is the mix play buffer.
  • the device further includes:
  • a mixing playback processing unit configured to assign an address of the sound mixing buffer to a source address of a DMA function pointer
  • the address of the mix play buffer is configured to support the DMA function from the address data of the mix play buffer to the FIFO queue of the virtual sound card.
  • the device further includes:
  • a sound recording processing unit configured to copy data of the sound mixing buffer into the sound recording buffer in an interrupt callback function of the DMA function, wherein the sound recording buffer is used to support an application layer Read the mixed audio data by turning on the virtual sound card.
  • the device further includes:
  • a registration unit configured to perform the following operations before the allocation of the mix play buffer and the mix recording buffer in the buffer unit memory space; registering the virtual sound card driver and the virtual sound card; registering the platform device and the platform device driver; registering the codec Device, Codec driver and Codec DAI.
  • the buffer unit is further configured to allocate a memory space normal play buffer for the DMA buffer, and the normal play buffer is configured to support the application layer to write audio data to be played by opening the virtual sound card;
  • the buffer unit is further configured to allocate a normal recording buffer to the DMA buffer, and the normal recording buffer is configured to support the application layer to read the original audio data input by the microphone by opening the virtual sound card.
  • an embodiment of the present invention provides a computer storage medium, where the computer storage medium stores executable instructions, and the executable instructions are used to execute an audio processing method provided by an embodiment of the present invention.
  • the play buffer address and the recording buffer address are obtained through the soft interrupt of the mix, and the mix processing function is called to perform the mixing process, for example, when running on the ARM processor.
  • the mixing processing at the Linux kernel level is realized (instead of the mixing processing implemented by the related technology in the application layer), and the mixing processing result is provided to the application layer, and the application layer does not need to perform the mixing processing by itself.
  • the application layer of the related art directly performs the mixing process to greatly shorten the ear return delay.
  • FIG. 1 is a schematic flowchart of an implementation process of an audio processing method according to an embodiment of the present invention
  • FIG. 2 is a flowchart of an ASoC-based audio processing method according to an embodiment of the present invention
  • FIG. 3 is a flowchart of a call of a soc_probe function according to an embodiment of the present invention.
  • FIG. 5 is a flowchart of a snd_soc_instantiate_card function call according to an embodiment of the present invention
  • FIG. 6 is a schematic diagram of a virtual sound card being mounted under a snd_card according to an embodiment of the present invention
  • FIG. 7 is a flowchart of a tasklet mixing according to an embodiment of the present invention.
  • FIG. 8 is a first schematic structural diagram of an audio processing device according to an embodiment of the present invention.
  • FIG. 9 is a second schematic structural diagram of an audio processing device according to an embodiment of the present invention.
  • Android devices have a relatively standard and robust architecture for processing audio.
  • the architecture includes: application layer, Java framework service Audio Mananger, local service Audio Flinger, abstraction layer Alsa HAL, local library, external (external) Alsa-lib support library, The underlying coding (Codec) driver;
  • the audio processing device described in the embodiment of the present invention is an Advanced Linux Sound Architecture (ALSA) based on Android, and is based on an Android device, an Advanced RISC Machine (ARM) device, and a Linux device running on an Android device.
  • the virtual sound card is added to the device list of the kernel, and the virtual sound card directly intercepts the audio data (such as the audio data input by the user through the microphone) and the background audio data (the background sound of the song playing) for mixing processing, and the application layer can directly obtain the mixed sound. Sound data, no need to be mixed by the application layer itself, reducing the ear return time;
  • a virtual sound card device (referred to as a virtual sound card) is added to the device list of the Linux kernel, and the virtual sound card resource is registered into the Linux.
  • the kernel is managed by the Linux kernel;
  • the audio processing device provided in this embodiment is based on the ALSA architecture of the system-on-a-chip (SOC), that is, ASOC, and the ASoC runs the Linux kernel for audio processing.
  • the Linux kernel running in the ASoC is provided with a virtual sound card, a Platform, a virtual sound card Codec, and a virtual sound card Codec driver.
  • the audio data is processed by the virtual sound card at the Linux kernel level (instead of the application layer), and the Linux kernel is added with a normal play buffer, a normal recording buffer, a mix play buffer, and a mix recording buffer for different
  • the application scene stores audio data, and the two channels of data are mixed by soft interrupt when the recorded data and the play data arrive, and the application layer can directly read the mixed data.
  • the driver of the virtual sound card is set under the driver management and registration mechanism of the Linux, including: defining the platform device (platform_device) structure corresponding to the virtual sound card, registering the platform_device structure corresponding to the virtual sound card, and defining the platform driver (platform_driver) structure corresponding to the virtual sound card. Body, and the platform_driver structure of the registered virtual sound card; adding virtual sound card, Platform, virtual sound card Codec and virtual sound card Codec driver processing follows the Linux driver Management and registration mechanism;
  • the Linux kernel running on the Android device includes a bus, that is, a virtual bus or platform bus, a platform device (platform_device), and a platform driver (platform_driver); the virtual bus binds the platform device and the platform driver: registering a platform driver At the time, the virtual bus looks for platform devices that match the platform drivers.
  • Virtual sound card resource registration and mixing soft interrupt (Tasklet) processing if you want a virtual sound card to work properly, you need to complete three steps: 1, virtual sound card driver and virtual sound card registration; 2, platform equipment and platform device driver
  • the registration of the platform device mainly implements the direct memory access (DMA) function.
  • the name of the platform device driver is consistent with the name of the platform device: 3.
  • the registration of the virtual sound card driver and the virtual sound card device (referred to as the virtual sound card), the name of the virtual sound card driver must be the same as the name of the platform device:
  • the resource information of the virtual sound card is described by the platform_device structure, which includes the name (name), the identifier (ID) of the virtual sound card, the codec resource of the defined virtual sound card, and the resource of the Codec of the virtual sound card. The number of bytes occupied.
  • platform device implements DMA function, platform driver name and platform device name are the same, both are zx-audio-platform:
  • the buffer contains The normal play buffer, the normal recording buffer, the mix play buffer, and the mix recording buffer are configured to store audio data for different application scenarios;
  • the soft break (tasklet) processing function is configured to process audio data input by the user through the microphone and Mixing of background audio.
  • Step 101 Allocate a memory space for a direct memory read (DMA) buffer, where the DMA buffer includes a mix play buffer and a mix recording buffer.
  • DMA direct memory read
  • Step 102 declaring the name of the soft interrupt handling the mix and the corresponding processing function.
  • Step 103 Acquire a play buffer address and a recording buffer address in the soft interrupt of the mix, call a mix processing function to perform a mixing process, and save the processed data in the mix play buffer.
  • the address of the mix play buffer is assigned a source address of the DMA function pointer; the DMA function is based on the address of the mix play buffer, from the address of the mix play buffer Data to the virtual sound card's first in first out (FIFO) queue.
  • FIFO first in first out
  • the data of the sound mixing buffer is copied into the sound recording buffer, and the sound recording buffer is used to support the application layer. Turn on the virtual sound card to read the audio data after the mix.
  • a normal play buffer is allocated for the DMA buffer, and the normal play buffer is used to support the application layer by opening the virtual
  • the sound card writes audio data that needs to be played;
  • the normal recording buffer is allocated to the DMA buffer, and the normal recording buffer is used to support the application layer to read the original audio data input by the microphone by opening the virtual sound card.
  • the following describes an audio processing method shown in FIG. 2 for an Android device such as a set top box running the above Linux kernel, including the following steps:
  • step 201 the platform bus matches the device and driver whose names are virtual sound cards.
  • step 202 also triggers the invocation of the soc_probe function, which is the entry for the entire ASoC driver initialization.
  • platform_driver if there is platform_device, there will be platform_driver.
  • the name field in the AS_C platform_driver is soc-audio, which is exactly the same as the name in the platform_device defined in step 1.
  • the platform bus will Matching the two devices and drivers with the same name will also trigger the call to soc_probe, which is the entry point for the entire ASoC driver initialization.
  • Step 202 Call the soc_probe function.
  • the call to the soc_probe function includes the following steps:
  • step 301 the snd_soc_register_card is called in the soc_probe function to apply for memory for the snd_soc_pcm_runtime array, and each dai_link corresponds to a unit of the snd_soc_pcm_runtime array.
  • Step 302 Copy the dai_link configuration in the snd_soc_card to the corresponding snd_soc_pcm_runtime.
  • step 303 the snd_soc_instantiate_card function is called.
  • Card->rtd kzalloc(sizeof(struct snd_soc_pcm_runtime)*(card->num_links+card->num_aux_devs), GFP_KERNEL)
  • Step 203 The snd_soc_instantiate_card function call process, The snd_soc_instantiate_card function traverses each pair of dai_links, binds Codec, Platform, and DAI, and the snd_soc_instantiate_card function calls the soc_probe_dai_link function.
  • the call flow of the soc_probe_dai_link function is shown in Figure 4.
  • the soc_probe_dai_link function the Codec, DAI, and platform-driven probes are called.
  • the soc_new_pcm() function is also called at the end to create a virtual sound card.
  • step 401 card->instantiated is used to determine whether the virtual sound card has been instantiated, and if it has been instantiated, it returns directly.
  • step 402 each pair of dai_links is traversed, and the binding of codec, platform, and DAI is performed.
  • step 403 the register buffer of Codec is initialized.
  • step 404 a virtual sound card is created.
  • FIG. 6 A schematic diagram of the virtual sound card being mounted under the snd_card is shown in FIG. 6.
  • step 405 the probe function of each substructure is called in turn.
  • step 406 the soc_probe_dai_link() function is executed.
  • Step 407 initialization and setting.
  • step 408 the virtual sound card is registered by calling the sound card registration function driven by the standard ALSA.
  • Step 204 The audio data input by the user through the microphone and the audio data of the background music are processed and mixed by processing a soft break of the mix.
  • step 204 is implemented by the following steps:
  • Step 501 Define a structure of a record buffer, including a normal play buffer, a normal recording buffer, a mix play buffer, and a mix recording buffer, and store audio data for different application scenarios.
  • the code is as follows:
  • the four pointers are assigned respectively.
  • Step 502 declaring the name of the tasklet that processes the mix and the corresponding processing function, that is, DECLARE_TASKLET (zx_i2s_spdif_mix_tasklet, zx_snd_soc_mix_taskelet, 0).
  • step 503 the tasklet is initialized in the DMA interrupt callback function (only needs to be initialized once), and the tasklet_schedule is called to dispatch the tasklet.
  • Step 504 Obtain a mix play buffer address and a mix recording buffer address in the mixed tasklet, call a mix processing function to perform a mix process, and save the processed data in the mix play buffer.
  • step 505a when the mixing is played, the address of the mixing play buffer is assigned to the source address of the DMA pointer, and the DMA transfers data from the address to the first-in-first-out (FIFO) queue of the virtual sound card, thereby realizing the mixing play. .
  • FIFO first-in-first-out
  • Step 506b when the sound recording is realized, in the DMA interrupt callback function, the data of the sound mixing buffer is copied into the sound recording buffer, and the application layer can read the mixed audio data by opening the virtual sound card. Normal play.
  • the tasklet mechanism is a relatively common mechanism, usually used to reduce the interrupt processing time, which should be in the interrupt service routine.
  • the completed task is converted to a soft interrupt completion.
  • the addresses of the normal play buffer, the normal recording buffer, and the mix play buffer are recorded as parameters, and the mixing process is performed by the following mixing algorithm:
  • tasklet_init &zx_i2s_spdif_mix_tasklet, zx_snd_soc_mix_taskelet, (unsigned long) arg) of the mix is registered for the first time, and tasklet_schedule(&zx_i2s_spdif_mix_tasklet) is called;
  • the DMA interrupt callback processing function firstly assign the stream pointer of the recorded data and the playback data to the global variable pcm_substream, and then pass the two-way audio stream pointer to the tasklet of the mixing process through the global variable. Finally, in the task bar of the mixing process, the two pointers are respectively applied to the above-mentioned mixing algorithm, and after the algorithm is processed, the mixed data is obtained (the data is stored in the buffer pointed to by the mixing play pointer). If the data for DMA transfer is 1 KB, the size of the recorded data and the playback data is 1 KB each time the mix is mixed, and the data of the mix output is still 1 KB.
  • the mixed data is played and the audio data is obtained through the virtual sound card. Therefore, in the DMA interrupt processing function, the physical address pointer of the DMA at the time of playback needs to be replaced with the mixed after the mixing processing. DMA physical address pointer for audio data playback, so After the change, the originally played sound data is replaced with the data after the mixing process, and the data of the sound mixing buffer is copied to the buffer pointed to by the sound recording buffer pointer, and snd_pcm_period_elapsed is called to notify the Linux kernel. The current data has been processed.
  • the data can be read by opening the device dev/snd/pcmC0D0c.
  • the application layer wants to play the sound it can be written by opening the dev/snd/pcmC1D0p device.
  • the function of mixing the device dev/snd/pcmC0D0c and the device dev/snd/pcmC1D0p can be realized by opening the dev/snd/pcmC2D0p device to write data.
  • the dev/snd/pcmC2D0c device can be opened to read the mixed data and send it to other nodes on the network.
  • the function pointer that needs to be transmitted in the function for processing the mix points to the mix play buffer, that is, the pointer records the virtual address, so it is necessary to allocate the record mix.
  • the dma_alloc_coherent is called to record the virtual address and the physical address of the buffer of the mixing process, and the virtual address and the physical address of the buffer of the mixing process are in a one-to-one correspondence, so that the buffer is processed into the buffer.
  • the virtual address writes data, it can be handled by transferring the physical address of the buffer of the mixing process to the DMA.
  • Two sets of resources are defined, which describe the resources of a virtual sound card.
  • the first group describes the bus address range occupied by the virtual sound card.
  • IORESOURCE_MEM indicates that the first group describes the memory type resource information, and the second group describes this.
  • the interrupt number of the mixing device, IORESOURCE_IRQ indicates that the second group describes the interrupt resource information, and the virtual sound card driver obtains the corresponding resource information according to the flags.
  • platform_device Based on the resource information, you can define platform_device. After defining the platform_device structure, you can call the function platform_add_devices to add a virtual sound card to the Linux system.
  • the virtual sound card can be registered by calling platform_device_register(). For the virtual sound card Codec device, only the name and ID identifier need to be defined.
  • the virtual sound card and the virtual sound card Codec will be added to the Linux system's device list.
  • the soc_new_pcm function in the Linux kernel will call the function that requests the memory space for the virtual sound card. This address space is used to record the data after the mixing process.
  • the DMA interrupt callback function the physics corresponding to the memory buffer processed by the mix is processed. The address is allocated to the DMA for mixing playback, and the mixing processing is completed based on the tasklet.
  • the tasklet reads the DMA-transferred microphone data and the background music sent by the application layer for the mixing process, and processes the recorded and played data.
  • the size is currently 1K of data per processing, and the data after mixing is also 1K.
  • the user can play back the mix by reading and writing /dev/snd/pcmC2D0p, and the mix can be recorded by dev/snd/pcmC2D0c.
  • the ear return time of the mixing scheme based on the technical solution of the embodiment of the present invention is reduced to 60 ms, which can meet the demand of the product.
  • the embodiment of the invention further describes a computer storage medium, wherein the computer storage medium stores executable instructions, and the executable instructions are used to execute the audio processing method shown in FIG. 1 or FIG.
  • the embodiment of the invention describes an audio processing device based on the Linux kernel, which performs mixing processing at the kernel level based on the running Linux kernel. As shown in FIG. 8, the device includes:
  • the buffer unit 100 is configured to allocate a memory space for the direct memory read DMA buffer, where the DMA buffer includes a mix play buffer and a mix recording buffer;
  • a soft interrupt declaration unit 200 configured to declare a name of a soft interrupt for processing a mix and a corresponding processing function
  • Soft interrupt processing unit 300 configured to acquire a play buffer address and a soft interrupt in the mix Record the buffer address, call the mix processing function to perform the mixing process, and save the processed data in the mix play buffer.
  • the device further includes:
  • the mixing playback processing unit 400 is connected to the soft interrupt processing unit 300, and configured to assign an address of the sound mixing buffer to a source address of the DMA function pointer;
  • the address of the mix play buffer is used to support the DMA function from the address data of the mix play buffer to the first in first out FIFO queue of the virtual sound card.
  • the device further includes:
  • the sound recording processing unit 500 is connected to the soft interrupt processing unit 300, and configured to copy the data of the sound mixing buffer into the sound recording buffer in the interrupt callback function of the DMA function, the mixing The tone recording buffer is used to support the application layer to read the mixed audio data by turning on the virtual sound card.
  • the device further includes:
  • the registration unit 600 is connected to the buffer unit 100, and configured to perform the following operations before registering the sound mixing buffer and the mixing recording buffer in the memory space of the buffer unit 100; registering the virtual sound card driver and the virtual sound card; Device and platform device drivers; registered codec Codec devices, Codec drivers and Codec digital audio interfaces DAI.
  • the buffer unit 100 is further configured to allocate a memory space normal play buffer for the DMA buffer, and the normal play buffer is used to support the application layer to write audio data to be played by opening the virtual sound card;
  • the buffer unit 100 is further configured to allocate a normal recording buffer to the DMA buffer, and the normal recording buffer is configured to support the application layer to read the original audio data input by the microphone by opening the virtual sound card.
  • Each of the above units is a virtual functional unit, and the actual application can be implemented by an ASoC such as a processor in a set top box (such as an ARM processor), a logic programmable gate array (FPGA), or a dedicated integrated power supply. Road (ASIC) implementation.
  • ASoC such as a processor in a set top box (such as an ARM processor), a logic programmable gate array (FPGA), or a dedicated integrated power supply. Road (ASIC) implementation.
  • the embodiment of the invention further provides a computer storage medium, wherein the computer storage medium stores executable instructions, and the executable instructions are used to execute the audio processing method described in the embodiment of the invention.
  • the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed.
  • the foregoing storage medium includes: a mobile storage device, a random access memory (RAM), a read-only memory (ROM), a magnetic disk, or an optical disk.
  • RAM random access memory
  • ROM read-only memory
  • magnetic disk or an optical disk.
  • optical disk A medium that can store program code.
  • the above-described integrated unit of the present invention may be stored in a computer readable storage medium if it is implemented in the form of a software function module and sold or used as a standalone product.
  • the technical solution of the embodiments of the present invention may be embodied in the form of a software product in essence or in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for making
  • a computer device which may be a personal computer, server, or network device, etc.
  • the foregoing storage medium includes various media that can store program codes, such as a mobile storage device, a RAM, a ROM, a magnetic disk, or an optical disk.

Landscapes

  • Engineering & Computer Science (AREA)
  • Computational Linguistics (AREA)
  • Signal Processing (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • Acoustics & Sound (AREA)
  • Multimedia (AREA)
  • Circuit For Audible Band Transducer (AREA)
  • Reverberation, Karaoke And Other Acoustics (AREA)

Abstract

公开一种音频处理方法和设备、计算机存储介质,方法包括:为DMA缓冲区分配内存空间,DMA缓冲区包括混音播放缓冲区和混音录制缓冲区;声明处理混音的软中断的名称以及对应的处理函数;在混音的软中断中获取播放缓冲区地址和录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保存在混音播放缓冲区。

Description

音频处理方法及设备、计算机存储介质 技术领域
本发明涉及嵌入式平台领域的音频技术,尤其涉及一种音频处理方法及设备、计算机存储介质。
背景技术
伴随着顶部(OTT,Over The Top)机顶盒业务的兴起,在机顶盒上安装K歌软件来实现在家庭里面实现卡拉OK的需求倍增。而目前基于Android的设备上,耳返时间(声音从麦克风输入的时间到从电视里面输出的延时)都在120毫秒(ms)以上,相对于iOS系统的40ms的耳返时间来说,较大耳返时间影响了用户使用体验。
对于有效减小基于Android设备的耳返时间,相关技术尚无有效解决方案。
发明内容
本发明实施例提供一种音频处理方法及设备、计算机存储介质,能够减少Android设备的耳返时间。
本发明实施例的技术方案是这样实现的:
本发明实施例提供一种音频处理方法,所述方法包括:
为直接内存读取(DMA)缓冲区分配内存空间,所述DMA缓冲区包括混音播放缓冲区和混音录制缓冲区;
声明处理混音的软中断的名称以及对应的处理函数;
在混音的软中断中获取播放缓冲区地址和录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保存在所述混音播放缓冲区。
优选地,所述方法还包括:
将所述混音播放缓冲区的地址赋值给DMA功能指针的源地址;
所述混音播放缓冲区的地址用于支持所述DMA功能从所述混音播放缓冲区的地址数据到虚拟声卡的先入先出(FIFO)队列。
优选地,所述方法还包括:
在DMA功能的中断回调函数中,将所述混音播放缓冲区的数据拷贝到所述混音录制缓冲区中,所述混音录制缓冲区用于支持应用层通过打开虚拟声卡读取混音后的音频数据。
优选地,在内存空间分配混音播放缓冲区和混音录制缓冲区之前,所述方法还包括:
注册虚拟声卡驱动和虚拟声卡;
注册平台设备和平台设备驱动;
注册编解码器(Codec)设备、Codec驱动和Codec数字音频接口(DAI)。
优选地,所述方法还包括:
为所述DMA缓冲区分配内存空间正常播放缓冲区,所述正常播放缓冲区用于支持应用层通过打开虚拟声卡写入需要播放的音频数据;
为所述DMA缓冲区分配正常录制缓冲区,所述正常录制缓冲区用于支持应用层通过打开所述虚拟声卡读取麦克风输入的原始音频数据。
本发明实施例提供一种音频处理设备,所述设备包括:
缓冲区单元,配置为为DMA缓冲区分配内存空间,所述DMA缓冲区包括混音播放缓冲区和混音录制缓冲区;
软中断声明单元,配置为声明处理混音的软中断的名称以及对应的处理函数;
软中断处理单元,配置为在混音的软中断中获取播放缓冲区地址和录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保 存在所述混音播放缓冲区。
优选地,所述设备还包括:
混音播放处理单元,配置为将所述混音播放缓冲区的地址赋值给DMA功能指针的源地址;
所述混音播放缓冲区的地址配置为支持所述DMA功能从所述混音播放缓冲区的地址数据到虚拟声卡的FIFO队列。
优选地,所述设备还包括:
混音录制处理单元,配置为在DMA功能的中断回调函数中,将所述混音播放缓冲区的数据拷贝到所述混音录制缓冲区中,所述混音录制缓冲区用于支持应用层通过打开虚拟声卡读取混音后的音频数据。
优选地,所述设备还包括:
注册单元,配置为在所述缓冲区单元内存空间分配混音播放缓冲区和混音录制缓冲区之前,执行以下操作;注册虚拟声卡驱动和虚拟声卡;注册平台设备和平台设备驱动;注册编解码器设备、Codec驱动和Codec DAI。
优选地,所述缓冲区单元还配置为为所述DMA缓冲区分配内存空间正常播放缓冲区,所述正常播放缓冲区用于支持应用层通过打开虚拟声卡写入需要播放的音频数据;
所述缓冲区单元还配置为为所述DMA缓冲区分配正常录制缓冲区,所述正常录制缓冲区用于支持应用层通过打开所述虚拟声卡读取麦克风输入的原始音频数据。
第三方面,本发明实施例提供一种计算机存储介质,所述计算机存储介质中存储有可执行指令,所述可执行指令用于执行本发明实施例提供的音频处理方法。
本发明实施例中,通过混音的软中断中获取播放缓冲区地址和录制缓冲区地址,调用混音处理函数进行混音处理,例如当在ARM处理器上运行 Android操作系统时,实现了在Linux内核层面的混音处理(代替了相关技术在应用层实现的混音处理),将混音处理结果提供给应用层,无需应用层自行进行混音处理,较相关技术的应用层自行进行混音处理大大缩短了耳返延时。
附图说明
图1为本发明实施例中音频处理方法的实现流程示意图;
图2为本发明实施例中基于ASoC的音频处理方法的流程图;
图3为本发明实施例中soc_probe函数的调用流程图;
图4为本发明实施例中soc_probe_dai_link()函数流程图;
图5为本发明实施例中snd_soc_instantiate_card函数调用流程图;
图6为本发明实施例中虚拟声卡挂载在snd_card下的示意图;
图7为本发明实施例中tasklet混音流程图;
图8为本发明实施例中音频处理设备的功能结构示意图一;
图9为本发明实施例中音频处理设备的功能结构示意图二。
具体实施方式
为了使本发明的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本发明进行进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
Android设备拥有一个比较标准和健全的架构处理音频,架构包括:应用层、Java framework服务Audio Mananger、本地服务Audio Flinger、抽象层Alsa HAL、本地库、用外部(external)的Alsa-lib支持库、底层的编码(Codec)驱动;
因为音频数据在上述架构中经过了太多的处理而导致音频延时增加,这样复杂的系统架构是不能满足实时性要求很高的场景的使用需求,例如 网络K歌,需要将混音后的数据发送给网络上的其他点播用户,较大的延迟影响了用户使用体验。
本发明实施例记载的音频处理设备为基于高级Linux音频架构(ALSA,Advanced Linux Sound Architecture)Android,基于Android设备中高级精简指令集机器(ARM,Advanced RISC Machine)处理器,在Android设备运行的Linux内核的设备链表中添加设置虚拟声卡,使用虚拟声卡直接截取音频数据(例如用户通过麦克风输入的音频数据)和背景音频数据(歌曲播放的背景音)来进行混音处理,应用层可以直接获取混音数据,无需由应用层自身进行混音处理,减少了耳返时间;
为实现上述目的,本发明实施例中,针对已有的Linux内核下不能进行混音的不足,在Linux内核的设备链表上添加虚拟声卡设备(简称虚拟声卡),将虚拟声卡的资源注册进Linux内核,由Linux内核统一管理;
本实施例提供的音频处理设备基于ALSA架构的片上系统(SOC)也即ASoC,ASoC运行Linux内核进行音频处理,ASoC运行的Linux内核中设置有虚拟声卡、Platform、虚拟声卡Codec和虚拟声卡Codec驱动,由虚拟声卡在Linux内核层面(代替应用层)对音频数据进行处理,Linux内核添加设置有正常播放缓冲区、正常录制缓冲区、混音播放缓冲区和混音录制缓冲区,用于在不同的应用场景存储音频数据,在录制数据和播放数据到达时通过软中断的方式将两路数据进行混音处理,应用层可以直接读取混音数据。
在Linux的驱动管理和注册机制下设置虚拟声卡的驱动,包括:定义虚拟声卡对应的平台设备(platform_device)结构体、注册虚拟声卡对应的platform_device结构体、定义虚拟声卡对应的平台驱动(platform_driver)结构体、以及注册虚拟声卡的platform_driver结构体;添加虚拟声卡、Platform、虚拟声卡Codec和虚拟声卡Codec驱动的处理遵循Linux的驱动 管理和注册机制;
以下对设置虚拟声卡、Platform、虚拟声卡Codec和虚拟声卡Codec驱动的处理进行说明,对于未尽的细节,请参见Linux的驱动管理和注册机制的相关规范文档。
Android设备中所运行的Linux内核中包括总线也即虚拟总线或平台(platform)总线、平台设备(platform_device)和平台驱动(platform_driver);虚拟总线将平台设备和平台驱动绑定:在注册一个平台驱动的时候,虚拟总线寻找与平台驱动匹配的平台设备。
虚拟声卡的资源注册与混音软中断(Tasklet)的处理,如果要想一个虚拟声卡正常工作,需要完成三个步骤:1、虚拟声卡驱动和虚拟声卡的注册;2、平台设备和平台设备驱动的注册,平台设备主要实现直接内存存取(DMA,Direct Memory Asset)功能,平台设备驱动的名称和平台设备的名称一致:3、编解码器(Codec)设备(简称Codec)、Codec驱动和Codec数字音频接口(DAI,Digital Aaudio Interface)的注册;下面分别进行说明:
1.虚拟声卡驱动和虚拟声卡设备(简称虚拟声卡)的注册,虚拟声卡驱动的名称必须和平台设备的名称一致:
1)设置虚拟声卡驱动,相关代码如下:
Figure PCTCN2016076802-appb-000001
2)注册虚拟声卡驱动,相关代码如下:
Figure PCTCN2016076802-appb-000002
3)设置虚拟声卡,包括虚拟声卡在内存中所占用的物理地址的开始和结束地址、以及相关标志位。
虚拟声卡的资源信息用platform_device结构体描述,platform_device结构体包含虚拟声卡的名称(name)、标识(ID),与定义的虚拟声卡的编解码器(Codec)的资源以及虚拟声卡的Codec的资源所占用的字节数目。
相关代码如下:
Figure PCTCN2016076802-appb-000003
4)注册虚拟声卡的资源(zx_devices为包含了所有定义的虚拟设备的数组),相关代码如下:
platform_add_devices(zx_devices,ARRAY_SIZE(zx_devices))
5)注册虚拟声卡,相关代码如下:
Figure PCTCN2016076802-appb-000004
Figure PCTCN2016076802-appb-000005
2、平台设备和平台驱动的注册,平台设备实现DMA功能,平台驱动的名称和平台设备的名称一致,均为zx-audio-platform:
1)平台驱动的设置,相关代码如下:
Figure PCTCN2016076802-appb-000006
2)平台驱动的注册,相关代码如下:
Figure PCTCN2016076802-appb-000007
3)平台设备的设置,相关代码如下:
Figure PCTCN2016076802-appb-000008
4)平台设备的注册:
platform_add_devices(zx_devices,ARRAY_SIZE(zx_devices));
3、Codec、Codec驱动和Codec DAI的注册。
1)Codec驱动的定义,相关代码如下:
Figure PCTCN2016076802-appb-000009
2)虚拟Codec驱动的注册,相关代码如下:
Figure PCTCN2016076802-appb-000010
3)虚拟Codec设备的定义,相关代码如下:
Figure PCTCN2016076802-appb-000011
4)虚拟Codec设备的注册,相关代码如下:
platform_add_devices(zx_devices,ARRAY_SIZE(zx_devices));
5)Codec DAI的定义,相关代码如下:
Figure PCTCN2016076802-appb-000012
Figure PCTCN2016076802-appb-000013
6)Codec DAI的注册,相关代码如下:
Figure PCTCN2016076802-appb-000014
除了根据上述步骤在Linux内核中设置虚拟声卡、Platform、虚拟声卡Codec和虚拟声卡Codec驱动,还需要设置记录缓冲区的结构体以及处理混音的软中断(tasklet)处理函数;其中,缓冲区包含正常播放缓冲区、正常录制缓冲区、混音播放缓冲区和混音录制缓冲区,配置为不同的应用场景存储音频数据;软中断(tasklet)处理函数配置为处理用户通过麦克风输入的音频数据和背景音频进行的混音。
如图1所示,基于运行上述Linux内核的Android设备如机顶盒,音频 处理方法包括以下步骤:
步骤101,为直接内存读取(DMA)缓冲区分配内存空间,所述DMA缓冲区包括混音播放缓冲区和混音录制缓冲区。
步骤102,声明处理混音的软中断的名称以及对应的处理函数。
步骤103,在混音的软中断中获取播放缓冲区地址和录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保存在混音播放缓冲区。
当需要混音播放时,将所述混音播放缓冲区的地址赋值DMA功能指针的源地址;所述DMA功能基于所述混音播放缓冲区的地址,从所述混音播放缓冲区的地址数据到虚拟声卡的先入先出(FIFO)队列。
当需要混音录制时,在DMA功能的中断回调函数中,将所述混音播放缓冲区的数据拷贝到所述混音录制缓冲区中,所述混音录制缓冲区用于支持应用层通过打开虚拟声卡读取混音后的音频数据。
此外,在执行上述操作之前,还需要在设置虚拟声卡,注册虚拟声卡驱动和虚拟声卡;注册平台设备和平台设备驱动;注册编解码器(Codec)设备、Codec驱动和Codec数字音频接口(DAI);注册平台设备和平台设备驱动用于实现DMA功能。
对于正常播放(也即非混音播放)之外的场景,当需要正常播放时,为所述DMA缓冲区分配内存空间正常播放缓冲区,所述正常播放缓冲区用于支持应用层通过打开虚拟声卡写入需要播放的音频数据;
当应用层需要获取麦克风输入的原始音频数据时,为所述DMA缓冲区分配正常录制缓冲区,所述正常录制缓冲区用于支持应用层通过打开所述虚拟声卡读取麦克风输入的原始音频数据。
下面就运行上述的Linux内核的Android设备如机顶盒实施图2所示的音频处理方法进行说明,包括以下步骤:
步骤201,平台总线匹配名称为虚拟声卡的device和driver。
后续步骤202同时会触发soc_probe函数的调用,soc_probe是整个ASoC驱动初始化的入口。
按照Linux的设备模型,有platform_device,就一定会有platform_driver,ASoC的platform_driver中的name字段为soc-audio,正好与在步骤1中定义的platform_device中的名称相同,按照Linux的设备模型,platform总线会匹配这两个名称相同的device和driver,同时会触发soc_probe的调用,它正是整个ASoC驱动初始化的入口。
步骤202:调用soc_probe函数。
如图3所示,soc_probe函数的调用包括如下步骤:
步骤301,在soc_probe函数中调用snd_soc_register_card为snd_soc_pcm_runtime数组申请内存,每一个dai_link对应snd_soc_pcm_runtime数组的一个单元。
步骤302,把snd_soc_card中的dai_link配置复制到相应的snd_soc_pcm_runtime中。
步骤303,调用snd_soc_instantiate_card函数。
soc_probe函数对应的代码如下所示:
snd_soc_card*card=platform_get_drvdata(pdev)
snd_soc_register_card(card)
card->rtd=kzalloc(sizeof(struct snd_soc_pcm_runtime)*(card->num_links+card->num_aux_devs),GFP_KERNEL)
for(i=0;i<card->num_links;i++)
          card->rtd[i].dai_link=
&card->dai_link[i]
snd_soc_instantiate_cards()
snd_soc_instantiate_card()
步骤203:snd_soc_instantiate_card函数调用流程, snd_soc_instantiate_card函数遍历每一对dai_link,进行Codec、Platform和DAI的绑定,snd_soc_instantiate_card函数调用soc_probe_dai_link函数,soc_probe_dai_link函数的调用流程如图4所示,在soc_probe_dai_link函数中,调用了Codec、DAI和platform驱动的probe函数外,在最后还调用了soc_new_pcm()函数用于创建虚拟声卡。
snd_soc_instantiate_card函数调用流程如图5所示,包括以下步骤:
步骤401,利用card->instantiated来判断虚拟声卡是否已经实例化,如果已经实例化则直接返回。
步骤402,遍历每一对dai_link,进行codec、platform和DAI的绑定。
步骤403,初始化Codec的寄存器缓存。
步骤404,创建虚拟声卡。
虚拟声卡挂载在snd_card下的示意图如图6所示。
步骤405,依次调用各个子结构的probe函数。
步骤406,执行soc_probe_dai_link()函数。
步骤407,初始化和设置。
步骤408,调用标准ALSA驱动的声卡注册函数对虚拟声卡进行注册。
步骤204:通过处理混音的软中断(tasklet),处理用户通过麦克风输入的音频数据和背景音乐的音频数据进行混音。
如图7所示,步骤204通过以下步骤实现:
步骤501,定义一个记录缓冲区的结构体,包含正常播放缓冲区、正常录制缓冲区、混音播放缓冲区和混音录制缓冲区,用于不同的应用场景存储音频数据,代码如下:
定义记录缓冲区的指针:
Figure PCTCN2016076802-appb-000015
Figure PCTCN2016076802-appb-000016
在为DMA缓冲区分配内核空间的函数中,分别将这4个指针赋值。
步骤502,声明处理混音的tasklet的名称以及对应的处理函数,即DECLARE_TASKLET(zx_i2s_spdif_mix_tasklet,zx_snd_soc_mix_taskelet,0)。
步骤503,tasklet在DMA的中断回调函数中初始化(只需要初始化一次),并调用tasklet_schedule来调度tasklet。
步骤504,在混音的tasklet中获取混音播放缓冲区地址和混音录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保存在混音播放缓冲区。
步骤505a,实现混音播放时,将混音播放缓冲区的地址赋值给DMA指针的源地址,让DMA从这个地址搬运数据到虚拟声卡的先入先出(FIFO)队列中,从而实现混音播放。
步骤506b,实现混音录制时,在DMA中断回调函数中,将混音播放缓冲区的数据拷贝到混音录制缓冲区中,应用层可以通过打开虚拟声卡读取混音后的音频数据,实现正常播放。
这样可以在每次录制数据和播放数据到达之后,将两路音频数据进行混音;tasklet机制是一种比较常见的机制,通常用于减少中断处理的时间,将本应该是在中断服务程序中完成的任务转换成软中断完成。
为了最大程度的避免中断处理时间过长(中断里面如果进行混音操作会导致中断处理时间过长)而导致中断丢失,把一些在中断处理中不是非常紧急的任务放在后面执行,而让中断处理程序尽快返回。
在tasklet处理中,将记录正常播放缓冲区、正常录制缓冲区和混音播放缓冲区的地址作为参数,通过如下混音算法进行混音处理:
使用A和B表示两路音频信号,使用Y表示混音后的音频信号。
对于n比特的音频样本信号,如果A和B都为负,则,
Y=A+B-(A*B/(-(2pow(n-1)-1)))
否则:
Y=A+B-(A*B/(2pow(n-1))。
C语言表示:
Figure PCTCN2016076802-appb-000017
在DMA中断回调处理函数中,第一次会注册混音的tasklet处理函数tasklet_init(&zx_i2s_spdif_mix_tasklet,zx_snd_soc_mix_taskelet,(unsigned long)arg),并调用tasklet_schedule(&zx_i2s_spdif_mix_tasklet);
在DMA中断回调处理函数中,首先分别将录音数据和放音数据的流指针赋值给全局变量pcm_substream,然后再通过这个全局变量将该这2路音频数据流指针传递到混音处理的tasklet中,最后在混音处理的tasklet中将这2个指针分别作用于上述的混音算法,经过该算法处理后,得到了混音后的数据(该数据存储在混音播放指针指向的缓冲区)。如果配置DMA搬运的数据为1KB,那么每次混音的时候,录音数据和播放数据的大小都为1KB,混音输出的数据依然为1KB。
由于混音后的数据要分两路处理,播放混音数据和通过虚拟声卡获取音频数据,因此在DMA中断处理函数中,需要将播放时候DMA的物理地址指针,替换成混音处理后的混音数据播放的DMA物理地址指针,这样替 换后,原来播放的声音数据就被替换成了混音处理后的数据,同时将混音播放缓冲区的数据拷贝到混音录制缓冲区指针所指向的缓冲区,同时调用snd_pcm_period_elapsed来通知Linux内核,当前的数据已经处理完毕。
当应用层层需要获取用户麦克风输入的原始音频数据,可以通过打开dev/snd/pcmC0D0c这个设备来读取数据,当应用层想播放声音的时候,可以通过打开dev/snd/pcmC1D0p这个设备来写入数据。当应用层想要直接播放混音数据的时候,可以通过打开dev/snd/pcmC2D0p这个设备来写入数据来实现将设备dev/snd/pcmC0D0c和设备dev/snd/pcmC1D0p声音混合的功能。当应用层想要通过网络传输混音后的数据时候,可以通过打开dev/snd/pcmC2D0c这个设备来读取混音后的数据,发给网络其他节点。
由于配置DMA的时候需要配置物理地址,而在处理混音的函数中需要传出的函数指针指向的是混音播放缓冲区,也即指针记录的是虚拟地址,因此需要在分配记录混音处理的缓冲区的时候,调用dma_alloc_coherent分别记录混音处理的缓冲区的虚拟地址和物理地址,混音处理的缓冲区的虚拟地址和物理地址是一一对应关系,这样向混音处理的缓冲区的虚拟地址写数据的时候,就可以通过将混音处理的缓冲区的物理地址传递给DMA来进行搬运处理。
本发明实施例的所涉及的虚拟声卡资源注册,主要是做如下工作:
定义了两组resource,它描述了一个虚拟声卡的资源,第1组描述了这个虚拟声卡所占用的总线地址范围,IORESOURCE_MEM表示第1组描述的是内存类型的资源信息,第2组描述了这个混音设备的中断号,IORESOURCE_IRQ表示第2组描述的是中断资源信息,虚拟声卡驱动会根据flags来获取相应的资源信息。
基于resource信息可以定义platform_device,定义platform_device结构体后可以调用函数platform_add_devices向Linux系统中添加虚拟声卡,之 后可以调用platform_device_register()进行对虚拟声卡进行注册,对于虚拟声卡Codec设备来说,只需要定义名称和ID标识符就可以。
调用platform_add_devices添加了虚拟声卡以及虚拟声卡Codec设备成功之后,虚拟声卡以及虚拟声卡Codec就会添加到Linux系统的设备链表中。
Linux内核中的soc_new_pcm函数会调用为虚拟声卡申请内存空间的函数,这个地址空间用来记录混音处理后的数据,在DMA的中断回调函数中,将混音处理过的内存缓冲区对应的物理地址配置给DMA,用来进行混音播放,而混音处理基于tasklet完成,tasklet每次读取DMA搬运来的麦克风数据和应用层下发的背景音乐进行混音处理,处理录制和播放的数据大小目前是每次处理1K的数据,混音后的数据也是1K。
当完成上述步骤时,用户可以通过读写/dev/snd/pcmC2D0p进行混音播放,可以通过dev/snd/pcmC2D0c进行混音录制。
经实际测试,基于本发明实施例的技术方案混音播放的耳返时间较减少至60ms,可以满足产品的需求。
本发明实施例还记载一种计算机存储介质,所述计算机存储介质中存储有可执行指令,所述可执行指令用于执行图1或图2所示的音频处理方法。
本发明实施例记载一种基于Linux内核的音频处理设备,基于运行的Linux内核在内核层面进行混音处理,如图8所示,设备包括:
缓冲区单元100,配置为为直接内存读取DMA缓冲区分配内存空间,所述DMA缓冲区包括混音播放缓冲区和混音录制缓冲区;
软中断声明单元200,配置为声明处理混音的软中断的名称以及对应的处理函数;
软中断处理单元300,配置为在混音的软中断中获取播放缓冲区地址和 录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保存在所述混音播放缓冲区。
作为一个示例,参见图9,所述设备还包括:
混音播放处理单元400,与软中断处理单元300连接,配置为将所述混音播放缓冲区的地址赋值给DMA功能指针的源地址;
所述混音播放缓冲区的地址用于支持所述DMA功能从所述混音播放缓冲区的地址数据到虚拟声卡的先入先出FIFO队列。
作为一个示例,参见图9,所述设备还包括:
混音录制处理单元500,与软中断处理单元300连接,配置为在DMA功能的中断回调函数中,将所述混音播放缓冲区的数据拷贝到所述混音录制缓冲区中,所述混音录制缓冲区用于支持应用层通过打开虚拟声卡读取混音后的音频数据。
作为一个示例,参见图9,所述设备还包括:
注册单元600,与缓冲区单元100连接,用于在所述缓冲区单元100内存空间分配混音播放缓冲区和混音录制缓冲区之前,执行以下操作;注册虚拟声卡驱动和虚拟声卡;注册平台设备和平台设备驱动;注册编解码器Codec设备、Codec驱动和Codec数字音频接口DAI。
作为一个示例,所述缓冲区单元100还配置为为所述DMA缓冲区分配内存空间正常播放缓冲区,所述正常播放缓冲区用于支持应用层通过打开虚拟声卡写入需要播放的音频数据;
所述缓冲区单元100还配置为为所述DMA缓冲区分配正常录制缓冲区,所述正常录制缓冲区用于支持应用层通过打开所述虚拟声卡读取麦克风输入的原始音频数据。
上述各单元均为虚拟的功能单元,实际应用中可以由ASoC如机顶盒中的处理器(如ARM处理器)、逻辑可编程门阵列(FPGA)或专用集成电 路(ASIC)实现。
本发明实施例还提供一种计算机存储介质,所述计算机存储介质中存储有可执行指令,所述可执行指令用于执行本发明实施例记载的音频处理方法。
本领域普通技术人员可以理解:实现上述方法实施例的全部或部分步骤可以通过程序指令相关的硬件来完成,前述的程序可以存储于一计算机可读取存储介质中,该程序在执行时,执行包括上述方法实施例的步骤;而前述的存储介质包括:移动存储设备、随机存取存储器(RAM,Random Access Memory)、只读存储器(ROM,Read-Only Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
或者,本发明上述集成的单元如果以软件功能模块的形式实现并作为独立的产品销售或使用时,也可以存储在一个计算机可读取存储介质中。基于这样的理解,本发明实施例的技术方案本质上或者说对相关技术做出贡献的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机、服务器、或者网络设备等)执行本发明各个实施例所述方法的全部或部分。而前述的存储介质包括:移动存储设备、RAM、ROM、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,仅为本发明的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明揭露的技术范围内,可轻易想到变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应以所述权利要求的保护范围为准。

Claims (11)

  1. 一种音频处理方法,所述方法包括:
    为直接内存读取DMA缓冲区分配内存空间,所述DMA缓冲区包括混音播放缓冲区和混音录制缓冲区;
    声明处理混音的软中断的名称以及对应的处理函数;
    在混音的软中断中获取播放缓冲区地址和录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保存在所述混音播放缓冲区。
  2. 如权利要求1所述的方法,其中,所述方法还包括:
    将所述混音播放缓冲区的地址赋值给DMA功能指针的源地址;
    所述混音播放缓冲区的地址配置为支持所述DMA功能从所述混音播放缓冲区的地址数据到虚拟声卡的先入先出FIFO队列。
  3. 如权利要求1所述的方法,其中,所述方法还包括:
    在DMA功能的中断回调函数中,将所述混音播放缓冲区的数据拷贝到所述混音录制缓冲区中,所述混音录制缓冲区用于支持应用层通过打开虚拟声卡读取混音后的音频数据。
  4. 如权利要求1所述的方法,其中,在内存空间分配混音播放缓冲区和混音录制缓冲区之前,所述方法还包括:
    注册虚拟声卡驱动和虚拟声卡;
    注册平台设备和平台设备驱动;
    注册编解码器Codec设备、Codec驱动和Codec数字音频接口DAI。
  5. 如权利要求1至4任一项所述的方法,其中,所述方法还包括:
    为所述DMA缓冲区分配内存空间正常播放缓冲区,所述正常播放缓冲区用于支持应用层通过打开虚拟声卡写入需要播放的音频数据;
    为所述DMA缓冲区分配正常录制缓冲区,所述正常录制缓冲区用于支持应用层通过打开所述虚拟声卡读取麦克风输入的原始音频数据。
  6. 一种音频处理设备,所述设备包括:
    缓冲区单元,配置为为直接内存读取DMA缓冲区分配内存空间,所述DMA缓冲区包括混音播放缓冲区和混音录制缓冲区;
    软中断声明单元,声明处理混音的软中断的名称以及对应的处理函数;
    软中断处理单元,配置为在混音的软中断中获取播放缓冲区地址和录制缓冲区地址,调用混音处理函数进行混音处理,将处理混音后的数据保存在所述混音播放缓冲区。
  7. 如权利要求6所述的系统,其中,所述设备还包括:
    混音播放处理单元,配置为将所述混音播放缓冲区的地址赋值给DMA功能指针的源地址;
    所述混音播放缓冲区的地址用于支持所述DMA功能从所述混音播放缓冲区的地址数据到虚拟声卡的先入先出FIFO队列。
  8. 如权利要求6所述的系统,其中,所述设备还包括:
    混音录制处理单元,配置为在DMA功能的中断回调函数中,将所述混音播放缓冲区的数据拷贝到所述混音录制缓冲区中,所述混音录制缓冲区用于支持应用层通过打开虚拟声卡读取混音后的音频数据。
  9. 如权利要求6所述的系统,其中,所述设备还包括:
    注册单元,配置为在所述缓冲区单元内存空间分配混音播放缓冲区和混音录制缓冲区之前,执行以下操作;注册虚拟声卡驱动和虚拟声卡;注册平台设备和平台设备驱动;注册编解码器Codec设备、Codec驱动和Codec数字音频接口DAI。
  10. 如权利要求6至9任一项所述的系统,其中,
    所述缓冲区单元还配置为为所述DMA缓冲区分配内存空间正常播放缓冲区,所述正常播放缓冲区用于支持应用层通过打开虚拟声卡写入需要播放的音频数据;
    所述缓冲区单元还用于为为所述DMA缓冲区分配正常录制缓冲区,所述正常录制缓冲区用于支持应用层通过打开所述虚拟声卡读取麦克风输入的原始音频数据。
  11. 一种计算机存储介质,所述计算机存储介质中存储有可执行指令,所述可执行指令配置为执行权利要求1至5任一项所述的音频处理方法。
PCT/CN2016/076802 2015-07-03 2016-03-18 音频处理方法及设备、计算机存储介质 Ceased WO2017005010A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510390087.2A CN106325804B (zh) 2015-07-03 2015-07-03 音频处理方法及系统
CN201510390087.2 2015-07-03

Publications (1)

Publication Number Publication Date
WO2017005010A1 true WO2017005010A1 (zh) 2017-01-12

Family

ID=57684848

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/076802 Ceased WO2017005010A1 (zh) 2015-07-03 2016-03-18 音频处理方法及设备、计算机存储介质

Country Status (2)

Country Link
CN (1) CN106325804B (zh)
WO (1) WO2017005010A1 (zh)

Cited By (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109600691A (zh) * 2017-09-30 2019-04-09 深圳市魅鸟科技有限公司 一种车载智能WiFi麦克风及其音频延时处理方法
CN112615853A (zh) * 2020-12-16 2021-04-06 瑞芯微电子股份有限公司 一种Android设备音频数据接入方法
CN112988249A (zh) * 2021-03-23 2021-06-18 上海摩勤智能技术有限公司 创建声卡的方法、装置、电子设备及存储介质
CN113409808A (zh) * 2021-06-18 2021-09-17 上海盈方微电子有限公司 一种回声消除时延估算方法及回声消除方法
CN113965844A (zh) * 2021-12-22 2022-01-21 深圳市维海德技术股份有限公司 低延时音频传输方法、装置、驱动设备及可读存储介质
CN115312072A (zh) * 2022-08-04 2022-11-08 世邦通信股份有限公司 音频路由管理方法、系统及电子设备
CN116074688A (zh) * 2021-11-02 2023-05-05 腾讯科技(深圳)有限公司 音频播放方法、装置和计算机可读存储介质
CN118101629A (zh) * 2024-02-08 2024-05-28 北京都是科技有限公司 一种音频直播及音频处理方法、装置及存储介质
CN118522317A (zh) * 2023-09-21 2024-08-20 浙江工业大学 一种双螺旋式结构的录放音调度方法
CN119621622A (zh) * 2024-11-12 2025-03-14 广州创龙电子科技有限公司 一种基于alsa框架的多通道pcm数据实时采集输出系统及方法

Families Citing this family (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107483731A (zh) * 2017-08-18 2017-12-15 广东欧珀移动通信有限公司 音频播放音量的控制方法、装置及存储介质和移动终端
CN107992282B (zh) * 2017-11-29 2020-11-03 珠海市魅族科技有限公司 音频数据处理方法及装置、计算机装置及可读存储装置
CN110096250B (zh) * 2018-01-31 2020-05-29 北京金山云网络技术有限公司 一种音频数据处理方法、装置、电子设备及存储介质
CN109462796A (zh) * 2018-10-25 2019-03-12 歌尔股份有限公司 一种音频处理系统及音频设备
CN109348297B (zh) * 2018-11-28 2021-03-23 湖南快乐阳光互动娱乐传媒有限公司 一种数据获取方法及装置
CN110007975B (zh) * 2019-04-02 2021-11-12 思必驰科技股份有限公司 声卡自适应加载方法及系统
CN111586529A (zh) * 2020-05-08 2020-08-25 北京三体云联科技有限公司 音频数据处理方法、装置、终端和计算机可读存储介质
CN111654743B (zh) * 2020-05-27 2022-04-22 海信视像科技股份有限公司 音频播放方法及显示设备
CN113038238B (zh) * 2021-03-22 2023-07-07 格兰菲智能科技有限公司 传输流数据码录制系统及传输流数据码录制方法
CN113282271A (zh) * 2021-07-22 2021-08-20 北京麟卓信息科技有限公司 一种Linux平台上安卓应用的音频处理方法及装置
CN119049491A (zh) * 2024-07-18 2024-11-29 瑞芯微电子股份有限公司 音频处理方法、系统芯片和音频处理系统

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060010267A1 (en) * 2001-05-18 2006-01-12 Jorge Abullarade Method and apparatus for playing analog audio to multiple codec outputs
CN101661748A (zh) * 2009-09-15 2010-03-03 福州瑞芯微电子有限公司 一种音频设备中实现混音的方法
US20130212341A1 (en) * 2012-02-15 2013-08-15 Microsoft Corporation Mix buffers and command queues for audio blocks
CN103578512A (zh) * 2013-10-18 2014-02-12 三星电子(中国)研发中心 录音快速回放的方法及其装置
CN104637488A (zh) * 2013-11-07 2015-05-20 华为终端有限公司 声音处理的方法和终端设备

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100511154C (zh) * 2006-09-05 2009-07-08 中兴通讯股份有限公司 一种音频驱动程序声音管理方法
KR20120108570A (ko) * 2011-03-24 2012-10-05 삼성전자주식회사 오디오 장치, 및 그 동작 방법

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20060010267A1 (en) * 2001-05-18 2006-01-12 Jorge Abullarade Method and apparatus for playing analog audio to multiple codec outputs
CN101661748A (zh) * 2009-09-15 2010-03-03 福州瑞芯微电子有限公司 一种音频设备中实现混音的方法
US20130212341A1 (en) * 2012-02-15 2013-08-15 Microsoft Corporation Mix buffers and command queues for audio blocks
CN103578512A (zh) * 2013-10-18 2014-02-12 三星电子(中国)研发中心 录音快速回放的方法及其装置
CN104637488A (zh) * 2013-11-07 2015-05-20 华为终端有限公司 声音处理的方法和终端设备

Cited By (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109600691A (zh) * 2017-09-30 2019-04-09 深圳市魅鸟科技有限公司 一种车载智能WiFi麦克风及其音频延时处理方法
CN112615853A (zh) * 2020-12-16 2021-04-06 瑞芯微电子股份有限公司 一种Android设备音频数据接入方法
CN112988249A (zh) * 2021-03-23 2021-06-18 上海摩勤智能技术有限公司 创建声卡的方法、装置、电子设备及存储介质
CN112988249B (zh) * 2021-03-23 2024-05-28 上海摩勤智能技术有限公司 创建声卡的方法、装置、电子设备及存储介质
CN113409808A (zh) * 2021-06-18 2021-09-17 上海盈方微电子有限公司 一种回声消除时延估算方法及回声消除方法
CN113409808B (zh) * 2021-06-18 2024-05-03 上海盈方微电子有限公司 一种回声消除时延估算方法及回声消除方法
CN116074688A (zh) * 2021-11-02 2023-05-05 腾讯科技(深圳)有限公司 音频播放方法、装置和计算机可读存储介质
CN113965844A (zh) * 2021-12-22 2022-01-21 深圳市维海德技术股份有限公司 低延时音频传输方法、装置、驱动设备及可读存储介质
CN115312072A (zh) * 2022-08-04 2022-11-08 世邦通信股份有限公司 音频路由管理方法、系统及电子设备
CN118522317A (zh) * 2023-09-21 2024-08-20 浙江工业大学 一种双螺旋式结构的录放音调度方法
CN118101629A (zh) * 2024-02-08 2024-05-28 北京都是科技有限公司 一种音频直播及音频处理方法、装置及存储介质
CN119621622A (zh) * 2024-11-12 2025-03-14 广州创龙电子科技有限公司 一种基于alsa框架的多通道pcm数据实时采集输出系统及方法

Also Published As

Publication number Publication date
CN106325804B (zh) 2019-05-31
CN106325804A (zh) 2017-01-11

Similar Documents

Publication Publication Date Title
WO2017005010A1 (zh) 音频处理方法及设备、计算机存储介质
US11861203B2 (en) Method, apparatus and electronic device for cloud service migration
CN109313566B (zh) 一种虚拟机的音频播放方法及其装置、移动终端
US8489799B2 (en) Efficient loading of data into memory of a computing system
CN114302040B (zh) 多应用共享单一摄像头的方法及相关产品
CN112749022A (zh) 相机资源访问方法、操作系统、终端和虚拟相机
CN105630683B (zh) 一种云测试体系架构
US20250123908A1 (en) Method and apparatus for data sharing
US20140029764A1 (en) Virtual machine-based sound control for computerized devices in a networked computing environment
TW202447430A (zh) 安卓容器顯示系統的優化方法、電子設備和電腦可讀儲存媒體
WO2025161674A1 (zh) 网络报文处理方法、装置、计算机设备和存储介质
CN115794023A (zh) 一种数据传输方法、装置、设备及存储介质
CN117608757A (zh) 存储设备控制方法、装置、电子设备及存储介质
CN117349870A (zh) 基于异构计算的透明加解密计算系统、方法、设备和介质
CN109739487B (zh) 一种业务逻辑处理方法、设备及计算机可读存储介质
CN110096355B (zh) 一种共享资源分配方法、装置和设备
WO2025251806A1 (zh) 生成媒体的方法、装置、设备和存储介质
CN108829530A (zh) 一种图像处理方法及装置
US12093528B2 (en) System and method for managing data access in distributed systems
CN103533672B (zh) 一种无线卡拉ok系统及其内部数据交互方法
WO2024103927A1 (zh) 混合部署场景下的作业调度方法、装置及电子设备
CN117891624A (zh) 基于虚拟化设备的应用间通信方法、装置及电子设备
WO2017054379A1 (zh) 一种音频数据的处理方法、装置和系统
WO2024119930A1 (zh) 调度方法、装置、计算机设备和存储介质
CN115640175A (zh) 一种客户端mock测试的方法及系统

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16820665

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16820665

Country of ref document: EP

Kind code of ref document: A1