Audio stream processing method and device, computer equipment and storage medium
By creating input buffers and output buffers in audio stream processing, and detecting the audio source activation status and buffer status, the problem of stuck and POP sounds caused by out-of-clock transmission of multi-source audio stream data is solved, achieving seamless switching and Continuous transmission improves user experience.
Patent Information
- Application Number
- CN202310255356.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-09
- Publication Date
- 2024-09-10
AI Technical Summary
During the audio stream data processing process of multiple audio sources, the data transmission between the input source and the output source is not clocked, resulting in freezes or POP sounds, and seamless switching cannot be achieved, causing inconvenience to users.
The input buffer area and the output buffer area are created corresponding to the input source and output source, and the activation status and buffer status are regularly detected to realize the continuous transmission and caching of audio data, avoid data discarding or reset, and ensure the smooth operation between different audio sources. seamless switching.
It effectively reduces the lag or POP sound caused by multi-audio playback under different clocks, achieves continuous transmission and seamless switching of audio data, and improves user experience.
Smart Images

Figure CN118629440A
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio processing technology, and in particular to an audio stream processing method, apparatus, computer equipment and storage medium. Background Art
[0002] When processing audio stream data from multiple audio sources, the data transmission between the input source and the output source is required to be isochronous (that is, the input speed is the same as the output speed). Generally, a digital signal clock with consistent sampling needs to be set in the audio source to meet the requirement of isochronous transmission. Otherwise, during the audio playback process, the playback may be stuck or have POP sounds due to data asynchrony. However, setting digital signal clocks in multiple audio sources not only has high design and cost requirements for hardware, but also causes obvious pauses when switching between different audio input sources, which brings trouble to users. Summary of the invention
[0003] The purpose of the embodiments of the present application is to propose an audio stream processing method, device, computer equipment and storage medium to solve the problem of freeze or too many POP sounds in multi-audio playback under different clocks and the inability to switch seamlessly.
[0004] In order to solve the above technical problems, the embodiment of the present application provides an audio stream processing method, which adopts the following technical solution:
[0005] Create an input buffer and an output buffer corresponding to the input source and output source respectively;
[0006] Detecting the activation state of the input source, and when the input source is activated, caching the audio data collected by the input source into the input buffer area;
[0007] Reading audio data from the input buffer area to the data processing module for data processing, and writing the processed audio data into the output buffer area; and
[0008] The activation state of the output source is detected, and when the output source is activated, the audio data in the output buffer area is written into the output source for audio output.
[0009] Furthermore, the step of detecting the activation state of the input source and caching the audio data collected by the input source into the input buffer area when the input source is activated specifically includes:
[0010] Regularly detecting whether the input source is activated;
[0011] If activated, get the input buffer status information;
[0012] Determining whether there is cache space in the input cache area that meets a preset data size according to the input cache area state information;
[0013] If it exists, write the audio data into the input buffer; and
[0014] If it does not exist, stop writing and discard the audio data of the current sampling period.
[0015] Furthermore, after the step of detecting the activation state of the input source, the method further includes:
[0016] When it is detected that the input source is inactive, determining whether the inactivation time is greater than a first preset threshold;
[0017] If it is greater, the input buffer area corresponding to the input source is cleared and the idle state is entered.
[0018] Furthermore, the step of detecting the activation state of the output source and, when the output source is activated, writing the audio data in the output buffer area into the output source for audio output specifically includes:
[0019] regularly detecting whether the output source is activated;
[0020] If activated, get the output buffer status information;
[0021] Determining whether there is audio data in the output buffer according to the output buffer state information;
[0022] If so, write the audio data to the output source; and
[0023] If it does not exist, the audio data of the previous sampling period is repeatedly written into the output source.
[0024] Furthermore, after the step of detecting the activation state of the output source, the method further includes:
[0025] When it is detected that the output source is inactive, determining whether the inactivation time is greater than a second preset threshold;
[0026] If it is greater, the output buffer area corresponding to the output source is cleared and enters the idle state.
[0027] Furthermore, the detecting the activation state of the input source and, when the input source is activated, caching the audio data collected by the input source into the input buffer area further comprises the following steps:
[0028] Acquire data processing module status information, and determine whether there is cache space in the data processing module that meets a preset data size according to the data processing module status information;
[0029] If so, instruct the data processing module to read the audio data in the input buffer area; and
[0030] If it does not exist, stop writing and discard the audio data of the current sampling period.
[0031] Furthermore, the step of reading the audio data from the input buffer area to the data processing module for data processing, and writing the processed audio data into the output buffer area specifically includes:
[0032] Reading the audio data in the input buffer area for data processing;
[0033] Acquire data processing module status information, and determine whether there is readable audio data in the data processing module according to the data processing module status information;
[0034] If so, the audio data of the data processing module is written into the corresponding output buffer area for caching; and
[0035] If not present, the data processing module is refreshed and re-detected.
[0036] In order to solve the above technical problems, the embodiment of the present application further provides an audio stream processing device, including:
[0037] An association creation module, used to create an input buffer area and an output buffer area corresponding to the input source and the output source respectively;
[0038] A data input module, used to detect the activation state of the input source, and when the input source is activated, cache the audio data collected by the input source into the input cache area;
[0039] a data processing module, configured to read audio data from the input buffer area for data processing, and write the processed audio data into the output buffer area; and
[0040] The data output module is used to detect the activation state of the output source, and when the output source is activated, write the audio data in the output buffer area into the output source for audio output.
[0041] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:
[0042] A computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above-mentioned audio stream processing method when executing the computer program.
[0043] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:
[0044] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the audio stream processing method described above are implemented.
[0045] Compared with the prior art, the embodiments of the present application have the following beneficial effects:
[0046] The audio stream processing method described in the embodiment of the present application, by creating an input buffer area and an output buffer area corresponding to the input source and the output source respectively, can enable the audio data collected by the input source to be continuously transmitted, thereby avoiding the situation in which the audio data is reset due to the input source's memory being too full or the output source's memory being empty during the transmission process, thereby effectively reducing the situation of stuttering or POP sound in multi-audio playback under different clocks, and at the same time enabling seamless switching between different input sources and output sources. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0048] Figure 1 A flowchart of an embodiment of an audio stream processing method according to the present application;
[0049] Figure 2 It is a schematic diagram of the audio data transmission process;
[0050] Figure 3 yes Figure 1 A flowchart of a specific implementation of step S20;
[0051] Figure 4 yes Figure 1 A flowchart of a specific implementation of step S40;
[0052] Figure 5 is a flowchart of a specific implementation method after step S20;
[0053] Figure 6 yes Figure 1 A flowchart of a specific implementation of step S30;
[0054] Figure 7 is a structural schematic diagram of an embodiment of an audio stream processing device according to the present application;
[0055] Figure 8 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION
[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.
[0057] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.
[0058] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.
[0059] refer to Figure 1 , shows a flow chart of an embodiment of an audio stream processing method according to the present application. The audio stream processing method comprises the following steps:
[0060] S10, creating an input buffer area and an output buffer area corresponding to the input source and the output source respectively;
[0061] S20, detecting the activation state of the input source, and when the input source is activated, caching the audio data collected by the input source into the input buffer area;
[0062] S30, reading audio data from the input buffer area to a data processing module for data processing, and writing the processed audio data into the output buffer area; and
[0063] S40, detecting the activation state of the output source, and when the output source is activated, writing the audio data in the output buffer area into the output source for audio output.
[0064] The audio stream processing method described in the embodiment of the present application, by creating an input buffer area and an output buffer area corresponding to the input source and the output source respectively, can enable the audio data collected by the input source to be continuously transmitted, thereby avoiding the situation in which the audio data is reset due to the input source's memory being too full or the output source's memory being empty during the transmission process, thereby effectively reducing the situation of stuttering or POP sound in multi-audio playback under different clocks, and at the same time enabling seamless switching between different input sources and output sources.
[0065] In this embodiment, the input source is associated with its corresponding input buffer area to form a data thread, and the output source is associated with its corresponding output buffer area to form another data thread. The two threads are independent of each other. Figure 2 In this embodiment, the input source, output source, input buffer area and output buffer area all include a plurality of them, and each data thread composed of the input source and the input buffer area, and the output source and the output buffer area is connected to the data processing module, wherein the data sizes that can be cached in the input buffer area and the output buffer area have the following relationship: the cache size of the input buffer area is an integral multiple of the least common multiple of the data flow size of the input source in each sampling period and the data size required to be input each time by the data processing module, and is larger than the data volume of the sampling period corresponding to the processing time of the data processing module; the cache size of the output buffer area is an integral multiple of the least common multiple of the data flow size of the output source in each sampling period and the data size processed and output by the data processing module each time. For example, the data flow size of each sampling cycle of the input source is 4000 bytes, the data size required by the data processing module to input each time is 3000 bytes, and the data size of the sampling cycle corresponding to the processing time of the data processing module is 10000 bytes. The data size that can be cached in the input buffer can be set to 12000 bytes. Similarly, the data flow size of each sampling cycle of the output source is 4000 bytes, and the data size of the output processed by the data processing module each time is 3500 bytes. The data size that can be cached in the output buffer can be set to 14000 bytes.
[0066] In this embodiment, each input source corresponds to an input device, and each output source corresponds to an output device. For example, when the input source is USB, it is detected whether the USB has entered the activated state. If it has entered, the audio data is read from the USB input sound card according to the set sampling period and written to the input buffer associated with the USB. When the input mode is not USB, the input buffer is cleared and the thread enters the idle state, and the sound card data is no longer read. When the output source is a speaker, it is detected whether the speaker has entered the activated state, and the output buffer associated with the speaker is continuously checked to see if there is valid audio data. If there is, the data block corresponding to the sampling period is taken out and written to the speaker output sound card to play from the speaker. When the output mode is not the speaker, the output buffer is cleared and the thread enters the idle state, and the output buffer is no longer checked. At the same time, in this embodiment, the single write size and single read size of the audio data of each of the above-mentioned input buffer and output buffer may be different, so the above-mentioned valid audio data refers to the audio data that meets the single read size of the output source.
[0067] The data processing module in this embodiment performs data processing on audio data including: algorithmic audio processing and channel matching processing, wherein the algorithmic audio processing is used for processing audio data whose output source is a speaker, and the channel matching processing is used for processing audio data whose output source is a headset. In specific implementation, the way in which the data processing module processes audio data can be adjusted according to different output sources to obtain good audio output effects.
[0068] Continue to refer Figure 3 , shows a flowchart of a specific embodiment of step S20, comprising the following steps:
[0069] S201, regularly detecting whether the input source is activated;
[0070] S202, if activated, obtaining input buffer state information;
[0071] S203, determining whether there is cache space in the input cache area that meets a preset data size according to the input cache area state information;
[0072] S204, if it exists, writing the audio data into the input buffer area;
[0073] S205, if it does not exist, stop writing and discard the audio data of the current sampling period; and
[0074] S206: If not activated, re-detect the input source.
[0075] This embodiment can determine whether the input source is activated to start the transmission of audio data by periodically detecting whether the input source is in an activated state. When the input source is detected to be activated, the input buffer state information is obtained, and the input buffer state information includes: the total buffer space size of the input buffer and the current buffer data size of the input buffer; when the input source is detected to be inactive, the input source is re-detected. By obtaining the input buffer state information to determine whether there is a buffer space that meets the preset size in the input buffer, it can effectively determine whether the current input buffer can still write audio data to perform corresponding operations on the audio data. In this embodiment, the preset size of the buffer space is the size of the audio data written in a single sampling cycle of the input source, which can be adjusted according to the specific usage. When the space left in the input buffer is less than the size of the audio data written in a single sampling cycle of the input source, the audio data is stopped from being written to the input buffer and is discarded. In actual use, due to the limited data processing speed of the data processing module, and the fact that the processing speed of the data processing module may be affected by the system and may not be processed in time, although the audio data is written and read in real time in the input buffer area, data accumulation may still occur. When the audio data fills the input buffer area, in order to ensure the continuous smoothness of the playback, the system will not delete the data already saved in the input buffer area, but will discard the audio data that has not been saved in the input buffer area. The discarded audio data will not affect the overall playback smoothness, so there will be no lag and no POP sound during playback.
[0076] After step S20 of this embodiment, the following steps are also included:
[0077] When it is detected that the input source is inactive, determining whether the inactivation time is greater than a first preset threshold;
[0078] If it is greater, the input buffer area corresponding to the input source is cleared and the idle state is entered.
[0079] This embodiment can effectively determine whether the current input device is correct and whether it is in the startup state by detecting the inactive state time of the input source, thereby adjusting the working state of the input source and the input buffer area accordingly. When it is determined that the inactive time of the input source is greater than the first preset threshold, it indicates that the input source will not be started again in a short time, so the audio data cached in the input buffer area is cleared, and the thread corresponding to the input source is idle, and enters the idle state at the same time, so as to release the system running memory and improve the processing speed of other running threads. When it is determined that the inactive time of the input source is less than the first preset threshold, the input source is re-detected until the input source is activated, or the inactive time of the input source is greater than the first preset threshold.
[0080] Continue to refer Figure 4 , shows a flowchart of a specific embodiment of step S40, comprising the following steps:
[0081] S401, regularly detecting whether the output source is activated;
[0082] S402, if activated, obtaining output buffer state information;
[0083] S403, determining whether there is audio data in the output buffer according to the input buffer state information;
[0084] S404, if it exists, writing the audio data into the output source;
[0085] S405, if it does not exist, then repeatedly write the audio data of the previous sampling period into the output source; and
[0086] S406: If not activated, re-detect the output source.
[0087] This embodiment can determine whether the output source has been activated to start the transmission of audio data by regularly detecting the activation state of the output source. When the output source is detected to be activated, the output buffer state information is obtained, and the output buffer state information includes: the total buffer space size of the output buffer and the current buffer data size of the output buffer; when the output source is detected to be inactive, the output source is re-detected. By detecting whether there is audio data in the output buffer, it is possible to effectively determine whether there is readable audio data in the output buffer to perform corresponding processing operations. In specific implementation, in order to ensure the smoothness of audio playback, when no readable audio data is detected in the output buffer, the audio data of the previous sampling period needs to be repeatedly written into the output source to complete the audio playback. Since the audio data is only a few tens of milliseconds in size, it does not affect the continuity and smoothness of the playback, thereby effectively avoiding jamming or POP sound during playback. For the detection of the output buffer, when there is audio data in the output buffer, and the size of the data cannot meet the data reading size of the output source, the output buffer should be divided into a situation where there is no audio data, so as to perform corresponding processing on the audio data. Similarly, this judgment criterion is also applicable to the above judgment on whether there is a cache space in the input cache area that meets the preset data size.
[0088] After step S40 of this embodiment, the following steps are also included:
[0089] When it is detected that the output source is inactive, determining whether the inactivation time is greater than a second preset threshold;
[0090] If it is greater, the output buffer area corresponding to the output source is cleared and enters the idle state.
[0091] By detecting the inactive state time of the output source, this embodiment can effectively determine whether the current output device is correct and whether it is in the startup state, so as to adjust the working state of the output source and the output buffer area accordingly. When it is determined that the inactive time of the output source is greater than the second preset threshold, it indicates that the output source will not be started again in a short time, so the audio data cached in the output buffer area is cleared, and the thread corresponding to the output source is idle, and enters the idle state at the same time to release the system running memory and improve the processing speed of other running threads. When it is determined that the inactive time of the output source is less than the second preset threshold, the output source is re-detected until the output source is activated, or the inactive time of the output source is greater than the second preset threshold. In this embodiment, the second preset threshold and the above-mentioned first preset threshold can be set to the same value, and can also be adjusted accordingly according to the specific input source and output source, for example, the first preset threshold is greater than the second preset threshold, or the second preset threshold is greater than the first preset threshold.
[0092] Continue to refer Figure 5 , after step S20, further comprising the following steps:
[0093] S207, obtaining data processing module status information, and determining whether there is cache space in the data processing module that meets a preset data size according to the data processing module status information;
[0094] S208, if it exists, instructing the data processing module to read the audio data in the input buffer area; and
[0095] S209, if not, stop writing and discard the audio data of the current sampling period. This embodiment can effectively determine whether there is a cache space that meets the preset data size in the data processing module by obtaining the data processing module status information, so as to judge the subsequent processing operations to be performed accordingly. The data processing module information includes: the total cache space size of the data processing module and the current cache data size of the data processing module. In the specific implementation, the data processing module processes the audio data as follows: check whether there is valid audio data in the input buffer area, if so, then apply for a temporary cache of the sampling period size corresponding to the input source, recorded as the write cache, and copy the corresponding data block from the input buffer area to the write cache, and at the same time apply for a temporary cache of the sampling period size corresponding to the output source, recorded as the read cache, and format it to 0, write the cache and read the cache according to the PCM data format frame by frame, and then each frame is expanded according to the number of channels, and then the sampling point data of the specified channel of the write cache is copied to the specified channel in the read cache, and the read cache is written to the output cache area after the copying is completed, and then the temporary cache write cache and read cache are released, so that the rearrangement and copying of the audio data channel can be completed. For example, the input source is a 16-bit wide 8-channel USB sound card, and the output sound source is a 16-bit wide stereo (dual channel) headset. We assume that USB Channel 0 corresponds to the left channel of the headset, and USB Channel 1 corresponds to the right channel of the headset. For each frame of a sampling period of period_frames, the sample data of each channel is processed, and Channel 0 and Channel 1 are copied to the output buffer. The data of other channels are not copied and discarded to complete the above processing operations. In this embodiment, since there are multiple input sources, the memory of the data processing module may be full during the processing of audio data, so it is necessary to detect the buffer space in the data processing module.
[0096] In this embodiment, the data processing module reads the audio data in the input buffer continuously and in real time. In order to ensure the smoothness of audio playback, it is necessary to discard the audio data when the data processing module cannot write the audio data.
[0097] Continue to refer Figure 6 , shows a flowchart of a specific embodiment of step S30, comprising the following steps:
[0098] S301, reading the audio data in the input buffer area for data processing;
[0099] S302, obtaining data processing module status information, and determining whether there is readable audio data in the data processing module according to the data processing module status information;
[0100] S303, if it exists, writing the audio data of the data processing module into the corresponding output buffer area for buffering; and
[0101] S304: If it does not exist, the data processing module is refreshed and re-detected.
[0102] This embodiment can effectively determine whether there is readable audio data in the data processing module by obtaining the data processing module status information, so as to judge the subsequent processing operations to be performed accordingly. The data processing module information includes: the total cache space size of the data processing module and the current cache data size of the data processing module. In this embodiment, the readable audio data refers to the audio data that can be directly read by the output source. Since the input source and the output source in this embodiment each correspond to an independent processing thread, the output source can read the audio data written into the data processing module by the specified input source. At the same time, the size of the audio data should be greater than the data reading size of the output buffer area for the audio data. If the audio data meets the above conditions, it is the audio data that can be directly read by the output source.
[0103] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0104] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.
[0105] Further references Figure 7 , as a response to the above Figure 1 The present application provides an embodiment of an audio stream processing device, and the device embodiment is similar to Figure 1Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.
[0106] like Figure 7 As shown, the audio stream processing device 5 described in this embodiment includes: an association creation module 501, a data input module 502, a data processing module 503, and a data output module 504. Among them:
[0107] The association creation module 501 is used to create an input buffer area and an output buffer area corresponding to the input source and the output source respectively;
[0108] The data input module 502 is used to detect the activation state of the input source, and when the input source is activated, cache the audio data collected by the input source into the input cache area;
[0109] A data processing module 503 is used to read audio data from the input buffer area for data processing, and write the processed audio data into the output buffer area; and
[0110] The data output module 504 is used to detect the activation state of the output source, and when the output source is activated, write the audio data in the output buffer area into the output source for audio output.
[0111] In this embodiment, by setting a system module corresponding to the audio stream processing method, the occurrence of freezes or pop sounds in multi-audio playback under different clocks can be effectively reduced, and seamless switching of different input sources during audio playback can be achieved.
[0112] To solve the above technical problems, the present application also provides a computer device. Figure 8 , Figure 8 This is a basic structural block diagram of the computer device in this embodiment.
[0113] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 6 with components 61-63, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.
[0114] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.
[0115] The memory 61 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk equipped on the computer device 6, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 61 can also include both the internal storage unit of the computer device 6 and its external storage device. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as the program code of the audio stream processing method, etc. In addition, the memory 61 can also be used to temporarily store various types of data that have been output or are to be output.
[0116] The processor 62 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run the program code stored in the memory 61 or process data, such as running the program code of the audio stream processing method.
[0117] The network interface 63 may include a wireless network interface or a wired network interface. The network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.
[0118] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores an audio stream processing program, and the audio stream processing program can be executed by at least one processor so that the at least one processor performs the steps of the audio stream processing method as described above.
[0119] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.
[0122] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.
Claims
1. A method for processing an audio stream, It is characterized in that The steps include: Create an input buffer and an output buffer corresponding to the input source and output source respectively; Detecting the activation state of the input source, and when the input source is activated, caching the audio data collected by the input source into the input buffer area; Read the audio data from the input buffer area to the data processing module for data processing, and write the processed audio data into the output buffer area; and The activation state of the output source is detected, and when the output source is activated, the audio data in the output buffer area is written into the output source for audio output.
2. The audio stream processing control method according to claim 1, It is characterized in that The step of detecting the activation state of the input source and caching the audio data collected by the input source into the input buffer area when the input source is activated specifically includes: Regularly detecting whether the input source is activated; If activated, get the input buffer status information; Determining whether there is cache space in the input cache area that meets a preset data size according to the input cache area state information; If it exists, write the audio data into the input buffer; and If it does not exist, stop writing and discard the audio data of the current sampling period.
3. The audio stream processing control method according to claim 2, It is characterized in that After the step of detecting the activation state of the input source, the method further comprises: When it is detected that the input source is inactive, determining whether the inactivation time is greater than a first preset threshold; If it is greater, the input buffer area corresponding to the input source is cleared and the idle state is entered.
4. The audio stream processing control method according to claim 1, It is characterized in that The step of detecting the activation state of the output source and, when the output source is activated, writing the audio data in the output buffer area into the output source for audio output specifically includes: regularly detecting whether the output source is activated; If activated, get the output buffer status information; Determining whether there is audio data in the output buffer according to the output buffer state information; If so, write the audio data to the output source; and If it does not exist, the audio data of the previous sampling period is repeatedly written into the output source.
5. The audio stream processing control method according to claim 4, It is characterized in that After the step of detecting the activation state of the output source, the method further comprises: When it is detected that the output source is inactive, determining whether the inactivation time is greater than a second preset threshold; If it is greater, the output buffer area corresponding to the output source is cleared and enters the idle state.
6. The audio stream processing control method according to claim 1, It is characterized in that The detecting the activation state of the input source and caching the audio data collected by the input source into the input buffer area when the input source is activated also includes the following steps: Acquire data processing module status information, and determine whether there is cache space in the data processing module that meets a preset data size according to the data processing module status information; If so, instruct the data processing module to read the audio data in the input buffer area; and If it does not exist, stop writing and discard the audio data of the current sampling period.
7. The audio stream processing control method according to claim 1, It is characterized in that The step of reading the audio data from the input buffer area to the data processing module for data processing, and writing the processed audio data into the output buffer area specifically includes: Reading the audio data in the input buffer area for data processing; Acquire data processing module status information, and determine whether there is readable audio data in the data processing module according to the data processing module status information; If so, the audio data of the data processing module is written into the corresponding output buffer area for caching; and If not present, the data processing module is refreshed and re-detected.
8. An audio stream processing device, It is characterized in that include: An association creation module, used to create an input buffer area and an output buffer area corresponding to the input source and the output source respectively; A data input module, used to detect the activation state of the input source, and when the input source is activated, cache the audio data collected by the input source into the input cache area; A data processing module, used for reading audio data from the input buffer area for data processing, and writing the processed audio data into the output buffer area; and The data output module is used to detect the activation state of the output source, and when the output source is activated, write the audio data in the output buffer area into the output source for audio output.
9. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the audio stream processing method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the audio stream processing method according to any one of claims 1 to 7 are implemented.
