WO2020107177A1 - 一种音频资源调用的方法、装置及电子设备 - Google Patents

一种音频资源调用的方法、装置及电子设备 Download PDF

Info

Publication number
WO2020107177A1
WO2020107177A1 PCT/CN2018/117523 CN2018117523W WO2020107177A1 WO 2020107177 A1 WO2020107177 A1 WO 2020107177A1 CN 2018117523 W CN2018117523 W CN 2018117523W WO 2020107177 A1 WO2020107177 A1 WO 2020107177A1
Authority
WO
WIPO (PCT)
Prior art keywords
audio
audio resource
resource
application
occupant
Prior art date
Application number
PCT/CN2018/117523
Other languages
English (en)
French (fr)
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 CN201880098446.9A priority Critical patent/CN113039517B/zh
Priority to PCT/CN2018/117523 priority patent/WO2020107177A1/zh
Publication of WO2020107177A1 publication Critical patent/WO2020107177A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/16Sound input; Sound output

Definitions

  • the invention relates to the field of information technology, in particular to a method, device and electronic device for calling 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 calling audio resources, including:
  • Monitor the state of the audio resource if the state of the audio resource is occupied, query the information of the occupant corresponding to the audio resource;
  • the audio resource is released, so that the application program calls the released audio resource.
  • An embodiment of the present application also provides a method for calling audio resources, including:
  • the audio resource is released, so that the application program calls the released audio resource.
  • An embodiment of the present application further provides an apparatus for calling audio resources.
  • the apparatus includes:
  • the receiving module is used to receive the audio resource call request of the application program
  • a monitoring module configured to monitor the state of the audio resource, and if the state of the audio resource is occupied, query the occupant information corresponding to the audio resource;
  • a release module configured to release the audio resource if the occupant information is empty, so that the application program can call the audio resource.
  • An embodiment of the present application further provides an apparatus for calling audio resources.
  • the apparatus includes:
  • the allocation module is used to allocate corresponding audio resources to the application
  • a monitoring module configured to monitor the state of the audio resource when the application calls the audio resource
  • the release module is configured to release the audio resource when the state of the audio resource is abnormal, so that the application program calls the released audio resource.
  • An embodiment of the present application further provides an electronic device, including a memory and a processor.
  • the memory stores a computer program, and when the computer program is executed by the processor, the processor is executed:
  • Monitor the state of the audio resource if the state of the audio resource is occupied, query the information of the occupant corresponding to the audio resource;
  • the audio resource is released, so that the application program calls the released audio resource.
  • An embodiment of the present application further provides an electronic device, including a memory and a processor.
  • the memory stores a computer program, and when the computer program is executed by the processor, the processor is executed:
  • the audio resource is released, so that the application program calls the released audio resource.
  • An embodiment of the present application further provides 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 steps of calling the audio resource as described above are realized.
  • the audio resource occupant is monitored, and if the occupant information is empty, the audio resource is immediately released, and further calls are made for application programs that need to call the audio resource. Improve the stability of the system and enhance the user experience.
  • FIG. 1 is a flowchart of an audio resource calling method according to an embodiment
  • FIG. 2 is a flowchart of an audio resource calling method according to another embodiment
  • FIG. 3 is a schematic structural diagram of an audio resource invoking device according to an embodiment
  • FIG. 4 is a schematic structural diagram of an audio resource invoking device according to another embodiment
  • FIG. 5 is a schematic diagram of the internal structure of an electronic device in an embodiment
  • FIG. 6 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 invoking an audio resource.
  • 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 called through the electronic device, and the audio resource can be called 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
  • audio input and output operations such as music playback, calls, voice prompts, recording and other operations, therefore, audio resource calls only need to use the corresponding audio call function to achieve this operation.
  • one or more application programs need to send an invocation request before using the audio resource.
  • the electronic device will perform permission confirmation after receiving the invocation request of the application program. Permission This allows the call, otherwise the call fails.
  • the audio resource when it is confirmed that the audio resource can be called, if the audio resource is not occupied, the audio resource is directly called, and if the audio resource is already occupied, it automatically waits until the previous application (that is, the audio resource The occupant) has already released the audio resource. Therefore, the prior art lacks a monitoring mechanism for the audio resource used by the previous application, resulting in that the audio resource cannot be discovered and released in time when the previous application abnormally occupies the music resource.
  • a brand-new monitoring mechanism is creatively proposed, that is, a system-level monitoring module is created at the system framework layer, and the state of the audio resource is monitored by the monitoring module, or a monitoring is independently created.
  • the process monitors the audio resource status of the application through a message transmission mechanism.
  • the electronic device can monitor the audio resource call of the application through the built-in monitoring function.
  • a system-level monitoring module can be created at the system framework layer (native/framework layer). The monitoring module monitors the audio mode of the application program, or independently creates a monitoring process and monitors the audio mode of the application program through a message transmission mechanism.
  • system_server system service program
  • you can also create an independent monitoring process set up and call a separate monitoring function in the process, can be set to start automatically after booting, and monitor the audio resource calls of any other application in real time. Specifically, it can be captured in real time. Get the ID information, status information and/or priority information of the application corresponding to the currently called audio resource to determine the application and its status corresponding to the current calling behavior. It can be independently developed and not coupled with the system, which is convenient for subsequent Development and upgrade. Further, it can also be monitored whether the status of the application program that currently calls the audio resource is normal. If the status is abnormal or the ID information is empty, it is determined that the application program abnormally occupies the audio resource, and the abnormally occupied audio resource needs to be processed.
  • the occupant is one or more applications currently occupying audio resources, and the occupant information is the status information or ID information of the current occupant. If the occupant information is empty, it means that the current occupant status is abnormal, then output Is null (Null or Error), or the information of the occupant is not detected, and the output is null (Null). At this time, it is determined that the occupant has an abnormality, that is, the audio resource is abnormally occupied. Therefore, the audio resource needs to be released to enable The application program calls the released audio resource.
  • the audio resource may be released through a reset operation, for example, restarting the audio manager to release the audio resource, or releasing the audio resource through an audio release interface, or restarting the audio system to release the audio Resources.
  • an audio resource call failure response message is sent to the requesting application program to prohibit the application program from calling the audio resource until The audio resource is normally released.
  • a conflict prompt message can be generated and displayed for the user to view at this time, and the occupier can be forcibly closed or restarted according to the user's further operation to release the audio resource and provide Used by the application that sent the request.
  • the audio resource can also be released according to the priority between applications. specifically,
  • the application is prohibited from calling the audio resource.
  • the requesting application program performs a recording operation through the audio resource or a playback operation through the audio resource.
  • the audio resource by monitoring the audio resource occupier, if the occupant information is empty, the audio resource is immediately released, and further calls are made for an application program that needs to call the audio resource. If the occupant information is not empty, the audio resource can be determined according to the priority information to decide whether to call the audio resource, thereby improving the stability of the system and the user experience.
  • an embodiment of the present application also provides a method for calling audio resources, including:
  • the electronic device actively allocates or pre-allocates corresponding audio resources for applications that need to use the audio resources.
  • the audio resources can be randomly allocated or fixed Thresholds are used to allocate audio resources.
  • the audio resource is allocated to the application program
  • the application program needs to call or starts to call the allocated audio resource
  • the state of the audio resource is monitored.
  • the monitoring process is specifically described in S120, which will not be described in detail in the embodiments of the present application.
  • the audio resource status is abnormal, that is, the current audio resource has been abnormally occupied.
  • the current audio resource has been occupied before the call and the occupant information is empty or abnormal, it is determined that the current audio resource status is abnormal.
  • the occupant is one or more applications currently occupying audio resources, and the occupant information is the status information or ID information of the current occupant. If the occupant information is empty, it means that the current occupant status is abnormal, then output Is null (Null or Error), or the information of the occupant is not detected, and the output is null (Null). At this time, it is determined that the occupant has an abnormality, that is, the audio resource is abnormally occupied. Therefore, the audio resource needs to be released to enable The application program calls the released audio resource.
  • the audio resource may be released through a reset operation, for example, restarting the audio manager to release the audio resource, or releasing the audio resource through an audio release interface, or restarting the audio system to release the audio Resources.
  • an audio resource call failure response message is sent to the requesting application program to prohibit the application program from calling the audio resource until The audio resource is normally released.
  • a conflict prompt message can be generated and displayed for the user to view at this time, and the occupier can be forcibly closed or restarted according to the user's further operation to release the audio resource and provide Used by the application that sent the request.
  • the audio resources may be released by restarting the audio manager, or the audio resources may be released through the audio release interface, or the audio system may be restarted to release the audio resources.
  • the priority of the application and the occupant are respectively obtained, if the priority of the application is higher than the priority of the occupant , The audio resource is released for the application to call the released audio resource; if the priority of the application is lower than the priority of the occupant, or the priority of the occupant If the same, then the application is prohibited from calling the audio resource.
  • a recording operation can be performed through the audio resource.
  • the status of the allocated audio resource is monitored by calling, and if the status is abnormal, the audio resource is released in time for the application program to make subsequent calls. Further, if the status is normal, it can also be determined whether to supply the application program for subsequent calls according to the priority, which improves the stability of the electronic device and improves the user experience.
  • an embodiment of the present application further provides an apparatus 30 for calling audio resources.
  • the apparatus 30 includes:
  • the receiving module 31 is used to receive an audio resource call request of an application program
  • 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 calling device can be implemented through the audio resource calling device, and the audio resource calling can be performed through the built-in processing function of the audio resource calling device.
  • the audio resource calling device installed with Android system as an example, in the Android system
  • Different types of functions are defined to achieve different ways of calling audio resources, including audio input and output operations, such as music playback, calls, voice prompts, and recording operations. Therefore, audio resource calls only need to use the corresponding audio calling function, that is This operation can be achieved.
  • one or more application programs need to send an invocation request before using the audio resource.
  • the audio resource invoking device will perform permission confirmation after receiving the invocation request of the application program.
  • the permission of the resource allows the call, otherwise the call fails.
  • the prior art when it is confirmed that the audio resource can be called, if the audio resource is not occupied, the audio resource is directly called, and if the audio resource is already occupied, it automatically waits until the previous application (that is, the audio resource The occupant) has already released the audio resource. Therefore, the prior art lacks a monitoring mechanism for the audio resource used by the previous application, resulting in that the audio resource cannot be discovered and released in time when the previous application abnormally occupies the music resource.
  • the monitoring module 32 is configured to monitor the state of the audio resource, and if the state of the audio resource is occupied, query the occupant information corresponding to the audio resource;
  • a brand-new monitoring mechanism is creatively proposed, that is, a monitoring module 32 is created at the system framework layer, and the state of the audio resource is monitored by the monitoring module, or the monitoring module 32 is created independently Monitor the process and monitor the audio resource status of the application through a message transmission mechanism.
  • the monitoring module 32 can monitor the audio resource call of the application through the built-in monitoring function.
  • the monitoring module 32 can be created at the system framework layer (native/framework layer) by The monitoring module 32 monitors the audio mode of the application, or the monitoring module 32 independently creates a monitoring process and monitors the audio mode of the application through a message transmission mechanism.
  • the listener module 32 can be set up in the framework layer and run in the system service program (system_server). Since the listener module 32 is set up in the system-level service framework layer, it can facilitate interaction with other system services without worrying about system calls Permissions issue at the time. In addition, you can also create an independent monitoring process, set up and call a separate monitoring function in the process, can be set to start automatically after booting, and monitor the audio resource calls of any other application in real time. Specifically, it can be captured in real time. Get the ID information, status information and/or priority information of the application corresponding to the currently called audio resource to determine the application and its status corresponding to the current calling behavior. It can be independently developed and not coupled with the system, which is convenient for subsequent Development and upgrade.
  • system_server system service program
  • the monitoring module 32 can also monitor whether the status of the application that currently calls the audio resource is normal. If the status is abnormal or the ID information is empty, it is determined that the application abnormally occupies the audio resource, and the abnormally occupied audio resource needs to be processed .
  • the release module 33 is configured to release the audio resource if the occupant information is empty, so that the application program calls the released audio resource.
  • the occupant is one or more applications currently occupying audio resources, and the occupant information is the status information or ID information of the current occupant. If the occupant information is empty, it means that the current occupant status is abnormal, then output Is null (Null or Error), or the information of the occupant is not detected, and the output is null (Null), it is determined that the occupant has an abnormality, that is, the audio resource is abnormally occupied, so the release module 33 needs to release the audio resource To enable the application to call the released audio resource.
  • the audio resource may be released through a reset operation, for example, restarting the audio manager to release the audio resource, or releasing the audio resource through an audio release interface, or restarting the audio system to release the audio Resources.
  • the audio resource invoking device may generate a conflict prompt message and display it for the user to view, and may perform a forced shutdown or restart on the occupant according to the user's further operation to release the Audio resources are also used by the requesting application.
  • the release module 33 may also release the audio resource according to the priority between applications. specifically,
  • the application is prohibited from calling the audio resource.
  • the requesting application program performs a recording operation through the audio resource or a playback operation through the audio resource.
  • the monitoring module 32 monitors the occupant of the audio resource, and if the occupant information is empty, the audio resource is immediately released by the release module 33 to make further calls for the application program that needs to call the audio resource. If the occupant information is not empty, the audio resource can be determined according to the priority information to decide whether to call the audio resource, thereby improving the stability of the system and the user experience.
  • an embodiment of the present application further provides an apparatus 40 for calling audio resources, including:
  • the allocation module 41 is used to allocate corresponding audio resources to the application program
  • the allocation module 41 is different from the receiving module 31 in the above embodiment.
  • the allocation module 41 actively allocates or pre-allocates corresponding audio resources to applications that need to use the audio resources.
  • the audio resources may be randomly allocated or may be based on a fixed threshold. Perform audio resource allocation.
  • the monitoring module 42 is configured to monitor the state of the audio resource when the application calls the audio resource;
  • the audio resource is allocated to the application program, when the application program needs to call or starts to call the allocated audio resource, the state of the audio resource is monitored.
  • the monitoring process is the same as the monitoring process of the monitoring module 32 in the above embodiment, which will not be repeated in the embodiments of the present application.
  • the release module 43 is configured to release the audio resource if the state of the audio resource is abnormal, so that the application program calls the released audio resource.
  • the audio resource status is abnormal, that is, the current audio resource has been abnormally occupied.
  • the current audio resource has been occupied before the call and the occupant information is empty or abnormal, it is determined that the current audio resource status is abnormal.
  • the occupant is one or more applications currently occupying audio resources, and the occupant information is the status information or ID information of the current occupant. If the occupant information is empty, it means that the current occupant status is abnormal, then output Is null (Null or Error), or the information of the occupant is not detected, and the output is null (Null).
  • the release module 43 needs to release the audio resource To enable the application to call the released audio resource.
  • the audio resource may be released through a reset operation, for example, restarting the audio manager to release the audio resource, or releasing the audio resource through an audio release interface, or restarting the audio system to release the audio Resources.
  • an audio resource call failure response message is sent to the requesting application program to prohibit the application program from calling the audio resource until The audio resource is normally released.
  • a conflict prompt message can be generated and displayed for the user to view at this time, and the occupier can be forcibly closed or restarted according to the user's further operation to release the audio resource and provide Used by the application that sent the request.
  • the audio resources may be released by restarting the audio manager, or the audio resources may be released through the audio release interface, or the audio system may be restarted to release the audio resources.
  • the release module 33 restarts the audio system to release the audio resource, or,
  • the priority of the application and the occupant are respectively obtained, if the priority of the application is higher than the priority of the occupant , The audio resource is released for the application to call the released audio resource; if the priority of the application is lower than the priority of the occupant, or the priority of the occupant If the same, then the application is prohibited from calling the audio resource.
  • a recording operation can be performed through the audio resource.
  • the state of the allocated audio resource is called by the monitoring module 42. If the state is abnormal, the audio resource is released in time by the release module 43, and the supplier program makes subsequent calls. Further, if the status is normal, it can also be determined whether to supply the application program for subsequent calls according to the priority, which improves the stability of the electronic device 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. 5 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 calling method may specifically be:
  • Monitor the state of the audio resource if the state of the audio resource is occupied, query the information of the occupant corresponding to the audio resource;
  • the audio resource is released, so that the application program calls the released audio resource.
  • monitoring the state of the audio resource may specifically include: creating a system-level monitoring module at the system framework layer, and monitoring the state of the audio resource through the monitoring module, or, independently creating Monitor the process and monitor the audio resource status of the application through a message transmission mechanism.
  • releasing the audio resource may specifically be: restarting the audio manager to release the audio resource, or releasing the audio resource through an audio release interface, or restarting the audio system to release the audio resource Audio resources.
  • the processor is also used to execute:
  • the processor is further configured to execute: generate and display a conflict prompt message.
  • the processor is also used to execute:
  • the application is prohibited from calling the audio resource.
  • the processor after the application program calls the audio resource, the processor performs a recording operation or a playback operation through the audio resource.
  • the above-mentioned audio resource calling method may specifically be:
  • the audio resource is released, so that the application program calls the released audio resource.
  • the monitoring of the state of the audio resource may specifically be:
  • the releasing the audio resource may specifically be: restarting the audio manager to release the audio resource, or releasing the audio resource through an audio release interface, or restarting the audio system to release The audio resource.
  • releasing the audio resource may specifically be:
  • the priority of the application and the occupant are respectively obtained, if the priority of the application is higher than the priority of the occupant , The audio resource is released for the application to call the released audio resource; if the priority of the application is lower than the priority of the occupant, or the priority of the occupant If the same, then the application is prohibited from calling the audio resource.
  • the processor is also used to perform: perform a recording operation through the audio resource.
  • embodiments of the present application further 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 steps of calling the audio resource described above are implemented.
  • An embodiment of the present invention also provides a computer device. As shown in FIG. 6, for convenience of description, only parts related to the embodiments of the present invention are shown. For specific technical details 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 610, a memory 620, an input unit 630, a display unit 640, a sensor 650, an audio circuit 660, a wireless fidelity (WiFi) module 670, a processor 680, and power supply 690 and other components.
  • a radio frequency (Radio Frequency) circuit 610 the electronic device includes: a radio frequency (Radio Frequency) circuit 610, a memory 620, an input unit 630, a display unit 640, a sensor 650, an audio circuit 660, a wireless fidelity (WiFi) module 670, a processor 680, and power supply 690 and other components.
  • WiFi wireless fidelity
  • the RF circuit 610 can be used to receive and send signals during sending and receiving information or during a call. It can receive the downlink information of the base station and process it to the processor 680; 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 610 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 620 may be used to store software programs and modules.
  • the processor 680 runs the software programs and modules stored in the memory 620 to execute various functional applications and data processing of the electronic device.
  • the memory 620 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 620 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 630 may be used to receive input numeric or character information, and generate key signal input related to user settings and function control of the electronic device 600.
  • the input unit 630 may include a touch panel 631 and other input devices 632.
  • the touch panel 631 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, stylus, etc. on or near the touch panel 631 Operation), and drive the corresponding connection device according to the preset program.
  • the touch panel 631 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 680, and can receive the command sent by the processor 680 and execute it.
  • the touch panel 631 may be implemented in various types such as resistive, capacitive, infrared, and surface acoustic waves.
  • the input unit 630 may also include other input devices 632.
  • the other input devices 632 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 640 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 640 may include a display panel 641.
  • the display panel 641 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 631 may cover the display panel 641, and after the touch panel 431 detects a touch operation on or near it, it is transmitted to the processor 680 to determine the type of touch event, and then the processor 680 according to The type of touch event provides corresponding visual output on the display panel 641.
  • the touch panel 631 and the display panel 641 are implemented as two independent components to realize the input and input functions of the electronic device, in some embodiments, the touch panel 631 and the display panel 641 may be integrated And realize the input and output functions of electronic equipment.
  • the electronic device 600 may further include at least one sensor 650, 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 661 according to the brightness of the ambient light, and the proximity sensor may close the display panel 661 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 660, the speaker 661, and the microphone 662 may provide an audio interface between the user and the electronic device.
  • the audio circuit 660 can transmit the converted electrical signal of the received audio data to the speaker 661, which converts the speaker 661 into a sound signal output; on the other hand, the microphone 662 converts the collected sound signal into an electrical signal, which is converted by the audio circuit 660 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 670. It provides users with wireless broadband Internet access.
  • FIG. 6 shows the WiFi module 670, it can be understood that it is not a necessary component of the electronic device 600, and may be omitted as needed.
  • the processor 680 is the control center of the electronic device, and uses various interfaces and lines to connect various parts of the entire electronic device, by running or executing the software programs and/or modules stored in the memory 620, and calling the data stored in the memory 620 , Perform various functions of electronic devices and process data, so as to monitor the electronic devices as a whole.
  • the processor 680 may include one or more processing units.
  • the processor 680 may integrate an application processor and a modem processor, where the application processor mainly processes the operating system, user interface, application programs, and the like; the modem processor mainly processes wireless communication. It can be understood that the above-mentioned modem processor may not be integrated into the processor 680.
  • the electronic device 600 further includes a power supply 690 (such as a battery) that supplies power to various components.
  • a power supply 690 (such as a battery) that supplies power to various components.
  • the power supply can be logically connected to the processor 680 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 600 may further include a camera, a Bluetooth module, and the like.
  • the processor 680 included in the computer device implements the method of the foregoing embodiments when executing the computer program stored in the memory, for example, including the method of calling the audio resource shown in FIG. 1 or FIG. 2.
  • 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.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Health & Medical Sciences (AREA)
  • Audiology, Speech & Language Pathology (AREA)
  • General Health & Medical Sciences (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Telephone Function (AREA)

Abstract

本发明涉及一种音频资源调用的方法,包括:接收应用程序的音频资源调用请求;对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。相应地,本发明提供了一种音频资源调用的装置及电子设备,提高了系统的稳定性,提升了用户体验。

Description

一种音频资源调用的方法、装置及电子设备 技术领域
本发明涉及信息技术领域,特别是涉及一种音频资源调用的方法、装置及电子设备。
背景技术
目前的移动终端中,其音频资源可通过不同的应用程序调用,例如,可通过音乐应用软件调用移动终端的音频资源以实现音乐的播放,可通过通话软件实现铃声的播放,也可通过录音软件实现麦克风等资源的调用。
然而,音频资源由于其独特性及唯一性,在使用过程中通常只能被一个应用程序占用而无法实现共用。以录音为例,当一个录音程序正在使用该录音资源时,另一个录音程序则无法同一时刻对该录音资源进行使用。
在现有技术中,当一方需要使用音频资源时需要等到正在使用方使用完该音频资源并全部释放后才可以使用,而若当前使用方无限期使用该资源或异常占用该音频资源没有得到相应地释放时,任何新的应用程序均不能调用该音频资源,造成使用异常,导致系统稳定性差,用户体验差。
发明内容
本申请实施例提供一种音频资源调用的方法,包括:
接收应用程序的音频资源调用请求;
对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
本申请实施例还提供一种音频资源调用的方法,包括:
为应用程序分配对应的音频资源;
在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
若所述音频资源状态异常,则释放所述音频资源,以使所述应用程序对所述释放 后的音频资源进行调用。
本申请实施例还提供一种音频资源调用的装置,所述装置包括:
接收模块,用于接收应用程序的音频资源调用请求;
监测模块,用于对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
释放模块,用于若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述音频资源进行调用。
本申请实施例还提供一种音频资源调用的装置,所述装置包括:
分配模块,用于为应用程序分配对应的音频资源;
监测模块,用于在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
释放模块,用于在所述音频资源状态异常时,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
本申请实施例还提供一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行:
接收应用程序的音频资源调用请求;
对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
本申请实施例还提供一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,所述计算机程序被所述处理器执行时,使得所述处理器执行:
为应用程序分配对应的音频资源;
在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
若所述音频资源状态异常,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
本申请实施例还提供一种计算机非易失性可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述的音频资源调用的步骤。
电子设备和计算机可读存储介质在实现上述方法时,对音频资源占用方进行监测, 若占用方信息为空则立即释放该音频资源,为需要调用该音频资源的应用程序进行进一步调用。提高了系统的稳定性,提升了用户体验。
附图说明
为了更清楚地说明本发明实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他实施例的附图。
图1为一实施例的音频资源调用方法流程图;
图2为另一实施例的音频资源调用方法流程图;
图3为一实施例的音频资源调用装置结构示意图;
图4为另一实施例的音频资源调用装置结构示意图;
图5为一实施例中电子设备的内部结构示意图;
图6为与本发明实施例提供的计算机设备相关的电子设备的部分结构的框图。
具体实施方式
为了便于理解本发明,下面将参照相关附图对本发明进行更全面的描述。附图中给出了本发明的较佳实施例。但是,本发明可以以许多不同的形式来实现,并不限于本文所描述的实施例。相反地,提供这些实施例的目的是使对本发明的公开内容的理解更加透彻全面。
如图1所示,本申请实施例提供了一种音频资源调用的方法,该方法包括:
S110、接收应用程序的音频资源调用请求;
音频资源在本申请实施例中,可以是播放音频所需要的资源,例如扬声器、声道、音频文件等,也可以是进行录音时所需要的资源,例如麦克风、音频电路、录制数据存储器、音频录制处理器等,本申请实施例对此并无限制。其中,可通过电子设备实现对应用程序的音频资源调用,对音频资源调用可以通过电子设备内置的处理函数进行,以安装了安卓系统的电子设备为例,在安卓系统中定义了不同种类的函数以实现不同方式的音频资源调用,包括音频的输入输出操作,如音乐播放、通话、语音提示、录音等操作,因此,音频资源调用只需要在使用对应的音频调用函数即可实现该操作。
在本申请实施例中,一个或多个应用程序在使用音频资源之前需要先发送调用请求,电子设备在接收到该应用程序的调用请求后会进行权限确认,若该应用程序具备调用音频资源的权限这允许调用,否则调用失败。现有技术中,在确认可以调用音频资源时,若该音频资源没有被占用,则直接调用该音频资源,若该音频资源已经被占用则自动进行等待,直到上一个应用程序(即音频资源的占用方)已经释放掉该音频资源,因此,现有技术缺少对上一个应用程序使用音频资源的监测机制,导致上一应用程序发生异常占用该音乐资源时不能及时发现及释放音频资源。
S120、对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
在本申请实施例中,创造性地提出了一种全新的监测机制,即:在系统框架层创建系统级的监测模块,通过所述监测模块对所述音频资源状态进行监测,或,独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。具体地,电子设备可通过内置的监听函数对应用程序的音频资源调用进行监听,以安卓系统的电子设备为例,可在系统框架层(native/framework层)创建系统级的监听模块,通过所述监听模块对所述应用程序的音频模式进行监听,或,独立创建监听进程,通过消息传输机制监听所述应用程序的音频模式。例如,可在框架层设立监听模块并运行在系统服务程序(system_server)中,由于该监听模块设立在系统级的服务框架层中,可方便与其他系统服务进行交互,同时无需担心系统调用时的权限问题。此外,也可以创建独立的监听进程,在该进程中设立并调用单独的监听函数,可设置为开机自启动,并实时对其他任何一个应用程序的音频资源调用进行监控,具体地,可实时抓取当前调用的音频资源对应应用程序的ID信息、状态信息和/或优先权信息等,以此确定当前调用行为对应的应用程序及其状态,可独立开发,不与系统进行耦合,方便后续的开发和升级。进一步地,还可以监测当前调用音频资源的应用程序状态是否正常,若状态异常,或ID信息为空,则认定该应用程序异常占用音频资源,需要对该异常占用的音频资源进行处理。
S130、若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
占用方即为当前占用了音频资源的一个或多个应用程序,占用方信息即为当前占用方的状态信息或ID信息,若占用方信息为空,即表示当前的占用方状态异常,则输 出为空(Null或Error),或没有监测到占用方的信息,输出为空(Null),此时确定该占用方出现异常,即异常占用该音频资源,因此,需要释放该音频资源,以使所述应用程序对所述释放后的音频资源进行调用。其中,可通过重启(Reset)操作来释放该音频资源,例如,重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。另,若所述占用方信息不为空,则确定占用方正常占用了该音频资源,则发送音频资源调用失败响应消息至发送请求的应用程序,禁止该应用程序对所述音频资源进行调用直到该音频资源被正常释放,可选地,此时可生成冲突提示消息并显示,供用户查看,并可根据用户的进一步操作,对占用方进行强制关闭或重启,以释放掉该音频资源并供该发送请求的应用程序使用。
此外,在本申请实施例中,还可以根据应用程序之间的优先级进行音频资源的释放与否。具体地,
若所述占用方信息不为空,确定所述占用方及所述应用程序的优先级;
若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所述应用程序对所述释放后的音频资源进行调用;
若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
需要说明的是,在所述应用程序对所述音频资源进行调用之后,该发送请求的应用程序通过所述音频资源进行录音操作,或通过所述音频资源进行播放操作。
本申请实施例中,通过对音频资源占用方进行监测,若占用方信息为空则立即释放该音频资源,为需要调用该音频资源的应用程序进行进一步调用。若占用方信息不为空,可根据优先权信息确定音频资源决定是否调用该音频资源,从而提高了系统的稳定性,提升了用户体验。
如图2所示,本申请实施例还提供了一种音频资源调用的方法,包括:
S210、为应用程序分配对应的音频资源;
与S110的依据请求再进行分配的机制不同,在S210中,电子设备主动为需要使用该音频资源的应用程序分配或预分配对应的音频资源,该音频资源可以是随机分配,也可以是按照固定阈值进行音频资源的分配。
S220、在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
为该应用程序分配了音频资源之后,在应用程序需要调用或开始调用该分配的音频资源时,对该音频资源状态进行监测。其监测过程具体如S120所述,本申请实施例中对此不再累述。
S230、若所述音频资源状态异常,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
音频资源状态异常,即当前音频资源已经被异常占用。在本申请实施例中,若当前音频资源在调用之前已经被占用,且占用方信息为空或异常,则确定当前音频资源状态异常。
占用方即为当前占用了音频资源的一个或多个应用程序,占用方信息即为当前占用方的状态信息或ID信息,若占用方信息为空,即表示当前的占用方状态异常,则输出为空(Null或Error),或没有监测到占用方的信息,输出为空(Null),此时确定该占用方出现异常,即异常占用该音频资源,因此,需要释放该音频资源,以使所述应用程序对所述释放后的音频资源进行调用。其中,可通过重启(Reset)操作来释放该音频资源,例如,重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。另,若所述占用方信息不为空,则确定占用方正常占用了该音频资源,则发送音频资源调用失败响应消息至发送请求的应用程序,禁止该应用程序对所述音频资源进行调用直到该音频资源被正常释放,可选地,此时可生成冲突提示消息并显示,供用户查看,并可根据用户的进一步操作,对占用方进行强制关闭或重启,以释放掉该音频资源并供该发送请求的应用程序使用。
其中,释放音频资源,具体可以通过重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。
可选地,若所述音频资源状态为已占用,且占用方信息为空,则重启音频系统以释放所述音频资源,或,
若所述音频资源状态为已占用,且占用方信息不为空,则分别获取所述应用程序及所述占用方的优先级,若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所述应用程序对所述释放后的音频资源进行调用;若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
在所述应用程序对所述音频资源进行调用之后,可通过所述音频资源进行录音操作。
本申请实施例中,通过监测调用已分配的音频资源状态,若该状态异常,则及时释放该音频资源,供应用程序进行后续调用。进一步地,若状态正常,还可以根据优先权决定是否供应用程序进行后续调用,提升了电子设备的稳定性,提高了用户体验。
如图3所示,本申请实施例还提供一种音频资源调用的装置30,该装置30包括:
接收模块31,用于接收应用程序的音频资源调用请求;
音频资源在本申请实施例中,可以是播放音频所需要的资源,例如扬声器、声道、音频文件等,也可以是进行录音时所需要的资源,例如麦克风、音频电路、录制数据存储器、音频录制处理器等,本申请实施例对此并无限制。其中,可通过音频资源调用装置实现对应用程序的音频资源调用,对音频资源调用可以通过音频资源调用装置内置的处理函数进行,以安装了安卓系统的音频资源调用装置为例,在安卓系统中定义了不同种类的函数以实现不同方式的音频资源调用,包括音频的输入输出操作,如音乐播放、通话、语音提示、录音等操作,因此,音频资源调用只需要在使用对应的音频调用函数即可实现该操作。
在本申请实施例中,一个或多个应用程序在使用音频资源之前需要先发送调用请求,音频资源调用装置在接收到该应用程序的调用请求后会进行权限确认,若该应用程序具备调用音频资源的权限这允许调用,否则调用失败。现有技术中,在确认可以调用音频资源时,若该音频资源没有被占用,则直接调用该音频资源,若该音频资源已经被占用则自动进行等待,直到上一个应用程序(即音频资源的占用方)已经释放掉该音频资源,因此,现有技术缺少对上一个应用程序使用音频资源的监测机制,导致上一应用程序发生异常占用该音乐资源时不能及时发现及释放音频资源。
监测模块32,用于对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
在本申请实施例中,创造性地提出了一种全新的监测机制,即:在系统框架层创建监测模块32,通过所述监测模块对所述音频资源状态进行监测,或,监测模块32独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。具体地,监测模块32可通过内置的监听函数对应用程序的音频资源调用进行监听,以安卓系统的音频资源调用装置为例,可在系统框架层(native/framework层)创建监听模块32,通 过监听模块32对所述应用程序的音频模式进行监听,或,监听模块32独立创建监听进程,通过消息传输机制监听所述应用程序的音频模式。例如,可在框架层设立监听模块32并运行在系统服务程序(system_server)中,由于该监听模块32设立在系统级的服务框架层中,可方便与其他系统服务进行交互,同时无需担心系统调用时的权限问题。此外,也可以创建独立的监听进程,在该进程中设立并调用单独的监听函数,可设置为开机自启动,并实时对其他任何一个应用程序的音频资源调用进行监控,具体地,可实时抓取当前调用的音频资源对应应用程序的ID信息、状态信息和/或优先权信息等,以此确定当前调用行为对应的应用程序及其状态,可独立开发,不与系统进行耦合,方便后续的开发和升级。进一步地,监测模块32还可以监测当前调用音频资源的应用程序状态是否正常,若状态异常,或ID信息为空,则认定该应用程序异常占用音频资源,需要对该异常占用的音频资源进行处理。
释放模块33,用于若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
占用方即为当前占用了音频资源的一个或多个应用程序,占用方信息即为当前占用方的状态信息或ID信息,若占用方信息为空,即表示当前的占用方状态异常,则输出为空(Null或Error),或没有监测到占用方的信息,输出为空(Null),此时确定该占用方出现异常,即异常占用该音频资源,因此,需要释放模块33释放该音频资源,以使所述应用程序对所述释放后的音频资源进行调用。其中,可通过重启(Reset)操作来释放该音频资源,例如,重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。另,若所述占用方信息不为空,则确定占用方正常占用了该音频资源,则发送音频资源调用失败响应消息至发送请求的应用程序,禁止该应用程序对所述音频资源进行调用直到该音频资源被正常释放,可选地,此时音频资源调用装置可生成冲突提示消息并显示,供用户查看,并可根据用户的进一步操作,对占用方进行强制关闭或重启,以释放掉该音频资源并供该发送请求的应用程序使用。
此外,在本申请实施例中,释放模块33还可以根据应用程序之间的优先级进行音频资源的释放与否。具体地,
若所述占用方信息不为空,确定所述占用方及所述应用程序的优先级;
若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所 述应用程序对所述释放后的音频资源进行调用;
若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
需要说明的是,在所述应用程序对所述音频资源进行调用之后,该发送请求的应用程序通过所述音频资源进行录音操作,或通过所述音频资源进行播放操作。
本申请实施例中,监测模块32通过对音频资源占用方进行监测,若占用方信息为空则通过释放模块33立即释放该音频资源,为需要调用该音频资源的应用程序进行进一步调用。若占用方信息不为空,可根据优先权信息确定音频资源决定是否调用该音频资源,从而提高了系统的稳定性,提升了用户体验。
如图4所示,本申请实施例还提供了一种音频资源调用的装置40,包括:
分配模块41,用于为应用程序分配对应的音频资源;
分配模块41与上述实施例中的接收模块31不同,分配模块41主动为需要使用该音频资源的应用程序分配或预分配对应的音频资源,该音频资源可以是随机分配,也可以是按照固定阈值进行音频资源的分配。
监测模块42,用于在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
为该应用程序分配了音频资源之后,在应用程序需要调用或开始调用该分配的音频资源时,对该音频资源状态进行监测。其监测过程与上述实施例中监测模块32的监测过程相同,本申请实施例中对此不再累述。
释放模块43,用于若所述音频资源状态异常,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
音频资源状态异常,即当前音频资源已经被异常占用。在本申请实施例中,若当前音频资源在调用之前已经被占用,且占用方信息为空或异常,则确定当前音频资源状态异常。
占用方即为当前占用了音频资源的一个或多个应用程序,占用方信息即为当前占用方的状态信息或ID信息,若占用方信息为空,即表示当前的占用方状态异常,则输出为空(Null或Error),或没有监测到占用方的信息,输出为空(Null),此时确定该占用方出现异常,即异常占用该音频资源,因此,需要释放模块43释放该音频资源,以使所述应用程序对所述释放后的音频资源进行调用。其中,可通过重启(Reset)操作 来释放该音频资源,例如,重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。另,若所述占用方信息不为空,则确定占用方正常占用了该音频资源,则发送音频资源调用失败响应消息至发送请求的应用程序,禁止该应用程序对所述音频资源进行调用直到该音频资源被正常释放,可选地,此时可生成冲突提示消息并显示,供用户查看,并可根据用户的进一步操作,对占用方进行强制关闭或重启,以释放掉该音频资源并供该发送请求的应用程序使用。
其中,释放音频资源,具体可以通过重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。
可选地,若所述音频资源状态为已占用,且占用方信息为空,则释放模块33重启音频系统以释放所述音频资源,或,
若所述音频资源状态为已占用,且占用方信息不为空,则分别获取所述应用程序及所述占用方的优先级,若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所述应用程序对所述释放后的音频资源进行调用;若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
在所述应用程序对所述音频资源进行调用之后,可通过所述音频资源进行录音操作。
本申请实施例中,通过监测模块42调用已分配的音频资源状态,若该状态异常,则通过释放模块43及时释放该音频资源,供应用程序进行后续调用。进一步地,若状态正常,还可以根据优先权决定是否供应用程序进行后续调用,提升了电子设备的稳定性,提高了用户体验。
图5为一实施例中电子设备的内部结构示意图。如图5所示,该电子设备包括通过系统总线连接的处理器、非易失性存储介质、内存储器和网络接口、声音采集装置、扬声器、显示屏和输入装置。其中,终端的非易失性存储介质存储有操作系统和计算机可读指令。该计算机可读指令被处理器执行时以实现一种电子设备的音频资源调用方法。该处理器用于提供计算和控制能力,支撑整个电子设备的运行。电子设备中的内存储器为非易失性存储介质中的计算机可读指令的运行提供环境。电子设备的显示屏可以是液晶显示屏或者电子墨水显示屏等,输入装置可以是显示屏上覆盖的触摸层, 也可以是电子设备外壳上设置的按键、轨迹球或触控板,也可以是外接的键盘、触控板或鼠标等。该电子设备可以是手机、平板电脑或者个人数字助理或穿戴式设备等。本领域技术人员可以理解,图5中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的电子设备的限定,具体的电子设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。
其中,上述提及的音频资源调用方法具体可以为:
接收应用程序的音频资源调用请求;
对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
在其中的一个实施例中,对所述音频资源状态进行监测,具体可以为:在系统框架层创建系统级的监测模块,通过所述监测模块对所述音频资源状态进行监测,或,独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。
在其中的一个实施例中,释放所述音频资源,具体可以为:重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。
在其中的一个实施例中,所述处理器还用于执行:
若所述占用方信息不为空,发送音频资源调用失败响应消息至所述应用程序,禁止所述应用程序对所述音频资源进行调用。
在其中的一个实施例中,所述处理器还用于执行:生成冲突提示消息并显示。
在其中的一个实施例中,所述处理器还用于执行:
若所述占用方信息不为空,确定所述占用方及所述应用程序的优先级;
若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所述应用程序对所述释放后的音频资源进行调用;
若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
在其中的一个实施例中,在所述应用程序对所述音频资源进行调用之后,所述处理器通过所述音频资源进行录音操作或播放操作。
此外,上述提及的音频资源调用方法具体还可以为:
为应用程序分配对应的音频资源;
在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
若所述音频资源状态异常,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
在其中的一个实施例中,所述对所述音频资源状态进行监测,具体可以为:
在系统框架层创建系统级的监测模块,通过所述监测模块对所述音频资源状态进行监测,或,独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。
在其中的一个实施例中,所述释放所述音频资源,具体可以为:重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。
在其中的一个实施例中,若所述音频资源状态异常,则释放所述音频资源,具体可以为:
若所述音频资源状态为已占用,且占用方信息为空,则重启音频系统以释放所述音频资源,或,
若所述音频资源状态为已占用,且占用方信息不为空,则分别获取所述应用程序及所述占用方的优先级,若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所述应用程序对所述释放后的音频资源进行调用;若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
其中,在所述应用程序对所述音频资源进行调用之后,该处理器还用于执行:通过所述音频资源进行录音操作。
此外,本申请实施例还提供了一种计算机非易失性可读存储介质,其上存储有计算机程序,所述计算机程序被处理器执行时实现如上述音频资源调用的步骤。
本发明实施例还提供了一种计算机设备。如图6所示,为了便于说明,仅示出了与本发明实施例相关的部分,具体技术细节未揭示的,请参照本发明实施例方法部分。该计算机设备可以为包括电子设备、平板电脑、PDA(Personal Digital Assistant,个人数字助理)、POS(Point of Sales,销售终端)、车载电脑、穿戴式 设备等任意终端设备,以计算机设备为电子设备为例:
图6为与本发明实施例提供的计算机设备相关的电子设备的部分结构的框图。参考图6,电子设备包括:射频(Radio Frequency,RF)电路610、存储器620、输入单元630、显示单元640、传感器650、音频电路660、无线保真(wireless fidelity,WiFi)模块670、处理器680、以及电源690等部件。本领域技术人员可以理解,图6所示的电子设备结构并不构成对电子设备的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
其中,RF电路610可用于收发信息或通话过程中,信号的接收和发送,可将基站的下行信息接收后,给处理器680处理;也可以将上行的数据发送给基站。通常,RF电路包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(Low Noise Amplifier,LNA)、双工器等。此外,RF电路610还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(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)等。
存储器620可用于存储软件程序以及模块,处理器680通过运行存储在存储器620的软件程序以及模块,从而执行电子设备的各种功能应用以及数据处理。存储器620可主要包括程序存储区和数据存储区,其中,程序存储区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能的应用程序、图像播放功能的应用程序等)等;数据存储区可存储根据电子设备的使用所创建的数据(比如音频数据、通讯录等)等。此外,存储器620可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元630可用于接收输入的数字或字符信息,以及产生与电子设备600的用户设置以及功能控制有关的键信号输入。具体地,输入单元630可包括触控面板631以及其他输入设备632。触控面板631,也可称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板631 上或在触控面板631附近的操作),并根据预先设定的程式驱动相应的连接装置。在一个实施例中,触控面板631可包括触摸监测装置和触摸控制器两个部分。其中,触摸监测装置监测用户的触摸方位,并监测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸监测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器680,并能接收处理器680发来的命令并加以执行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板631。除了触控面板631,输入单元630还可以包括其他输入设备632。具体地,其他输入设备632可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)等中的一种或多种。
显示单元640可用于显示由用户输入的信息或提供给用户的信息以及电子设备的各种菜单。显示单元640可包括显示面板641。在一个实施例中,可以采用液晶显示器(Liquid Crystal Display,LCD)、有机发光二极管(Organic Light-Emitting Diode,OLED)等形式来配置显示面板641。在一个实施例中,触控面板631可覆盖显示面板641,当触控面板431监测到在其上或附近的触摸操作后,传送给处理器680以确定触摸事件的类型,随后处理器680根据触摸事件的类型在显示面板641上提供相应的视觉输出。虽然在图6中,触控面板631与显示面板641是作为两个独立的部件来实现电子设备的输入和输入功能,但是在某些实施例中,可以将触控面板631与显示面板641集成而实现电子设备的输入和输出功能。
电子设备600还可包括至少一种传感器650,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板661的亮度,接近传感器可在电子设备移动到耳边时,关闭显示面板661和/或背光。运动传感器可包括加速度传感器,通过加速度传感器可监测各个方向上加速度的大小,静止时可监测出重力的大小及方向,可用于识别电子设备姿态的应用(比如横竖屏切换)、振动识别相关功能(比如计步器、敲击)等;此外,电子设备还可配置陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器等。
音频电路660、扬声器661和传声器662可提供用户与电子设备之间的音频接口。音频电路660可将接收到的音频数据转换后的电信号,传输到扬声器661,由扬声器661转换为声音信号输出;另一方面,传声器662将收集的声音信号转换为 电信号,由音频电路660接收后转换为音频数据,再将音频数据输出处理器680处理后,经RF电路610可以发送给另一电子设备,或者将音频数据输出至存储器620以便后续处理。
WiFi属于短距离无线传输技术,电子设备通过WiFi模块670可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图6示出了WiFi模块670,但是可以理解的是,其并不属于电子设备600的必须构成,可以根据需要而省略。
处理器680是电子设备的控制中心,利用各种接口和线路连接整个电子设备的各个部分,通过运行或执行存储在存储器620内的软件程序和/或模块,以及调用存储在存储器620内的数据,执行电子设备的各种功能和处理数据,从而对电子设备进行整体监控。在一个实施例中,处理器680可包括一个或多个处理单元。在一个实施例中,处理器680可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等;调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器680中。
电子设备600还包括给各个部件供电的电源690(比如电池),优选的,电源可以通过电源管理系统与处理器680逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管理等功能。
在一个实施例中,电子设备600还可以包括摄像头、蓝牙模块等。
在本发明实施例中,该计算机设备所包括的处理器680执行存储在存储器上的计算机程序时实现上述各实施例的方法,例如,包括图1或图2所示的音频资源调用的方法。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的程序可存储于一非易失性计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实施例的流程。其中,所述的存储介质可为磁碟、光盘、只读存储记忆体(Read-Only Memory,ROM)等。本发明实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,该程序被处理器执行时上述各实施例的方法。
以上所述实施例的各技术特征可以进行任意的组合,为使描述简洁,未对上述实施例中的各个技术特征所有可能的组合都进行描述,然而,只要这些技术特征的组合 不存在矛盾,都应当认为是本说明书记载的范围。
以上所述实施例仅表达了本发明的几种实施方式,其描述较为具体和详细,但并不能因此而理解为对发明专利范围的限制。应当指出的是,对于本领域的普通技术人员来说,在不脱离本发明构思的前提下,还可以做出若干变形和改进,这些都属于本发明的保护范围。因此,本发明专利的保护范围应以所附权利要求为准。

Claims (19)

  1. 一种音频资源调用的方法,其特征在于,包括:
    接收应用程序的音频资源调用请求;
    对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
    若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
  2. 根据权利要求1所述的方法,其特征在于,所述对所述音频资源状态进行监测,包括:
    在系统框架层创建系统级的监测模块,通过所述监测模块对所述音频资源状态进行监测,或,
    独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。
  3. 根据权利要求1所述的方法,其特征在于,所述释放所述音频资源,包括:
    重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。
  4. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    若所述占用方信息不为空,发送音频资源调用失败响应消息至所述应用程序,禁止所述应用程序对所述音频资源进行调用。
  5. 根据权利要求4所述的方法,其特征在于,所述方法还包括:
    生成冲突提示消息并显示。
  6. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    若所述占用方信息不为空,确定所述占用方及所述应用程序的优先级;
    若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所述应用程序对所述释放后的音频资源进行调用;
    若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
  7. 根据权利要求1所述的方法,其特征在于,在所述应用程序对所述音频资源进行调用之后,所述方法还包括:
    通过所述音频资源进行录音操作。
  8. 根据权利要求1所述的方法,其特征在于,在所述应用程序对所述音频资源进行调用之后,所述方法还包括:
    通过所述音频资源进行播放操作。
  9. 一种音频资源调用的方法,其特征在于,包括:
    为应用程序分配对应的音频资源;
    在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
    若所述音频资源状态异常,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
  10. 根据权利要求9所述的方法,其特征在于,所述对所述音频资源状态进行监测,包括:
    在系统框架层创建系统级的监测模块,通过所述监测模块对所述音频资源状态进行监测,或,
    独立创建监听进程,通过消息传输机制监测所述应用程序的音频资源状态。
  11. 根据权利要求9所述的方法,其特征在于,所述释放所述音频资源,包括:
    重启音频管理器以释放所述音频资源,或通过音频释放接口对所述音频资源进行释放,或重启音频系统以释放所述音频资源。
  12. 根据权利要求9所述的方法,其特征在于,若所述音频资源状态异常,则释放所述音频资源,包括:
    若所述音频资源状态为已占用,且占用方信息为空,则重启音频系统以释放所述音频资源,或,
    若所述音频资源状态为已占用,且占用方信息不为空,则分别获取所述应用程序及所述占用方的优先级,若所述应用程序的优先级高于所述占用方优先级,则释放所述音频资源,以供所述应用程序对所述释放后的音频资源进行调用;若所述应用程序的优先级低于所述占用方优先级,或与所述占用方优先级相同,则禁止所述应用程序对所述音频资源进行调用。
  13. 根据权利要求9所述的方法,其特征在于,在所述应用程序对所述音频资源进行调用之后,所述方法还包括:
    通过所述音频资源进行录音操作。
  14. 一种音频资源调用的装置,其特征在于,所述装置包括:
    接收模块,用于接收应用程序的音频资源调用请求;
    监测模块,用于对所述音频资源状态进行监测,若所述音频资源状态为已占用状态,查询所述音频资源对应的占用方信息;
    释放模块,用于若所述占用方信息为空,则释放所述音频资源,以使所述应用程序对所述音频资源进行调用。
  15. 一种音频资源调用的装置,其特征在于,所述装置包括:
    分配模块,用于为应用程序分配对应的音频资源;
    监测模块,用于在所述应用程序调用所述音频资源时,对所述音频资源状态进行监测;
    释放模块,用于在所述音频资源状态异常时,则释放所述音频资源,以使所述应用程序对所述释放后的音频资源进行调用。
  16. 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求1-8中任一项所述的音频资源调用的步骤。
  17. 一种电子设备,包括存储器及处理器,所述存储器中储存有计算机程序,其特征在于,所述计算机程序被所述处理器执行时,使得所述处理器执行如权利要求9-13中任一项所述的音频资源调用的步骤。
  18. 一种计算机非易失性可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求1-8中任一项所述的音频资源调用的步骤。
  19. 一种计算机非易失性可读存储介质,其上存储有计算机程序,其特征在于,所述计算机程序被处理器执行时实现如权利要求9-13中任一项所述的音频资源调用的步骤。
PCT/CN2018/117523 2018-11-26 2018-11-26 一种音频资源调用的方法、装置及电子设备 WO2020107177A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201880098446.9A CN113039517B (zh) 2018-11-26 2018-11-26 一种音频资源调用的方法、装置及电子设备
PCT/CN2018/117523 WO2020107177A1 (zh) 2018-11-26 2018-11-26 一种音频资源调用的方法、装置及电子设备

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2018/117523 WO2020107177A1 (zh) 2018-11-26 2018-11-26 一种音频资源调用的方法、装置及电子设备

Publications (1)

Publication Number Publication Date
WO2020107177A1 true WO2020107177A1 (zh) 2020-06-04

Family

ID=70853378

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/117523 WO2020107177A1 (zh) 2018-11-26 2018-11-26 一种音频资源调用的方法、装置及电子设备

Country Status (2)

Country Link
CN (1) CN113039517B (zh)
WO (1) WO2020107177A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114071212A (zh) * 2021-11-15 2022-02-18 北京字节跳动网络技术有限公司 一种信息显示处理方法、装置及电子设备

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113434222B (zh) * 2021-06-30 2023-06-09 青岛海尔科技有限公司 应用程序的控制方法、装置、存储介质及电子装置

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103294553A (zh) * 2012-02-24 2013-09-11 中兴通讯股份有限公司 移动终端多媒体资源的管理方法及装置
US20150220517A1 (en) * 2012-06-21 2015-08-06 Emc Corporation Efficient conflict resolution among stateless processes
CN106101367A (zh) * 2016-05-26 2016-11-09 广东欧珀移动通信有限公司 录音处理方法和系统
WO2018210049A1 (zh) * 2017-05-17 2018-11-22 中兴通讯股份有限公司 一种音频占用处理方法、装置和存储介质

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105550037B (zh) * 2015-12-11 2019-07-12 北京元心科技有限公司 多系统中分配音频资源的方法及装置

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103294553A (zh) * 2012-02-24 2013-09-11 中兴通讯股份有限公司 移动终端多媒体资源的管理方法及装置
US20150220517A1 (en) * 2012-06-21 2015-08-06 Emc Corporation Efficient conflict resolution among stateless processes
CN106101367A (zh) * 2016-05-26 2016-11-09 广东欧珀移动通信有限公司 录音处理方法和系统
WO2018210049A1 (zh) * 2017-05-17 2018-11-22 中兴通讯股份有限公司 一种音频占用处理方法、装置和存储介质

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114071212A (zh) * 2021-11-15 2022-02-18 北京字节跳动网络技术有限公司 一种信息显示处理方法、装置及电子设备

Also Published As

Publication number Publication date
CN113039517A (zh) 2021-06-25
CN113039517B (zh) 2022-12-13

Similar Documents

Publication Publication Date Title
US10437631B2 (en) Operating system hot-switching method and apparatus and mobile terminal
US10069818B2 (en) Method, system, device, and terminal for network initialization of multimedia playback device
WO2017206916A1 (zh) 处理器中内核运行配置的确定方法以及相关产品
US11108955B2 (en) Mobile terminal-based dual camera power supply control method, system and mobile terminal
US20160314219A1 (en) Method and apparatus for invoking application programming interface
CN106775833B (zh) 设备驱动程序加载方法、终端及系统
WO2020103070A1 (zh) 一种对应用程序进行处理的方法、装置和电子设备
US20210255746A1 (en) Application control method and electronic device
CN107786424B (zh) 音视频通信方法、终端及服务器
WO2018049934A1 (zh) 一种数据迁移的方法及终端
WO2018049894A1 (zh) 数据传输方法及设备
WO2020118495A1 (zh) 一种音频资源分配方法、装置和电子设备
JP2021508989A (ja) サービス処理方法及び移動通信端末
WO2017206901A1 (zh) 进程控制方法及相关设备
WO2015062234A1 (zh) 移动终端资源处理方法、装置和设备
WO2020103045A1 (zh) 一种对应用程序进行处理的方法、装置和电子设备
WO2020107177A1 (zh) 一种音频资源调用的方法、装置及电子设备
US20200412792A1 (en) Bluetooth transmission control method, control system, and storage medium
WO2020097927A1 (zh) 通话控制方法和装置、计算机可读存储介质、电子设备
KR101876394B1 (ko) 단말기에 미디어 데이터를 재생하는 방법 및 장치
WO2015078349A1 (zh) 麦克风收音状态的切换方法和装置
CN110891262A (zh) 一种蓝牙配对的方法、系统和终端设备
WO2015062241A1 (zh) 应用程序保护方法、装置和终端
WO2020052354A1 (zh) 游戏加载方法及相关产品
WO2019237954A1 (zh) 网络连接方法、装置、可读存储介质及智能终端

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: 18941929

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

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 02.11.2021)

122 Ep: pct application non-entry in european phase

Ref document number: 18941929

Country of ref document: EP

Kind code of ref document: A1