Method and device for identifying keep-alive audio stream
By obtaining and analyzing the sample values of the audio stream and identifying and cleaning the keep-alive audio stream, the problems of waste of resources and increased power consumption in electronic devices are solved, and selective cleaning and energy saving effects are achieved.
Patent Information
- Application Number
- CN202211145821.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-09-20
- Publication Date
- 2025-08-29
- Estimated Expiration
- 2042-09-20
AI Technical Summary
Electronic devices cannot effectively identify and clean up the keep-alive audio streams and non-keep audio streams running in the background, resulting in waste of resources and increased power consumption.
By obtaining multiple sampled values in the audio stream played by the application, using the energy value, numerical characteristics and preset conditions of the sampled value to determine whether the audio stream is a keep-alive audio stream, and selective cleaning is achieved.
Improves the accuracy and efficiency of electronic devices in recognition of keep-alive audio streams, reduces power consumption and frees up resources.
Smart Images

Figure CN117789760B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic products, and in particular to a method and device for identifying a keep-alive audio stream. Background Art
[0002] When an electronic device is running, it will detect the applications (APP) running in the background and clean up the applications running in the background when necessary to reduce the power consumption of the electronic device.
[0003] Currently, some applications use the method of playing audio streams (such as keep-alive audio streams) to keep running continuously in the background. Because electronic devices cannot distinguish between normally played audio streams (such as non-keep-alive audio streams) and keep-alive audio streams, electronic devices are unable to selectively clear applications that play keep-alive audio streams and non-keep-alive audio streams. Therefore, there is an urgent need for a keep-alive audio stream identification method to identify the audio stream played by the application and determine whether the audio stream played by the application is a keep-alive audio stream. Summary of the Invention
[0004] The embodiments of the present application provide a method and apparatus for identifying a keep-alive audio stream, which can identify an audio stream played by an application and determine whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream.
[0005] In a first aspect, a method for identifying a keep-alive audio stream is provided, comprising:
[0006] Get multiple sample values from the audio stream played by the application;
[0007] It is determined whether the audio stream is a keep-alive audio stream according to the multiple sampling values, where the keep-alive audio stream is used to keep the application in a running state.
[0008] For example, the electronic device may calculate the energy value of the audio stream based on multiple sampling values and determine whether the audio stream is a keep-alive audio stream based on the energy value. Alternatively, the electronic device may determine whether the audio stream is a keep-alive audio stream based on the numerical characteristics of the multiple sampling values.
[0009] In an embodiment of the present application, the electronic device can judge the audio stream based on multiple sampling values in the audio stream to determine whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream, so that the electronic device can selectively clean up applications that play keep-alive audio streams and applications that play non-keep-alive audio streams based on the judgment result to reduce the power consumption of the electronic device.
[0010] Optionally, determining whether the audio stream is a keep-alive audio stream based on the multiple sampling values includes: determining an energy value of the audio stream based on the multiple sampling values; and determining that the audio stream is a keep-alive audio stream when the energy value is lower than an energy threshold.
[0011] For example, the energy value can be determined based on the absolute values of multiple sample values. Specifically, the absolute values of multiple sample values can be determined, the average of the multiple absolute values can be calculated, and the energy value of the audio stream can be represented by the average value. Alternatively, the maximum absolute value can be determined from the multiple absolute values, and the energy value of the audio stream can be represented by the maximum absolute value. Alternatively, the multiple absolute values can be summed to obtain a cumulative value of the multiple sample values, and the energy value of the audio stream can be represented by the cumulative value. When the energy value is lower than an energy value threshold, the audio stream is determined to be a keep-alive audio stream. When the energy value is greater than or equal to the energy threshold, the audio stream is determined to be a non-keep-alive audio stream.
[0012] In an embodiment of the present application, whether an audio stream is a keep-alive audio stream is determined by the energy value of the audio stream. Since the keep-alive audio stream does not need to be heard by the user, the energy carried by the keep-alive audio stream is lower than the energy carried by the non-keep-alive audio stream. When the audio stream played by the application is identified based on this difference between the keep-alive audio stream and the non-keep-alive audio stream, it can be more accurately determined whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream. At the same time, when the energy value of the audio stream is determined by the absolute value of the sampled value in the audio stream, the energy value of the audio stream is represented by the average value, cumulative value or maximum value of multiple absolute values, which can simplify the calculation process of the energy value and improve the efficiency of judging the keep-alive audio stream.
[0013] Optionally, determining whether the audio stream is a keep-alive audio stream based on the multiple sampling values includes: determining a statistical number of the multiple sampling values, wherein the sampling values with the same value are counted once; when the statistical number is lower than a number threshold, determining that the audio stream is a keep-alive audio stream.
[0014] For example, after obtaining multiple sampling values of an audio stream within a preset duration, the multiple sampling values can be counted, with sampling values with the same value counted only once to obtain a statistical count. The statistical count is then compared with a threshold value. If the statistical count is lower than the threshold value, it indicates that the values of the multiple sampling values are relatively uniform, and the audio stream can be determined to be a keep-alive audio stream. Conversely, if the statistical count is greater than or equal to the threshold value, it indicates that the values of the multiple sampling values are relatively diverse, and the audio stream can be determined to be a non-keep-alive audio stream.
[0015] In the embodiment of the present application, whether an audio stream is a keep-alive audio stream is determined by the numerical characteristics of the sample values in the audio stream. Since the sample values in a non-keep-alive audio stream are more diverse than the sample values in a keep-alive audio stream, this difference between the keep-alive audio stream and the non-keep-alive audio stream can more accurately determine whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream.
[0016] Optionally, determining whether the audio stream is a keep-alive audio stream based on the multiple sampling values includes: determining an energy value of the audio stream based on the multiple sampling values; determining a statistical number of the multiple sampling values, wherein the sampling values with the same value are counted once; when the energy value is lower than an energy threshold and the statistical number is lower than a number threshold, determining that the audio stream is a keep-alive audio stream.
[0017] Optionally, the application is an application that meets preset conditions.
[0018] For example, the preset condition may be that the application exhibits a target behavior. When the application exhibits the target behavior, the audio stream played by the application is judged to determine whether the audio stream played by the application is a keep-alive audio stream or a non-keep-alive audio stream.
[0019] For another example, the preset condition may be that the type of application is inconsistent with the target type. The types of applications include audio, video, life application, and navigation, etc. Target type applications are applications that need to play audio streams when running in the background to provide services to users. Target type applications include audio applications and navigation applications. Such applications can continue to provide services to users when running in the background, such as playing music and providing voice navigation and other services. After monitoring the application playing an audio stream, if it is determined that the type of application is inconsistent with the target type, it is determined whether the audio stream played by the application is a keep-alive audio stream. On the contrary, if the type of application is consistent with the target type, the audio stream played by the application is not identified.
[0020] For another example, the preset condition may be that the application is not an application that the user actively keeps alive. The user can manually add some applications to the application whitelist as needed. When an application is on the application whitelist, the audio stream played by the application is not recognized.
[0021] In the embodiment of the present application, when the application meets the preset conditions, the audio stream played by the application is judged, which can avoid judging all audio streams, making the judgment of the keep-alive audio stream more in line with user needs and reducing the power consumption of the electronic device. In conjunction with the above example, when the preset condition is that the application type is inconsistent with the target type, the audio stream played by the target type application can be avoided from being judged.
[0022] Optionally, the values of the multiple sampling values are different.
[0023] For example, after obtaining a sample value from the audio track's buffer for the first time, the sample value obtained for the first time is saved. Each subsequent time a sample value is obtained from the audio track's buffer, the currently obtained sample value is compared with the pre-stored sample value. If the obtained sample value is different from each pre-stored sample value, the obtained sample value is stored. If the obtained sample value is the same as one or more pre-stored sample values, the obtained sample value is discarded. Sample values of application input are continuously obtained from the buffer, and sample values of the same value are only obtained once, so that multiple sample values with different values can be obtained.
[0024] In an embodiment of the present application, in the process of obtaining sampling values, sampling values with the same numerical value are only obtained once, which can reduce the number of sampling values to reduce the storage pressure in the electronic device, and can avoid processing a large number of sampling values during the judgment process, thereby improving the judgment efficiency.
[0025] Optionally, determining whether the audio stream is a keep-alive audio stream based on the multiple sampling values includes: determining whether the audio stream is a keep-alive audio stream based on a target sampling value among the multiple sampling values, the target sampling value being a sampling value among the multiple sampling values whose absolute value is greater than or equal to an absolute value threshold.
[0026] For example, after determining the absolute value of each sample value, the absolute values whose absolute values are greater than or equal to the absolute value threshold can be determined from all absolute values, and then the average or cumulative value can be calculated based on the determined absolute values, or the maximum absolute value can be determined from all absolute values whose absolute values are greater than or equal to the absolute value threshold. Similarly, when statistics are collected on multiple sample values, only the sample values whose absolute values are greater than the absolute value threshold can be counted to obtain the statistical quantity.
[0027] An audio stream typically includes a large number of sample values. When the absolute value of a sample value is below an absolute value threshold, the sample value is generally meaningless. Determining the energy value or statistical quantity based on a target sample value whose absolute value is not less than the absolute value threshold can reduce the number of sample values used in the judgment process, thereby improving judgment efficiency.
[0028] Optionally, the multiple sampling values include sampling values of the audio stream within a preset time length.
[0029] For example, before starting to acquire samples from the audio stream, a linked list is created. The linked list can store multiple samples of the audio stream within a preset duration. After starting to acquire samples from the audio track's buffer, each sample value input by the application is retrieved from the buffer and stored in the linked list. After the linked list is full, each time a new sample value is acquired, the oldest sample value in the linked list is deleted from the linked list and the new sample value is stored in the linked list, maintaining the number of samples in the linked list unchanged.
[0030] In the embodiment of the present application, sampling values of an audio stream within a preset duration are obtained, and it is possible to accurately determine whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream based on the obtained multiple sampling values. Furthermore, by only obtaining sampling values within the preset duration of the audio stream, it is possible to avoid increasing the storage pressure of the electronic device when there are too many sampling values, and it is possible to avoid processing a large number of sampling values during the judgment process, thereby improving judgment efficiency.
[0031] In a second aspect, a device for identifying a keep-alive audio stream is provided, comprising:
[0032] The acquisition module is used to obtain multiple sampling values in the audio stream played by the application;
[0033] The judging module is configured to judge whether the audio stream is a keep-alive audio stream according to the multiple sampling values, where the keep-alive audio stream is used to keep the application in a running state.
[0034] Optionally, the judgment module is specifically configured to determine an energy value of the audio stream according to a plurality of sampling values; when the energy value is lower than an energy threshold, determine that the audio stream is a keep-alive audio stream.
[0035] Optionally, the judgment module is specifically configured to determine a statistical number of multiple sampling values, wherein sampling values with the same value are counted once; when the statistical number is lower than a number threshold, the audio stream is determined to be a keep-alive audio stream.
[0036] Optionally, the judgment module is specifically used to determine the energy value of the audio stream based on multiple sampling values; determine the statistical number of multiple sampling values, wherein sampling values with the same value are counted once; when the energy value is lower than the energy threshold and the statistical number is lower than the number threshold, determine that the audio stream is a keep-alive audio stream.
[0037] Optionally, the application is an application that meets preset conditions.
[0038] Optionally, the values of the multiple sampling values are different.
[0039] Optionally, the judgment module is specifically configured to determine whether the audio stream is a keep-alive audio stream according to a target sampling value among the multiple sampling values, where the target sampling value is a sampling value among the multiple sampling values whose absolute value is greater than or equal to an absolute value threshold.
[0040] Optionally, the judgment module is specifically configured to determine the energy value according to the absolute values of the plurality of sampling values.
[0041] Optionally, the judgment module is specifically configured to determine the energy value according to an average value, a cumulative value or a maximum value of the absolute value.
[0042] Optionally, the multiple sampling values include sampling values of the audio stream within a preset time length.
[0043] Optionally, the device further includes: a control module, configured to close an application when determining that the audio stream is a keep-alive audio stream.
[0044] In a third aspect, an electronic device is provided, comprising: one or more processors and one or more memories; the one or more processors are coupled to the one or more memories, the one or more memories are used to store computer program code, the computer program code comprising computer instructions, and when the one or more processors execute the computer instructions, the electronic device executes the method described in the first aspect.
[0045] In a fourth aspect, a readable storage medium is provided, in which a computer program product is stored. The computer program product includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described in the first aspect.
[0046] In a fifth aspect, a chip system is provided, which is applied to an electronic device. The chip system includes one or more processors, and the processor is used to call computer instructions to enable the electronic device to execute the method described in the first aspect.
[0047] In a sixth aspect, a computer program product is provided, comprising computer instructions, which, when executed on an electronic device, causes the electronic device to execute the method as described in the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 A schematic diagram showing an application scenario provided by an embodiment of the present application is shown.
[0049] Figure 2 A hardware structure diagram of an electronic device suitable for the above method is shown.
[0050] Figure 3 A schematic diagram of audio playback of an electronic device provided in an embodiment of the present application is shown.
[0051] Figure 4 A flowchart of the steps of a method for identifying a keep-alive audio stream provided in an embodiment of the present application is shown.
[0052] Figure 5 A schematic diagram of an audio stream provided in an embodiment of the present application is shown.
[0053] Figure 6 A schematic diagram of a keep-alive audio stream identification process provided in an embodiment of the present application is shown.
[0054] Figure 7 A schematic diagram of a sampling value acquisition process provided in an embodiment of the present application is shown.
[0055] Figure 8 A schematic diagram of a keep-alive audio stream determination process provided in an embodiment of the present application is shown.
[0056] Figure 9 A schematic diagram of another sampling value acquisition process provided in an embodiment of the present application is shown.
[0057] Figure 10 A schematic diagram of another process for determining a keep-alive audio stream provided in an embodiment of the present application is shown.
[0058] Figure 11 A schematic structural diagram of a keep-alive audio stream identification device provided in an embodiment of the present application is shown.
[0059] Figure 12 A schematic structural diagram of another electronic device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0060] The technical solutions of this application will be described below in conjunction with the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of this application, rather than all the embodiments.
[0061] In the following description, specific details such as specific system structures and techniques are provided for purposes of illustration rather than limitation to facilitate a thorough understanding of the embodiments of the present application. However, it will be apparent to those skilled in the art that the present application may be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to avoid obscuring the description of the present application with unnecessary detail.
[0062] The term "comprising" herein indicates the presence of the described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or their collections. The terms "include," "comprising," "having" and their variations all mean "including but not limited to," unless otherwise specifically emphasized.
[0063] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.
[0064] The term "and / or" in this document simply describes a relationship between related objects, indicating that three possible relationships exist. For example, "A and / or B" can mean: A exists alone, A and B exist simultaneously, or B exists alone. Additionally, the character " / " in this document generally indicates that the related objects are in an "or" relationship.
[0065] Figure 1 The following is a schematic diagram illustrating an application scenario provided by an embodiment of the present application. Multiple applications are installed in an electronic device 100. These applications are referred to as applications for short, and different applications have different functions. For example, an audio application 1011 can play audio, a video application 1012 can play videos, a sports application 1013 can monitor a user's pulse, body temperature, and other vital signs during exercise, and a browser application 1014 can allow the user to browse the web. Applications in electronic devices include, but are not limited to, these.
[0066] After being launched, an application can run in the foreground or background of the electronic device. An application running in the foreground can directly provide services to the user, while an application running in the background can quickly switch to the foreground when the user next uses it, or continue to run in the background to provide services to the user. For example, the audio application 1011 can continue to play audio for the user while running in the background, and the sports application 1013 can continue to monitor the user's vital signs data while running in the background.
[0067] Both background and foreground apps consume memory, processors, and other resources on electronic devices, increasing their power consumption. When background apps consume more resources, foreground apps run out of resources, preventing them from running smoothly, and increasing their power consumption.
[0068] Electronic devices can clean up background apps to reduce power consumption and free up resources like memory and processors, allowing foreground apps to run smoothly. Because some apps can continue to provide services to users while running in the background, electronic devices must selectively clean up background apps to avoid closing apps that users need.
[0069] Generally speaking, when an electronic device is cleaning up applications running in the background, if it detects that an application is playing an audio stream, it determines that the application is an application that the user needs to run, and does not clean up the application. Based on this, some applications will keep themselves alive by playing audio streams when running in the background to avoid being cleaned up by the electronic device. For example, when the browser application 1014 is switched to the background to run, it can continue to play the audio stream. When an electronic device is cleaning up applications running in the background, if it finds that the browser application 1014 is playing an audio stream, it will not clean up the browser application 1014. At this time, even if the user does not need the services provided by the browser application 1014, the browser application 1014 will continue to run in the background, occupying resources and increasing power consumption.
[0070] In summary, electronic devices may have applications playing keep-alive audio streams and applications playing non-keep-alive audio streams in the background. Since it cannot distinguish between keep-alive and non-keep-alive audio streams, electronic devices cannot selectively clear background applications. Therefore, there is an urgent need for a method to identify keep-alive audio streams that can determine whether the audio stream played by an application is a keep-alive audio stream, so that electronic devices can selectively clear background applications.
[0071] In the technical solution provided in the embodiments of the present application, the electronic device determines whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream through multiple sampling values in the audio stream, so that the electronic device can selectively clear applications running in the background according to the judgment result, while freeing up resources and reducing power consumption, and avoiding clearing applications required by the user.
[0072] The method for identifying a keep-alive audio stream provided in the embodiments of the present application can be applied to electronic devices such as mobile phones, tablet computers, laptop computers, ultra-mobile personal computers (UMPCs), handheld computers, netbooks, personal digital assistants (PDAs), wearable devices, and virtual reality devices, and the embodiments of the present application do not impose any restrictions on this.
[0073] Figure 2 A hardware structure diagram of an electronic device suitable for the above method is shown.
[0074] like Figure 2As shown, the electronic device 200 may include a processor 210, an audio module 220, a display screen 230, a communication module 240, a storage module 250, a camera 260, and a power module 270. The electronic device may also include a sensor module, a universal serial bus (USB) interface, a charging management module, a power management module, a battery, an antenna, an antenna, an external memory interface, an internal memory, a speaker, a receiver, a microphone, an earphone interface, buttons, a motor, an indicator, and a subscriber identification module (SIM) card interface.
[0075] The processor 210 may include one or more processing units. For example, the processor 210 may include at least one of the following processing units: an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and a neural-network processing unit (NPU). Different processing units may be independent devices or integrated devices.
[0076] The electronic device 200 can implement audio functions such as audio playback and recording through the audio module 220 , the microphone 221 , the receiver 222 , the speaker 223 , and the application processor.
[0077] The audio module 220 is used to convert digital audio information into an analog audio signal for output, and can also be used to convert an analog audio signal into a digital audio signal. The audio module 220 can also be used to encode and decode audio signals. In some embodiments, the audio module 220 or some functional modules of the audio module 220 can be provided in the processor 210.
[0078] The microphone 221 , also called a “microphone” or a “microphone”, is used to convert audio signals into electrical signals.
[0079] The receiver 222, also called a "handset", is used to convert audio electrical signals into audio signals. When the electronic device 200 receives a call or voice message, the voice can be heard by placing the receiver 223 close to the human ear.
[0080] Speaker 223, also known as a "horn," is used to convert audio electrical signals into audio signals for playback. For example, an audio stream in pulse code modulation (PCM) format is used when an application on an electronic device plays audio. The audio file is first decoded to obtain a PCM audio stream, which is then transmitted to speaker 223, where it is converted into an audio signal for playback.
[0081] Electronic device 200 can implement display functions through a GPU, display screen 230, and an application processor. The GPU is a microprocessor for image processing that connects display screen 230 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 210 may include one or more GPUs that execute program instructions to generate or modify display information.
[0082] The display screen 230 can be used to display images or videos. The display screen 230 includes a display panel. The display panel can be a liquid crystal display 230 (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a mini light-emitting diode (Mini LED), a micro light-emitting diode (Micro LED), a micro OLED, or a quantum dot light-emitting diode (QLED).
[0083] The communication function of the electronic device 200 can be implemented through the antenna and the communication module 240. The communication module 240 can provide solutions for wireless communications such as 2G / 3G / 4G / 5G applied to electronic devices, and can include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The communication module 240 can receive electromagnetic waves through the antenna, filter, amplify, and process the received electromagnetic waves, and transmit them to the modem processor for demodulation. The communication module 240 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation through the antenna.
[0084] In some embodiments, the communication module 240 can provide wireless communication solutions for electronic devices, including wireless local area networks (WLAN), Bluetooth (BT), global navigation satellite system (GNSS), near field communication (NFC), infrared technology (IR), etc.
[0085] Storage module 250 is used to store instructions and data. Storage module 250, such as a cache memory, can store instructions or data that have just been used or are being recycled by processor 210. If processor 210 needs to use the same instruction or data again, it can directly retrieve it from storage module 250. This avoids duplicate accesses, reduces processor 210 latency, and thus improves system efficiency.
[0086] The processor 210 and the storage module 250 may be combined into a processing device, or more commonly, they are independent components. In specific implementations, the storage module 250 may also be integrated into the processor 210 or independent of the processor 210.
[0087] In some embodiments, the processor 210 and the camera 260 communicate via a camera serial interface (CSI) to implement the shooting function of the electronic device 200.
[0088] The power module 270 is used to provide power to various devices or circuits in the electronic device 200, and may include a charging management unit, a power management unit, a battery, and the like.
[0089] It should be noted that Figure 2 The connection relationship between the modules shown is only for illustrative purposes and does not limit the connection relationship between the modules of the electronic device 200. Optionally, the modules of the electronic device 200 may also adopt a combination of the multiple connection modes in the above embodiments. Figure 2 The structure shown does not constitute a specific limitation on the electronic device 200. The electronic device 200 may include Figure 2 More or fewer components than those shown, or the electronic device 200 may include Figure 2 Combinations of some of the components shown, or alternatively, the electronic device 200 may include Figure 2 Subassemblies of some of the components shown. Figure 2 The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0090] Figure 3 A schematic diagram of audio playback of an electronic device provided by an embodiment of the present application is shown. The operating system (OS) of the electronic device includes an audio subsystem, which includes a media player, an audio track, an audio flinger, an audio driver, and other components.
[0091] Generally speaking, applications in electronic devices can play audio streams in two ways, one is through a media player, and the other is through an audio track. The audio track has no decoding function and can only play audio streams in PCM format. When playing an audio stream through an audio track, the application creates an instance of the audio track class, passes the audio stream to the audio track, and the audio track processes the audio stream output by the application. When playing an audio stream through a media player, the media player creates a corresponding audio decoder and audio track. The media player inputs the audio file into the audio decoder, decodes it to obtain an audio stream in PCM format, and then passes the PCM format audio stream to the audio track for processing. Therefore, when playing an audio stream through the above two methods, the application will create an audio track and output the audio stream to the audio track.
[0092] When creating an audio track, the application sets a buffer for the audio track and registers the audio track with the audio guard. During audio stream playback, the PCM audio stream is input into the audio track buffer. When the buffer is full, the audio guard mixes the audio streams from all audio tracks and sends the mixed audio stream to the audio module (such as the speaker) through the audio driver. The audio module converts the audio stream into an audio signal for playback.
[0093] It should be noted that Figure 3 This is only an example and does not limit the audio playback method applicable to the embodiments of the present application.
[0094] The following describes a method for identifying a keep-alive audio stream according to an embodiment of the present application with reference to the accompanying drawings.
[0095] See Figure 4 , Figure 4 A flowchart of a method for identifying a keep-alive audio stream provided in an embodiment of the present application is shown. The specific process is as follows:
[0096] Step 401: Acquire multiple sampling values in the audio stream played by the application.
[0097] The application may be any application running in the electronic device. After startup, the application may run in the foreground of the electronic device or be switched to the background. Among the at least one application running in the electronic device, some applications may play audio streams under user control, such as an audio application playing music under user control. Some applications may automatically play audio streams to stay active in the background, such as a browser application automatically playing audio streams when switched to the background to avoid being cleared by the electronic device and continuing to run in the background.
[0098] In the above example, an application creates an audio track when playing an audio stream. The electronic device can monitor the audio tracks in the audio subsystem. When an application creates an audio track, the electronic device can determine that the application is playing the audio stream. The method for determining whether an application is playing an audio stream can be specifically configured based on the application's audio streaming method, and this embodiment does not impose any restrictions on this.
[0099] After detecting that an application is playing an audio stream, the electronic device can obtain multiple sample values from the audio stream. For example, after detecting that an application is creating an audio track, the electronic device can continuously monitor the audio track buffer and obtain sample values from the application input buffer to obtain multiple sample values from the audio stream.
[0100] Figure 5 A schematic diagram of an audio stream provided by an embodiment of the present application is shown. Figure 5 The horizontal axis represents time, and the vertical axis represents the size of the sample value. The size of the sample value corresponds to the amplitude of the audio. Curve 500 represents an audio segment in the audio stream, and each point in curve 500 represents a sample value in the audio stream. The horizontal axis corresponding to the sample value represents the relative time of the sample value in the audio stream. Multiple consecutive sample values constitute an audio stream.
[0101] After the application starts playing the audio stream, it continuously inputs the sample values in the audio stream into the audio track buffer according to the relative time of each sample value in the audio stream. The electronic device can start obtaining sample values from the application input buffer at any time during the audio stream playback, and continuously obtain sample values from the buffer to obtain each sample value in the application input buffer.
[0102] It should be noted that when obtaining sample values from the buffer of the audio track, only the sample values in the buffer are copied, which does not affect the normal processing of the sample values by the audio track.
[0103] Optionally, the multiple sampling values include sampling values of the audio stream within a preset duration. When obtaining the multiple sampling values in the audio stream, the multiple sampling values of the audio stream within the preset duration may be obtained, and the preset duration is not less than the shortest playback duration of the audio stream, so that the number of sample values obtained is not less than the number of sample values within the shortest playback duration of the audio stream.
[0104] In one embodiment, the electronic device may store sample values obtained from the buffer in a linked list, where the number of sample values stored in the linked list is equal to the number of sample values of the audio stream within a preset duration. The capacity of the linked list may be set based on the number of sample values of the audio stream within the preset duration. If the preset duration is greater than or equal to the shortest playback duration, the number of sample values stored in the linked list may be no less than the number of sample values of the audio stream within the shortest playback duration.
[0105] For example, before acquiring sample values from the audio stream, a linked list is created. After acquiring sample values from the audio track's buffer, each sample value input by the application is acquired from the buffer and stored in the linked list. After the linked list is full, each time a new sample value is acquired, the oldest sample value in the linked list is deleted from the linked list and the new sample value is stored in the linked list, maintaining the number of sample values in the linked list unchanged. The specific storage method for the sample values can be configured as required and is not limited in this embodiment.
[0106] The application continuously plays the audio stream. When the application does not stop playing the audio stream, each sample value in the application input buffer can be continuously obtained. If every sample value in the audio stream is stored, it will result in an excessive number of sample values, increasing the storage pressure of the electronic device. At the same time, when the number of sample values is large, when judging whether the audio stream is a keep-alive audio stream based on multiple sample values, a large number of sample values need to be processed, which will reduce the judgment efficiency.
[0107] In a short period of time (shorter than the shortest playback duration of the audio stream), the characteristics of the sampling values in a non-keep-alive audio stream may be the same as those in a keep-alive audio stream. Therefore, it is impossible to accurately determine whether an audio stream is a keep-alive audio stream based on a small number of sampling values.
[0108] In the embodiment of the present application, sampling values of an audio stream within a preset duration are obtained, and it is possible to accurately determine whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream based on the obtained multiple sampling values. Furthermore, by only obtaining sampling values within the preset duration of the audio stream, it is possible to avoid increasing the storage pressure of the electronic device when there are too many sampling values, and it is possible to avoid processing a large number of sampling values during the judgment process, thereby improving judgment efficiency.
[0109] It should be noted that the specific value of the preset duration can be set according to needs, and this embodiment does not impose any restrictions on this.
[0110] Optionally, when acquiring sampling values in the audio stream, sampling values with the same value may be acquired only once to obtain multiple sampling values with different values.
[0111] For example, after obtaining a sample value from the audio track's buffer for the first time, the sample value obtained for the first time is saved. Each subsequent time a sample value is obtained from the audio track's buffer, the currently obtained sample value is compared with the pre-stored sample value. If the obtained sample value is different from each pre-stored sample value, the obtained sample value is stored. If the obtained sample value is the same as one or more pre-stored sample values, the obtained sample value is discarded. Sample values of application input are continuously obtained from the buffer, and sample values of the same value are only obtained once, so that multiple sample values with different values can be obtained.
[0112] Alternatively, each sampling value in the audio stream may be first obtained and stored. After obtaining multiple sampling values, the multiple sampling values are filtered. For multiple sampling values with the same value, only one is retained and the other sampling values are deleted to obtain multiple sampling values with different values.
[0113] The audio stream contains a large number of sample values. If each sample value in the audio stream is obtained, a large number of sample values will be obtained. A large number of sample values not only increases the storage pressure of the electronic device, but also requires processing a large number of sample values during the judgment process, which reduces judgment efficiency.
[0114] In an embodiment of the present application, in the process of obtaining sampling values, sampling values with the same numerical value are only obtained once, which can reduce the number of sampling values to reduce the storage pressure in the electronic device, and can avoid processing a large number of sampling values during the judgment process, thereby improving the judgment efficiency.
[0115] Step 402: Determine whether the audio stream is a keep-alive audio stream based on multiple sampling values.
[0116] In this embodiment, after obtaining multiple sampling values in the audio stream, it can be determined whether the audio stream is a keep-alive audio stream according to the multiple sampling values.
[0117] Optionally, step 402 may include:
[0118] determining an energy value of an audio stream according to a plurality of sample values;
[0119] When the energy value is lower than the energy threshold, the audio stream is determined to be a keep-alive audio stream.
[0120] In one embodiment, the energy value of the audio stream can be determined based on multiple sampling values, and whether the audio stream is a keep-alive audio stream can be determined based on the size of the energy value. The energy formula of the audio signal is as follows:
[0121]
[0122] The audio signal is an analog signal. By sampling the analog audio signal at a certain sampling frequency, we can get the following Figure 5 The sample value sequence shown in the figure above consists of multiple consecutive sample values in the sample value sequence, which constitutes an audio stream. The size of the sample value represents the amplitude of the audio signal. In the above formula, |f(t)| is the amplitude of the audio signal, and the energy carried by the audio signal is proportional to the square of the amplitude.
[0123] Since the keep-alive audio stream does not need to be heard by the user, the energy carried by the keep-alive audio stream is relatively low. The energy value of the audio stream can be calculated based on multiple sampling values in the audio stream. When calculating the energy value of the audio stream, the integration time is the time corresponding to the multiple sampling values obtained. In conjunction with the above example, if the multiple sampling values obtained include multiple sampling values of the keep-alive audio stream within a preset time, the integration time is the preset time. Alternatively, the number of sampling times of the audio stream per unit time can be determined based on the sampling frequency of the audio stream. The sampling number is the number of sampling values per unit time, and the ratio of the number of multiple sampling values to the sampling number is the integration time.
[0124] Combine Figure 5 As shown, a function f(t) of the audio stream can be constructed based on multiple sampling values and the time corresponding to each sampling value. The above energy formula can be constructed based on the function f(t) and the integration duration. Then, the energy value of the audio stream can be calculated based on the energy formula. The specific method for calculating the energy value based on the energy formula can be set according to needs and is not limited in this embodiment.
[0125] Optionally, the step of determining the energy value of the audio stream according to the multiple sampling values may include: determining the energy value according to the absolute values of the multiple sampling values.
[0126] Since the keep-alive audio stream does not need to be heard by the user, the absolute value of each sample value in the keep-alive audio stream is relatively low. The energy carried by the audio stream can be measured by the average, cumulative value, and maximum value of the absolute values of multiple sample values.
[0127] In one embodiment, when calculating the energy value of an audio stream, the absolute values of multiple sample values can be first determined, and then the average of these absolute values can be calculated. The average value represents the energy value of the audio stream. Since the keep-alive audio stream does not need to be heard by the user, if the average of the multiple absolute values is low, it can be determined that each sample value in the audio stream is relatively low, indicating that the energy carried by the audio stream is low and the user cannot hear the audio stream when it is played.
[0128] When the energy value of an audio stream is represented by an average value, the energy threshold can be represented by an average energy threshold. The average energy threshold can be pre-set. When the average of multiple absolute values is lower than the average energy threshold, the audio stream is determined to be a keep-alive stream. When the average of multiple absolute values is greater than or equal to the average energy threshold, the audio stream is determined to be a non-keep-alive stream.
[0129] For example, after a certain audio stream is pre-determined to be a keep-alive audio stream, multiple sampling values within a preset duration can be selected from the keep-alive audio stream, and the average of the multiple sampling values can be calculated, and the average value can be used as the average energy threshold. Specific methods for determining the average energy threshold may include but are not limited to the above examples.
[0130] In another embodiment, after determining the absolute values of the multiple sample values, a maximum absolute value can be determined from the multiple absolute values, and the maximum absolute value can be used to represent the energy value of the audio stream. Since the keep-alive audio stream does not need to be heard by the user, when the maximum absolute value among the multiple absolute values is low, it can be determined that each sample value in the audio stream is relatively low, indicating that the energy carried by the audio stream is low and the user cannot hear the audio stream when it is played.
[0131] When the energy value of an audio stream is represented by its maximum absolute value, the energy threshold can be represented by its upper sampling limit. The upper sampling limit can be pre-set. When the maximum absolute value is lower than the upper sampling limit, the audio stream is determined to be a keep-alive stream. When the maximum absolute value is greater than or equal to the upper sampling limit, the audio stream is determined to be a non-keep-alive stream.
[0132] The upper limit of the sampling value is a positive value. The sampling value with the largest absolute value can be determined from one or more predetermined keep-alive audio streams, and the absolute value of the sampling value is used as the upper limit of the sampling value. The method for determining the upper limit of the sampling value may include but is not limited to the above examples.
[0133] In another embodiment, after determining the absolute values of multiple sampling values, the multiple absolute values can be summed to obtain a cumulative value of the multiple sampling values, and the energy value of the audio stream is represented by the cumulative value. In combination with the above example, if the multiple sampling values obtained are multiple sampling values of the keep-alive audio stream within a preset time length, the cumulative value can represent the energy value of the audio stream within the preset time length. The larger the cumulative value, the greater the energy carried by the audio stream within the preset time length, and the smaller the cumulative value, the smaller the energy carried by the audio stream within the preset time length. Since the keep-alive audio stream does not need to be heard by the user, when the cumulative value is low, it means that the energy carried by the audio stream is low, and the audio stream cannot be heard by the user when it is played.
[0134] When the energy value of an audio stream is represented by a cumulative value, the energy threshold can be represented by a cumulative energy threshold. The cumulative energy threshold can be pre-set. When the cumulative value of multiple absolute values is lower than the cumulative energy threshold, the audio stream is determined to be a keep-alive audio stream. When the cumulative value is greater than or equal to the cumulative energy threshold, the audio stream is determined to be a non-keep-alive audio stream.
[0135] The cumulative energy threshold can be pre-set based on multiple sampling values of a keep-alive audio stream within a preset duration. For example, after determining that an audio stream is a keep-alive audio stream, multiple sampling values within the preset duration of the keep-alive audio stream can be obtained, the absolute values of the multiple sampling values can be determined, and then the multiple absolute values can be summed, with the summed result serving as the cumulative energy threshold. The specific method for determining the cumulative energy threshold can be set as needed and is not limited in this embodiment.
[0136] It should be noted that the method of determining the energy value through the absolute values of multiple sampling values may include but is not limited to the above examples.
[0137] In this embodiment of the present application, whether an audio stream is a keep-alive audio stream is determined by its energy value. Since keep-alive audio streams do not need to be heard by the user, the energy carried by keep-alive audio streams is lower than the energy carried by non-keep-alive audio streams. When the audio stream played by the application is identified based on this difference between keep-alive and non-keep-alive audio streams, it can be more accurately determined whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream.
[0138] At the same time, when determining the energy value of the audio stream by the absolute value of the sampling value in the audio stream, the energy value of the audio stream can be represented by the average value, cumulative value or maximum value of multiple absolute values, which can simplify the calculation process of the energy value and improve the efficiency of the judgment of the keep-alive audio stream.
[0139] Optionally, step 402 may include:
[0140] Determine the statistical quantity of multiple sampling values, where sampling values with the same value are counted once;
[0141] When the counted number is lower than the number threshold, the audio stream is determined to be a keep-alive audio stream.
[0142] A non-keep-alive audio stream is typically a sequence of sampled values obtained by sampling an analog audio signal at a specific sampling frequency. Therefore, in a non-keep-alive audio stream, the sample values are random, with a high frequency of different values and a relatively high diversity of sample values. In contrast, since a keep-alive audio stream does not need to be heard by the user, it is typically automatically generated by electronic devices such as mobile phones or computers. Therefore, in a keep-alive audio stream, the sample values are relatively regular, with a high frequency of identical values and a low frequency of different values, resulting in a relatively uniform sample value.
[0143] In one embodiment, the audio stream can be judged as a keep-alive audio stream or a non-keep-alive audio stream based on the numerical characteristics of the sampling values. In combination with the above example, after obtaining multiple sampling values of the audio stream within a preset time length, the multiple sampling values can be counted, and the sampling values with the same value are counted only once to obtain the statistical number. For example, if the number of sampling values is 10 (the number of sampling values in practice is greater than this value), the values of the 1st to 4th of the 10 sampling values are N, the values of the 5th to 8th sampling values are M, and the values of the 9th and 10th sampling values are X. The sampling value of each value is counted only once, and the statistical number obtained is 3.
[0144] After obtaining the statistical number of multiple sampling values, the statistical number is compared with the number threshold. If the statistical number is lower than the number threshold, the numerical values of the multiple sampling values are relatively uniform, and the audio stream can be determined to be a keep-alive audio stream. Conversely, if the statistical number is greater than or equal to the number threshold, the numerical values of the multiple sampling values are relatively diverse, and the audio stream can be determined to be a non-keep-alive audio stream.
[0145] The quantity threshold can be pre-set based on the sample values in one or more keep-alive audio streams. For example, after determining that a particular audio stream is a keep-alive audio stream, multiple sample values within a preset duration can be obtained from the keep-alive audio stream. These multiple sample values are then counted, with sample values of the same value counted only once to obtain a statistical quantity, which is then used as the quantity threshold. Alternatively, the same method can be used to obtain the statistical quantity of multiple keep-alive audio streams, and the average of the multiple statistical quantities can be calculated, with the average value used as the quantity threshold. Specific methods for determining the quantity threshold may include, but are not limited to, the examples above.
[0146] In the embodiment of the present application, whether an audio stream is a keep-alive audio stream is determined by the numerical characteristics of the sample values in the audio stream. Since the sample values in a non-keep-alive audio stream are more diverse than the sample values in a keep-alive audio stream, this difference between the keep-alive audio stream and the non-keep-alive audio stream can more accurately determine whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream.
[0147] Optionally, step 402 includes:
[0148] determining an energy value of an audio stream according to a plurality of sample values;
[0149] Determine the number of statistics for multiple sample values, wherein sample values with the same value are counted once;
[0150] When the energy value is lower than the energy threshold and the statistical quantity is lower than the quantity threshold, the audio stream is determined to be a keep-alive audio stream.
[0151] In one embodiment, whether an audio stream is a keep-alive audio stream can be determined by combining the energy value and the statistical quantity of the audio stream. In the above example, after obtaining multiple sample values in the audio stream, the energy value of the audio stream can be determined based on the absolute values of the multiple sample values, and the multiple sample values can be counted to obtain the statistical quantity.
[0152] Then, the audio stream energy value is compared with the energy threshold, and the statistical quantity is compared with the quantity threshold. If the energy value of the audio stream is lower than the energy threshold and the statistical quantity is lower than the quantity threshold, the audio stream is determined to be a protected audio stream. Conversely, if the energy value of the audio stream is greater than or equal to the energy threshold, or the statistical quantity is greater than or equal to the quantity threshold, the audio stream is determined to be a non-protected audio stream.
[0153] In an embodiment of the present application, whether an audio stream is a keep-alive audio stream is determined by combining the energy value of the audio stream and the numerical characteristics of the sampling value, which can improve the accuracy of the judgment and avoid misjudgment. For example, the statistical number of some keep-alive audio streams is large. If the judgment is made only based on the statistical number, the keep-alive audio stream may be judged as a non-keep-alive audio stream. Combining the energy value of the audio stream can avoid misjudging the keep-alive audio stream as a non-keep-alive audio stream when the statistical number of keep-alive audio streams is large. Similarly, when the energy threshold is set to a small value, if the energy value of some keep-alive audio streams is large, the keep-alive audio stream may be misjudged as a non-keep-alive audio stream. Combining the numerical characteristics of the sampling value can avoid misjudgment and accurately identify the keep-alive audio stream.
[0154] Optionally, determining whether the audio stream is a keep-alive audio stream according to multiple sampling values includes:
[0155] Whether the audio stream is a keep-alive audio stream is determined according to a target sampling value among multiple sampling values, where the target sampling value is a sampling value among the multiple sampling values whose absolute value is greater than or equal to an absolute value threshold.
[0156] In one embodiment, when determining whether an audio stream is a keep-alive audio stream based on multiple sample values, sample values whose absolute values are lower than an absolute value threshold may be filtered out, and only sample values whose absolute values are greater than or equal to the absolute value threshold may be used to determine whether the audio stream is a keep-alive audio stream. For example, after determining the absolute value of each sample value, absolute values whose absolute values are greater than or equal to the absolute value threshold may be determined from all absolute values. Then, an average or cumulative value may be calculated based on the determined absolute values, or a maximum absolute value may be determined from all absolute values whose absolute values are greater than or equal to the absolute value threshold.
[0157] Similarly, when statistics are performed on a plurality of sampling values, only the sampling values whose absolute values are greater than the absolute value threshold may be counted to obtain the statistical quantity.
[0158] An audio stream typically includes a large number of sample values. When the absolute value of a sample value is below an absolute value threshold, the sample value is generally meaningless. Determining the energy value or statistical quantity based on a target sample value whose absolute value is not less than the absolute value threshold can reduce the number of sample values used in the judgment process, thereby improving judgment efficiency.
[0159] It should be noted that the specific value of the absolute value threshold can be set according to specific needs, and this embodiment does not limit this.
[0160] Optionally, the application is an application that meets preset conditions.
[0161] The electronic device may only identify the audio stream played by an application that meets preset conditions and determine whether the audio stream played by the application is a keep-alive audio stream, so as to avoid identifying the audio streams played by all applications.
[0162] In one embodiment, the preset condition may be that the application exhibits a target behavior. When the application exhibits the target behavior, the audio stream played by the application is judged to determine whether the audio stream played by the application is a keep-alive audio stream or a non-keep-alive audio stream. The application behavior is an action performed by the application or a triggering of an event, such as displaying a user interface (UI), playing a video, obtaining location information, or displaying a pop-up reminder box on the display screen.
[0163] For example, a behavior blacklist can be pre-established, which includes at least one target behavior. When an application displays a target behavior in the behavior blacklist, it indicates that the application is likely to be kept active in the background, and keeping the application active in the background does not meet user needs, so the audio stream played by the application needs to be identified.
[0164] For example, the target behavior in the behavior blacklist can be the behavior of automatically playing an audio stream. When the application automatically plays the audio stream without receiving any user input instructions, it means that the application most likely needs to be kept alive by playing the audio stream. The audio stream played by the application can be judged.
[0165] For another example, a behavior blacklist might target an application that plays an audio stream immediately after startup. If an application starts playing an audio stream immediately after startup, and this behavior differs from normal audio playback, the application can be added to the behavior blacklist. When the application exhibits this behavior, the application's audio stream playback will be judged. The behaviors in the behavior blacklist include, but are not limited to, the examples above.
[0166] Specifically, after the electronic device detects that an application is playing an audio stream, if it also detects that the application is performing a target behavior in the behavior blacklist, it executes steps 401 and 402 to determine whether the audio stream played by the application is a keep-alive audio stream. Conversely, if the application does not perform a target behavior in the behavior blacklist, the audio stream played by the application is not determined.
[0167] It should be noted that the target behavior can be specifically set according to actual needs, and this embodiment does not impose any restrictions on this.
[0168] In another embodiment, the preset condition may be that the application does not display a user interface on the display screen. Generally, when an application displays a user interface on the display screen, it indicates that the user is using the application. When a user is using an application, there is no need to control the application, and therefore there is no need to determine whether the audio stream played by the application is a keep-alive audio stream.
[0169] Specifically, after detecting that an application is playing an audio stream, if the electronic device detects that the application does not display a user interface on the display screen, it executes steps 401 and 402 to determine whether the audio stream played by the application is a keep-alive audio stream. Conversely, if the application displays a user interface on the display screen, the audio stream played by the application is not identified.
[0170] In another embodiment, the preset condition may be that the application type is inconsistent with the target type. Application types include audio, video, life applications, and navigation. The application type classification method can be specifically set according to needs and is not limited in this embodiment.
[0171] Target applications are applications that need to play audio streams while running in the background to provide user services. Examples of target applications include audio applications and navigation applications. These applications can continue to provide user services, such as playing music and providing voice navigation, while running in the background.
[0172] After the electronic device detects that the application is playing an audio stream, if it determines that the type of the application is inconsistent with the target type, it executes steps 401 and 402 to determine whether the audio stream played by the application is a keep-alive audio stream. On the contrary, if the type of the application is consistent with the target type, the audio stream played by the application is not identified.
[0173] Specifically, the electronic device can obtain the type information of the application from the description information of the application and determine the type of the application according to the type information. The method for determining the type of the application can be set according to needs and is not limited in this embodiment.
[0174] In another embodiment, the preset condition may be that the application is not an application that the user actively keeps active. For example, the user can manually add some applications to the application whitelist as needed. If the user determines that an application does not need to be cleared when it switches to the background while using the application, the user can add the application to the application whitelist. Methods for establishing a behavioral whitelist may include but are not limited to the examples above.
[0175] After detecting an application playing an audio stream, the electronic device first determines whether the application is on the application whitelist. If not, steps 401 and 402 are executed to determine whether the audio stream played by the application is a keep-alive audio stream. Conversely, if the application is on the application whitelist, the audio stream played by the application is not determined.
[0176] The method for the user to set an active keep-alive application may include but is not limited to a method of using an application whitelist.
[0177] It should be noted that the preset conditions may include one or more of the preset conditions in the above examples, and the preset conditions may include but are not limited to the above examples.
[0178] In an embodiment of the present application, when the application meets the preset conditions, the audio stream played by the application is judged, which can avoid judging all audio streams, making the judgment of the keep-alive audio stream more in line with user needs, and can reduce the power consumption of the electronic device. In conjunction with the above example, when the preset condition is that the type of application is inconsistent with the target type, it is possible to avoid judging the audio stream played by the target type application. When the preset condition is that the application is not an application that the user actively keeps alive, it is possible to avoid judging the audio stream played by the application that the user needs to keep alive in the background. Only judging the audio streams played by some applications can reduce the power consumption of the electronic device.
[0179] Among them, after determining that the audio stream played by the application is a keep-alive audio stream, the application playing the keep-alive audio stream can be controlled. For example, the application playing the keep-alive audio stream can be frozen. Specifically, the process freezing technology (freezing of tasks) can be used to freeze the application process, prohibiting the application from using resources such as the memory and processor of the electronic device or restricting the application from using memory and processor resources. The specific freezing method can be set according to needs, and this embodiment does not limit this.
[0180] In one embodiment, when it is determined that the audio stream played by the application is a keep-alive audio stream, the application thread may be killed. For example, when the application starts a main thread and at least one child thread, the main thread and all child threads started by the application may be killed, or only all child threads started by the application may be killed, or only the thread started by the application for playing the keep-alive audio stream may be killed. Specific methods for killing application threads may include, but are not limited to, the examples above.
[0181] Optionally, when the audio stream is determined to be a keep-alive audio stream, the application program may be closed. For example, when the application program is running in the background, the application program running in the background may be closed.
[0182] It should be noted that after determining that the audio stream is a keep-alive audio stream, the application can also be managed and controlled in other ways. For example, the background service of the application can be stopped, for example, the StopService method can be called to stop the background service of the application. Alternatively, the user can be notified to control the application, for example, a reminder box can pop up on the display to remind the user that the application is being kept alive by playing the audio stream, so that the user can manually manage the application. Specific methods for managing and controlling the application may include but are not limited to the above examples, and this embodiment does not limit this.
[0183] Figure 6 A schematic diagram of a keep-alive audio stream identification process provided in an embodiment of the present application is shown.
[0184] like Figure 6 As shown, when the application in the electronic device plays the audio stream, it executes step 61 to output the audio stream to the audio subsystem. Specifically, the application can create an audio track and input the sample values in the audio stream into the buffer of the audio track.
[0185] Optionally, a monitoring module may be provided in the operating system of the electronic device to monitor whether the application program outputs an audio stream. After detecting that an application program has created an audio track, the monitoring module may execute step 62 to obtain each sample value output by the application program from the buffer of the audio track.
[0186] Optionally, a judgment module may be provided in the operating system to judge whether the audio stream is a keep-alive audio stream based on the multiple sampling values. After obtaining the multiple sampling values, the monitoring module may execute step 63 to send the multiple sampling values to the judgment module.
[0187] After receiving the multiple sampled values, the judgment module executes step 64 to analyze the multiple sampled values and obtain an analysis result. The analysis result may include the energy value and / or statistical quantity in the above example. For example, the judgment module may determine the absolute values of the multiple sampled values and then calculate the average of the multiple absolute values, or sum the multiple absolute values to obtain a cumulative value, or determine the maximum absolute value from the multiple absolute values. Similarly, the judgment module may also perform statistics on the multiple sampled values, with sampled values with the same value only being counted once to obtain a statistical quantity.
[0188] Before or after step 64, the judgment module may execute step 65 to send a request to other modules in the operating system to obtain application information such as the application type and behavior. For example, the judgment module may send a request to an activity component in the operating system, and the activity component may execute step 66 to send the application's behavior information to the judgment module. For example, the judgment module may execute step 65 to send a request to the storage module. Correspondingly, the storage module may execute step 66 to send the application's type information to the judgment module.
[0189] After obtaining the analysis results and application information, the determination module may execute step 67 to determine whether the audio stream is a keep-alive audio stream based on the application information and the analysis results, thereby obtaining a determination result. In conjunction with the above example, after determining that the application meets the preset conditions based on the application information, the determination module may determine whether the audio stream is a keep-alive audio stream based on the energy value and / or statistical quantity in the analysis results, thereby obtaining a determination result.
[0190] After obtaining the judgment result, the judgment module executes step 68 to send the judgment result to the management and control module.
[0191] When the control module determines that the audio stream is a keep-alive audio stream, it controls the application using the method in the above example; when the control module determines that the audio stream is a non-keep-alive audio stream, it does not control the application.
[0192] Figure 7 A schematic diagram of a sampling value acquisition process provided in an embodiment of the present application is shown.
[0193] Combine Figure 6 As shown, step 62 includes sub-steps 71 to 77 .
[0194] In the process of obtaining the sample values, the monitoring module first executes sub-step 71 to obtain the sample values in the buffer of the application input audio track.
[0195] After acquiring a sampled value, the monitoring module executes sub-step 72 to compare the acquired sampled value with the pre-stored sampled values. If the acquired sampled value differs from any of the pre-stored sampled values, sub-step 74 is executed to store the acquired sampled value. If the acquired sampled value is the same as one or more pre-stored sampled values, sub-step 73 is executed to discard the acquired sampled value, and the process then returns to sub-step 71 to acquire the next sampled value from the buffer. When the first sampled value is acquired, it is stored. Sub-steps 71 through 74 are executed repeatedly to obtain multiple sampled values with different values.
[0196] After storing a sample value, execute sub-step 75 to determine whether the duration of obtaining the sample value is greater than the preset duration. If it is less than the preset duration, return to execute sub-step 71. If it is greater than the preset duration, execute sub-step 76.
[0197] In sub-step 76, it is determined whether the interval between the last time the sampling value was sent to the judgment module and the current time is greater than the reporting interval. If it is less than the reporting interval, the process returns to sub-step 71. Conversely, if it is greater than or equal to the reporting interval, the process proceeds to sub-step 77.
[0198] In sub-step 77, the monitoring module selects sampling values whose absolute values are greater than or equal to the absolute value threshold from all stored sampling values and sends them to the judgment module. The judgment module judges whether the audio stream is a keep-alive audio stream based on the multiple sampling values.
[0199] Figure 8 A schematic diagram of a keep-alive audio stream determination process provided in an embodiment of the present application is shown.
[0200] Combine Figure 6 and Figure 7 As shown, step 67 includes sub-steps 81 to 85.
[0201] After receiving the multiple sample values sent by the monitoring module and the application information sent by other modules, the determination module executes step 67. During step 67, sub-step 81 is first executed to determine whether the application playing the audio stream is an application that has been actively kept alive by the user. If the application is an application that has been actively kept alive by the user, sub-step 85 is executed to determine whether the audio stream is a non-keep-alive audio stream. If the application is determined not to be an application that has been actively kept alive by the user, sub-step 82 is executed.
[0202] In sub-step 82, the determination module determines whether the application is a target type application. If the application is a target type application, sub-step 85 is executed to determine whether the audio stream is a non-keep-alive audio stream. If the application is not a target type application, sub-step 83 is executed.
[0203] In sub-step 83, the determination module determines whether the energy value of the audio stream is lower than the energy threshold. If the energy value of the audio stream is greater than or equal to the energy threshold, sub-step 85 is executed to determine that the audio stream is a non-keep-alive audio stream. If the energy value of the audio stream is lower than the energy threshold, sub-step 84 is executed to determine that the audio stream is a keep-alive audio stream.
[0204] It should be noted that the execution order of sub-step 81, sub-step 82 and sub-step 83 can be as follows: Figure 8 As shown, it can also be adjusted according to needs, and this embodiment does not limit this.
[0205] Combine Figure 7 and Figure 8 In step 62, when the monitoring module obtains the sampled values, the sampled values of the same value are obtained only once, which can reduce the number of sampled values.
[0206] At the same time, in the process of obtaining the sampling value, when the duration of the obtained sampling value is greater than the preset duration (the preset duration is greater than the shortest playback duration of the audio stream), the obtained sampling value is sent to the judgment module, so that the judgment module can identify the audio stream based on the sampling value in a longer time, and avoid identifying the audio stream based on the sampling value in a shorter time, so as to avoid misjudgment.
[0207] Furthermore, during the process of acquiring a sample value, if the interval between the last time a sample value was sent to the determination module and the current time is greater than a preset reporting interval, the sample value is sent to the determination module, thereby avoiding frequent sending of sample values to the determination module. The specific value of the reporting interval can be set as required and is not limited in this embodiment.
[0208] When sending sampling values to the judgment module, only the sampling values whose absolute values are greater than or equal to the absolute value threshold are sent to the judgment module, which can reduce the number of sampling values and the number of sampling values processed by the judgment module, thereby improving judgment efficiency.
[0209] During the entire audio stream identification process, the audio stream is identified by combining the energy value and the numerical characteristics of the sampling value of the audio stream. This can more accurately determine whether the audio stream is a keep-alive audio stream and avoid false positives. At the same time, it can avoid judging audio streams actively kept alive by users and played by target applications.
[0210] In step 67, the obtained multiple sampling values may be counted to obtain a statistical quantity. When the statistical quantity is greater than or equal to a quantity threshold, the audio stream is determined to be a non-keep-alive audio stream; when the statistical quantity is lower than the quantity threshold and the energy value is lower than the energy threshold, the audio stream is determined to be a keep-alive audio stream.
[0211] Figure 9A schematic diagram of another sampling value acquisition process provided in an embodiment of the present application is shown.
[0212] Combine Figure 6 As shown, step 62 includes sub-steps 91 to 95 .
[0213] During step 62, the monitoring module first executes sub-step 91 to obtain sample values from the buffer of the application input audio track. Then, sub-step 92 is executed to store the obtained sample values. In the above example, when storing the sample values, the monitoring module may store the obtained sample values in a linked list, where the number of sample values stored in the linked list is no less than the number of sample values within the minimum playback duration of the audio stream.
[0214] After storing the sampled value, sub-step 93 is executed to determine whether the duration of acquiring the sampled value is greater than a preset duration, that is, whether the number of sampled values stored in the linked list is less than the number of sampled values within the preset duration. If so, the process returns to sub-step 91. If so, the process proceeds to sub-step 94.
[0215] In sub-step 94, the monitoring module determines whether the interval between the time when the sampling value was last sent to the determination module and the current time is greater than the reporting interval. If it is less than the reporting interval, the process returns to sub-step 91. Conversely, if it is greater than or equal to the reporting interval, the process proceeds to sub-step 95.
[0216] In sub-step 95 , the monitoring module determines the sampling values whose absolute values are greater than or equal to the absolute value threshold from all stored sampling values, and sends the sampling values whose absolute values are greater than or equal to the absolute value threshold to the judgment module.
[0217] Figure 10 A schematic diagram of another process for determining a keep-alive audio stream provided in an embodiment of the present application is shown.
[0218] Combine Figure 6 and Figure 7 As shown, step 67 includes sub-steps 101 to 106 .
[0219] After receiving the multiple sample values sent by the monitoring module and the application information sent by other modules, the determination module executes step 67. During step 67, sub-step 101 is first executed to determine whether the application playing the audio stream is an application that has been actively kept alive by the user. If the application is an application that has been actively kept alive by the user, sub-step 106 is executed to determine whether the audio stream is a non-keep-alive audio stream. If the application is determined not to be an application that has been actively kept alive by the user, sub-step 102 is executed.
[0220] In sub-step 102, the determination module determines whether the application is a target type application. If the application is a target type application, sub-step 106 is executed to determine whether the audio stream is a non-keep-alive audio stream. If the application is not a target type application, sub-step 103 is executed.
[0221] In sub-step 103, the determination module first counts the multiple sample values, counting the sample values with the same value once to obtain a statistical number. If the statistical number is greater than or equal to the number threshold, sub-step 106 is executed to determine that the audio stream is a non-keep-alive audio stream. If the statistical number is less than the number threshold, sub-step 104 is executed.
[0222] In sub-step 104, the judgment module determines the energy value of the audio stream and whether the energy value of the audio stream is lower than the energy threshold. If the energy value of the audio stream is greater than or equal to the energy threshold, sub-step 106 is executed to determine that the audio stream is a non-keep-alive audio stream. If the energy value of the audio stream is lower than the energy threshold, sub-step 105 is executed to determine that the audio stream is a keep-alive audio stream.
[0223] It should be noted that the execution order of sub-step 101, sub-step 102, sub-step 103 and sub-step 104 can be as follows: Figure 10 As shown, it can also be adjusted according to needs, and this embodiment does not limit this.
[0224] Combine Figure 9 and Figure 10 In step 62, when the duration of the sampled value is greater than the preset duration (the preset duration is greater than the shortest playback duration of the audio stream), the monitoring module sends the sampled value to the judgment module during the process of obtaining the sampled value. This allows the judgment module to identify the audio stream based on the sampled value over a longer period of time, and avoids judging the audio stream based on the sampled value over a shorter period of time, thereby avoiding misjudgment.
[0225] At the same time, in the process of obtaining the sampling value, the sampling value is sent to the judgment module when the interval between the last time the sampling value was sent to the judgment module and the current time is greater than the reporting time interval, which can avoid frequently sending the sampling value to the judgment module.
[0226] When sending sampling values to the judgment module, only the sampling values whose absolute values are greater than or equal to the absolute value threshold are sent to the judgment module, which can reduce the number of sampling values and the number of sampling values processed by the judgment module, thereby improving judgment efficiency.
[0227] During the entire audio stream identification process, the audio stream is identified by combining the energy value and the numerical characteristics of the sampling value of the audio stream. This can more accurately determine whether the audio stream is a keep-alive audio stream and avoid false positives. At the same time, it can avoid judging audio streams actively kept alive by users and played by target applications.
[0228] In summary, in an embodiment of the present application, multiple sampling values are obtained from an audio stream played by an application, and based on the multiple sampling values, it is determined whether the audio stream is a keep-alive audio stream. The electronic device can determine whether the audio stream is a keep-alive audio stream or a non-keep-alive audio stream based on the multiple sampling values in the audio stream. This allows the electronic device to selectively clear applications that play keep-alive audio streams and applications that play non-keep-alive audio streams based on the determination result, thereby reducing the power consumption of the electronic device.
[0229] At the same time, selectively cleaning up applications that play keep-alive audio streams and non-keep-alive audio streams can avoid cleaning up applications required by users.
[0230] Figure 11 A schematic structural diagram of a keep-alive audio stream identification device provided in an embodiment of the present application is shown. The device 11 may include:
[0231] An acquisition module 111 is configured to acquire a plurality of sample values from an audio stream played by an application program;
[0232] The determination module 112 is configured to determine whether the audio stream is a keep-alive audio stream according to a plurality of sampling values. The keep-alive audio stream is used to keep the application program in a running state.
[0233] Optionally, the judgment module 112 is specifically configured to determine an energy value of the audio stream according to the multiple sampling values; when the energy value is lower than an energy threshold, determine that the audio stream is a keep-alive audio stream.
[0234] Optionally, the judgment module 112 is specifically configured to determine a statistical number of multiple sampling values, wherein sampling values with the same value are counted once; when the statistical number is lower than a number threshold, the audio stream is determined to be a keep-alive audio stream.
[0235] Optionally, the judgment module 112 is specifically used to determine the energy value of the audio stream based on multiple sampling values; determine the statistical number of multiple sampling values, wherein sampling values with the same value are counted once; when the energy value is lower than the energy threshold and the statistical number is lower than the number threshold, determine that the audio stream is a keep-alive audio stream.
[0236] Optionally, the application is an application that meets preset conditions.
[0237] Optionally, the numerical values of the multiple sampling values are different.
[0238] Optionally, the judgment module 112 is specifically configured to determine whether the audio stream is a keep-alive audio stream according to a target sampling value among the multiple sampling values, where the target sampling value is a sampling value among the multiple sampling values whose absolute value is greater than or equal to an absolute value threshold.
[0239] Optionally, the judgment module 112 is specifically configured to determine the energy value according to the absolute values of the multiple sampling values.
[0240] Optionally, the judgment module 112 is specifically configured to determine the energy value according to an average value, a cumulative value or a maximum value of the absolute value.
[0241] Optionally, the multiple sampling values include sampling values of the audio stream within a preset time length.
[0242] Optionally, the apparatus 11 further includes: a control module, configured to close the application program when determining that the audio stream is a keep-alive audio stream.
[0243] Figure 12 The electronic device 12 may be a schematic diagram of another electronic device provided in an embodiment of the present application. Figure 2 The electronic device 200 shown includes a processor 121, a memory 122, a communication interface 123, and a bus 124. The memory 122 is used to store instructions, and the processor 121 is used to execute the instructions stored in the memory 122. The processor 121, the memory 122, and the communication interface 123 are connected to each other via the bus 124.
[0244] The present application also provides a chip system, which is applied to an electronic device. The chip system includes one or more processors, and the processor is used to call computer instructions to enable the electronic device to execute the method described above.
[0245] The present application also provides a computer program product, including computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described above.
[0246] The computer program product may also be a code solidified in a chip. This application does not limit the specific form of the computer program product.
[0247] The present application also provides a readable storage medium, in which a computer program product is stored. The computer program product includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method described above.
[0248] The readable storage medium may be a volatile memory or a non-volatile memory, or may include both volatile and non-volatile memories. The non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of RAM are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link DRAM (SLDRAM), and direct RAM bus random access memory (DR RAM).
[0249] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and equipment and the technical effects produced can refer to the corresponding processes and technical effects in the aforementioned method embodiments, and will not be repeated here.
[0250] In the several embodiments provided in this application, the disclosed systems, devices and methods can be implemented in other ways. For example, some features of the method embodiments described above can be ignored or not executed. The device embodiments described above are merely schematic, and the division of units is only a logical function division. There may be other division methods in actual implementation, and multiple units or components may be combined or integrated into another system. In addition, the coupling between the units or the coupling between the components may be direct coupling or indirect coupling, and the above coupling includes electrical, mechanical or other forms of connection.
[0251] It should be understood that in the various embodiments of the present application, the size of the serial number of each process does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0252] In short, the above description is only a preferred embodiment of the technical solution of this application and is not intended to limit the scope of protection of this application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this application shall be included in the scope of protection of this application.
Claims
1. A method for identifying a keep-alive audio stream, characterized in that: include: Get multiple sample values from the audio stream played by the application; determining, according to the plurality of sampling values, whether the audio stream is a keep-alive audio stream, wherein the keep-alive audio stream is used to keep the application in a running state; When it is determined that the audio stream is a keep-alive audio stream, closing the application; The determining, according to the multiple sampling values, whether the audio stream is a keep-alive audio stream includes: Determining a statistical quantity based on the multiple sampling values, wherein the sampling values with the same value are counted once; When the statistical quantity is not lower than the quantity threshold, it is determined that the audio stream is not a keep-alive audio stream.
2. The method according to claim 1, wherein The determining, based on the multiple sampling values, whether the audio stream is a keep-alive audio stream further includes: determining an energy value of the audio stream according to the multiple sampling values; When the energy value is lower than an energy threshold and the statistical quantity is lower than a quantity threshold, the audio stream is determined to be a keep-alive audio stream.
3. The method according to claim 1 or 2, wherein: The application program is an application program that meets preset conditions.
4. The method according to any one of claims 1 to 3, wherein Different sampling values among the multiple sampling values have different values.
5. The method according to any one of claims 1 to 4, wherein The determining of a statistical quantity according to the plurality of sampling values comprises: The statistical quantity is determined according to a target sampling value among the multiple sampling values, where the target sampling value is a sampling value among the multiple sampling values whose absolute value is greater than or equal to an absolute value threshold.
6. The method according to claim 2, wherein The determining the energy value of the audio stream according to the multiple sampling values includes: The energy value is determined according to the absolute values of the plurality of sample values.
7. The method according to claim 6, wherein The determining the energy value according to the absolute values of the plurality of sampling values comprises: The energy value is determined according to an average value, a cumulative value or a maximum value of the absolute values of the plurality of sampling values.
8. The method according to any one of claims 1 to 7, wherein The multiple sampling values include sampling values of the audio stream within a preset time length.
9. A device for identifying a keep-alive audio stream, characterized in that: include: The acquisition module is used to obtain multiple sampling values in the audio stream played by the application; a determination module, configured to determine, based on the plurality of sampling values, whether the audio stream is a keep-alive audio stream, wherein the keep-alive audio stream is used to keep the application in a running state; The judgment module is specifically configured to determine a statistical quantity based on the multiple sampling values, wherein the sampling values with the same value are counted once; and when the statistical quantity is not less than a quantity threshold, determine that the audio stream is not a keep-alive audio stream.
10. The device according to claim 9, wherein The judgment module is specifically configured to determine an energy value of the audio stream according to the multiple sampling values; and when the energy value is lower than an energy threshold and the statistical quantity is lower than a quantity threshold, determine that the audio stream is a keep-alive audio stream.
11. The device according to claim 9 or 10, characterized in that The application program is an application program that meets preset conditions.
12. The device according to any one of claims 9 to 11, characterized in that Different sampling values among the multiple sampling values have different values.
13. The device according to any one of claims 9 to 12, characterized in that The judgment module is specifically configured to determine the statistical quantity according to a target sampling value among the multiple sampling values, where the target sampling value is a sampling value among the multiple sampling values whose absolute value is greater than or equal to an absolute value threshold.
14. The device according to claim 10, wherein The judgment module is specifically configured to determine the energy value according to the absolute values of the multiple sampling values.
15. The device according to claim 14, wherein The judgment module is specifically configured to determine the energy value according to an average value, a cumulative value or a maximum value of the absolute values of the multiple sampling values.
16. The device according to any one of claims 9 to 15, characterized in that The multiple sampling values include sampling values of the audio stream within a preset time length.
17. An electronic device, characterized in that: include: One or more processors and one or more memories; the one or more processors are coupled to the one or more memories, the one or more memories are used to store computer program code, the computer program code includes computer instructions, when the one or more processors execute the computer instructions, the electronic device performs the method according to any one of claims 1 to 8.
18. A readable storage medium, characterized in that: The readable storage medium stores a computer program product, wherein the computer program product includes computer instructions. When the computer instructions are executed on an electronic device, the electronic device executes the method according to any one of claims 1 to 8.
19. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the processor is used to call computer instructions to enable the electronic device to execute the method as described in any one of claims 1-8.
20. A computer program product, characterized in that The method comprises computer instructions, which, when executed on an electronic device, cause the electronic device to execute the method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Application processing method and device and electronic equipment
CN113986190A
Audio and video resource processing method and device, terminal and storage medium
CN119472972A
Method and device for detecting silent audio
CN119576105A
Audio Data Processing Method and Apparatus
US20190327284A1