Method for eliminating popping sound in audio, electronic device and readable storage medium

By detecting the priority of the audio data transfer thread and the operation of the processor core, the problem of POP sound during the audio data transfer process is solved, and the fluency and quality of audio playback are improved.

CN117707752BActive Publication Date: 2024-10-08HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310635794.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-31
Publication Date
2024-10-08
Estimated Expiration
2043-05-31

AI Technical Summary

Technical Problem

In electronic equipment, the POP sound problem caused by untimely hierarchical scheduling during the audio data transmission process affects the quality and fluency of audio playback.

Method used

By detecting the amount of data in the shared buffer, adjusting the priority of the audio data transfer thread and processor core operation, it can predict and eliminate POP sounds in time, and reduce the probability of POP sounds when the amount of data is small.

Benefits of technology

It improves the audio playback effect, reduces the possibility of POP sound, and ensures the smoothness and quality of audio data transmission.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117707752B_ABST
    Figure CN117707752B_ABST
Patent Text Reader

Abstract

The present application discloses a method for eliminating popping sounds in audio, an electronic device, and a readable storage medium, and belongs to the field of computer technology. The method includes: in the process of playing audio, detecting the amount of data in the first shared buffer, and when the amount of data in the first shared buffer is small, raising the priority of the first audio data transmission thread from the first priority to the second priority, and if the amount of data in the first shared buffer is still small after adjusting the priority, then continuing to adjust the first audio data transmission thread from the first core to the second core with stronger processing power, and if the amount of data in the first shared buffer increases after the adjustment, it is determined that the elimination of the POP sound in the audio has been completed. In the embodiment of the present application, when the amount of data in the first shared buffer is small, a series of parameter adjustments are made to reduce the possibility of the occurrence of POP sounds, eliminate the POP sounds in the audio, and improve the audio playback effect.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method for eliminating popping sounds in audio, an electronic device, and a readable storage medium. Background Art

[0002] Audio playback is one of the important functions of electronic devices. However, during audio playback, popping sounds may occur. In the operating system of electronic devices, the transmission of audio data involves five parts: application layer, application framework layer, hardware abstraction layer, kernel layer, and hardware layer. During the audio transmission process, if one layer does not schedule the audio data in time, popping sounds may occur, thus affecting the quality and fluency of audio playback.

[0003] Therefore, in order to avoid affecting the audio playback, it is usually necessary to eliminate the POP sound in the audio. Summary of the invention

[0004] The present application provides a method for eliminating popping sounds in audio, an electronic device, and a readable storage medium, which can be used to solve the impact of popping sounds on audio playback in the related art. The technical solution is as follows:

[0005] In a first aspect, a method for eliminating popping sounds in audio is provided, which is applied to an electronic device, and the method comprises:

[0006] During the audio playback, in a first detection period, the amount of data in a first shared buffer is detected to be a first value, the first shared buffer is a buffer for caching audio data transmitted by a first audio data transmission thread, and in the first detection period, the priority of the first audio data transmission thread is a first priority and runs on a first core of a processor;

[0007] In a second detection period, when the priority of the first audio data transmission thread is the first priority and the first audio data transmission thread runs in the first core, the data amount of the first shared buffer is a second value, and the second value is less than the first value, the priority of the first audio data transmission thread is adjusted from the first priority to a second priority, and the second priority is higher than the first priority;

[0008] In a third detection period, when the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread is running in the first core, and the amount of data in the first shared buffer is a third value, and the third value is less than the first value, the first audio data transmission thread is adjusted to run in the second core of the processor, and the processing capability of the second core is greater than the processing capability of the first core;

[0009] In a fourth detection period, when the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread runs in the second core, the amount of data in the first shared buffer is a fourth value, and the fourth value is greater than the first value, it is determined that the current round of elimination of the pop sound in the audio has been completed;

[0010] Among them, during the first detection period, the second detection period, the third detection period and the fourth detection period, the amount of data in the second shared buffer is greater than the first value, and the second shared buffer is a buffer for caching audio data transmitted to the first audio data transmission thread.

[0011] In this way, during the audio playback process, when the amount of data in the first shared buffer is small, a series of parameter adjustments are made to reduce the possibility of POP sound, eliminate the POP sound that occurs when the amount of data in the first shared buffer is small, and improve the audio playback effect.

[0012] As an example of the present application, the electronic device includes a POP sound prediction module; the first audio data transmission thread includes a hardware abstraction layer thread;

[0013] The method of detecting, during the audio playback process, in a first detection period, that the amount of data in the first shared buffer is a first value includes:

[0014] During the process of playing the audio, if a data reporting period is met, the first shared buffer reports a first write message to the hardware abstraction layer thread, where the first write message carries the first value;

[0015] After receiving the first write message, the hardware abstraction layer thread sends a first data message to the POP sound prediction module, where the first data message carries the first value;

[0016] The POP sound prediction module obtains the first value from the first data message.

[0017] In this way, during the audio playback process, by obtaining the data volume of the first shared buffer, it is possible to predict whether POP sound will be generated in the audio, and then the POP sound can be eliminated in time, reducing the possibility of POP sound generation.

[0018] As an example of the present application, in the second detection period, the priority of the first audio data transmission thread is the first priority, and it runs in the first core, the data amount of the first shared buffer is a second value, and the second value is less than the first value, the priority of the first audio data transmission thread is adjusted from the first priority to the second priority, including:

[0019] In the second detection period, when the priority of the first audio data transmission thread is the first priority and it runs in the first core, the data volume of the first shared buffer is the second value, and the second value is smaller than the first value, the priority value corresponding to the first audio data transmission thread is adjusted from the first priority value to the second priority value, the second priority value is a value smaller than the first priority value, and the priority value is negatively correlated with the priority.

[0020] In this way, the priority is adjusted by adjusting the priority value, so that the adjustment of the priority has specific numerical support, thereby improving the accuracy of adjusting the priority.

[0021] As an example of the present application, the electronic device includes a POP sound prediction module and a POP sound active elimination module; the first audio data transmission thread includes a hardware abstraction layer thread;

[0022] In the second detection period, when the priority of the first audio data transmission thread is the first priority and the first audio data transmission thread runs in the first core, the amount of data in the first shared buffer is a second value, and the second value is less than the first value, adjusting the priority of the first audio data transmission thread from the first priority to the second priority, including:

[0023] In the second detection period, when the priority of the first audio data transmission thread is the first priority and the first core is running, if the data reporting period is met, the first shared buffer reports a second write message to the hardware abstraction layer thread, and the second write message carries the second value;

[0024] When receiving the second write message, the hardware abstraction layer thread sends a second data message to the POP sound prediction module, where the second data message carries the second value;

[0025] When the second value is less than the first value, the POP sound prediction module sends a first adjustment message to the POP sound active elimination module, where the first adjustment message carries a buffer identifier of the first shared buffer;

[0026] After receiving the first adjustment message, the POP audio active module determines to adjust the priority of the first audio data transmission thread, and adjusts the priority corresponding to the first audio data transmission thread from the first priority to the second priority.

[0027] In this way, by carrying the buffer identifier of the first shared buffer in the first adjustment message, the POP sound active elimination module can accurately know which audio data transmission thread parameters need to be adjusted, making the parameter adjustment more targeted and improving the accuracy of the adjustment parameters.

[0028] As an example of the present application, in the third detection period, the priority of the first audio data transmission thread is the second priority, and it runs in the first core, the amount of data in the first shared buffer is a third value, and the third value is less than the first value, after adjusting the first audio data transmission thread to run in the second core of the processor, it also includes:

[0029] In the fourth detection period, if the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread runs on the second core, the amount of data in the first shared buffer is a fifth value, and the fifth value is less than the first value, then a virtual load is added to the processor so that the minimum operating frequency of the processor increases from the preset frequency to the first frequency;

[0030] In the fifth detection period, when the priority of the first audio data transmission thread is the second priority and it runs on the second core, the operating frequency of the processor is the first frequency, the amount of data in the first shared buffer is the sixth value, and the sixth value is greater than the first value, it is determined that this round of elimination of POP sounds in the audio has been completed.

[0031] In this way, by adding a virtual load to the processor, the minimum operating frequency of the processor can be increased, so that when the audio data is transmitted at the beginning of each transmission cycle, the processor can respond quickly, thereby increasing the transmission speed of the audio data and reducing the possibility of generating POP sound.

[0032] As an example of the present application, in the fourth detection period, the priority of the first audio data transmission thread is the second priority, and it runs on the second core, the amount of data in the first shared buffer is a fourth value, and the fourth value is greater than the first value, after determining that the current round of elimination of the pop sound in the audio has been completed, it also includes:

[0033] Receiving a playback stop operation on the audio;

[0034] In response to a playback suspension operation on the audio, playback of the audio is stopped, and a state of the first audio data transmission thread and a state of the processor are restored to states corresponding to the first detection period.

[0035] In this way, after the audio playback is stopped, the state of the first audio data transmission thread and the state of the processor are restored to the state corresponding to the first detection period, which can avoid long-term impact on other threads due to parameter adjustment.

[0036] As an example of the present application, in the fourth detection period, the priority of the first audio data transmission thread is the second priority, and it runs on the second core, the amount of data in the first shared buffer is a fourth value, and the fourth value is greater than the first value, after determining that the current round of elimination of the pop sound in the audio has been completed, it also includes:

[0037] In a sixth detection period, when the priority of the second audio data transmission thread is the first priority, the second audio data transmission thread runs in the first core, the amount of data in the second shared buffer is a seventh value, and the seventh value is less than the first value, the priority of the second audio data transmission thread is adjusted from the first priority to the second priority;

[0038] In a seventh detection period, if the priority of the second audio data transmission thread is the second priority and the second audio data transmission thread is running in the first core, and the amount of data in the second shared buffer is an eighth value, and the eighth value is less than the first value, the second audio data transmission thread is adjusted to run in the second core;

[0039] In the eighth detection period, when the priority of the second audio data transmission thread is the second priority and it runs on the second core, the amount of data in the second shared buffer is a ninth value, and the ninth value is greater than the first value, it is determined that a new round of elimination of POP sounds in the audio has been completed.

[0040] In this way, when the amount in the second shared buffer is insufficient to support audio playback, the relevant parameters of the second audio data transmission thread are adjusted until the amount of data in the second shared buffer does not cause POP sound to be generated, thereby reducing the possibility of POP sound occurrence, eliminating the POP sound that occurs when the amount of data in the second shared buffer is small, and improving the audio playback effect.

[0041] As an example of the present application, the electronic device includes a POP sound prediction module and a POP sound active elimination module;

[0042] In the sixth detection period, when the priority of the second audio data transmission thread is the first priority, the second audio data transmission thread runs in the first core, the amount of data in the second shared buffer is a seventh value, and the seventh value is less than the first value, adjusting the priority of the second audio data transmission thread from the first priority to the second priority, including:

[0043] In the sixth detection period, when the priority of the second audio data transmission thread is the first priority and the second audio data transmission thread runs in the first core, the first audio data transmission thread obtains the amount of data in the second shared buffer from the second shared buffer to obtain the seventh value;

[0044] When the first audio data transmission thread obtains the seventh value, it sends a third data message to the POP sound prediction module, where the third data message carries the seventh value;

[0045] When the seventh value is less than the first value, the POP sound prediction module sends a second adjustment message to the POP sound active elimination module, where the second adjustment message carries a buffer identifier of the second shared buffer;

[0046] When the POP sound active elimination module receives the second adjustment message, it determines to adjust the priority of the second audio data transmission thread, and adjusts the priority of the second audio data transmission thread from the first priority to the second priority.

[0047] In this way, the amount of data in the second shared buffer is obtained from the second shared buffer through the first audio data transmission thread, so that it is possible to promptly discover whether the amount of data in the second shared buffer will cause the occurrence of POP sound, thereby improving the timeliness of eliminating POP sound.

[0048] In a second aspect, an electronic device is provided, wherein the structure of the electronic device includes a processor and a memory, wherein the memory is used to store a program that supports the electronic device to execute the method for eliminating pop sounds in audio provided in the first aspect, and to store data involved in implementing the method for eliminating pop sounds in audio provided in the first aspect. The processor is configured to execute the program stored in the memory. The electronic device may also include a communication bus, wherein the communication bus is used to establish a connection between the processor and the memory.

[0049] In a third aspect, a computer-readable storage medium is provided, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is executed on a computer, the computer executes the method for eliminating pop sounds in audio as described in the first aspect.

[0050] In a fourth aspect, a computer program product comprising instructions is provided, which, when executed on a computer, enables the computer to execute the method for eliminating pop sounds in audio as described in the first aspect.

[0051] The technical effects obtained by the above-mentioned second aspect, third aspect and fourth aspect are similar to the technical effects obtained by the corresponding technical means in the above-mentioned first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0052] Figure 1 It is a schematic diagram of a transmission route of audio data in various layers of an operating system provided by an embodiment of the present application;

[0053] Figure 2 This is a schematic diagram of the transmission process of audio data in various layers provided by an embodiment of the present application;

[0054] Figure 3 is a schematic diagram of a software architecture of an electronic device provided in an embodiment of the present application;

[0055] Figure 4 It is a flowchart of a method for eliminating popping sounds in audio provided by an embodiment of the present application;

[0056] Figure 5 This is a schematic diagram of a change in the amount of data in a shared buffer during a pop elimination process provided by an embodiment of the present application;

[0057] Figure 6 This is a schematic diagram of the trends of various types of data in the process of eliminating pop sounds provided by an embodiment of the present application;

[0058] Figure 7 It is a schematic diagram of parameters that need to be adjusted in the process of eliminating popping sound provided by an embodiment of the present application;

[0059] Figure 8 It is a flowchart of another method for eliminating popping sounds in audio provided by an embodiment of the present application;

[0060] Fig. 9 It is a flowchart of another method for eliminating popping sounds in audio provided by an embodiment of the present application;

[0061] Fig.10 It is a flowchart of another method for eliminating popping sounds in audio provided by an embodiment of the present application;

[0062] Fig.11 It is a structural schematic diagram of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0063] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below in conjunction with the accompanying drawings.

[0064] It should be understood that the "multiple" mentioned in this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in order to facilitate the clear description of the technical solution of this application, the words "first" and "second" are used to distinguish between the same items or similar items with basically the same functions and effects. Those skilled in the art can understand that the words "first" and "second" do not limit the quantity and execution order, and the words "first" and "second" do not limit them to be different.

[0065] References to "one embodiment" or "some embodiments" etc. described in the specification of this application mean that one or more embodiments of the present application include specific features, structures or characteristics described in conjunction with the embodiment. Therefore, the statements "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear in different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0066] With the development of terminal technology, audio playback has become an indispensable function for electronic devices such as mobile phones and tablet computers. Figure 1 As shown, the transmission of audio data involves the application layer, application framework layer, hardware abstract layer (HAL), kernel layer and hardware layer of the electronic device, wherein the application layer includes a music application and an application layer thread (i.e., a second audio data transmission thread), the application framework layer includes a second shared buffer and a framework layer thread, the second shared buffer is used to cache the audio data transmitted by the application layer thread; the HAL layer includes a HAL layer thread (i.e., a hardware abstract layer thread), the kernel layer includes a first shared buffer, the first shared buffer is used to cache the audio data transmitted by the HAL layer thread; the hardware layer may include a digital signal processor (DSP) and a speaker. The transmission process of audio data in each layer of the electronic device is as follows: Figure 2 As shown, see Figure 2 , Step A: During the audio playback process, the application layer thread can pass audio data to the second shared buffer; Step B: After receiving the audio data passed by the application layer thread, the second shared buffer can return feedback information to the application layer thread, and the feedback information is used to feedback the received and passed audio data. Step C: The framework layer thread can obtain audio data from the second shared buffer, and pass the obtained audio data to the HAL layer thread through a write function, and the write function can be an out_write function; Step D: After receiving the audio data passed by the framework layer thread, the HAL layer thread can pass the received audio data to the first shared buffer through a transfer function, and the transfer function can be pcm_write. At the same time, the HAL layer thread can also return feedback information to the framework layer thread. Step E: After receiving the audio data passed by the HAL layer thread, the first shared buffer can return feedback information to the HAL layer thread. Step F: The DSP in the hardware layer can read audio data from the first shared buffer and send the read audio data to the speaker. Step G: The speaker plays the received audio data.

[0067] However, since multiple layers in the operating system are involved in the audio playback process, if a certain layer does not schedule the audio data in time and does not pass enough audio data to the shared buffer of the next layer, the thread of the lower layer of the shared buffer will not be able to read the audio data, resulting in the generation of POP sound. For example, in a possible scenario, when an electronic device is playing audio through a music application, if the music application is switched from the foreground to the background, the operating system of the electronic device will lower the priority of the application layer thread. In this case, the speed at which the application layer thread transfers audio data to the second shared buffer slows down, and the audio data cached in the second shared buffer gradually decreases during the audio playback process, resulting in the framework layer thread being unable to obtain enough audio data from the second shared buffer to support audio playback at a certain moment. For example, the size of a frame of audio data is 8k (kilobytes), and the amount of audio data cached in the second shared buffer is less than 8k. The audio data obtained by the framework layer thread is less than 8k, which will cause POP sound in the audio, thereby affecting the audio playback. In another possible scenario, during the audio playback process, if there are other tasks in the electronic device, for example, the electronic device also starts a navigation application during the audio playback process, this will lead to high processor usage and full load on all cores of the processor. Since the priority of the hardware abstraction layer thread itself is relatively low, in this case, the scheduling resources allocated to the HAL layer thread by the operating system of the electronic device will be reduced, resulting in a slower speed at which the HAL layer thread transfers data to the first shared buffer. The audio data cached in the first shared buffer gradually decreases during the audio playback process, resulting in the DSP being unable to obtain enough audio data from the first shared buffer to support audio playback at a certain point in time, which in turn causes POP sound to be generated in the audio.

[0068] In order to reduce the probability of POP occurrence in audio and eliminate POP sounds in audio, an embodiment of the present application provides a method for eliminating popping sounds in audio. In this method, during the audio playback process, if the data amount in the second shared buffer is large and the data amount in the first shared buffer is small, the priority of the first audio data transmission thread can be increased. If the data amount in the first shared buffer is still small after adjusting the priority, the first audio data transmission thread can continue to be adjusted to run in a core with stronger processing capability. If the data amount in the first shared buffer increases after adjusting the core where the first audio data transmission thread is located, it means that the data amount in the first shared buffer is sufficient to support smooth audio playback, thereby reducing the possibility of POP sounds, eliminating the POP sounds that occur when the data amount in the first shared buffer is small, and improving the audio playback effect.

[0069] Next, the software system of the electronic device 100 will be described.

[0070] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present application takes the Android system of the layered architecture as an example to exemplify the software system of the electronic device 100.

[0071] Figure 3 1 is a block diagram of a software system of an electronic device 100 provided in an embodiment of the present application. Figure 3 The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer (also called the application layer), the application framework layer (also called the application framework layer), the HAL layer, and the kernel layer.

[0072] The application layer can include a series of application packages. Figure 3 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, music, video, etc.

[0073] As an example, the application layer may also include a second audio data transmission thread, and the second audio data transmission thread is used to transmit audio data of the audio to be played to the application framework layer.

[0074] The application framework layer provides application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 3As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make these data accessible to applications. These data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build the display interface of the application, and the display interface can be composed of one or more views, for example, including a view for displaying a text message notification icon, including a view for displaying text, and including a view for displaying pictures. The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including connecting, hanging up, etc.). The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction. For example, the notification manager is used to notify download completion, message reminders, etc. The notification manager can also be a notification that appears in the system top status bar in the form of an icon or scroll bar text, such as a notification of an application running in the background. The notification manager can also be a notification that appears on the screen in the form of a dialog window, such as a text message in the status bar, a reminder sound, an electronic device vibrating, an indicator light flashing, etc.

[0075] As an example, the application framework layer also includes a second shared buffer and a framework layer thread, wherein the second shared buffer is used to cache the audio data transmitted by the second audio data transmission thread, and the framework layer thread is used to obtain the audio data cached in the second shared buffer from the second shared buffer, and pass the obtained audio data to the HAL layer.

[0076] As an example, the HAL layer may include a HAL layer thread and a POP sound processing module, and the POP sound processing module may include a POP sound prediction module and a POP sound active elimination module. The HAL layer thread is used to receive the audio data transmitted by the framework layer thread, and continue to transmit the received audio data to the kernel layer; the POP sound prediction module is used to determine whether a POP sound will be generated during the audio playback process, and if it is determined that a POP sound will be generated, notify the POP sound active elimination module to eliminate the POP sound in the audio.

[0077] The kernel layer is the layer between hardware and software. The kernel layer contains at least display driver, camera driver, audio driver, and sensor driver.

[0078] As an example, the kernel layer may further include a first shared buffer, where the first shared buffer is used to cache audio data transferred by the HAL layer thread.

[0079] The following is an illustrative description of the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.

[0080] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, timestamp of the touch operation, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the raw input event. For example, if the touch operation is a single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer, starts the camera application, and then calls the kernel layer to start the camera driver to capture static images or videos through the camera 193.

[0081] Based on the execution subject provided in the above embodiment, the method for eliminating popping sound in audio provided in the embodiment of the present application is introduced below. Figure 4 , Figure 4 The present invention is a flow chart of a method for eliminating popping sound in audio according to an exemplary embodiment. As an example but not a limitation, the method is applied to an electronic device equipped with an audio playback function, and the electronic device is configured to Figure 3 Taking the interaction of multiple modules shown in the figure as an example, the method may include some or all of the following contents:

[0082] Step 401: During audio playback, a second audio data transmission thread transmits audio data to a second shared buffer.

[0083] It should be noted that the second audio data transmission thread is also the above Figure 1 and Figure 2 After receiving the audio data transmitted by the music application, the second application data thread may transmit the received audio data to the second shared buffer.

[0084] As an example, the second audio data transmission thread can periodically transmit audio data to the second shared buffer. Exemplarily, after transmitting the data stream of audio data to the second shared buffer once, the second audio data transmission thread waits for a certain period of time (for example, 2 seconds, which is the transmission period of the second audio data transmission thread transmitting audio data to the second shared buffer), and then continues to transmit the data stream of audio data to the second shared buffer once.

[0085] Step 402: When receiving the audio data transmitted by the second audio data transmission thread, the second shared buffer caches the received audio data.

[0086] It should be noted that, when the second shared buffer receives the audio data transmitted by the second audio data transmission thread, it can also return feedback information to the second audio data transmission thread, where the feedback information is used to feedback that the audio data has been successfully received.

[0087] Step 403: The framework layer thread reads audio data from the second shared buffer and detects the amount of data in the second shared buffer.

[0088] It should be noted that the data volume of the second shared buffer refers to the data volume of the audio data currently cached in the second shared buffer. The thread name of the framework layer thread can be audioOut, and the framework layer thread can be created by a framework layer process, and the process name of the framework layer process can be audioserver. The embodiment of the present application does not impose specific restrictions on this.

[0089] In order to reduce the probability of generating POP sound during audio playback and to eliminate the POP sound in the audio in a timely manner, the framework layer thread can not only read audio data from the second shared buffer, but also detect the data amount of the second shared buffer.

[0090] In some embodiments, the framework layer thread can detect the data volume of the second shared buffer while reading the audio data from the second shared buffer, or can periodically detect the data volume of the second shared buffer. Exemplarily, the framework layer thread can detect the data volume of the second shared buffer according to a preset detection period.

[0091] It should be noted that the preset detection period can be pre-set according to demand, for example, the preset detection period can be 15 seconds or 30 seconds.

[0092] Step 404: The framework layer thread sends a message carrying the data amount of the second shared buffer to the POP sound prediction module, and transfers the audio data to the HAL layer thread.

[0093] It should be noted that, since the operating system of the electronic device includes the first shared buffer and the second shared buffer, in order to accurately adjust the parameters later, the message carrying the data amount of the second shared buffer sent by the framework layer thread to the POP sound prediction module may also carry the buffer identifier of the second shared buffer. The buffer identifier is used to uniquely identify the corresponding shared buffer, and the buffer identifier may be at least one of numbers, letters, and symbols.

[0094] As an example, the thread name of the HAL layer thread may be Writer(hal) or Audio hal, and the HAL layer thread may be created by a HAL layer process, and the process name of the HAL layer process may be xxx.hardware.Audio.service, which is not specifically limited in the embodiments of the present application.

[0095] Step 405: When the POP sound prediction module receives a message from the framework layer thread carrying the data amount of the second shared buffer, if it determines that the data amount of the second shared buffer is small, it sends a message to the POP sound active elimination module to adjust the second audio data transmission thread.

[0096] It should be noted that the message for adjusting the second audio data transmission thread sent to the POP sound active elimination module carries the buffer identifier in the second shared buffer.

[0097] In some embodiments, see Figure 5 At time T1, the amount of data in the second shared buffer is less than the first preset threshold. In this case, it can be determined that the amount of data in the second shared buffer is small, and the POP sound prediction module can send a message to the POP sound active elimination module to adjust the second audio data transmission thread. Alternatively, when the amount of data in the second shared buffer detected this time is less than the amount of data in the second shared buffer detected previously, it is determined that the amount of data in the second shared buffer is small. In this case, a message to adjust the second audio data transmission thread is sent to the POP sound active elimination module.

[0098] It should be noted that the first preset threshold can be pre-set according to demand. For example, the first preset threshold can be any value greater than one frame of audio data (such as 8K).

[0099] As an example, the POP sound prediction module can detect the data volume of the second shared buffer not only through the framework layer thread, but also through other methods. Figure 6 , when the data reporting cycle is met, the second shared buffer can send the amount of cached audio data to the POP prediction module, so that the POP prediction module can detect the amount of data in the second shared buffer. Figure 6 The dotted line in the figure indicates the flow direction related to the second shared buffer.

[0100] In some embodiments, the situations in which the data reporting period is satisfied may include the situation in which the amount of data in the second shared buffer is less than a second preset threshold, or the situation in which the number of times audio data is written in the second shared buffer reaches a first preset number of times, or the situation in which the second shared buffer reaches a first preset reporting period, etc. The embodiments of the present application do not impose specific restrictions on this.

[0101] It should be noted that the second preset threshold can be pre-set according to demand, and the second preset threshold is greater than the first preset threshold. As can be seen from the above, the second audio data transmission thread periodically transmits audio data to the second shared buffer. Therefore, the first predicted number of times can be the number of times the second audio data transmission thread transmits audio data to the second shared buffer. The first preset number of times can also be pre-set according to demand. For example, the first preset number of times can be 3 times, 4 times or 5 times. The first preset reporting period can be a pre-set fixed value. For example, the first preset reporting period can be 10 seconds, 20 seconds or 30 seconds.

[0102] Step 406: upon receiving the message for adjusting the second audio data transmission thread, the POP sound active elimination module adjusts the parameters of the second audio data transmission thread.

[0103] As an example, the POP sound active elimination module adjusts the parameters of the second audio data transmission thread, including adjusting the priority of the second audio data transmission thread, adjusting the core where the second audio data transmission thread is located, adjusting the minimum operating frequency of the processor, etc.

[0104] For example, see Figure 7, adjusting the parameters of the adjustable threads includes adjusting the priority of the adjustable threads in each layer of the control system, adjusting the affinity of the processor or central processing unit (CPU) and adjusting the control group function (Control Group, CGroup). Among them, the adjustable threads include the adjustment of the priority of the real-time thread and the adjustment of the priority of the non-real-time thread, and the adjustment of the priority of the real-time thread can be achieved through the chrt command, and the priority adjustment of the non-real-time thread can be achieved through the renice command. The application layer thread (that is, the second audio data transmission thread) is usually a non-real-time thread. Therefore, in the case where the second audio data transmission thread needs to be adjusted, the POP sound active elimination module can adjust the second audio data transmission thread through the nice command. The adjustment of CPU affinity refers to adjusting the adjustable thread to run on other cores. This process can be completed through the taskset mechanism, that is, in the case where the core where the second audio data transmission thread is located needs to be adjusted, the POP sound active elimination module can adjust the second audio data transmission thread to run on other cores through the taskset mechanism. The adjustment of CGroup may include the adjustment of the minimum operating frequency of the CPU, and the minimum operating frequency of the CPU is usually increased by increasing the virtual load for the CPU.

[0105] As an example, the POP sound active elimination module adjusts the priority of the second audio data transmission thread by: adjusting the priority value corresponding to the second audio data transmission thread from a first priority value to a second priority value, so as to adjust the priority of the second audio data transmission thread from a first priority value to a second priority value, the second priority value is a value smaller than the first priority value, the priority value is negatively correlated with the priority, and the second priority is higher than the first priority.

[0106] It should be noted that the value range of the priority value can be preset. For example, the value range of the priority value of a non-real-time thread can be between -20 and 20, and the lower the priority value, the higher the priority.

[0107] As an example, the POP sound active elimination module can directly adjust the priority of the second audio data transmission thread to the highest priority, or adjust the priority of the second audio data transmission thread to any level higher than the first priority. The embodiments of the present application do not impose specific restrictions on this.

[0108] As an example, the adjustment of the core where the second audio data transmission thread is located by the POP sound active elimination module includes: adjusting the second audio data transmission thread from the first core of the processor to the second core, and the processing capacity of the second core is greater than the processing capacity of the first core.

[0109] It should be noted that the POP sound active elimination module can directly adjust the second audio data transmission thread to run in the core with the strongest processing capability, or it can adjust the second audio data transmission thread to run in any core with higher processing capability than the first core. The embodiment of the present application does not impose specific restrictions on this.

[0110] As an example, the operation of the POP audio active elimination module adjusting the minimum operating frequency of the processor includes: adding a virtual load to the processor.

[0111] Since the transmission of audio data is periodic, that is, the audio data is transmitted at intervals, when it is not transmitted, the CPU will reduce the operating frequency according to its own algorithm. Then, after the CPU is reduced to the lowest operating frequency, when there is audio data transmission, the CPU may not have time to increase the operating frequency, which may cause the audio data to be processed slowly, and then cause the generation of POP sound. Therefore, in order to reduce the possibility of POP sound generation and eliminate POP sound, the POP active elimination module can add a virtual load to the processor to increase the minimum operating frequency of the CPU. That is, the minimum operating frequency of the CPU is increased from the preset frequency to the first frequency.

[0112] In some embodiments, the POP active elimination module can simultaneously adjust the priority of the second audio data transmission thread, adjust the core where the second audio data transmission thread is located, and increase the virtual load of the processor. Of course, since adjusting multiple parameters at the same time may bring about some other sacrifices, for example, it may affect the operation of other threads. Therefore, the POP sound active elimination module can also adjust one parameter at a time. After adjusting one of the parameters, the next time the POP sound prediction module detects that the amount of data in the second shared buffer is still small, the POP sound active elimination module can continue to adjust one of the remaining parameters. If the POP sound prediction module detects that the amount of data in the second shared buffer is large next time, the POP sound active elimination module will no longer continue to adjust the remaining unadjusted parameters.

[0113] As an example, the case where the amount of data in the second shared buffer is larger may include the case where the amount of data in the re-detected second shared buffer is greater than or equal to the third preset threshold, or the case where the amount of data in the re-detected second shared buffer is greater than the amount of data in the second shared buffer detected before adjusting the second audio data delivery thread. Figure 5 At time T2, the POP sound prediction module detects that the amount of data in the second shared buffer is greater than or equal to the third preset threshold. In this case, the POP sound prediction module will no longer send messages to the POP active elimination module, and the POP sound active elimination module will no longer adjust parameters.

[0114] It should be noted that the third preset threshold can be pre-set according to demand, and the third preset threshold is greater than the first preset threshold.

[0115] Exemplarily, after the POP sound active elimination module adjusts the priority of the second audio data transmission thread from the first priority to the second priority, the POP sound prediction module can re-detect the amount of data in the second shared buffer in the manner of step 405 above. When it is detected that the amount of data in the second shared buffer is small, the POP sound active elimination module can adjust the second audio data transmission thread from the first core of the processor to run on the second core; thereafter, the POP sound prediction module detects the amount of data in the second shared buffer again, and adds a virtual load to the CPU when the amount of data in the second shared buffer is small. The POP sound prediction module can continue to detect the amount of data in the second shared buffer. When it is detected that the amount of data in the second shared buffer is large, the POP sound prediction module will not send a message to the POP sound active elimination module, so that the POP sound active elimination module will no longer perform any operation. If the amount of data in the second shared buffer detected again is still small, the POP sound prediction module can continue to send a message to the POP active elimination module, and the POP sound active elimination module can once again increase the priority of the second audio data transmission thread. That is, when the amount of data in the second shared buffer is small, the POP sound active elimination module can continue to adjust the parameters of the second audio data transmission thread in the order of adjusting priority, adjusting the core, and increasing the virtual load until the POP sound prediction module detects that the amount of data in the second shared buffer is large.

[0116] It is worth noting that by adjusting the parameters of the second audio data transmission thread one by one, it is possible to avoid affecting other threads in the electronic device during the process of adjusting multiple parameters at the same time.

[0117] In some embodiments, when the POP sound active elimination module adjusts parameters one by one, if the priority of the second audio data transmission thread is already the highest priority, in this case, the POP sound active elimination module can directly adjust the core where the second audio data transmission thread is located; if there is no core in the processor with a processing power higher than the core where the second audio data transmission thread is currently located, the POP sound active elimination module can directly increase the virtual load for the CPU.

[0118] In some embodiments, if the amount of data in the second shared buffer is large, that is, during the audio playback process, POP sound will not be generated in the audio due to the amount of data in the second shared buffer, then the POP sound prediction module will not send a message to the POP sound active elimination module to adjust the second audio data transmission thread, and the POP sound active elimination will not adjust the parameters of the second audio data transmission thread.

[0119] Step 407: When the HAL layer thread receives the audio data transmitted by the framework layer thread, it transmits the received audio data to the first shared buffer.

[0120] It should be noted that in the embodiment of the present application, the order of executing step 405, step 406 and step 407 is not limited, that is, the operation of step 405 can be performed simultaneously with the operation of step 407, or the operations of step 405 and step 406 can be performed in sequence, and then the operation of step 407 can be performed, or the operation of step 407 can be performed first, and then the operations of steps 405 and 406 are performed in sequence. The implementation of the present application does not impose any specific restrictions on this.

[0121] As an example, the kernel layer may provide an interface for the HAL layer, and the HAL layer thread may transfer audio data to the first shared buffer through the interface provided by the kernel layer.

[0122] It should be noted that the HAL layer thread also periodically transmits audio data to the first shared buffer. For example, the HAL layer thread transmits audio data to the first shared buffer according to the above transmission period.

[0123] Step 408: When receiving the audio data transmitted by the HAL layer thread, the first shared buffer caches the received audio data.

[0124] Step 409: When the data reporting period is met, the first shared buffer may send a message carrying the data volume of the first shared buffer to the POP sound prediction module.

[0125] It should be noted that, during the process of playing audio, if the audio data is written to the first shared buffer for the first time, the embodiment of the present application can perform relevant operations in the order of step 407, step 408 and step 409. If the audio data is not written to the first shared buffer for the first time, the embodiment of the present application does not limit the execution order of step 407, step 408 and step 409. That is, during the process of playing audio, if the audio data is not written to the first shared buffer for the first time, the embodiment of the present application can be executed in the order of step 407, step 408 and step 409, or in the order of step 409, step 407 and step 408, or in the order of step 407, step 409 and step 408, or the operation of step 407 or step 408 can also be performed simultaneously with the operation of step 409, etc. The embodiment of the present application does not impose specific restrictions on this.

[0126] As an example, the first shared buffer may send a message carrying the data amount of the first shared buffer to the POP sound prediction module through an interrupt handler of the kernel layer.

[0127] As an example, the situation where the first shared buffer meets the data reporting cycle may include the situation where the amount of data in the first shared buffer is less than a fourth preset threshold, or the situation where the number of times audio data is written in the first shared buffer reaches a second preset number of times, or the situation where the first shared buffer reaches a second preset reporting cycle, etc. The embodiments of the present application do not impose specific restrictions on this.

[0128] It should be noted that the fourth preset threshold can be pre-set according to demand, and the fourth preset threshold is greater than the first preset threshold. The fourth preset threshold may be the same as the second preset threshold or different, and the embodiment of the present application does not impose specific restrictions on this. As can be seen from the above, the HAL layer thread also periodically transmits audio data to the first shared buffer. Therefore, the second predicted number of times can be the number of times the HAL layer thread transmits audio data to the first shared buffer. The second preset number of times can also be pre-set according to demand. For example, the second preset number of times can be 3 times, 4 times or 5 times, etc. The second preset number of times can be the same as the first preset number of times or different. The second preset reporting period can be a pre-set fixed value. For example, the second preset reporting period can be 10 seconds, 20 seconds or 30 seconds, etc., and the second preset reporting period can be the same as or different from the first preset reporting period.

[0129] In some embodiments, when the data reporting period is met, see Figure 6 , the first shared buffer can directly send a message carrying the data volume of the first shared buffer to the POP sound prediction module. Figure 6 The bold solid line in the figure indicates the flow direction related to the first shared buffer. Alternatively, the first shared buffer may send a message carrying the data volume of the first shared buffer to the HAL layer thread, and then the HAL layer thread forwards the message carrying the data volume of the first shared buffer to the POP sound prediction module.

[0130] Step 410: When the POP sound prediction module receives a message carrying the data amount of the first shared buffer, if it determines that the data amount of the first shared buffer is small, it sends a message to the POP sound active elimination module to adjust the first audio data transmission thread.

[0131] It should be noted that the first audio data transmission thread includes a framework layer thread and a HAL layer thread. The message for adjusting the first audio data transmission thread sent to the POP sound active elimination module carries the buffer identifier of the first shared buffer.

[0132] As an example, the case where the amount of data in the first shared buffer is small includes the case where the amount of data in the first shared buffer is less than a first preset threshold, such as Figure 5 As shown, or, the data amount of the first shared buffer detected this time is less than the data amount of the first shared buffer detected previously.

[0133] Step 411: upon receiving a message for adjusting the first audio data transmission thread, the POP sound active elimination module adjusts the parameters of the first audio data transmission thread.

[0134] It can be seen from the above that the first audio data transmission thread includes a framework layer thread and a HAL layer thread. Therefore, adjusting the parameters of the first audio data transmission thread refers to adjusting the parameters of the framework layer thread and the parameters of the HAL layer thread.

[0135] For example, see Figure 7 , adjusting the parameters of the adjustable threads includes adjusting the priority of the adjustable threads in each layer of the control system, adjusting the CPU affinity and adjusting the control group function (Control Group, CGroup). Among them, the adjustable threads include the adjustment of the priority of the real-time thread and the adjustment of the priority of the non-real-time thread, and the adjustment of the priority of the real-time thread can be achieved through the chrt command, and the adjustment of the priority of the non-real-time thread can be achieved through the renice command. The framework layer thread and the HAL layer thread can belong to the real-time thread or the non-real-time thread. Therefore, when the first audio data transmission thread is needed, the POP sound active elimination module can adjust the priority of the first audio data transmission thread through the chrt command, and can also adjust the priority of the first audio data transmission thread through the renice command.

[0136] It should be noted that the adjustment of the parameters of the first audio data transmission thread by the POP sound active elimination module can refer to the operation of adjusting the parameters of the second audio data transmission thread by the POP sound active elimination module in the above step 406, and the embodiment of the present application will not go into details about this.

[0137] As an example, the first shared buffer and the second shared buffer may have a problem with a small amount of data at the same time, or any one of the first shared buffer and the second shared buffer may have a problem with a small amount of data. In the case where the problems occur at the same time, the POP sound active elimination module can adjust the parameters of the first audio data transmission thread and the parameters of the second audio data transmission thread at the same time. In the case where a problem occurs in one of the shared buffers, the parameters of the corresponding audio transmission threads are adjusted one by one until the amount of data in the shared buffer with the problem increases, and then the adjustment is stopped.

[0138] For example, see Figure 8In the process of playing audio, the POP sound prediction module can determine whether POP sound may be generated according to the data volume of the first shared buffer and the data volume of the second shared buffer when detecting the data volume of the first shared buffer and the data volume of the second shared buffer. If POP sound will not be generated, no message will be sent to the POP sound active elimination module, that is, no parameter adjustment will be performed; if POP sound will be generated, an adjustment message will be sent to the POP sound active elimination module, and the POP sound active elimination module can determine the audio data transmission thread that needs to be adjusted according to the buffer identifier carried in the adjustment message. Afterwards, it is determined whether the priority of the audio data transmission thread that needs to be adjusted is the highest priority. If it is not the highest priority, the priority of the audio data transmission thread is adjusted, that is, the priority is increased; if the priority is already the highest priority, it is determined whether there is a core of a processor with stronger processing power. If there is a core with stronger processing power, the audio data transmission thread that needs to be adjusted is adjusted to run in the core with stronger processing power; if there is no core with stronger processing power, it is determined whether the minimum operating frequency of the processor is the preset frequency. If so, the minimum operating frequency of the processor is increased. If not, no parameter adjustment is performed. After any parameter is adjusted, the POP sound prediction module continues to determine whether a POP sound will be generated.

[0139] In an embodiment of the present application, during the audio playback process, when the amount of data in any one of the first shared buffer and the second shared buffer is small, the priority of the corresponding audio data transmission thread can be increased. If after adjusting the priority, the amount of data in the shared buffer with the problem is still small, the corresponding audio data transmission thread can continue to be adjusted to the core with stronger processing capability. If after the adjustment, the amount of data in the shared buffer with the problem becomes larger, it means that the amount of data in each shared buffer is sufficient to support smooth audio playback. That is, when the amount of data in the first shared buffer or the second shared buffer is small, through a series of parameter adjustments, the possibility of POP sound is reduced, the POP sound that occurs when the amount of data in the shared buffer is small is eliminated, and the audio playback effect is improved.

[0140] In order to facilitate understanding of the embodiments of the present application, the following example is taken as an example where the amount of data in the second shared buffer is large and the parameters of the second audio data transmission thread do not need to be adjusted, while the amount of data in the first shared buffer is small and the parameters of the first audio data transmission thread need to be adjusted. Fig. 9 , Fig. 9 The present invention is a flowchart of a method for eliminating popping sounds in audio according to an exemplary embodiment. As an example but not a limitation, the method is described here by taking the application of the method in an electronic device equipped with an audio playback function as an example. The method may include some or all of the following contents:

[0141] Step 901: During audio playback, in a first detection period, detect that the amount of data in a first shared buffer is a first value.

[0142] It should be noted that the first shared buffer is a buffer for caching audio data transmitted by the first audio data transmission thread, or it can be said that the first shared buffer is used to cache audio data transmitted by the first audio data transmission thread; in the first detection period, the priority of the first audio data transmission thread is the first priority, and it runs on the first core of the processor. The first value is greater than the first preset threshold.

[0143] From the above, it can be seen that the electronic device includes a POP sound prediction module; the first audio data transmission thread includes a hardware abstraction layer thread (HAL layer thread); as an example, during the process of playing audio, the electronic device detects that the amount of data in the first shared buffer is a first value during the first detection period, and the operation includes: during the process of playing audio, when the data reporting cycle is met, the first shared buffer reports a first write message to the hardware abstraction layer thread, and the first write message carries the first value; after receiving the first write message, the hardware abstraction layer thread sends a first data message to the POP sound prediction module, and the first data message carries the first value; the POP sound prediction module obtains the first value from the first data message.

[0144] It should be noted that the first write message can be a message carrying the data amount of the first shared buffer sent by the first shared buffer to the HAL layer thread in the above step 409, and the first data message can be a message carrying the data amount of the first shared buffer forwarded by the HAL layer thread to the POP sound prediction module in the above step 409.

[0145] As an example, when the data reporting cycle is met, the first shared buffer can also directly report the first write message to the POP sound prediction module, and the embodiment of the present application does not impose any specific restrictions on this.

[0146] It is worth noting that during the audio playback process, by obtaining the data volume of the first shared buffer, it is possible to predict whether POP sound will be generated in the audio, and then the POP sound can be eliminated in time, reducing the possibility of POP sound generation.

[0147] Step 902: During the second detection period, when the priority of the first audio data transmission thread is the first priority and it runs in the first core, the amount of data in the first shared buffer is the second value, and the second value is smaller than the first value, the priority of the first audio data transmission thread is adjusted from the first priority to the second priority.

[0148] It should be noted that the second priority is higher than the first priority. The second detection period is any detection period after the first detection period.

[0149] As an example, if a first preset threshold is set in the electronic device, the second value is not only smaller than the first value, but also smaller than the first preset threshold.

[0150] As can be seen from the above, the priority of a thread can be reflected by the priority value of the thread, and the priority value is negatively correlated with the priority, that is, the lower the priority value, the higher the priority. Therefore, in the second detection period, when the priority of the first audio data transmission thread is the first priority, and it runs in the first core, the amount of data in the first shared buffer is the second value, and the second value is less than the first value, the electronic device can adjust the priority value corresponding to the first audio data transmission thread from the first priority value to the second priority value, and the second priority value is a value less than the first priority value.

[0151] It should be noted that the way in which the electronic device detects the amount of data in the first shared buffer during the second detection period is the same as the way in which the electronic device detects the amount of data in the first shared buffer during the first detection period, and this embodiment of the present application will not be described in detail.

[0152] It is worth noting that by adjusting the priority value to adjust the priority, the adjustment of the priority has specific numerical support, which improves the accuracy of adjusting the priority.

[0153] In some embodiments, since during the second detection period, the state of the first audio data transmission thread has not changed compared to the first detection period, but during the second detection period, the amount of data in the first shared buffer is reduced, if the electronic device is provided with a first preset threshold, then when the second value is less than the first preset threshold, it indicates that the probability of generating a POP sound in the audio is very high, and therefore, the electronic device may increase the priority of the first audio data transmission thread to increase resource allocation to the first audio data transmission thread and reduce the possibility of generating a POP sound. If the electronic device does not have a first preset threshold, then when the second value is less than the first value, it indicates that the speed of writing audio data to the first shared buffer by the first audio data transmission thread has decreased, and there is also the possibility of generating a POP sound, and therefore, the electronic device may increase the priority of the first audio data transmission thread.

[0154] As can be seen from the above, the electronic device includes a POP sound prediction module and a POP sound active elimination module; as an example, in the second detection period, the priority of the first audio data transmission thread is the first priority, and it runs in the first core, the data volume of the first shared buffer is the second value, and the second value is less than the first value, the priority of the first audio data transmission thread is adjusted from the first priority to the second priority, and the second priority is higher than the first priority. The operation includes: in the second detection period, the priority of the first audio data transmission thread is the first priority, and it runs in the first core. If the data reporting cycle is met, the first shared buffer reports a second write message to the hardware abstraction layer thread, and the second write message carries the second value; when the hardware abstraction layer thread receives the second write message, it sends a second data message to the POP sound prediction module, and the second data message carries the second value; when the second value is less than the first value, the POP sound prediction module sends a first adjustment message to the POP sound active elimination module, and the first adjustment message carries the buffer identifier of the first shared buffer; after receiving the first adjustment message, the POP audio active module determines to adjust the priority of the first audio data transmission thread, and adjusts the priority corresponding to the first audio data transmission thread from the first priority to the second priority.

[0155] It should be noted that the first adjustment message may be a message sent by the POP sound prediction module to the POP sound active elimination module in the above step 410 to adjust the first audio data transmission thread.

[0156] As an example, the POP sound prediction module may send a first adjustment message to the POP sound active elimination module when the second value is less than the first value, or may send a first adjustment message to the POP sound active elimination module when the second value is less than the first preset threshold.

[0157] Since the first audio data transmission thread includes a framework layer thread and a HAL layer thread, the electronic device can adjust the priority of the framework layer thread and the HAL layer thread at the same time, or adjust the priority of one of the threads, that is, the electronic device can adjust the priority of the framework layer thread without adjusting the priority of the HAL layer thread, or the electronic device adjusts the priority of the HAL layer thread without adjusting the priority of the framework layer thread.

[0158] It is worth noting that by carrying the buffer identifier of the first shared buffer in the first adjustment message, the POP sound active elimination module can accurately know which audio data transmission thread parameters need to be adjusted, making the parameter adjustment more targeted and improving the accuracy of the adjustment parameters.

[0159] In some embodiments, during the second detection period, the priority of the first audio data transmission thread is the first priority and it runs in the first core, the amount of data in the first shared buffer is the second value, and the second value is less than the first value, if the priority of the first audio data transmission thread is currently the highest priority, the electronic device may not adjust the priority of the first audio data transmission thread, but adjust the first audio data transmission thread to run in the second core of the processor, and the processing power of the second core is greater than the processing power of the first core.

[0160] Step 903: In the third detection period, when the priority of the first audio data transmission thread is the second priority and it runs in the first core, the amount of data in the first shared buffer is a third value, and the third value is less than the first value, the first audio data transmission thread is adjusted to run in the second core of the processor.

[0161] It should be noted that the processing capacity of the second core is greater than the processing capacity of the first core. The third detection period is any period after the second detection period. The electronic device detects the amount of data in the first shared buffer in the third detection period in the same way as the electronic device detects the amount of data in the first shared buffer in the first detection period, and the embodiments of the present application will not be described one by one.

[0162] Since the third value is smaller than the first value, it indicates that the amount of data in the first shared buffer has not increased sufficiently. In this case, POP sound may still be generated in the audio. Therefore, the electronic device can adjust the first audio data transmission thread to run in the second core.

[0163] It should be noted that, when the third value is less than the first value, the third value may be greater than the second value or less than the second value, and the embodiment of the present application does not impose specific restrictions on this. If a first preset threshold is set, the third value is less than or equal to the first preset threshold.

[0164] It is worth noting that by adjusting the first audio data transmission thread to run in the second core with higher processing power, the speed at which the first audio data transmission thread transmits audio data is improved, which can further reduce the possibility of POP sound.

[0165] As an example, when there is no core in the processor with processing power greater than that of the first core, for example, when the first core is the core with the strongest processing power in the processor, or, the processor is a single-core processor and there are no other cores in the processor except the first core, in this case, the electronic device can continue to run the first audio data transmission thread in the first core and once again increase the priority of the first audio data transmission thread, or, the electronic device can increase the virtual load for the processor to increase the minimum operating frequency of the processor.

[0166] Step 904: In the fourth detection period, when the priority of the first audio data transmission thread is the second priority and it runs on the second core, the amount of data in the first shared buffer is the fourth value, and the fourth value is greater than the first value, it is determined that this round of elimination of POP sounds in the audio has been completed.

[0167] Since the fourth value is greater than the first value, it means that the amount of data in the first shared buffer has increased sufficiently. In this case, the possibility of generating POP sound in the audio is small. Therefore, the electronic device can determine that this round of elimination of POP sound in the audio has been completed.

[0168] As an example, if a third preset threshold is set in the electronic device, when the fourth value is greater than the first value, the fourth value is also greater than the third preset threshold.

[0169] It should be noted that the way in which the electronic device detects the amount of data in the first shared buffer in the fourth detection period is the same as the way in which the above-mentioned electronic device detects the amount of data in the first shared buffer in the first detection period, and this embodiment of the present application will not be described in detail.

[0170] In some embodiments, during the fourth detection period, the amount of data in the first shared buffer may also be less than the first value. In this case, the electronic device needs to continue to adjust the relevant parameters of the first audio data transmission thread. That is, during the fourth detection period, the priority of the first audio data transmission thread is the second priority, and it runs on the second core, the amount of data in the first shared buffer is the fifth value, and the fifth value is less than the first value, then the virtual load is added to the processor to increase the minimum operating frequency of the processor from the preset frequency to the first frequency; during the fifth detection period, the priority of the first audio data transmission thread is the second priority, and it runs on the second core, the operating frequency of the processor is the first frequency, the amount of data in the first shared buffer is the sixth value, and the sixth value is greater than the first value, then it is determined that this round of elimination of POP sounds in the audio has been completed.

[0171] In some embodiments, the electronic device may increase the virtual load on the processor, and may again increase the priority of the first audio data transmission thread, or again adjust the first audio data transmission thread to a core having a processing capability greater than that of the second core.

[0172] It is worth noting that by adding a virtual load to the processor, the minimum operating frequency of the processor can be increased, so that the processor can respond quickly when transmitting audio data at the beginning of each transmission cycle, thereby increasing the transmission speed of audio data and reducing the possibility of generating POP sound.

[0173] In some embodiments, in the fifth detection period, when the amount of data in the first shared buffer is still less than the first value, the electronic device can once again increase the priority of the first audio data transmission thread, or once again adjust the first audio data transmission thread to a core whose processing capacity is greater than that of the second core. Exemplarily, in the fifth detection period, when the priority of the first audio data transmission thread is the second priority and it runs on the second core, the operating frequency of the processor is the first frequency, the amount of data in the first shared buffer is the tenth value, and the tenth value is less than the first value, the priority of the first audio data transmission thread is adjusted from the second priority to the third priority, and the third priority is higher than the second priority.

[0174] It should be noted that, in the above-mentioned first detection period, second detection period, third detection period and fourth detection period, the amount of data in the second shared buffer is greater than the first value, and the second shared buffer is a buffer for caching audio data transmitted to the first audio data transmission thread (it can also be said that the second shared buffer is used to cache audio data transmitted by the second audio data transmission thread). That is, in the first detection period, the second detection period, the third detection period and the fourth detection period, the amount of data in the second shared buffer is large enough and will not cause the generation of POP sound.

[0175] In some embodiments, during the fourth detection period, the priority of the first audio data transmission thread is the second priority and it runs on the second core, the amount of data in the first shared buffer is a fourth value, and the fourth value is greater than the first value, after determining that this round of elimination of POP sounds in the audio has been completed, the electronic device can receive an operation to terminate the playback of the audio; in response to the operation to terminate the playback of the audio, the playback of the audio is stopped, and the state of the first audio data transmission thread and the state of the processor are restored to the state corresponding to the first detection period.

[0176] During the audio playback process, the user may interrupt the playback of the current audio, for example, switch to the next audio, or pause the playback of the current audio, or exit the music application where the currently playing audio is located, etc. In these cases, the electronic device may receive an operation to stop the playback of the audio. In response to the operation, the electronic device may stop the playback of the current audio and restore the state of the first audio data transmission thread and the state of the processor to the state corresponding to the first detection period. That is, the priority of the first audio data transmission thread is restored to the first priority, and the first audio data transmission thread is restored to run in the first core, and the virtual load of the processor is removed, so that the minimum operating frequency of the processor is the preset frequency.

[0177] It is worth noting that after stopping the audio playback, restoring the state of the first audio data transmission thread and the state of the processor to the state corresponding to the first detection period can avoid long-term impact on other threads due to parameter adjustment.

[0178] In an embodiment of the present application, during audio playback, when the amount of data in the first shared buffer is small, the priority of the first audio data transmission thread can be increased. If, after adjusting the priority, the amount of data in the first shared buffer is still small, the first audio data transmission thread can continue to be adjusted to the core with stronger processing capability. If, after the adjustment, the amount of data in the first shared buffer increases, it means that the amount of data in the first shared buffer is sufficient to support smooth audio playback. That is, when the amount of data in the first shared buffer is small, through a series of parameter adjustments, the possibility of POP sound is reduced, the POP sound that occurs when the amount of data in the first shared buffer is small is eliminated, and the audio playback effect is improved.

[0179] Since the amount of data in the second shared buffer changes at any time, in the fourth detection period, the priority of the first audio data transmission thread is the second priority, and it runs on the second core, the amount of data in the first shared buffer is the fourth value, and the fourth value is greater than the first value. After it is determined that the elimination of the POP sound in the audio has been completed, the amount of data in the second shared buffer may become smaller, resulting in the generation of POP sound in the audio. Therefore, the following example is used to explain that the amount of data in the second shared buffer is small and the parameters of the second audio data transmission thread need to be adjusted. Please refer to Fig.10 , Fig.10 This is a flowchart of a method for eliminating popping sounds in audio according to another exemplary embodiment. As an example but not a limitation, the method is described here by taking the application of the method in an electronic device equipped with an audio playback function as an example. The method may include some or all of the following contents:

[0180] Step 1001: In the sixth detection period, when the priority of the second audio data transmission thread is the first priority and the second audio data transmission thread runs in the first core, the amount of data in the second shared buffer is the seventh value and the seventh value is less than the first value, the priority of the second audio data transmission thread is adjusted from the first priority to the second priority.

[0181] Since the seventh value is smaller than the first value, it indicates that the amount of data in the second shared buffer is small, which may cause POP sound in the audio. Therefore, the electronic device can adjust the priority of the second audio data transmission thread from the first priority to the second priority.

[0182] It should be noted that, when a first preset threshold is set, the seventh value is less than the first preset threshold. The sixth detection period is any period after the fourth detection period.

[0183] As can be seen from the above, the electronic device includes a POP sound prediction module and a POP sound active elimination module; as an example, in the sixth detection period, the priority of the second audio data transmission thread is the first priority, and the second audio data transmission thread runs in the first core, the data volume of the second shared buffer is the seventh value, and the seventh value is less than the first value, the operation of adjusting the priority of the second audio data transmission thread from the first priority to the second priority includes: in the sixth detection period, the priority of the second audio data transmission thread is the first priority, and the second audio data transmission thread runs in the first core, the first audio data transmission thread obtains the data volume in the second shared buffer from the second shared buffer to obtain the seventh value; when the first audio data transmission thread obtains the seventh value, the third data message is sent to the POP sound prediction module, and the third data message carries the seventh value; when the seventh value is less than the first value, the POP sound prediction module sends a second adjustment message to the POP sound active elimination module, and the second adjustment message carries the buffer identifier of the second shared buffer; when the POP sound active elimination module receives the second adjustment message, it is determined to adjust the priority of the second audio data transmission thread, and adjust the priority of the second audio data transmission thread from the first priority to the second priority.

[0184] It should be noted that the second adjustment message is the message sent to the POP sound active elimination module in the above step 405 to adjust the second audio data transmission thread.

[0185] As an example, the operation of the POP sound active elimination module adjusting the priority of the second sound data transmission thread from the first priority to the second priority can refer to the operation of the POP sound active elimination module adjusting the priority of the second sound data transmission thread from the first priority to the second priority in the above step 406, and the embodiments of the present application will not elaborate on this one by one.

[0186] It is worth noting that by obtaining the amount of data in the second shared buffer from the second shared buffer through the first audio data transmission thread, it is possible to promptly discover whether the amount of data in the second shared buffer will cause the occurrence of POP sound, thereby improving the timeliness of eliminating POP sound.

[0187] Step 1002: In the seventh detection period, the priority of the second audio data transmission thread is the second priority and it runs in the first core, the amount of data in the second shared buffer is the eighth value, and the eighth value is less than the first value, the second audio data transmission thread is adjusted to run in the second core.

[0188] It should be noted that the processing capacity of the second core is greater than the processing capacity of the first core. The seventh detection period is any period after the sixth detection period. The way in which the electronic device detects the amount of data in the second shared buffer in the seventh detection period is the same as the way in which the above-mentioned electronic device detects the amount of data in the second shared buffer in the sixth detection period, and the embodiments of the present application will not be described one by one.

[0189] Since the eighth value is smaller than the first value, it indicates that the amount of data in the second shared buffer has not increased sufficiently. In this case, POP sound may still be generated in the audio. Therefore, the electronic device can adjust the second audio data transmission thread to run in the second core.

[0190] It should be noted that, when the eighth value is less than the first value, the eighth value may be greater than the seventh value or less than the seventh value, and the embodiment of the present application does not impose specific restrictions on this. If a first preset threshold is set, the eighth value is less than the first preset threshold.

[0191] Step 1003: In the eighth detection period, when the priority of the second audio data transmission thread is the second priority and it runs on the second core, the amount of data in the second shared buffer is the ninth value, and the ninth value is greater than the first value, it is determined that a new round of elimination of POP sounds in the audio has been completed.

[0192] Since the ninth value is greater than the first value, it indicates that the amount of data in the second shared buffer has increased sufficiently. In this case, the possibility of generating POP sounds in the audio is small. Therefore, the electronic device can determine that a new round of elimination of POP sounds in the audio has been completed.

[0193] It should be noted that the way in which the electronic device detects the amount of data in the second shared buffer in the eighth detection period is the same as the way in which the above-mentioned electronic device detects the amount of data in the second shared buffer in the sixth detection period, and the embodiment of the present application will not be described in detail.

[0194] In some embodiments, during the eighth detection period, the amount of data in the second shared buffer may also be less than the first value. In this case, the electronic device needs to continue to adjust the relevant parameters of the second audio data transmission thread. The operation of the electronic device continuing to adjust the relevant parameters of the second audio data transmission thread can refer to the operation of the electronic device adjusting the relevant parameters of the second audio data transmission thread in the fourth detection period in step 904 above, and this embodiment of the application will not be repeated one by one.

[0195] In some embodiments, when the electronic device is in the eighth detection period, the priority of the second audio data transmission thread is the second priority and it runs on the second core, the amount of data in the second shared buffer is the ninth value, and the ninth value is greater than the first value, after determining that a new round of elimination of POP sounds in the audio has been completed, if the electronic device receives an operation to terminate the playback of the audio, it will stop the playback of the audio in response to the operation to terminate the playback of the audio, and restore the state of the second audio data transmission thread and the state of the processor to the state corresponding to the first detection period, the second detection period, the third detection period or the fourth detection period.

[0196] In an embodiment of the present application, when the amount in the second shared buffer is insufficient to support audio playback, the relevant parameters of the second audio data transmission thread are adjusted until the amount of data in the second shared buffer does not cause POP sound to be generated, thereby reducing the possibility of POP sound occurrence, eliminating the POP sound that occurs when the amount of data in the second shared buffer is small, and improving the audio playback effect.

[0197] Next, the electronic device involved in the embodiment of the present application is described.

[0198] Fig.11 is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Fig.11The electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0199] It is to be understood that the structure illustrated in the embodiment of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or split some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0200] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.

[0201] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0202] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0203] In some embodiments, the processor 110 may include one or more interfaces, such as an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0204] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present application is only a schematic illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0205] The charging management module 140 is used to receive charging input from a charger. The charger may be a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 may receive charging input from a wired charger through the USB interface 130. In some wireless charging embodiments, the charging management module 140 may receive wireless charging input through a wireless charging coil of the electronic device 100. While the charging management module 140 is charging the battery 142, it may also power the electronic device 100 through the power management module 141.

[0206] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193 and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle number, battery health status (leakage, impedance), etc. In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0207] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0208] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. GNSS may include the global positioning system (GPS), the global navigation satellite system (GLONASS), the Beidou navigation satellite system (BDS), the quasi-zenith satellite system (QZSS) and / or the satellite based augmentation system (SBAS).

[0209] The electronic device 100 implements the display function through a GPU, a display screen 194, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 may include one or more GPUs that execute program instructions to generate or change display information.

[0210] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), Miniled, MicroLed, Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include 1 or N display screens 194, where N is an integer greater than 1.

[0211] The electronic device 100 can realize the shooting function through ISP, camera 193, video codec, GPU, display screen 194 and application processor.

[0212] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to implement a data storage function, such as storing music, video and other files in the external memory card.

[0213] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area may store data created by the electronic device 100 during use (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0214] The electronic device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone interface 170D and the application processor.

[0215] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110.

[0216] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.

[0217] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.

[0218] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.

[0219] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130, or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0220] The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A can be set on the display screen 194. There are many types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, capacitive pressure sensors, etc. The capacitive pressure sensor can be a parallel plate including at least two conductive materials. When a force acts on the pressure sensor 180A, the capacitance between the electrodes changes. The electronic device 100 determines the intensity of the pressure based on the change in capacitance. When a touch operation acts on the display screen 194, the electronic device 100 detects the touch operation intensity according to the pressure sensor 180A. The electronic device 100 can also calculate the touch position according to the detection signal of the pressure sensor 180A. In some embodiments, touch operations acting on the same touch position but with different touch operation intensities can correspond to different operation instructions. For example: when a touch operation with a touch operation intensity less than a pressure threshold acts on a short message application icon, an instruction to view the short message is executed. When a touch operation with a touch operation intensity greater than or equal to the pressure threshold acts on a short message application icon, an instruction to create a new short message is executed.

[0221] The gyro sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyro sensor 180B. The gyro sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyro sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyro sensor 180B can also be used for navigation and somatosensory game scenes.

[0222] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude through the air pressure value measured by the air pressure sensor 180C to assist positioning and navigation.

[0223] The touch sensor 180K is also called a "touch panel". The touch sensor 180K can be set on the display screen 194, and the touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen". The touch sensor 180K is used to detect touch operations acting on or near it. The touch sensor 180K can pass the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through the display screen 194. In other embodiments, the touch sensor 180K can also be set on the surface of the electronic device 100, which is different from the position of the display screen 194.

[0224] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions may be transmitted from a website site, computer, server or data center by wired (such as: coaxial cable, optical fiber, data subscriber line (Digital Subscriber Line, DSL)) or wireless (such as: infrared, wireless, microwave, etc.) mode to another website site, computer, server or data center. The computer-readable storage medium may be any available medium that a computer can access, or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a digital versatile disc (DVD)), or a semiconductor medium (such as a solid state disk (SSD)).

[0225] The above are optional embodiments provided for the present application and are not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the technical scope disclosed in the present application shall be included in the protection scope of the present application.

Claims

1. A method for eliminating popping sounds in audio, characterized in that: Applied in an electronic device, the method comprises: During the audio playback, in a first detection period, the amount of data in a first shared buffer is detected to be a first value, the first shared buffer is a buffer for caching audio data transmitted by a first audio data transmission thread, and in the first detection period, the priority of the first audio data transmission thread is a first priority and runs on a first core of a processor; In a second detection period, when the priority of the first audio data transmission thread is the first priority and the first audio data transmission thread runs in the first core, the data amount of the first shared buffer is a second value, and the second value is less than the first value, the priority of the first audio data transmission thread is adjusted from the first priority to a second priority, and the second priority is higher than the first priority; In a third detection period, when the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread is running in the first core, and the amount of data in the first shared buffer is a third value, and the third value is less than the first value, the first audio data transmission thread is adjusted to run in the second core of the processor, and the processing capability of the second core is greater than the processing capability of the first core; In a fourth detection period, when the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread runs in the second core, the amount of data in the first shared buffer is a fourth value, and the fourth value is greater than the first value, it is determined that the current round of elimination of the pop sound in the audio has been completed; Among them, during the first detection period, the second detection period, the third detection period and the fourth detection period, the amount of data in the second shared buffer is greater than the first value, and the second shared buffer is a buffer for caching audio data transmitted to the first audio data transmission thread.

2. The method according to claim 1, characterized in that The electronic device includes a POP sound prediction module; the first audio data transmission thread includes a hardware abstraction layer thread; The method of detecting, during the audio playback process, in a first detection period, that the amount of data in the first shared buffer is a first value includes: During the process of playing the audio, if a data reporting period is met, the first shared buffer reports a first write message to the hardware abstraction layer thread, where the first write message carries the first value; After receiving the first write message, the hardware abstraction layer thread sends a first data message to the POP sound prediction module, where the first data message carries the first value; The POP sound prediction module obtains the first value from the first data message.

3. The method according to claim 1, characterized in that In the second detection period, when the priority of the first audio data transmission thread is the first priority and the first audio data transmission thread runs in the first core, the amount of data in the first shared buffer is a second value, and the second value is less than the first value, adjusting the priority of the first audio data transmission thread from the first priority to the second priority, including: In the second detection period, when the priority of the first audio data transmission thread is the first priority and it runs in the first core, the data volume of the first shared buffer is the second value, and the second value is smaller than the first value, the priority value corresponding to the first audio data transmission thread is adjusted from the first priority value to the second priority value, the second priority value is a value smaller than the first priority value, and the priority value is negatively correlated with the priority.

4. The method according to claim 1, characterized in that The electronic device includes a POP sound prediction module and a POP sound active elimination module; the first audio data transmission thread includes a hardware abstraction layer thread; In the second detection period, when the priority of the first audio data transmission thread is the first priority and the first audio data transmission thread runs in the first core, the amount of data in the first shared buffer is a second value, and the second value is less than the first value, adjusting the priority of the first audio data transmission thread from the first priority to the second priority, including: In the second detection period, when the priority of the first audio data transmission thread is the first priority and the first core is running, if the data reporting period is met, the first shared buffer reports a second write message to the hardware abstraction layer thread, and the second write message carries the second value; When receiving the second write message, the hardware abstraction layer thread sends a second data message to the POP sound prediction module, where the second data message carries the second value; When the second value is less than the first value, the POP sound prediction module sends a first adjustment message to the POP sound active elimination module, where the first adjustment message carries a buffer identifier of the first shared buffer; After receiving the first adjustment message, the POP audio active module determines to adjust the priority of the first audio data transmission thread, and adjusts the priority corresponding to the first audio data transmission thread from the first priority to the second priority.

5. The method according to claim 1, characterized in that In the third detection period, if the priority of the first audio data transmission thread is the second priority and the first core is running, the amount of data in the first shared buffer is a third value, and the third value is less than the first value, after adjusting the first audio data transmission thread to run in the second core of the processor, the method further includes: In the fourth detection period, if the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread runs on the second core, the amount of data in the first shared buffer is a fifth value, and the fifth value is less than the first value, then a virtual load is added to the processor so that the minimum operating frequency of the processor increases from the preset frequency to the first frequency; In the fifth detection period, when the priority of the first audio data transmission thread is the second priority and it runs on the second core, the operating frequency of the processor is the first frequency, the amount of data in the first shared buffer is the sixth value, and the sixth value is greater than the first value, it is determined that this round of elimination of POP sounds in the audio has been completed.

6. The method according to any one of claims 1 to 5, characterized in that In the fourth detection period, when the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread is running in the second core, the amount of data in the first shared buffer is a fourth value, and the fourth value is greater than the first value, after determining that the current round of elimination of the pop sound in the audio has been completed, the method further includes: Receiving a playback stop operation on the audio; In response to a playback suspension operation on the audio, playback of the audio is stopped, and a state of the first audio data transmission thread and a state of the processor are restored to states corresponding to the first detection period.

7. The method according to any one of claims 1 to 5, characterized in that In the fourth detection period, when the priority of the first audio data transmission thread is the second priority and the first audio data transmission thread is running in the second core, the amount of data in the first shared buffer is a fourth value, and the fourth value is greater than the first value, after determining that the current round of elimination of the pop sound in the audio has been completed, the method further includes: In a sixth detection period, when the priority of the second audio data transmission thread is the first priority, the second audio data transmission thread runs in the first core, the amount of data in the second shared buffer is a seventh value, and the seventh value is less than the first value, the priority of the second audio data transmission thread is adjusted from the first priority to the second priority; In a seventh detection period, if the priority of the second audio data transmission thread is the second priority and the second audio data transmission thread is running in the first core, and the amount of data in the second shared buffer is an eighth value, and the eighth value is less than the first value, the second audio data transmission thread is adjusted to run in the second core; In the eighth detection period, when the priority of the second audio data transmission thread is the second priority and it runs on the second core, the amount of data in the second shared buffer is a ninth value, and the ninth value is greater than the first value, it is determined that a new round of elimination of POP sounds in the audio has been completed.

8. The method according to claim 7, characterized in that The electronic device includes a POP sound prediction module and a POP sound active elimination module; In the sixth detection period, when the priority of the second audio data transmission thread is the first priority, the second audio data transmission thread runs in the first core, the amount of data in the second shared buffer is a seventh value, and the seventh value is less than the first value, adjusting the priority of the second audio data transmission thread from the first priority to the second priority, including: In the sixth detection period, when the priority of the second audio data transmission thread is the first priority and the second audio data transmission thread runs in the first core, the first audio data transmission thread obtains the amount of data in the second shared buffer from the second shared buffer to obtain the seventh value; When the first audio data transmission thread obtains the seventh value, it sends a third data message to the POP sound prediction module, where the third data message carries the seventh value; When the seventh value is less than the first value, the POP sound prediction module sends a second adjustment message to the POP sound active elimination module, where the second adjustment message carries a buffer identifier of the second shared buffer; When the POP sound active elimination module receives the second adjustment message, it determines to adjust the priority of the second audio data transmission thread, and adjusts the priority of the second audio data transmission thread from the first priority to the second priority.

9. An electronic device, characterized in that: The structure of the electronic device includes a processor and a memory; The memory is used to store a program that supports the electronic device to execute the method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the method according to any one of claims 1 to 8.