WO2020097787A1 - Method, apparatus, and electronic device for audio resource release - Google Patents

Method, apparatus, and electronic device for audio resource release Download PDF

Info

Publication number
WO2020097787A1
WO2020097787A1 PCT/CN2018/115190 CN2018115190W WO2020097787A1 WO 2020097787 A1 WO2020097787 A1 WO 2020097787A1 CN 2018115190 W CN2018115190 W CN 2018115190W WO 2020097787 A1 WO2020097787 A1 WO 2020097787A1
Authority
WO
WIPO (PCT)
Prior art keywords
application
audio
audio resource
application program
resource
Prior art date
Application number
PCT/CN2018/115190
Other languages
French (fr)
Chinese (zh)
Inventor
李亚军
Original Assignee
深圳市欢太科技有限公司
Oppo广东移动通信有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 深圳市欢太科技有限公司, Oppo广东移动通信有限公司 filed Critical 深圳市欢太科技有限公司
Priority to PCT/CN2018/115190 priority Critical patent/WO2020097787A1/en
Priority to CN201880098219.6A priority patent/CN112997131A/en
Publication of WO2020097787A1 publication Critical patent/WO2020097787A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F1/00Details not covered by groups G06F3/00 - G06F13/00 and G06F21/00
    • G06F1/26Power supply means, e.g. regulation thereof
    • G06F1/32Means for saving power

Definitions

  • the invention relates to the field of information technology, in particular to a method, device and electronic device for releasing audio resources.
  • its audio resources can be called through different applications, for example, the audio resources of the mobile terminal can be called through the music application software to achieve music playback, the ringtone can be played through the calling software, or the recording software Realize the call of microphone and other resources.
  • audio resources are usually occupied by only one application and cannot be shared during use.
  • recording when a recording program is using the recording resource, another recording program cannot use the recording resource at the same time.
  • An embodiment of the present application provides a method for releasing audio resources, including:
  • the application program If the running time of the application program in the background state exceeds a preset threshold, and the application program outputs an abnormal identifier when the audio resource is occupied, the audio resource is released.
  • An embodiment of the present application further provides an apparatus for releasing audio resources.
  • the apparatus includes:
  • An allocation module configured to allocate audio resources to the application program, so that the application program calls the audio resource
  • a monitoring module configured to monitor the audio resource release behavior of the application program
  • the recording module is used to record the running time of the application program in the background state when the application program is switched to the background operation;
  • a release module configured to output an abnormal identifier to release the audio resource if the application program runs in a background state for a duration exceeding a preset threshold and the application program occupies the audio resource.
  • An embodiment of the present application further provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and when the computer program is executed by the processor, the processor causes the processor to perform the above-mentioned audio resource release step.
  • Embodiments of the present application also provide a computer non-volatile readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned steps of releasing audio resources are realized.
  • the electronic device and the computer-readable storage medium implement the above method, when the application program is switched to the background and the audio resource is abnormally called, the audio resource is released in time, which reduces the power consumption of the system, improves the stability of the system, and improves the user Experience.
  • FIG. 1 is a flowchart of an audio resource release method according to an embodiment
  • FIG. 2 is a schematic structural diagram of an audio resource releasing device according to an embodiment
  • FIG. 3 is a schematic diagram of the internal structure of an electronic device in an embodiment
  • FIG. 4 is a block diagram of a partial structure of an electronic device related to a computer device provided by an embodiment of the present invention.
  • an embodiment of the present application provides a method for releasing audio resources, which is applied to an electronic device.
  • the method includes:
  • Audio resources in the embodiments of the present application may be resources required for playing audio, such as speakers, audio channels, audio files, etc., or resources required for recording, such as microphones, audio circuits, recording data storage, audio
  • the recording processor and the like are not limited in the embodiments of the present application.
  • the audio resource of the application can be released through the electronic device, and the audio resource can be released through the processing function built in the electronic device.
  • the electronic device with the Android system as an example, different types of functions are defined in the Android system
  • the release of audio resources only needs to use the corresponding audio call function to achieve this operation.
  • a brand-new monitoring mechanism is creatively proposed, that is, a system-level monitoring module is created at the system framework layer, and the audio resource status is monitored through the monitoring interface of the monitoring module, or, Create a monitoring process independently, and monitor the audio resource status of the application through a message transmission mechanism.
  • the monitoring interface may be a monitoring function
  • the electronic device may monitor the release of audio resources of the application through the built-in monitoring function.
  • a system may be created at the system framework layer (native / framework layer)
  • the monitoring module of the same level monitors the audio mode of the application through the monitoring module, or independently creates a monitoring process and monitors the audio mode of the application through a message transmission mechanism.
  • the application can be divided into two states: foreground operation and background operation.
  • the foreground operation indicates that the current application is running in the current main program.
  • running in the background means that the current application program is not the main program running.
  • the operation interface of the application program is not displayed on the operation interface, the application program is always running.
  • the monitoring mechanism can be developed independently without coupling with the system, which is convenient for subsequent development and upgrade.
  • the duration of the application running in the background state can be recorded through the monitoring interface provided above.
  • a timer can be set, which can be activated when an application that occupies audio resources is switched from the foreground to the background, and can count or record the duration of the application running in the background running state.
  • the application program outputs the abnormal identifier when occupying the audio resource, which may specifically be: acquiring audio data output by the application program within a preset time period;
  • Verify the audio data and if the verification result of the output audio data is abnormal, determine that the application program abnormally occupies the audio resource, and the abnormality identifier is a verification result that the output is abnormal .
  • the audio data verification result is abnormal, it is determined that the audio data is invalid data.
  • the audio data is verified, and the verification result of the output audio data is abnormal, which may specifically be: analyzing the real-time volume value contained in the audio data; if the real-time volume value Equal to 0, it is determined that the verification result of the audio data is abnormal, and the audio data is invalid data.
  • the method for determining invalid data may include two specific methods.
  • the first method is to perform sampling analysis on any frame of digital data contained in the audio data, and determine the ratio of the number of data equal to 0 to the total number of digital data in one frame. ; If the ratio is greater than a certain threshold, the audio data is determined to be invalid data.
  • T for example, 30 minutes
  • the monitoring process is started and the audio data is valid, such as the audio data is Invalid data, then close Kill or restart the reset operation of the application to release the audio resource, or reacquire the audio resource.
  • the priority information of the application can also be obtained; and according to the priority information, it is determined whether the application needs to be restarted or directly closed, for example, for a high-priority application ( (Application priority is higher than the preset level), then select restart operation to reacquire the audio resource; and for low priority applications (application priority is lower than the preset level), select close operation.
  • the priority of the application program may be determined according to the use frequency and permission information of the application program.
  • the power of the electronic device can also be obtained. If the power of the electronic device is lower than the preset power, the application running time in the background state exceeds a preset threshold, and the The application program outputs an abnormal identifier when occupying the audio resource, and closes the application program to release the audio resource. For example, the current battery is 20% and is below the threshold of 25%. If the current application abnormally occupies audio resources in the background state for more than the preset time, the application is forcibly closed to save power.
  • the forced shutdown process can only be performed when the power is low Starting automatically under a certain threshold can further improve the system processing efficiency.
  • the amount of change in the electricity amount of the electronic device within a preset time may also be obtained, where the amount of electricity change indicates the magnitude of the amount of change in the electricity amount during the preset time / unit time.
  • the amount of change in power of the electronic device within a preset time is greater than or equal to the amount of change in preset power, the duration of the application running in the background state exceeds a preset threshold, and the application occupies the audio
  • An abnormal identifier is output when the resource is closed, and the application program is closed to release the audio resource. For example, if the current power consumption is serious, the amount of power change is high, and if it is higher than a certain threshold, an audio resource release process is started to forcibly close the application and release the audio resource.
  • the audio resource when the application is switched to the background and the audio resource is abnormally called, the audio resource is released in time, which reduces the power consumption of the system, improves the stability of the system, and improves the user experience.
  • an embodiment of the present application further provides an apparatus 20 for releasing audio resources.
  • the apparatus 20 includes:
  • the allocation module 21 is configured to allocate audio resources to the application program, so that the application program calls the audio resource;
  • Audio resources in the embodiments of the present application may be resources required for playing audio, such as speakers, audio channels, audio files, etc., or resources required for recording, such as microphones, audio circuits, recording data storage, audio
  • the recording processor and the like are not limited in the embodiments of the present application.
  • the audio resource of the application can be released through the electronic device, and the audio resource can be released through the processing function built in the electronic device.
  • the electronic device with the Android system as an example, different types of functions are defined in the Android system
  • the release of audio resources only needs to use the corresponding audio call function to achieve this operation.
  • the monitoring module 22 is configured to monitor the audio resource release behavior of the application program
  • a brand-new monitoring mechanism is creatively proposed, that is, a system-level monitoring module 22 is created at the system framework layer, and the audio resource status is monitored through the monitoring interface of the monitoring module 22, Or, instead of setting up the monitoring module 22 through the system framework layer, a non-system level monitoring module 22 is created, through which the monitoring process is independently created, and the audio resource status of the application is monitored through a message transmission mechanism.
  • the monitoring interface may be a monitoring function
  • the electronic device may monitor the release of audio resources of the application through the built-in monitoring function.
  • a system may be created at the system framework layer (native / framework layer)
  • the monitoring module of the same level monitors the audio mode of the application through the monitoring module, or independently creates a monitoring process and monitors the audio mode of the application through a message transmission mechanism.
  • system_server system service program
  • the application can be divided into two states: foreground operation and background operation.
  • the foreground operation indicates that the current application is running in the current main program.
  • running in the background means that the current application program is not the main program running.
  • the operation interface of the application program is not displayed on the operation interface, the application program is always running.
  • the monitoring mechanism can be developed independently without coupling with the system, which is convenient for subsequent development and upgrade.
  • the recording module 23 is used to record the running time of the application in the background when the application is switched to the background;
  • the recording module 23 may record the running time of the application in the background state through the monitoring interface provided by the monitoring module 22.
  • a timer can be set, which can be activated when an application that occupies audio resources is switched from the foreground to the background, and can count or record the duration of the application running in the background running state.
  • the release module 24 is configured to output an abnormal identifier to release the audio resource if the application program runs in a background state for more than a preset threshold and the application program occupies the audio resource.
  • the release module 24 confirms that the application program outputs the abnormal identifier when occupying the audio resource, which may specifically be: acquiring audio data output by the application program within a preset time period;
  • Verify the audio data and if the verification result of the output audio data is abnormal, determine that the application program abnormally occupies the audio resource, and the abnormality identifier is a verification result that the output is abnormal .
  • the audio data verification result is abnormal, it is determined that the audio data is invalid data.
  • the audio data is verified, and the verification result of the output audio data is abnormal, which may specifically be: analyzing the real-time volume value contained in the audio data; if the real-time volume value is equal to 0. It is determined that the verification result of the audio data is abnormal, and the audio data is invalid data.
  • the method for determining invalid data may include two specific methods.
  • the first method is to perform sampling analysis on any frame of digital data contained in the audio data, and determine the ratio of the number of data equal to 0 to the total number of digital data in one frame. ; If the ratio is greater than a certain threshold, the audio data is determined to be invalid data.
  • T for example, 30 minutes
  • the monitoring process is started and the audio data is valid, such as the audio data is If the data is invalid, the application will close Kill or restart the reset operation to release the audio resource.
  • the release module 24 can also obtain priority information of the application; and based on the priority information, determine whether the application needs to be restarted or directly closed, for example, for high priority For applications (application priority is higher than the preset level), restart operation is selected, and for applications with low priority (application priority is lower than the preset threshold), close operation is selected.
  • the priority of the application program may be determined according to the use frequency and permission information of the application program.
  • the release module 24 may also obtain the power of the electronic device, if the power of the electronic device is lower than the preset power, and the duration of the application running in the background state exceeds a preset threshold , And the application program outputs an abnormal identifier when occupying the audio resource, and closes the application program to release the audio resource.
  • the current battery is 20% and is below the threshold of 25%. If the current application abnormally occupies audio resources in the background state for more than the preset time, the application is forcibly closed to save power.
  • the forced shutdown process can only be performed when the power is low Starting automatically under a certain threshold can further improve the system processing efficiency.
  • the release module 24 may also obtain the amount of change in power of the electronic device within a preset time, and the amount of change in power represents the amount of change in power per unit time. Similarly, if the amount of change in power of the electronic device within a preset time is greater than or equal to the amount of change in preset power, the duration of the application running in the background state exceeds a preset threshold, and the application occupies the audio An abnormal identifier is output when the resource is closed, and the application program is closed to release the audio resource. For example, if the current power consumption is serious, the amount of power change is high, and if it is higher than a certain threshold, an audio resource release process is started to forcibly close the application and release the audio resource.
  • the release module when the application is switched to the background and the audio resource is abnormally called, the release module can release the audio resource in time, which reduces the power consumption of the system, improves the stability of the system, and improves the user experience.
  • the electronic device includes a processor connected through a system bus, a non-volatile storage medium, an internal memory and a network interface, a sound collection device, a speaker, a display screen, and an input device.
  • the non-volatile storage medium of the terminal stores an operating system and computer-readable instructions.
  • the processor is used to provide computing and control capabilities to support the operation of the entire electronic device.
  • the internal memory in the electronic device provides an environment for the execution of computer-readable instructions in the non-volatile storage medium.
  • the display screen of the electronic device may be a liquid crystal display screen or an electronic ink display screen, etc.
  • the input device may be a touch layer covered on the display screen, a button, a trackball or a touch pad provided on the housing of the electronic device, or External keyboard, touchpad or mouse, etc.
  • the electronic device may be a mobile phone, a tablet computer, a personal digital assistant or a wearable device.
  • FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied.
  • the specific electronic device may It includes more or fewer components than shown in the figure, or some components are combined, or have a different component arrangement.
  • the above-mentioned audio resource release method may specifically be:
  • the application program If the running time of the application program in the background state exceeds a preset threshold, and the application program outputs an abnormal identifier when the audio resource is occupied, the audio resource is released.
  • the monitoring of the audio resource release behavior of the application program specifically includes: creating a system-level monitoring interface at the system framework layer, and releasing the audio resource of the application program through the monitoring interface Behavior monitoring, or, independently create a monitoring process, and monitor the audio resource release behavior of the application through a message transmission mechanism.
  • the processor is also used to execute:
  • the application If the duration of the application running in the background state exceeds a preset threshold, and the application outputs an abnormal identifier when the audio resource is occupied, if the priority of the application is higher than the preset level, restart the application To release the audio resource, or if the priority of the application is lower than a preset threshold, close the application to release the audio resource.
  • the processor is also used to execute:
  • the priority of the application is determined according to the frequency of use of the application and permission information.
  • the processor is also used to execute:
  • the duration of the application running in the background exceeds the preset threshold, and the application outputs an abnormal identifier when the audio resource is occupied, close the application to release The audio resource.
  • the processor is also used to execute:
  • the amount of change in power of the electronic device within a preset time is greater than or equal to the amount of change in preset power, the duration of the application running in the background state exceeds a preset threshold, and the output is output when the application occupies the audio resource Abnormal identification, close the application to release the audio resource.
  • the audio resource is abnormally occupied while the application is running, including:
  • the verification of the audio data if the verification result of the output audio data is abnormal, includes:
  • the embodiments of the present application also provide a computer non-volatile readable storage medium on which a computer program is stored, and when the computer program is executed by the processor, the steps of releasing the audio resource as described above are realized.
  • An embodiment of the present invention also provides a computer device. As shown in FIG. 4, for ease of description, only parts related to the embodiments of the present invention are shown, and specific technical details are not disclosed, please refer to the method part of the embodiments of the present invention.
  • the computer device may be any terminal device including an electronic device, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), an in-vehicle computer, a wearable device, etc.
  • the computer device is an electronic device For example:
  • the electronic device includes: a radio frequency (Radio Frequency) circuit 410, a memory 420, an input unit 430, a display unit 440, a sensor 450, an audio circuit 460, a wireless fidelity (WiFi) module 470, a processor 480, and power supply 490 and other components.
  • a radio frequency (Radio Frequency) circuit 410 for detecting radio frequency (Radio Frequency)
  • a memory 420 for a digital signal
  • an input unit 430 a keyboard
  • a display unit 440 a sensor 450
  • an audio circuit 460 a wireless fidelity (WiFi) module
  • WiFi wireless fidelity
  • processor 480 and power supply 490 and other components.
  • power supply 490 other components.
  • the structure of the electronic device shown in FIG. 4 does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine some components, or arrange different components.
  • the RF circuit 410 can be used to receive and send signals during the sending and receiving of information or during a call. It can receive the downlink information of the base station and process it to the processor 480; it can also send the uplink data to the base station.
  • RF circuits include but are not limited to antennas, at least one amplifier, transceiver, coupler, low noise amplifier (Low Noise Amplifier, LNA), duplexer, and so on.
  • the RF circuit 410 can also communicate with other devices through a wireless communication network.
  • the above wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile (GSM), General Packet Radio Service (GPRS), and Code Division Multiple Access (Code Division) Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Message Service (SMS), etc.
  • GSM Global System of Mobile
  • GPRS General Packet Radio Service
  • CDMA Code Division Multiple Access
  • WCDMA Wideband Code Division Multiple Access
  • LTE Long Term Evolution
  • SMS Short Message Service
  • the memory 420 may be used to store software programs and modules.
  • the processor 480 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 420.
  • the memory 420 may mainly include a program storage area and a data storage area, where the program storage area may store an operating system and at least one function-required application program (such as a sound playback function application program, an image playback function application program, etc.), etc .;
  • the data storage area can store data (such as audio data, address book, etc.) created according to the use of electronic devices.
  • the memory 420 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
  • the input unit 430 may be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device 400.
  • the input unit 430 may include a touch panel 431 and other input devices 432.
  • the touch panel 431 also known as a touch screen, can collect user's touch operations on or near it (for example, the user uses any suitable objects or accessories such as fingers or stylus on or near the touch panel 431 Operation), and drive the corresponding connection device according to the preset program.
  • the touch panel 431 may include a touch monitoring device and a touch controller.
  • the touch monitoring device monitors the user's touch orientation, and monitors the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch monitoring device, and converts it into contact coordinates, and then sends To the processor 480, and can receive the command sent by the processor 480 and execute it.
  • the touch panel 431 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 430 may also include other input devices 432.
  • the other input devices 432 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.).
  • the display unit 440 may be used to display information input by the user or information provided to the user and various menus of the electronic device.
  • the display unit 440 may include a display panel 441.
  • the display panel 441 may be configured in the form of a liquid crystal display (Liquid Crystal) (LCD), an organic light-emitting diode (Organic Light-Emitting Diode, OLED), or the like.
  • the touch panel 431 may cover the display panel 441, and after the touch panel 431 detects a touch operation on or near it, it is transmitted to the processor 480 to determine the type of touch event, and then the processor 480 according to The type of touch event provides corresponding visual output on the display panel 441.
  • the touch panel 431 and the display panel 441 are implemented as two independent components to realize the input and input functions of the electronic device, in some embodiments, the touch panel 431 and the display panel 441 may be integrated And realize the input and output functions of electronic equipment.
  • the electronic device 400 may further include at least one sensor 450, such as a light sensor, a motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 441 according to the brightness of the ambient light, and the proximity sensor may close the display panel 441 and the electronic device when moving to the ear / Or backlight.
  • the motion sensor may include an acceleration sensor. The acceleration sensor can monitor the magnitude of acceleration in various directions, and can monitor the magnitude and direction of gravity when at rest.
  • electronic devices can be used for applications that recognize the posture of electronic devices (such as horizontal and vertical screen switching), and vibration recognition related functions ( For example, pedometer, percussion, etc .; in addition, electronic devices can also be equipped with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc.
  • sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc.
  • the audio circuit 460, the speaker 461, and the microphone 462 may provide an audio interface between the user and the electronic device.
  • the audio circuit 460 can transmit the converted electrical signal of the received audio data to the speaker 461, which converts the speaker 461 into a sound signal for output; on the other hand, the microphone 462 converts the collected sound signal into an electrical signal, which is converted by the audio circuit 460 After receiving, it is converted into audio data, and then processed by the audio data output processor 680, and then sent to another electronic device via the RF circuit 610, or the audio data is output to the memory 620 for subsequent processing.
  • WiFi is a short-range wireless transmission technology. Electronic devices can help users send and receive emails, browse web pages, and access streaming media through the WiFi module 470. It provides users with wireless broadband Internet access.
  • FIG. 4 shows the WiFi module 470, it can be understood that it is not a necessary component of the electronic device 400, and may be omitted as needed.
  • the processor 480 is the control center of the electronic device, and uses various interfaces and lines to connect the various parts of the entire electronic device, by running or executing the software programs and / or modules stored in the memory 420, and calling the data stored in the memory 420 , Perform various functions of electronic devices and process data, so as to monitor the electronic devices as a whole.
  • the processor 480 may include one or more processing units.
  • the processor 480 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, user interface, application programs, and the like; the modem processor mainly processes wireless communication. It can be understood that the foregoing modem processor may not be integrated into the processor 480.
  • the electronic device 400 further includes a power supply 490 (such as a battery) that supplies power to various components.
  • a power supply 490 (such as a battery) that supplies power to various components.
  • the power supply can be logically connected to the processor 480 through the power management system, so as to implement functions such as charging, discharging, and power management through the power management system .
  • the electronic device 400 may further include a camera, a Bluetooth module, and the like.
  • the processor 480 included in the computer device implements the method of the foregoing embodiments when executing the computer program stored on the memory, for example, including the method of releasing audio resources shown in FIG. 1.
  • the program may be stored in a non-volatile computer-readable storage medium
  • the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), etc.
  • An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the methods of the foregoing embodiments.

Abstract

Provided are a method, apparatus, and electronic device for audio resource release, said method comprising: assigning an audio resource to an application so that said application invokes said audio resource (S110); monitoring the audio resource release behavior of the application (S120); if the application switches to run in the background, recording the duration of running of the application in the background state (S130); if the running time of the application in the background state exceeds a preset threshold and the application outputs an exception identifier when the audio resource is occupied, then releasing the audio resource (S140). The method reduces the power consumption of the system, improving system stability.

Description

一种音频资源释放的方法、装置及电子设备Audio resource release method, device and electronic equipment 技术领域Technical field
本发明涉及信息技术领域,特别是涉及一种音频资源释放的方法、装置及电子设备。The invention relates to the field of information technology, in particular to a method, device and electronic device for releasing audio resources.
背景技术Background technique
目前的移动终端中,其音频资源可通过不同的应用程序调用,例如,可通过音乐应用软件调用移动终端的音频资源以实现音乐的播放,可通过通话软件实现铃声的播放,也可通过录音软件实现麦克风等资源的调用。In the current mobile terminal, its audio resources can be called through different applications, for example, the audio resources of the mobile terminal can be called through the music application software to achieve music playback, the ringtone can be played through the calling software, or the recording software Realize the call of microphone and other resources.
然而,音频资源由于其独特性及唯一性,在使用过程中通常只能被一个应用程序占用而无法实现共用。以录音为例,当一个录音程序正在使用该录音资源时,另一个录音程序则无法同一时刻对该录音资源进行使用。However, due to its uniqueness and uniqueness, audio resources are usually occupied by only one application and cannot be shared during use. Taking recording as an example, when a recording program is using the recording resource, another recording program cannot use the recording resource at the same time.
在现有技术中,当调用方已切换回后台时,可以继续调用该音频资源直至正常释放,然而,对于已切换至后台后调用音频资源异常的情况,却缺少相应的监测机制,导致音频资源未得到合理释放,系统功耗大,且稳定性差。In the prior art, when the caller has switched back to the background, it can continue to call the audio resource until it is released normally, however, for the situation where the call to the audio resource is abnormal after switching to the background, the corresponding monitoring mechanism is lacking, resulting in the audio resource Without a reasonable release, the system consumes a lot of power and has poor stability.
发明内容Summary of the invention
本申请实施例提供一种音频资源释放的方法,包括:An embodiment of the present application provides a method for releasing audio resources, including:
为应用程序分配音频资源,以使所述应用程序调用所述音频资源;Assign audio resources to the application program, so that the application program calls the audio resource;
对所述应用程序的音频资源释放行为进行监测;Monitoring the audio resource release behavior of the application program;
当应用程序切换为后台运行时,对所述应用程序在后台状态下运行时长进行记录;When the application is switched to run in the background, record the running time of the application in the background state;
若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,释放所述音频资源。If the running time of the application program in the background state exceeds a preset threshold, and the application program outputs an abnormal identifier when the audio resource is occupied, the audio resource is released.
本申请实施例还提供一种音频资源释放的装置,所述装置包括:An embodiment of the present application further provides an apparatus for releasing audio resources. The apparatus includes:
分配模块,用于为应用程序分配音频资源,以使所述应用程序调用所述音频资源;An allocation module, configured to allocate audio resources to the application program, so that the application program calls the audio resource;
监测模块,用于对所述应用程序的音频资源释放行为进行监测;A monitoring module, configured to monitor the audio resource release behavior of the application program;
记录模块,用于当应用程序切换为后台运行时,对所述应用程序在后台状态下运行时长进行记录;The recording module is used to record the running time of the application program in the background state when the application program is switched to the background operation;
释放模块,用于若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,释放所述音频资源。A release module, configured to output an abnormal identifier to release the audio resource if the application program runs in a background state for a duration exceeding a preset threshold and the application program occupies the audio resource.
本申请实施例还提供一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行上述的音频资源释放的步骤。An embodiment of the present application further provides an electronic device, including a memory and a processor, where a computer program is stored in the memory, and when the computer program is executed by the processor, the processor causes the processor to perform the above-mentioned audio resource release step.
本申请实施例还提供一种计算机非易失性可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述的音频资源释放的步骤。Embodiments of the present application also provide a computer non-volatile readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the above-mentioned steps of releasing audio resources are realized.
电子设备和计算机可读存储介质在实现上述方法时,当应用程序切换到后台且异常调用音频资源时,及时释放该音频资源,降低了系统的功耗,提高了系统的稳定性,提升了用户体验。When the electronic device and the computer-readable storage medium implement the above method, when the application program is switched to the background and the audio resource is abnormally called, the audio resource is released in time, which reduces the power consumption of the system, improves the stability of the system, and improves the user Experience.
附图说明BRIEF DESCRIPTION
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他实施例的附图。In order to more clearly explain the embodiments of the present invention or the technical solutions in the prior art, the following will briefly introduce the drawings required in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present invention. For those of ordinary skill in the art, without paying any creative labor, drawings of other embodiments can be obtained based on these drawings.
图1为一实施例的音频资源释放方法流程图;1 is a flowchart of an audio resource release method according to an embodiment;
图2为一实施例的音频资源释放装置结构示意图;2 is a schematic structural diagram of an audio resource releasing device according to an embodiment;
图3为一实施例中电子设备的内部结构示意图;3 is a schematic diagram of the internal structure of an electronic device in an embodiment;
图4为与本发明实施例提供的计算机设备相关的电子设备的部分结构的框图。4 is a block diagram of a partial structure of an electronic device related to a computer device provided by an embodiment of the present invention.
具体实施方式detailed description
为了便于理解本发明,下面将参照相关附图对本发明进行更全面的描述。附图中给出了本发明的较佳实施例。但是,本发明可以以许多不同的形式来实现,并不限于本文所描述的实施例。相反地,提供这些实施例的目的是使对本发明的公开内容的理解更加透彻全面。In order to facilitate understanding of the present invention, the present invention will be described more fully below with reference to related drawings. The drawings show preferred embodiments of the invention. However, the present invention can be implemented in many different forms, and is not limited to the embodiments described herein. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present invention more thorough and comprehensive.
如图1所示,本申请实施例提供了一种音频资源释放的方法,应用于电子设备,该方法包括:As shown in FIG. 1, an embodiment of the present application provides a method for releasing audio resources, which is applied to an electronic device. The method includes:
S101、为应用程序分配音频资源,以使所述应用程序调用所述音频资源;S101. Assign audio resources to an application program, so that the application program calls the audio resource;
音频资源在本申请实施例中,可以是播放音频所需要的资源,例如扬声器、声道、音频文件等,也可以是进行录音时所需要的资源,例如麦克风、音频电路、录制数据存储器、音频录制处理器等,本申请实施例对此并无限制。其中,可通过电子设备实现对应用程序的音频资源释放,对音频资源释放可以通过电子设备内置的处理函数进行,以安装了安卓系统的电子设备为例,在安卓系统中定义了不同种类的函数以实现不同方式的音频资源释放,包括音频的输入输出操作,如音乐播放、通话、语音提示、录音等操作,因此,音频资源释放只需要在使用对应的音频调用函数即可实现该操作。Audio resources in the embodiments of the present application may be resources required for playing audio, such as speakers, audio channels, audio files, etc., or resources required for recording, such as microphones, audio circuits, recording data storage, audio The recording processor and the like are not limited in the embodiments of the present application. Among them, the audio resource of the application can be released through the electronic device, and the audio resource can be released through the processing function built in the electronic device. Taking the electronic device with the Android system as an example, different types of functions are defined in the Android system To achieve the release of audio resources in different ways, including audio input and output operations, such as music playback, calls, voice prompts, recording and other operations, therefore, the release of audio resources only needs to use the corresponding audio call function to achieve this operation.
S102、对所述应用程序的音频资源释放行为进行监测;S102: Monitor the audio resource release behavior of the application program;
在本申请实施例中,创造性地提出了一种全新的监测机制,即:在系统框架层创建系统级的监测模块,通过所述监测模块的监测接口对所述音频资源状态进行监测,或,独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。具体地,监测接口可以是监听函数,电子设备可通过内置的监听函数对应用程序的音频资源释放进行监听,以安卓系统的电子设备为例,可在系统框架层(native/framework层)创建系统级的监测模块,通过所述监测模块对所述应用程序的音频模式进行监听,或,独立创建监听进程,通过消息传输机制监听所述应用程序的音频模式。例如,可在框架层设 立监测模块并运行在系统服务程序(system_server)中,由于该监测模块设立在系统级的服务框架层中,可方便与其他系统服务进行交互,同时无需担心系统调用时的权限问题。此外,也可以创建独立的监听进程,在该进程中设立并调用单独的监听函数,可设置为开机自启动,并实时对其他任何一个应用程序的音频资源释放进行监控,具体地,可监听当前应用程序的音频调用时长、音频资源的ID,以及该应用程序状态等信息,一般地,应用程序可分为前台运行和后台运行两种状态,其中前台运行表示当前应用程序为主程序运行在当前电子设备的界面上,后台运行则表示当前应用程序不是运行的主程序,虽然在操作界面上并没有显示该应用程序的运行界面,但应用程序一直在运行。该监测机制可独立开发,不与系统进行耦合,方便后续的开发和升级。In the embodiments of the present application, a brand-new monitoring mechanism is creatively proposed, that is, a system-level monitoring module is created at the system framework layer, and the audio resource status is monitored through the monitoring interface of the monitoring module, or, Create a monitoring process independently, and monitor the audio resource status of the application through a message transmission mechanism. Specifically, the monitoring interface may be a monitoring function, and the electronic device may monitor the release of audio resources of the application through the built-in monitoring function. Taking the electronic device of the Android system as an example, a system may be created at the system framework layer (native / framework layer) The monitoring module of the same level monitors the audio mode of the application through the monitoring module, or independently creates a monitoring process and monitors the audio mode of the application through a message transmission mechanism. For example, you can set up a monitoring module at the framework layer and run it in the system service program (system_server). Because the monitoring module is set up at the system-level service framework layer, you can easily interact with other system services without worrying about system calls. Permissions issue. In addition, you can also create an independent monitoring process, set up and call a separate monitoring function in this process, can be set to start automatically after booting, and monitor the audio resource release of any other application in real time, specifically, you can monitor the current The duration of the audio call of the application, the ID of the audio resource, and the status of the application. In general, the application can be divided into two states: foreground operation and background operation. The foreground operation indicates that the current application is running in the current main program. On the interface of the electronic device, running in the background means that the current application program is not the main program running. Although the operation interface of the application program is not displayed on the operation interface, the application program is always running. The monitoring mechanism can be developed independently without coupling with the system, which is convenient for subsequent development and upgrade.
S103、当应用程序切换为后台运行时,对所述应用程序在后台状态下运行时长进行记录;S103: When the application program is switched to run in the background, record the running time of the application program in the background state;
在S103中,可通过上述提供的监测接口对该应用程序在后台状态下运行时长进行记录。例如,可设置定时器,在占用了音频资源的应用程序从前台切换为后台时,可激活该定时器,并对该应用程序在后台运行状态下运行的时长进行计时或记录。In S103, the duration of the application running in the background state can be recorded through the monitoring interface provided above. For example, a timer can be set, which can be activated when an application that occupies audio resources is switched from the foreground to the background, and can count or record the duration of the application running in the background running state.
S104、若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,释放所述音频资源。S104: If the running time of the application program in the background state exceeds a preset threshold, and the application program outputs an abnormal identifier when the audio resource is occupied, the audio resource is released.
其中,确认应用程序占用所述音频资源时输出异常标识,具体可以是:获取预设时间段内所述应用程序输出的音频数据;Wherein, it is confirmed that the application program outputs the abnormal identifier when occupying the audio resource, which may specifically be: acquiring audio data output by the application program within a preset time period;
对所述音频数据进行校验,若所述输出的音频数据的校验结果为异常,则确定所述应用程序异常占用所述音频资源,所述异常标识为所述输出为异常的校验结果。此外,若该音频数据校验结果为异常,则确定该音频数据为无效数据。具体地,对所述音频数据进行校验,且所述输出的音频数据的校验结果为异常,具体可以为:对所述音频数据中包含的实时音量值进行分析;若所述实时音量值等于0,确定所述音频数据的校验结果为异常,该音频数 据为无效数据。判断无效数据的方法具体可以包括两种,第一种为:对所述音频数据中包含的任意一帧数字数据进行抽样分析,确定等于0的数据的数量与一帧数字数据的总数量的比例;若所述比例大于某一阈值,确定所述音频数据为无效数据。当应用程序连续在后台运行一段时间T(例如30分钟),且该时间T内应用程序一直没有释放掉该音频资源时才会启动该监听流程,并判断该音频数据是否有效,如音频数据为无效数据,则将该应用程序进行关闭Kill或重启reset操作,以释放掉该音频资源,或重新获取该音频资源。Verify the audio data, and if the verification result of the output audio data is abnormal, determine that the application program abnormally occupies the audio resource, and the abnormality identifier is a verification result that the output is abnormal . In addition, if the audio data verification result is abnormal, it is determined that the audio data is invalid data. Specifically, the audio data is verified, and the verification result of the output audio data is abnormal, which may specifically be: analyzing the real-time volume value contained in the audio data; if the real-time volume value Equal to 0, it is determined that the verification result of the audio data is abnormal, and the audio data is invalid data. The method for determining invalid data may include two specific methods. The first method is to perform sampling analysis on any frame of digital data contained in the audio data, and determine the ratio of the number of data equal to 0 to the total number of digital data in one frame. ; If the ratio is greater than a certain threshold, the audio data is determined to be invalid data. When the application continues to run in the background for a period of time T (for example, 30 minutes), and the application has not released the audio resource within the time T, the monitoring process is started and the audio data is valid, such as the audio data is Invalid data, then close Kill or restart the reset operation of the application to release the audio resource, or reacquire the audio resource.
可选地,在释放音频资源时,还可以获取到应用程序的优先级信息;并根据该优先级信息,判断是否需要将应用程序进行重启或直接关闭,例如,对于高优先级的应用程序(应用程序优先级高于预设等级),则选择重启操作,重新获取该音频资源;而对于低优先级的应用程序(应用程序优先级低于预设等级),则选择关闭操作。其中,可根据所述应用程序的使用频率及权限信息确定所述应用程序的优先级。Optionally, when the audio resource is released, the priority information of the application can also be obtained; and according to the priority information, it is determined whether the application needs to be restarted or directly closed, for example, for a high-priority application ( (Application priority is higher than the preset level), then select restart operation to reacquire the audio resource; and for low priority applications (application priority is lower than the preset level), select close operation. Wherein, the priority of the application program may be determined according to the use frequency and permission information of the application program.
可选地,在释放音频资源时,还可以获取所述电子设备的电量,若所述电子设备的电量低于预设电量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。例如,当前电量为20%,低于阈值25%,若当前应用程序在后台状态下异常占用音频资源超过预设时长,则强制关闭该应用程序以节省电量,该强制关闭流程可以只在电量低于某一阈值下自行启动,可进一步提高系统处理效率。Optionally, when the audio resource is released, the power of the electronic device can also be obtained. If the power of the electronic device is lower than the preset power, the application running time in the background state exceeds a preset threshold, and the The application program outputs an abnormal identifier when occupying the audio resource, and closes the application program to release the audio resource. For example, the current battery is 20% and is below the threshold of 25%. If the current application abnormally occupies audio resources in the background state for more than the preset time, the application is forcibly closed to save power. The forced shutdown process can only be performed when the power is low Starting automatically under a certain threshold can further improve the system processing efficiency.
可选地,除了获取电量,还可以获取所述电子设备在预设时间内的电量变化量,电量变化量表示预设时间/单位时间内该电量的变化大小。同理,若所述电子设备在预设时间内的电量变化量大于或等于预设电量变化量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。例如,当前耗电量严重,则电量变化量高,若高于某一阈值时,则启动音频资源释放流程,强制关闭应用程序并释放掉所述音频资源。Optionally, in addition to acquiring the electricity amount, the amount of change in the electricity amount of the electronic device within a preset time may also be obtained, where the amount of electricity change indicates the magnitude of the amount of change in the electricity amount during the preset time / unit time. Similarly, if the amount of change in power of the electronic device within a preset time is greater than or equal to the amount of change in preset power, the duration of the application running in the background state exceeds a preset threshold, and the application occupies the audio An abnormal identifier is output when the resource is closed, and the application program is closed to release the audio resource. For example, if the current power consumption is serious, the amount of power change is high, and if it is higher than a certain threshold, an audio resource release process is started to forcibly close the application and release the audio resource.
本申请实施例中,当应用程序切换到后台且异常调用音频资源时,及时释放该音频资源,降低了系统的功耗,提高了系统的稳定性,提升了用户体验。In the embodiment of the present application, when the application is switched to the background and the audio resource is abnormally called, the audio resource is released in time, which reduces the power consumption of the system, improves the stability of the system, and improves the user experience.
如图2所示,本申请实施例还提供一种音频资源释放的装置20,该装置20包括:As shown in FIG. 2, an embodiment of the present application further provides an apparatus 20 for releasing audio resources. The apparatus 20 includes:
分配模块21,用于为应用程序分配音频资源,以使所述应用程序调用所述音频资源;The allocation module 21 is configured to allocate audio resources to the application program, so that the application program calls the audio resource;
音频资源在本申请实施例中,可以是播放音频所需要的资源,例如扬声器、声道、音频文件等,也可以是进行录音时所需要的资源,例如麦克风、音频电路、录制数据存储器、音频录制处理器等,本申请实施例对此并无限制。其中,可通过电子设备实现对应用程序的音频资源释放,对音频资源释放可以通过电子设备内置的处理函数进行,以安装了安卓系统的电子设备为例,在安卓系统中定义了不同种类的函数以实现不同方式的音频资源释放,包括音频的输入输出操作,如音乐播放、通话、语音提示、录音等操作,因此,音频资源释放只需要在使用对应的音频调用函数即可实现该操作。Audio resources in the embodiments of the present application may be resources required for playing audio, such as speakers, audio channels, audio files, etc., or resources required for recording, such as microphones, audio circuits, recording data storage, audio The recording processor and the like are not limited in the embodiments of the present application. Among them, the audio resource of the application can be released through the electronic device, and the audio resource can be released through the processing function built in the electronic device. Taking the electronic device with the Android system as an example, different types of functions are defined in the Android system To achieve the release of audio resources in different ways, including audio input and output operations, such as music playback, calls, voice prompts, recording and other operations, therefore, the release of audio resources only needs to use the corresponding audio call function to achieve this operation.
监测模块22,用于对所述应用程序的音频资源释放行为进行监测;The monitoring module 22 is configured to monitor the audio resource release behavior of the application program;
在本申请实施例中,创造性地提出了一种全新的监测机制,即:在系统框架层创建系统级的监测模块22,通过所述监测模块22的监测接口对所述音频资源状态进行监测,或,不通过系统框架层设立该监测模块22,而是创建非系统层级的监测模块22,通过该监测模块22独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。具体地,监测接口可以是监听函数,电子设备可通过内置的监听函数对应用程序的音频资源释放进行监听,以安卓系统的电子设备为例,可在系统框架层(native/framework层)创建系统级的监测模块,通过所述监测模块对所述应用程序的音频模式进行监听,或,独立创建监听进程,通过消息传输机制监听所述应用程序的音频模式。例如,可在框架层设立监测模块并运行在系统服务程序(system_server)中,由于该监测模块设立在系统级的服务框架层中,可方便与其他系统服务 进行交互,同时无需担心系统调用时的权限问题。此外,也可以创建独立的监听进程,在该进程中设立并调用单独的监听函数,可设置为开机自启动,并实时对其他任何一个应用程序的音频资源释放进行监控,具体地,可监听当前应用程序的音频调用时长、音频资源的ID,以及该应用程序状态等信息,一般地,应用程序可分为前台运行和后台运行两种状态,其中前台运行表示当前应用程序为主程序运行在当前电子设备的界面上,后台运行则表示当前应用程序不是运行的主程序,虽然在操作界面上并没有显示该应用程序的运行界面,但应用程序一直在运行。该监测机制可独立开发,不与系统进行耦合,方便后续的开发和升级。In the embodiment of the present application, a brand-new monitoring mechanism is creatively proposed, that is, a system-level monitoring module 22 is created at the system framework layer, and the audio resource status is monitored through the monitoring interface of the monitoring module 22, Or, instead of setting up the monitoring module 22 through the system framework layer, a non-system level monitoring module 22 is created, through which the monitoring process is independently created, and the audio resource status of the application is monitored through a message transmission mechanism. Specifically, the monitoring interface may be a monitoring function, and the electronic device may monitor the release of audio resources of the application through the built-in monitoring function. Taking the electronic device of the Android system as an example, a system may be created at the system framework layer (native / framework layer) The monitoring module of the same level monitors the audio mode of the application through the monitoring module, or independently creates a monitoring process and monitors the audio mode of the application through a message transmission mechanism. For example, you can set up a monitoring module at the framework layer and run it in the system service program (system_server). Because the monitoring module is set up at the system-level service framework layer, you can easily interact with other system services without worrying about system calls. Permissions issue. In addition, you can also create an independent monitoring process, set up and call a separate monitoring function in this process, can be set to start automatically after booting, and monitor the audio resource release of any other application in real time, specifically, you can monitor the current The duration of the audio call of the application, the ID of the audio resource, and the status of the application. In general, the application can be divided into two states: foreground operation and background operation. The foreground operation indicates that the current application is running in the current main program. On the interface of the electronic device, running in the background means that the current application program is not the main program running. Although the operation interface of the application program is not displayed on the operation interface, the application program is always running. The monitoring mechanism can be developed independently without coupling with the system, which is convenient for subsequent development and upgrade.
记录模块23,用于当应用程序切换为后台运行时,对所述应用程序在后台状态下运行时长进行记录;The recording module 23 is used to record the running time of the application in the background when the application is switched to the background;
记录模块23可通过监测模块22提供的监测接口对该应用程序在后台状态下运行时长进行记录。例如,可设置定时器,在占用了音频资源的应用程序从前台切换为后台时,可激活该定时器,并对该应用程序在后台运行状态下运行的时长进行计时或记录。The recording module 23 may record the running time of the application in the background state through the monitoring interface provided by the monitoring module 22. For example, a timer can be set, which can be activated when an application that occupies audio resources is switched from the foreground to the background, and can count or record the duration of the application running in the background running state.
释放模块24,用于若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,释放所述音频资源。The release module 24 is configured to output an abnormal identifier to release the audio resource if the application program runs in a background state for more than a preset threshold and the application program occupies the audio resource.
其中,释放模块24确认应用程序占用所述音频资源时输出异常标识,具体可以是:获取预设时间段内所述应用程序输出的音频数据;Wherein, the release module 24 confirms that the application program outputs the abnormal identifier when occupying the audio resource, which may specifically be: acquiring audio data output by the application program within a preset time period;
对所述音频数据进行校验,若所述输出的音频数据的校验结果为异常,则确定所述应用程序异常占用所述音频资源,所述异常标识为所述输出为异常的校验结果。此外,若该音频数据校验结果为异常,则确定该音频数据为无效数据。具体地,所述音频数据进行校验,且所述输出的音频数据的校验结果为异常,具体可以为:对所述音频数据中包含的实时音量值进行分析;若所述实时音量值等于0,确定所述音频数据的校验结果为异常,该音频数据为无效数据。判断无效数据的方法具体可以包括两种,第一种为:对所述音频数据中包含的任意一帧数字数据进行抽样分析,确定等于0的数据的数 量与一帧数字数据的总数量的比例;若所述比例大于某一阈值,确定所述音频数据为无效数据。当应用程序连续在后台运行一段时间T(例如30分钟),且该时间T内应用程序一直没有释放掉该音频资源时才会启动该监听流程,并判断该音频数据是否有效,如音频数据为无效数据,则将该应用程序进行关闭Kill或重启reset操作,以释放掉该音频资源。Verify the audio data, and if the verification result of the output audio data is abnormal, determine that the application program abnormally occupies the audio resource, and the abnormality identifier is a verification result that the output is abnormal . In addition, if the audio data verification result is abnormal, it is determined that the audio data is invalid data. Specifically, the audio data is verified, and the verification result of the output audio data is abnormal, which may specifically be: analyzing the real-time volume value contained in the audio data; if the real-time volume value is equal to 0. It is determined that the verification result of the audio data is abnormal, and the audio data is invalid data. The method for determining invalid data may include two specific methods. The first method is to perform sampling analysis on any frame of digital data contained in the audio data, and determine the ratio of the number of data equal to 0 to the total number of digital data in one frame. ; If the ratio is greater than a certain threshold, the audio data is determined to be invalid data. When the application continues to run in the background for a period of time T (for example, 30 minutes), and the application has not released the audio resource within the time T, the monitoring process is started and the audio data is valid, such as the audio data is If the data is invalid, the application will close Kill or restart the reset operation to release the audio resource.
可选地,在释放音频资源时,释放模块24还可以获取到应用程序的优先级信息;并根据该优先级信息,判断是否需要将应用程序进行重启或直接关闭,例如,对于高优先级的应用程序(应用程序优先级高于预设等级),则选择重启操作,而对于低优先级的应用程序(应用程序优先级低于预设阈值),则选择关闭操作。其中,可根据所述应用程序的使用频率及权限信息确定所述应用程序的优先级。Optionally, when releasing audio resources, the release module 24 can also obtain priority information of the application; and based on the priority information, determine whether the application needs to be restarted or directly closed, for example, for high priority For applications (application priority is higher than the preset level), restart operation is selected, and for applications with low priority (application priority is lower than the preset threshold), close operation is selected. Wherein, the priority of the application program may be determined according to the use frequency and permission information of the application program.
可选地,在释放音频资源时,释放模块24还可以获取所述电子设备的电量,若所述电子设备的电量低于预设电量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。例如,当前电量为20%,低于阈值25%,若当前应用程序在后台状态下异常占用音频资源超过预设时长,则强制关闭该应用程序以节省电量,该强制关闭流程可以只在电量低于某一阈值下自行启动,可进一步提高系统处理效率。Optionally, when the audio resource is released, the release module 24 may also obtain the power of the electronic device, if the power of the electronic device is lower than the preset power, and the duration of the application running in the background state exceeds a preset threshold , And the application program outputs an abnormal identifier when occupying the audio resource, and closes the application program to release the audio resource. For example, the current battery is 20% and is below the threshold of 25%. If the current application abnormally occupies audio resources in the background state for more than the preset time, the application is forcibly closed to save power. The forced shutdown process can only be performed when the power is low Starting automatically under a certain threshold can further improve the system processing efficiency.
可选地,除了获取电量,释放模块24还可以获取所述电子设备在预设时间内的电量变化量,电量变化量表示单位时间内该电量的变化大小。同理,若所述电子设备在预设时间内的电量变化量大于或等于预设电量变化量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。例如,当前耗电量严重,则电量变化量高,若高于某一阈值时,则启动音频资源释放流程,强制关闭应用程序并释放掉所述音频资源。Optionally, in addition to acquiring power, the release module 24 may also obtain the amount of change in power of the electronic device within a preset time, and the amount of change in power represents the amount of change in power per unit time. Similarly, if the amount of change in power of the electronic device within a preset time is greater than or equal to the amount of change in preset power, the duration of the application running in the background state exceeds a preset threshold, and the application occupies the audio An abnormal identifier is output when the resource is closed, and the application program is closed to release the audio resource. For example, if the current power consumption is serious, the amount of power change is high, and if it is higher than a certain threshold, an audio resource release process is started to forcibly close the application and release the audio resource.
本申请实施例中,当应用程序切换到后台且异常调用音频资源时,释放模块可及时释放该音频资源,降低了系统的功耗,提高了系统的稳定性,提 升了用户体验。In the embodiment of the present application, when the application is switched to the background and the audio resource is abnormally called, the release module can release the audio resource in time, which reduces the power consumption of the system, improves the stability of the system, and improves the user experience.
图3为一实施例中电子设备的内部结构示意图。如图3所示,该电子设备包括通过系统总线连接的处理器、非易失性存储介质、内存储器和网络接口、声音采集装置、扬声器、显示屏和输入装置。其中,终端的非易失性存储介质存储有操作系统和计算机可读指令。该计算机可读指令被处理器执行时以实现一种电子设备的音频资源释放方法。该处理器用于提供计算和控制能力,支撑整个电子设备的运行。电子设备中的内存储器为非易失性存储介质中的计算机可读指令的运行提供环境。电子设备的显示屏可以是液晶显示屏或者电子墨水显示屏等,输入装置可以是显示屏上覆盖的触摸层,也可以是电子设备外壳上设置的按键、轨迹球或触控板,也可以是外接的键盘、触控板或鼠标等。该电子设备可以是手机、平板电脑或者个人数字助理或穿戴式设备等。本领域技术人员可以理解,图3中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。3 is a schematic diagram of an internal structure of an electronic device in an embodiment. As shown in FIG. 3, the electronic device includes a processor connected through a system bus, a non-volatile storage medium, an internal memory and a network interface, a sound collection device, a speaker, a display screen, and an input device. Among them, the non-volatile storage medium of the terminal stores an operating system and computer-readable instructions. When the computer-readable instructions are executed by the processor, a method for releasing audio resources of an electronic device is realized. The processor is used to provide computing and control capabilities to support the operation of the entire electronic device. The internal memory in the electronic device provides an environment for the execution of computer-readable instructions in the non-volatile storage medium. The display screen of the electronic device may be a liquid crystal display screen or an electronic ink display screen, etc. The input device may be a touch layer covered on the display screen, a button, a trackball or a touch pad provided on the housing of the electronic device, or External keyboard, touchpad or mouse, etc. The electronic device may be a mobile phone, a tablet computer, a personal digital assistant or a wearable device. Those skilled in the art can understand that the structure shown in FIG. 3 is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the electronic device to which the solution of the present application is applied. The specific electronic device may It includes more or fewer components than shown in the figure, or some components are combined, or have a different component arrangement.
其中,上述提及的音频资源释放方法具体可以为:Among them, the above-mentioned audio resource release method may specifically be:
为应用程序分配音频资源,以使所述应用程序调用所述音频资源;Assign audio resources to the application program, so that the application program calls the audio resource;
对所述应用程序的音频资源释放行为进行监测;Monitoring the audio resource release behavior of the application program;
当应用程序切换为后台运行时,对所述应用程序在后台状态下运行时长进行记录;When the application is switched to run in the background, record the running time of the application in the background state;
若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,释放所述音频资源。If the running time of the application program in the background state exceeds a preset threshold, and the application program outputs an abnormal identifier when the audio resource is occupied, the audio resource is released.
在其中的一个实施例中,所述对所述应用程序的音频资源释放行为进行监测,具体为:在系统框架层创建系统级的监测接口,通过所述监测接口所述应用程序的音频资源释放行为进行监测,或,独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源释放行为。In one of the embodiments, the monitoring of the audio resource release behavior of the application program specifically includes: creating a system-level monitoring interface at the system framework layer, and releasing the audio resource of the application program through the monitoring interface Behavior monitoring, or, independently create a monitoring process, and monitor the audio resource release behavior of the application through a message transmission mechanism.
在其中的一个实施例中,所述处理器还用于执行:In one of the embodiments, the processor is also used to execute:
获取所述应用程序的优先级;Obtain the priority of the application;
若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,若所述应用程序的优先级高于预设等级,重启所述应用程序以释放所述音频资源,或若所述应用程序的优先级低于预设阈值,关闭所述应用程序以释放所述音频资源。If the duration of the application running in the background state exceeds a preset threshold, and the application outputs an abnormal identifier when the audio resource is occupied, if the priority of the application is higher than the preset level, restart the application To release the audio resource, or if the priority of the application is lower than a preset threshold, close the application to release the audio resource.
在其中的一个实施例中,所述处理器还用于执行:In one of the embodiments, the processor is also used to execute:
根据所述应用程序的使用频率及权限信息确定所述应用程序的优先级。The priority of the application is determined according to the frequency of use of the application and permission information.
在其中的一个实施例中,所述处理器还用于执行:In one of the embodiments, the processor is also used to execute:
获取所述电子设备的电量;Obtaining the power of the electronic device;
若所述电子设备的电量低于预设电量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。If the power of the electronic device is lower than the preset power, the duration of the application running in the background exceeds the preset threshold, and the application outputs an abnormal identifier when the audio resource is occupied, close the application to release The audio resource.
在其中的一个实施例中,所述处理器还用于执行:In one of the embodiments, the processor is also used to execute:
获取所述电子设备在预设时间内的电量变化量;Obtain the amount of change in power of the electronic device within a preset time;
若所述电子设备在预设时间内的电量变化量大于或等于预设电量变化量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。If the amount of change in power of the electronic device within a preset time is greater than or equal to the amount of change in preset power, the duration of the application running in the background state exceeds a preset threshold, and the output is output when the application occupies the audio resource Abnormal identification, close the application to release the audio resource.
在其中的一个实施例中,所述应用程序运行中异常占用所述音频资源,包括:In one of the embodiments, the audio resource is abnormally occupied while the application is running, including:
获取预设时间段内所述应用程序输出的音频数据;Obtain audio data output by the application within a preset time period;
对所述音频数据进行校验,若所述输出的音频数据的校验结果为异常,,则确定所述应用程序异常占用所述音频资源,所述异常标识为所述输出为异常的校验结果。Verify the audio data, and if the verification result of the output audio data is abnormal, determine that the application program abnormally occupies the audio resource, and the abnormality identifier is a verification that the output is abnormal result.
在其中的一个实施例中,所述对所述音频数据进行校验,若输出的音频数据的校验结果为异常,包括:In one of the embodiments, the verification of the audio data, if the verification result of the output audio data is abnormal, includes:
对所述音频数据中包含的实时音量值进行分析;Analyze the real-time volume value contained in the audio data;
若所述实时音量值等于0,确定所述输出的音频数据的校验结果为异常。If the real-time volume value is equal to 0, it is determined that the verification result of the output audio data is abnormal.
此外,本申请实施例还提供了一种计算机非易失性可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述音频资源释放的步骤。In addition, the embodiments of the present application also provide a computer non-volatile readable storage medium on which a computer program is stored, and when the computer program is executed by the processor, the steps of releasing the audio resource as described above are realized.
本发明实施例还提供了一种计算机设备。如图4所示,为了便于说明,仅示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照本发明实施例方法部分。该计算机设备可以为包括电子设备、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式设备等任意终端设备,以计算机设备为电子设备为例:An embodiment of the present invention also provides a computer device. As shown in FIG. 4, for ease of description, only parts related to the embodiments of the present invention are shown, and specific technical details are not disclosed, please refer to the method part of the embodiments of the present invention. The computer device may be any terminal device including an electronic device, a tablet computer, a PDA (Personal Digital Assistant), a POS (Point of Sales), an in-vehicle computer, a wearable device, etc. The computer device is an electronic device For example:
图4为与本发明实施例提供的计算机设备相关的电子设备的部分结构的框图。参考图4,电子设备包括:射频(Radio Frequency,RF)电路410、存储器420、输入单元430、显示单元440、传感器450、音频电路460、无线保真(wireless fidelity,WiFi)模块470、处理器480、以及电源490等部件。本领域技术人员可以理解,图4所示的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。4 is a block diagram of a partial structure of an electronic device related to a computer device provided by an embodiment of the present invention. 4, the electronic device includes: a radio frequency (Radio Frequency) circuit 410, a memory 420, an input unit 430, a display unit 440, a sensor 450, an audio circuit 460, a wireless fidelity (WiFi) module 470, a processor 480, and power supply 490 and other components. Those skilled in the art may understand that the structure of the electronic device shown in FIG. 4 does not constitute a limitation on the electronic device, and may include more or fewer components than shown, or combine some components, or arrange different components.
其中,RF电路410可用于收发信息或通话过程中,信号的接收和发送,可将基站的下行信息接收后,给处理器480处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路410还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(Global System of Mobile communication,GSM)、通用分组无线服务(General Packet Radio Service,GPRS)、码分多址(Code Division Multiple Access,CDMA)、宽带码分多址(Wideband Code Division Multiple Access,WCDMA)、长期演进(Long Term Evolution,LTE))、电子邮件、短消息服务(Short Messaging Service,SMS)等。Among them, the RF circuit 410 can be used to receive and send signals during the sending and receiving of information or during a call. It can receive the downlink information of the base station and process it to the processor 480; it can also send the uplink data to the base station. Generally, RF circuits include but are not limited to antennas, at least one amplifier, transceiver, coupler, low noise amplifier (Low Noise Amplifier, LNA), duplexer, and so on. In addition, the RF circuit 410 can also communicate with other devices through a wireless communication network. The above wireless communication can use any communication standard or protocol, including but not limited to Global System of Mobile (GSM), General Packet Radio Service (GPRS), and Code Division Multiple Access (Code Division) Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), e-mail, Short Message Service (SMS), etc.
存储器420可用于存储软件程序以及模块,处理器480通过运行存储在存储器420的软件程序以及模块,从而执行电子设备的各种功能应用以及数据处理。存储器420可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据电子设备的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器420可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。The memory 420 may be used to store software programs and modules. The processor 480 executes various functional applications and data processing of the electronic device by running the software programs and modules stored in the memory 420. The memory 420 may mainly include a program storage area and a data storage area, where the program storage area may store an operating system and at least one function-required application program (such as a sound playback function application program, an image playback function application program, etc.), etc .; The data storage area can store data (such as audio data, address book, etc.) created according to the use of electronic devices. In addition, the memory 420 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
输入单元430可用于接收输入的数字或字符信息,以及产生与电子设备400的用户设置以及功能控制有关的键信号输入。具体地,输入单元430可包括触控面板431以及其他输入设备432。触控面板431,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板431上或在触控面板431附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板431可包括触摸监测装置和触摸控制器两个部分。其中,触摸监测装置监测用户的触摸方位,并监测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸监测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器480,并能接收处理器480发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板431。除了触控面板431,输入单元430还可以包括其他输入设备432。具体地,其他输入设备432可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。The input unit 430 may be used to receive input digital or character information, and generate key signal input related to user settings and function control of the electronic device 400. Specifically, the input unit 430 may include a touch panel 431 and other input devices 432. The touch panel 431, also known as a touch screen, can collect user's touch operations on or near it (for example, the user uses any suitable objects or accessories such as fingers or stylus on or near the touch panel 431 Operation), and drive the corresponding connection device according to the preset program. In one embodiment, the touch panel 431 may include a touch monitoring device and a touch controller. Among them, the touch monitoring device monitors the user's touch orientation, and monitors the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch monitoring device, and converts it into contact coordinates, and then sends To the processor 480, and can receive the command sent by the processor 480 and execute it. In addition, the touch panel 431 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves. In addition to the touch panel 431, the input unit 430 may also include other input devices 432. Specifically, the other input devices 432 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, switch keys, etc.).
显示单元440可用于显示由用户输入的信息或提供给用户的信息以及电子设备的各种菜单。显示单元440可包括显示面板441。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板441。在一个实施例中,触控面板431可覆盖显示面板441,当触控面板431监测 到在其上或附近的触摸操作后,传送给处理器480以确定触摸事件的类型,随后处理器480根据触摸事件的类型在显示面板441上提供相应的视觉输出。虽然在图4中,触控面板431与显示面板441是作为两个独立的部件来实现电子设备的输入和输入功能,但是在某些实施例中,可以将触控面板431与显示面板441集成而实现电子设备的输入和输出功能。The display unit 440 may be used to display information input by the user or information provided to the user and various menus of the electronic device. The display unit 440 may include a display panel 441. In one embodiment, the display panel 441 may be configured in the form of a liquid crystal display (Liquid Crystal) (LCD), an organic light-emitting diode (Organic Light-Emitting Diode, OLED), or the like. In one embodiment, the touch panel 431 may cover the display panel 441, and after the touch panel 431 detects a touch operation on or near it, it is transmitted to the processor 480 to determine the type of touch event, and then the processor 480 according to The type of touch event provides corresponding visual output on the display panel 441. Although in FIG. 4, the touch panel 431 and the display panel 441 are implemented as two independent components to realize the input and input functions of the electronic device, in some embodiments, the touch panel 431 and the display panel 441 may be integrated And realize the input and output functions of electronic equipment.
电子设备400还可包括至少一种传感器450,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板441的亮度,接近传感器可在电子设备移动到耳边时,关闭显示面板441和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可监测各个方向上加速度的大小,静止时可监测出重力的大小及方向,可用于识别电子设备姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,电子设备还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。The electronic device 400 may further include at least one sensor 450, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor, wherein the ambient light sensor may adjust the brightness of the display panel 441 according to the brightness of the ambient light, and the proximity sensor may close the display panel 441 and the electronic device when moving to the ear / Or backlight. The motion sensor may include an acceleration sensor. The acceleration sensor can monitor the magnitude of acceleration in various directions, and can monitor the magnitude and direction of gravity when at rest. It can be used for applications that recognize the posture of electronic devices (such as horizontal and vertical screen switching), and vibration recognition related functions ( For example, pedometer, percussion, etc .; in addition, electronic devices can also be equipped with other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc.
音频电路460、扬声器461和传声器462可提供用户与电子设备之间的音频接口。音频电路460可将接收到的音频数据转换后的电信号,传输到扬声器461,由扬声器461转换为声音信号输出;另一方面,传声器462将收集的声音信号转换为电信号,由音频电路460接收后转换为音频数据,再将音频数据输出处理器680处理后,经RF电路610可以发送给另一电子设备,或者将音频数据输出至存储器620以便后续处理。The audio circuit 460, the speaker 461, and the microphone 462 may provide an audio interface between the user and the electronic device. The audio circuit 460 can transmit the converted electrical signal of the received audio data to the speaker 461, which converts the speaker 461 into a sound signal for output; on the other hand, the microphone 462 converts the collected sound signal into an electrical signal, which is converted by the audio circuit 460 After receiving, it is converted into audio data, and then processed by the audio data output processor 680, and then sent to another electronic device via the RF circuit 610, or the audio data is output to the memory 620 for subsequent processing.
WiFi属于短距离无线传输技术,电子设备通过WiFi模块470可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图4示出了WiFi模块470,但是可以理解的是,其并不属于电子设备400的必须构成,可以根据需要而省略。WiFi is a short-range wireless transmission technology. Electronic devices can help users send and receive emails, browse web pages, and access streaming media through the WiFi module 470. It provides users with wireless broadband Internet access. Although FIG. 4 shows the WiFi module 470, it can be understood that it is not a necessary component of the electronic device 400, and may be omitted as needed.
处理器480是电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器420内的软件程序和/或模块,以及调用存储在存储器420内的数据,执行电子设备的各种功能 和处理数据,从而对电子设备进行整体监控。在一个实施例中,处理器480可包括一个或多个处理单元。在一个实施例中,处理器480可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器480中。The processor 480 is the control center of the electronic device, and uses various interfaces and lines to connect the various parts of the entire electronic device, by running or executing the software programs and / or modules stored in the memory 420, and calling the data stored in the memory 420 , Perform various functions of electronic devices and process data, so as to monitor the electronic devices as a whole. In one embodiment, the processor 480 may include one or more processing units. In one embodiment, the processor 480 may integrate an application processor and a modem processor, where the application processor mainly processes an operating system, user interface, application programs, and the like; the modem processor mainly processes wireless communication. It can be understood that the foregoing modem processor may not be integrated into the processor 480.
电子设备400还包括给各个部件供电的电源490(比如电池),优选的,电源可以通过电源管理系统与处理器480逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。The electronic device 400 further includes a power supply 490 (such as a battery) that supplies power to various components. Preferably, the power supply can be logically connected to the processor 480 through the power management system, so as to implement functions such as charging, discharging, and power management through the power management system .
在一个实施例中,电子设备400还可以包括摄像头、蓝牙模块等。In one embodiment, the electronic device 400 may further include a camera, a Bluetooth module, and the like.
在本发明实施例中,该计算机设备所包括的处理器480执行存储在存储器上的计算机程序时实现上述各实施例的方法,例如,包括图1所示的音频资源释放的方法。In the embodiment of the present invention, the processor 480 included in the computer device implements the method of the foregoing embodiments when executing the computer program stored on the memory, for example, including the method of releasing audio resources shown in FIG. 1.
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等。本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时上述各实施例的方法。Those of ordinary skill in the art may understand that all or part of the processes in the method of the above embodiments may be completed by instructing relevant hardware through a computer program, and the program may be stored in a non-volatile computer-readable storage medium In this case, when the program is executed, it may include the flow of the above method embodiments. Wherein, the storage medium may be a magnetic disk, an optical disk, a read-only memory (Read-Only Memory, ROM), etc. An embodiment of the present invention also provides a computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the methods of the foregoing embodiments.
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合不存在矛盾,都应当认为是本说明书记载的范围。The technical features of the above-mentioned embodiments can be combined arbitrarily. To simplify the description, all possible combinations of the technical features in the above-mentioned embodiments are not described. However, as long as there is no contradiction in the combination of these technical features, All should be considered within the scope of this description.
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。The above-mentioned embodiments only express several embodiments of the present invention, and their descriptions are more specific and detailed, but they should not be construed as limiting the scope of the invention patent. It should be noted that, for a person of ordinary skill in the art, without departing from the concept of the present invention, several modifications and improvements can also be made, which all fall within the protection scope of the present invention. Therefore, the protection scope of the invention patent shall be subject to the appended claims.

Claims (11)

  1. 一种音频资源释放的方法,应用于电子设备,其特征在于,包括:A method for releasing audio resources, which is applied to electronic equipment, is characterized by comprising:
    为应用程序分配音频资源,以使所述应用程序调用所述音频资源;Assign audio resources to the application program, so that the application program calls the audio resource;
    对所述应用程序的音频资源释放行为进行监测;Monitoring the audio resource release behavior of the application program;
    当应用程序切换为后台运行时,对所述应用程序在后台状态下运行时长进行记录;When the application is switched to run in the background, record the running time of the application in the background state;
    若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,释放所述音频资源。If the running time of the application program in the background state exceeds a preset threshold, and the application program outputs an abnormal identifier when the audio resource is occupied, the audio resource is released.
  2. 根据权利要求1所述的方法,其特征在于,所述对所述应用程序的音频资源释放行为进行监测,包括:The method according to claim 1, wherein the monitoring of the audio resource release behavior of the application program comprises:
    在系统框架层创建系统级的监测接口,通过所述监测接口对所述应用程序的音频资源释放行为进行监测,或,Create a system-level monitoring interface at the system framework layer, and monitor the audio resource release behavior of the application through the monitoring interface, or,
    独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源释放行为。The monitoring process is independently created, and the audio resource release behavior of the application program is monitored through a message transmission mechanism.
  3. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    获取所述应用程序的优先级;Obtain the priority of the application;
    若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,若所述应用程序的优先级高于预设等级,重启所述应用程序以重新获取所述音频资源,或若所述应用程序的优先级低于预设阈值,关闭所述应用程序以释放所述音频资源。If the duration of the application running in the background state exceeds a preset threshold, and the application outputs an abnormal identifier when the audio resource is occupied, if the priority of the application is higher than the preset level, restart the application To reacquire the audio resource, or if the priority of the application is lower than a preset threshold, close the application to release the audio resource.
  4. 根据权利要求3所述的方法,其特征在于,所述方法还包括:The method according to claim 3, wherein the method further comprises:
    根据所述应用程序的使用频率及权限信息确定所述应用程序的优先级。The priority of the application is determined according to the frequency of use of the application and permission information.
  5. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    获取所述电子设备的电量;Obtaining the power of the electronic device;
    若所述电子设备的电量低于预设电量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。If the power of the electronic device is lower than the preset power, the duration of the application running in the background exceeds the preset threshold, and the application outputs an abnormal identifier when the audio resource is occupied, close the application to release The audio resource.
  6. 根据权利要求1所述的方法,其特征在于,所述方法还包括:The method according to claim 1, wherein the method further comprises:
    获取所述电子设备在预设时间内的电量变化量;Obtain the amount of change in power of the electronic device within a preset time;
    若所述电量变化量大于或等于预设电量变化量、所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,关闭所述应用程序以释放所述音频资源。If the amount of change in power is greater than or equal to the amount of change in preset power, the duration of the application running in the background exceeds the preset threshold, and the application outputs an abnormal identifier when the audio resource is occupied, close the application To release the audio resource.
  7. 根据权利要求1所述的方法,其特征在于,所述应用程序占用所述音频资源时输出异常标识,包括:The method according to claim 1, wherein the output of the abnormal identifier when the application program occupies the audio resource includes:
    获取预设时间段内所述应用程序输出的音频数据;Obtain audio data output by the application within a preset time period;
    对所述音频数据进行校验,若所述输出的音频数据的校验结果为异常,,则确定所述应用程序异常占用所述音频资源,所述异常标识为所述输出为异常的校验结果。Verify the audio data, and if the verification result of the output audio data is abnormal, determine that the application program abnormally occupies the audio resource, and the abnormality identifier is a verification that the output is abnormal result.
  8. 根据权利要求7所述的方法,其特征在于,所述对所述音频数据进行校验,若输出的音频数据的校验结果为异常,包括:The method according to claim 7, wherein the verification of the audio data, if the verification result of the output audio data is abnormal, includes:
    对所述音频数据中包含的实时音量值进行分析;Analyze the real-time volume value contained in the audio data;
    若所述实时音量值等于0,确定所述输出的音频数据的校验结果为异常。If the real-time volume value is equal to 0, it is determined that the verification result of the output audio data is abnormal.
  9. 一种音频资源释放的装置,其特征在于,包括:A device for releasing audio resources is characterized in that it includes:
    分配模块,用于为应用程序分配音频资源,以使所述应用程序调用所述音频资源;An allocation module, configured to allocate audio resources to the application program, so that the application program calls the audio resource;
    监测模块,用于对所述应用程序的音频资源释放行为进行监测;A monitoring module, configured to monitor the audio resource release behavior of the application program;
    记录模块,用于当应用程序切换为后台运行时,对所述应用程序在后台状态下运行时长进行记录;The recording module is used to record the running time of the application program in the background state when the application program is switched to the background operation;
    释放模块,用于若所述应用程序在后台状态下运行时长超过预设阈值,且所述应用程序占用所述音频资源时输出异常标识,释放所述音频资源。A release module, configured to output an abnormal identifier to release the audio resource if the application program runs in a background state for a duration exceeding a preset threshold and the application program occupies the audio resource.
  10. 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求1-8中任一项所述的音频资源释放的步骤。An electronic device includes a memory and a processor, and a computer program is stored in the memory, wherein when the computer program is executed by the processor, the processor is caused to execute any of claims 1-8 A step of releasing audio resources.
  11. 一种计算机非易失性可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1-8中任一项所述的音频资源释放的步骤。A computer non-volatile readable storage medium on which a computer program is stored, characterized in that when the computer program is executed by a processor, the audio resource according to any one of claims 1-8 is released step.
PCT/CN2018/115190 2018-11-13 2018-11-13 Method, apparatus, and electronic device for audio resource release WO2020097787A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
PCT/CN2018/115190 WO2020097787A1 (en) 2018-11-13 2018-11-13 Method, apparatus, and electronic device for audio resource release
CN201880098219.6A CN112997131A (en) 2018-11-13 2018-11-13 Audio resource release method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/115190 WO2020097787A1 (en) 2018-11-13 2018-11-13 Method, apparatus, and electronic device for audio resource release

Publications (1)

Publication Number Publication Date
WO2020097787A1 true WO2020097787A1 (en) 2020-05-22

Family

ID=70730209

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/115190 WO2020097787A1 (en) 2018-11-13 2018-11-13 Method, apparatus, and electronic device for audio resource release

Country Status (2)

Country Link
CN (1) CN112997131A (en)
WO (1) WO2020097787A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434222B (en) * 2021-06-30 2023-06-09 青岛海尔科技有限公司 Control method and device of application program, storage medium and electronic device

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050048960A1 (en) * 2003-09-03 2005-03-03 Sharp Kabushiki Kaisha Information processing device, control device, communication device, communication equipment, electronic device, information processing system, power management method, power management program, and recording medium
CN105791933A (en) * 2016-03-25 2016-07-20 青岛海信电器股份有限公司 Method of switching audio and video applications, device and intelligent television
CN105955693A (en) * 2016-04-21 2016-09-21 北京元心科技有限公司 Method and device for distributing audio-video resource in multisystem
CN106648032A (en) * 2016-12-30 2017-05-10 维沃移动通信有限公司 Control method for application program operating in background and mobile terminal

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103324500B (en) * 2013-05-06 2016-08-31 广州市动景计算机科技有限公司 A kind of method and device reclaiming internal memory
CN105117295A (en) * 2015-09-18 2015-12-02 北京金山安全软件有限公司 Memory resource release method and device and electronic equipment

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050048960A1 (en) * 2003-09-03 2005-03-03 Sharp Kabushiki Kaisha Information processing device, control device, communication device, communication equipment, electronic device, information processing system, power management method, power management program, and recording medium
CN105791933A (en) * 2016-03-25 2016-07-20 青岛海信电器股份有限公司 Method of switching audio and video applications, device and intelligent television
CN105955693A (en) * 2016-04-21 2016-09-21 北京元心科技有限公司 Method and device for distributing audio-video resource in multisystem
CN106648032A (en) * 2016-12-30 2017-05-10 维沃移动通信有限公司 Control method for application program operating in background and mobile terminal

Also Published As

Publication number Publication date
CN112997131A (en) 2021-06-18

Similar Documents

Publication Publication Date Title
WO2017206916A1 (en) Method for determining kernel running configuration in processor and related product
US10069818B2 (en) Method, system, device, and terminal for network initialization of multimedia playback device
WO2016150331A1 (en) Method and device for operating game client
WO2020103070A1 (en) Method and apparatus for processing application program, and electronic device
CN103488939A (en) Method, device and terminal for prompting user
CN106371964B (en) Method and device for prompting message
CN107465841B (en) Fault information reporting method and terminal
WO2018049934A1 (en) Data migration method and terminals
CN104427083A (en) Volume adjusting method and device
WO2018049894A1 (en) Data transmission method and device
WO2020118495A1 (en) Audio resource allocation method, device, and electronic apparatus
CN108322602B (en) Method, terminal and computer readable storage medium for processing application no response
CN105162930B (en) The way of recording and device of mobile terminal
CN109669662A (en) A kind of pronunciation inputting method, device, storage medium and mobile terminal
WO2020103045A1 (en) Application processing method and apparatus and electronic device
CN112805988B (en) Call control method and device, computer readable storage medium and electronic equipment
CN105100361B (en) The way of recording and device of mobile terminal
CN107770449B (en) Continuous shooting method, electronic device and storage medium
WO2015078349A1 (en) Microphone sound-reception status switching method and apparatus
CN113039517B (en) Audio resource calling method and device and electronic equipment
CN110989816B (en) Application processing method and device and storage medium
WO2017215663A1 (en) Sound effect processing method and terminal
WO2020097787A1 (en) Method, apparatus, and electronic device for audio resource release
CN110891262A (en) Bluetooth pairing method, system and terminal equipment
CN109891942A (en) The method and terminal device of terminal device recovery data service

Legal Events

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

Ref document number: 18940141

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18940141

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 30.09.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 18940141

Country of ref document: EP

Kind code of ref document: A1