Audio processing method and related device
By judging the microphone switch status in the electronic device and switching to use the USB microphone or the onboard microphone, the problem of the recording application being unable to obtain audio data when the microphone switch is turned off is solved and the user experience is improved.
Patent Information
- Application Number
- CN202311163548.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-08
- Publication Date
- 2024-10-11
- Estimated Expiration
- 2043-09-08
AI Technical Summary
In some scenarios, when the microphone switch of the electronic device is turned off, the recording application cannot obtain audio data, resulting in a degraded user experience.
By judging the switch status of the microphone, when the microphone receiver is connected to the electronic device and the switch is turned on, the USB microphone is used for recording; when the switch is turned off, the onboard microphone of the electronic device is used for recording, thereby realizing the recording function in any scenario.
This ensures that users can obtain recording data normally regardless of whether the microphone is turned on or off, thereby improving user experience and eliminating the need to frequently plug, unplug or switch the microphone receiver.
Smart Images

Figure CN117577141B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of terminal technology, and in particular to an audio processing method and related devices. Background Art
[0002] Some applications in electronic devices can receive sound. For example, when a user uses a singing application to sing, the singing application can receive audio, or when a user uses a camera application to record a video, the camera application can receive video.
[0003] However, in some scenarios, applications that require sound reception may not receive sound, which reduces the user experience. Summary of the invention
[0004] The audio processing method and related device provided by the embodiment of the present application can determine the switch state of the microphone by the electronic device. When the microphone receiver is connected to the electronic device and the microphone switch is turned on, the recording application can use the USB microphone to record; when the microphone receiver is connected to the electronic device and the microphone switch is turned off, the recording application can use the onboard microphone of the electronic device to record. In this way, when the user uses the recording application to record, for the scenario where the microphone switch is turned off, the recording application can still obtain the recording data and realize the recording function, thereby improving the user experience.
[0005] In the first aspect, the audio processing method provided by the embodiment of the present application includes: at a first moment, the electronic device is connected to an external microphone, the external microphone includes a switch, the state of the switch is in an open state, and the first application of the electronic device uses the external microphone to receive sound; at a second moment, the electronic device is connected to an external microphone, the state of the switch is in a closed state, the electronic device exits the first application, and the second moment is later than the first moment; at a third moment, the electronic device is connected to an external microphone, the state of the switch is in a closed state, and the electronic device starts a second application, and the third moment is later than the second moment; at a fourth moment, the electronic device is connected to an external microphone, the state of the switch is in a closed state, and the second application uses the built-in microphone in the electronic device to receive sound, and the fourth moment is later than the third moment. In this way, when the user uses the application to receive sound, for the scenario where the external microphone switch is turned off, the application can still obtain audio data to realize the receiving function, thereby improving the user experience.
[0006] In a possible implementation, at the first moment, the switch state of the external microphone stored in the electronic device is in the on state, and from the second moment to the fourth moment, the switch state of the external microphone stored in the electronic device is in the off state. In this way, the electronic device stores the switch state of the external microphone and can record the switch state of the external microphone in real time, which is convenient for the subsequent electronic device to query the switch state of the external microphone.
[0007] In a possible implementation, a third application for managing an external microphone is installed in the electronic device, and the method further includes: when the switch of the external microphone is turned on, the third application transmits the switch state of the external microphone to the electronic device as an on state, and the electronic device saves the switch state of the external microphone as an on state; when the switch of the external microphone is turned off, the third application transmits the switch state of the external microphone to the electronic device as an off state, and the electronic device saves the switch state of the external microphone as an off state. In this way, when the user turns on or off the switch of the external microphone, the third application can detect the switch state of the external microphone in real time and report it to the electronic device, so that the correct switch state of the external microphone is saved in the electronic device.
[0008] In a possible implementation, the electronic device includes an audio management module AudioManager and an audio processing service AudioFlinger, a third application transmits the switch state of the external microphone to the electronic device as an on state, and the electronic device saves the switch state of the external microphone as an on state, including: the third application calls the setParameters() interface of the audio management module AudioManager to transmit the switch state of the external microphone to the audio processing service AudioFlinger, wherein the parameters of the setParameters() interface include parameters used to indicate that the switch state of the external microphone is an on state; the audio processing service AudioFlinger saves the switch state of the external microphone as an on state; the third application transmits the switch state of the external microphone to the electronic device as an off state, and the electronic device saves the switch state of the external microphone as an off state, including: the third application calls the setParameters() interface of the audio management module AudioManager to transmit the switch state of the external microphone to the audio processing service AudioFlinger, wherein the parameters of the setParameters() interface include parameters used to indicate that the switch state of the external microphone is an off state; the audio processing service AudioFlinger saves the switch state of the external microphone as an off state. In this way, the electronic device can obtain the correct switch state of the external microphone.
[0009] In a possible implementation, before the second application uses the built-in microphone in the electronic device to receive sound, the process also includes: the electronic device determines that an external microphone is connected, and the electronic device selects the external microphone as the hardware receiving device; the electronic device obtains that the switch state of the external microphone is off, and the electronic device reselects the built-in microphone as the hardware receiving device. In this way, the user does not need to frequently plug and unplug the microphone receiver or frequently switch the external microphone on and off, so that the application can obtain the recording data, thereby realizing the recording function and improving the user experience.
[0010] In a possible implementation, the electronic device includes an audio policy engine module AudioPolicyEngine and an audio policy management module AudioPolicyManager. Before the electronic device determines that an external microphone is connected and the electronic device selects the external microphone as a hardware sound receiving device, it also includes: a second application calls the getInputForAttr() interface of the audio policy management module AudioPolicyManager to obtain the hardware sound receiving device, wherein the parameters of the getInputForAttr() interface include the audio source; the audio policy engine module AudioPolicyEngine obtains the available hardware sound receiving devices in the electronic device; the electronic device determines that an external microphone is connected and the electronic device selects the external microphone as the hardware sound receiving device, including: the audio policy engine module AudioPolicyEngine determines The available hardware sound receiving devices include an external microphone, and the audio policy engine module AudioPolicyEngine selects the external microphone as the hardware sound receiving device from the available hardware sound receiving devices according to the audio source and priority policy; the electronic device obtains the switch state of the external microphone as the off state, and the electronic device reselects the built-in microphone as the hardware sound receiving device, including: the audio policy engine module AudioPolicyEngine calls the getParameters() interface of the audio management module AudioManager to obtain the switch state of the external microphone from the audio processing service AudioFlinger; the audio policy engine module AudioPolicyEngine determines that the switch state of the external microphone is off, and the audio policy engine module AudioPolicyEngine reselects the built-in microphone as the hardware sound receiving device. In this way, when the external microphone is not available, the electronic device can use the built-in microphone to pick up the recording data, so that the application can obtain the recording data, thereby realizing the recording function and improving the user experience.
[0011] In a possible implementation, the audio source is different, and the audio policy engine module AudioPolicyEngine selects the hardware audio device with different priority policies. In this way, the application can determine the selected audio source according to the needs of the usage scenario, so that the electronic device can provide the application with a hardware audio device that is more suitable for the usage scenario.
[0012] In a possible implementation, when the second application is used in a singing scene or a recording scene, and the audio source of the second application is AUDIO_SOURCE_MIC, the priority strategy of the audio policy engine module AudioPolicyEngine to select the hardware sound receiving device includes: the priority of the Bluetooth headset device is higher than the priority of the external microphone, and the priority of the external microphone is higher than the priority of the built-in microphone; or, when the second application is used in a recording scene, and the audio source of the second application is AUDIO_SOURCE_CAMCORDER, the priority strategy of the audio policy engine module AudioPolicyEngine to select the hardware sound receiving device includes: the priority of the built-in back microphone of the electronic device is higher than the priority of the built-in bottom microphone of the electronic device, and the priority of the built-in bottom microphone is higher than the priority of the external microphone. In this way, the application can determine the selected audio source according to the needs of the usage scenario, so that the electronic device can provide the application with a recording device that is more suitable for the usage scenario.
[0013] In a possible implementation, before the first moment, it also includes: the USB driver of the kernel layer of the electronic device determines that the external microphone is inserted, and the USB driver transmits a message to the USB driver module of the hardware abstraction layer to indicate that the external microphone is inserted; the USB driver module of the hardware abstraction layer transmits a message to the USB manager UsbManager of the application framework layer to indicate that the external microphone is inserted; the USB manager UsbManager determines that the external microphone is an audio device, and transmits a message to the USB type audio device module UsbAlsaManager to indicate that the external microphone is an audio device; the USB type audio device module UsbAlsaManager initializes the USB type audio device object UsbAlsaDevice, and the USB type audio device object UsbAlsaDevice transmits a message to the audio manager AudioManager of the application framework layer to indicate that the USB type audio device object UsbAlsaDevice is in place; the audio manager AudioManager updates the audio device based on the USB type audio device object UsbAlsaDevice. In this way, after the electronic device recognizes the external microphone, the audio device can be updated, and the electronic device can use the external microphone to pick up audio data.
[0014] In a second aspect, an embodiment of the present application provides an audio processing device, which may be an electronic device, or a chip or chip system in an electronic device. The device may include a processing unit. The processing unit is used to implement any method related to processing performed by the electronic device in the first aspect or any possible implementation of the first aspect. When the device is an electronic device, the processing unit may be a processor. The device may also include a storage unit, which may be a memory. The storage unit is used to store instructions, and the processing unit executes the instructions stored in the storage unit so that the electronic device implements the method described in the first aspect or any possible implementation of the first aspect. When the device is a chip or chip system in an electronic device, the processing unit may be a processor. The processing unit executes the instructions stored in the storage unit so that the electronic device implements the method described in the first aspect or any possible implementation of the first aspect. The storage unit may be a storage unit in the chip (for example, a register, a cache, etc.), or a storage unit in the electronic device located outside the chip (for example, a read-only memory, a random access memory, etc.).
[0015] Exemplarily, the processing unit is used to collect sound using an external microphone, to exit the first application, to start the second application, and specifically to collect sound using a built-in microphone in the electronic device.
[0016] In a possible implementation, the switch state of the external microphone used for storage is an open state, and the switch state of the external microphone also used for storage is a closed state.
[0017] In a possible implementation, when the switch of the external microphone is turned on, the switch state of the external microphone is saved as the on state; when the switch of the external microphone is turned off, the switch state of the external microphone is also saved as the off state.
[0018] In one possible implementation, it is used to call the setParameters() interface of the audio management module AudioManager to pass the switch state of the external microphone to the audio processing service AudioFlinger, and is also used to save the switch state of the external microphone as an on state; it is also used to call the setParameters() interface of the audio management module AudioManager to pass the switch state of the external microphone to the audio processing service AudioFlinger, and is specifically used to save the switch state of the external microphone as an off state.
[0019] In a possible implementation, it is used to determine whether an external microphone is connected, and is also used to select the external microphone as a hardware sound receiving device; it is also used to obtain the switch state of the external microphone as an off state, and is specifically used to reselect the built-in microphone as the hardware sound receiving device.
[0020] In one possible implementation, it is used to call the getInputForAttr() interface of the audio policy management module AudioPolicyManager to obtain the hardware sound receiving device, and is also used to obtain the available hardware sound receiving devices in the electronic device; it is also used to determine whether the available hardware sound receiving devices include an external microphone, and is also used to select the external microphone as the hardware sound receiving device from the available hardware sound receiving devices according to the audio source and priority policy; specifically, it is also used to call the getParameters() interface of the audio management module AudioManager to obtain the switch state of the external microphone from the audio processing service AudioFlinger; it is also used to determine that the switch state of the external microphone is off, and is also used to reselect the built-in microphone as the hardware sound receiving device.
[0021] In a possible implementation, the audio source is different, and the audio policy engine module AudioPolicyEngine has different priority strategies for selecting hardware audio devices.
[0022] In one possible implementation, when the second application is used in a singing scene or a recording scene and the audio source of the second application is AUDIO_SOURCE_MIC, the audio policy engine module AudioPolicyEngine selects a priority strategy for the hardware sound receiving device including: the priority of the Bluetooth headset device is higher than the priority of the external microphone, and the priority of the external microphone is higher than the priority of the built-in microphone; or, when the second application is used in a recording scene and the audio source of the second application is AUDIO_SOURCE_CAMCORDER, the audio policy engine module AudioPolicyEngine selects a priority strategy for the hardware sound receiving device including: the priority of the built-in back microphone of the electronic device is higher than the priority of the built-in bottom microphone of the electronic device, and the priority of the built-in bottom microphone is higher than the priority of the external microphone.
[0023] In one possible implementation, it is used to determine whether an external microphone is inserted, and is also used to pass a message indicating that an external microphone is inserted to a USB driver module of a hardware abstraction layer; it is also used to pass a message indicating that an external microphone is inserted to a USB manager UsbManager of an application framework layer; it is specifically used to determine whether the external microphone is an audio device, and is also used to pass a message indicating that the external microphone is an audio device to a USB type audio device module UsbAlsaManager; it is specifically used to initialize a USB type audio device object UsbAlsaDevice, and is also used to pass a message indicating that a USB type audio device object UsbAlsaDevice is in place to an audio manager AudioManager of an application framework layer; it is also used to update an audio device based on a USB type audio device object UsbAlsaDevice.
[0024] In a third aspect, an embodiment of the present application provides a terminal device, including a processor and a memory, the memory being used to store code instructions, and the processor being used to run the code instructions to execute the method described in the first aspect or any possible implementation of the first aspect.
[0025] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a computer program or instructions are stored. When the computer program or instructions are run on a computer, the computer executes the method described in the first aspect or any possible implementation of the first aspect.
[0026] In a fifth aspect, an embodiment of the present application provides a computer program product including a computer program. When the computer program runs on a computer, the computer executes the method described in the first aspect or any possible implementation manner of the first aspect.
[0027] In a sixth aspect, the present application provides a chip or a chip system, the chip or chip system comprising at least one processor and a communication interface, the communication interface and the at least one processor are interconnected by a line, and the at least one processor is used to run a computer program or instruction to execute the method described in the first aspect or any possible implementation of the first aspect. The communication interface in the chip can be an input / output interface, a pin or a circuit, etc.
[0028] In a possible implementation, the chip or chip system described above in the present application further includes at least one memory, in which instructions are stored. The memory may be a storage unit inside the chip, such as a register, a cache, etc., or a storage unit of the chip (e.g., a read-only memory, a random access memory, etc.).
[0029] It should be understood that the second to sixth aspects of the present application correspond to the technical solutions of the first aspect of the present application, and the beneficial effects achieved by each aspect and the corresponding feasible implementation methods are similar and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Figure 1 A schematic diagram of a USB microphone provided in an embodiment of the present application;
[0031] Figure 2 A schematic diagram of a pop-up window displayed in a mixer application provided in an embodiment of the present application;
[0032] Figure 3 A schematic diagram of a data flow during recording provided in an embodiment of the present application;
[0033] Figure 4 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0034] Figure 5 A schematic diagram of the software structure of an electronic device provided in an embodiment of the present application;
[0035] Figure 6 A schematic diagram of module interaction of an audio processing method provided in an embodiment of the present application;
[0036] Figure 7 A schematic diagram of an audio processing method provided in an embodiment of the present application;
[0037] Figure 8 A schematic diagram of the structure of a chip provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] In order to clearly describe the technical solutions of the embodiments of the present application, some terms and technologies involved in the embodiments of the present application are briefly introduced below:
[0039] 1. Terminology
[0040] In the embodiments of the present application, words such as "first" and "second" are used to distinguish the same or similar items with substantially the same functions and effects. For example, the first chip and the second chip are only used to distinguish different chips, and their order is not limited. Those skilled in the art can understand that words such as "first" and "second" do not limit the quantity and execution order, and words such as "first" and "second" do not necessarily limit them to be different.
[0041] It should be noted that in the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or descriptions. Any embodiment or design described as "exemplary" or "for example" in the present application should not be interpreted as being more preferred or more advantageous than other embodiments or designs. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a specific way.
[0042] In the embodiments of the present application, "at least one" refers to one or more, and "more than one" refers to two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b, or c can represent: a, b, c, ab, a--c, bc, or abc, where a, b, c can be single or multiple.
[0043] Some applications in the electronic device can receive sound, and the applications that need to receive sound may include recording applications, singing applications, camera applications, free call applications, super call applications, etc. For example, when a user uses a recording application to record, the recording application can record audio; when a user uses a singing application to sing, the singing application can receive audio; or when a user uses a camera application to record a video, the camera application can receive video sound; or when a user uses a free call application or a super call application to make a call, the free call application or the super call application can receive call sound, etc.
[0044] For ease of description, the recording application is used as an example for explanation. It is understandable that in the embodiment of the present application, recording can also be understood as receiving sound, and for applications that require receiving sound, a recording file may be generated or not, and the embodiment of the present application does not limit this.
[0045] In some scenarios, the recording application can receive sound through a microphone. The following takes the electronic device as a smart screen as an example to illustrate the process of a user using a microphone and a recording application on the smart screen.
[0046] like Figure 1 As shown, the microphone may also be referred to as a microphone system, which may include a microphone 101 and a microphone receiver 103 .
[0047] The microphone 101 may also be referred to as a handheld microphone 101 or an external microphone 101. The microphone 101 may include a switch 102, and the microphone 101 has the ability to pick up sound only when the switch 102 is turned on.
[0048] The microphone receiver 103 may also be referred to as the receiver 103. The receiver 103 may include a USB interface 104, and the USB interface 104 may include a Type-A standard interface. The microphone system may be connected to the smart screen via the USB interface 104. It is understood that, relative to the smart screen, the microphone system may be a USB type external recording device, so the microphone system may also be referred to as a USB microphone.
[0049] like Figure 2 As shown, when the user inserts the microphone receiver into the smart screen 201, the smart screen 201 can display a pop-up window 202 of the application corresponding to the microphone system. Among them, the smart screen can also be called the system side or the smart screen system, and the application corresponding to the microphone system can be, for example, a microphone mixer application. The microphone mixer application can be understood as a preset application on the system side, and the microphone mixer application can be provided by the manufacturer of the microphone system.
[0050] The pop-up window 202 may display the name 203 of the microphone mixer application, a prompt message 204 for prompting the user whether to allow the microphone mixer application to access the USB device, a prompt message 205 for prompting the user of the default situation, an OK button 206, and a cancel button 207. The prompt message 204 may include "Do you allow the microphone mixer application to access the USB device?", and the prompt message 205 may include "Used for the USB device by default", and the specific contents of the prompt message 204 and the prompt message 205 are not limited in the embodiment of the present application.
[0051] When the smart screen 201 receives the user's operation of triggering the confirmation button 206, the smart screen 201 can cancel the display of the pop-up window 202, and the microphone mixer application can access the USB device. When the smart screen 201 receives the user's operation of triggering the cancel button 207, the smart screen 201 can cancel the display of the pop-up window 202, and the microphone mixer application cannot access the USB device.
[0052] After the user agrees that the microphone mixer application can access the USB device, the user can open the recording application. When the switch 102 is turned on, the recording application can use the USB microphone to record.
[0053] like Figure 3As shown, during the recording process, the microphone can be understood as the main body of picking up sound, and the microphone can transmit the picked up recording data to the receiver by wireless transmission, for example, the wireless transmission method can include Bluetooth transmission, and the specific wireless transmission method is not limited in the embodiment of the present application. The receiver can transmit the recording data to the smart screen system through the USB protocol, and the smart screen system can store the recording data in a certain memory after processing the audio signal through single-channel and dual-channel conversion, sampling rate resampling, etc., and the recording application can call the relevant interface to obtain the recording data from the memory.
[0054] However, in some scenarios, when the user is not using the microphone, the microphone switch can be turned off, but the microphone receiver is still connected to the smart screen. The next time the user uses an application that requires sound reception, the smart screen recognizes that a microphone receiver is currently plugged in, and the smart screen can choose to use a USB microphone to pick up the recording data. If the user does not turn on the microphone switch, the microphone cannot pick up the recording data, making the audio data obtained by the smart screen system silent data, causing the recording application to not record sound, thus affecting the user experience.
[0055] In view of this, the audio processing method provided in the embodiment of the present application allows the electronic device to determine the switch state of the microphone. When the microphone receiver is connected to the electronic device and the microphone switch is turned on, the recording application can use the USB microphone to record; when the microphone receiver is connected to the electronic device and the microphone switch is turned off, the recording application can use the onboard microphone of the electronic device to record. In this way, when the user uses the recording application to record, for the scenario where the microphone switch is turned off, the recording application can still obtain the recording data and realize the recording function, thereby improving the user experience.
[0056] Among them, the onboard microphone can be understood as a built-in microphone in the electronic device. The onboard microphone can be located at the top, bottom, side or back of the electronic device, etc. The specific position of the onboard microphone in the electronic device is not limited in the embodiments of the present application.
[0057] The electronic device of the embodiment of the present application may also be a terminal device in any form. For example, the electronic device may include: a television, a smart screen, a large screen, a mobile phone, a tablet computer, a PDA, a laptop computer, a mobile Internet device (MID), a wearable device, a virtual reality (VR) device, an augmented reality (AR) device, a wireless terminal in industrial control, a wireless terminal in self driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, a wireless terminal in a smart home, a cellular phone, a cordless phone, a session initiation protocol (SIP) phone, a wireless local loop (WLL) station, a personal digital assistant (PDA), a wireless communication device, ... assistant, PDA), handheld devices with wireless communication capabilities, computing devices or other processing devices connected to a wireless modem, vehicle-mounted devices, wearable devices, electronic devices in 5G networks, or electronic devices in future evolved public land mobile communication networks (public landmobile network, PLMN), etc., and the embodiments of the present application are not limited to this.
[0058] As an example but not limitation, in the embodiments of the present application, the electronic device may also be a wearable device. Wearable devices may also be referred to as wearable smart devices, which are a general term for wearable devices that are intelligently designed and developed using wearable technology for daily wear, such as glasses, gloves, watches, clothing, and shoes. A wearable device is a portable device that is worn directly on the body or integrated into the user's clothes or accessories. Wearable devices are not only hardware devices, but also powerful functions achieved through software support, data interaction, and cloud interaction. Broadly speaking, wearable smart devices include full-featured, large-sized, and fully or partially independent of smartphones, such as smart watches or smart glasses, as well as devices that only focus on a certain type of application function and need to be used in conjunction with other devices such as smartphones, such as various types of smart bracelets and smart jewelry for vital sign monitoring.
[0059] In addition, in the embodiments of the present application, the electronic device may also be an electronic device in an Internet of Things (IoT) system. IoT is an important part of the future development of information technology. Its main technical feature is to connect objects to the network through communication technology, thereby realizing an intelligent network that interconnects people and machines and things.
[0060] The electronic devices in the embodiments of the present application may also be referred to as: user equipment (UE), mobile station (MS), mobile terminal (MT), access terminal, user unit, user station, mobile station, mobile station, remote station, remote terminal, mobile device, user terminal, terminal, wireless communication equipment, user agent or user device, etc.
[0061] In an embodiment of the present application, the electronic device or each network device includes a hardware layer, an operating system layer running on the hardware layer, and an application layer running on the operating system layer. The hardware layer includes hardware such as a central processing unit (CPU), a memory management unit (MMU), and a memory (also called main memory). The operating system can be any one or more computer operating systems that implement business processing through processes, such as Linux operating system, Unix operating system, Android operating system, iOS operating system, or Windows operating system. The application layer includes applications such as browsers, address books, word processing software, and instant messaging software.
[0062] For example, Figure 4 A schematic structural diagram of an electronic device is shown.
[0063] The electronic device may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a power management module 140, a wireless communication module 150, an audio module 160, a speaker 160A, a receiver 160B, a microphone 160C, an earphone interface 160D, a button 170, an indicator 171, a camera 172, and a display screen 173, etc.
[0064] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device. In other embodiments of the present application, the electronic device may include more or fewer components than shown in the figure, or combine certain components, or split certain components, or arrange the components differently. The illustrated components may be implemented by hardware, software, or a combination of software and hardware.
[0065] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated into one or more processors. The controller may generate an operation control signal according to the instruction opcode and the timing signal to complete the control of fetching and executing instructions.
[0066] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0067] In some embodiments, the processor 110 may include one or more interfaces. The interface may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, and / or a USB interface, etc.
[0068] It is understandable that the interface connection relationship between the modules illustrated in the embodiment of the present invention is only a schematic illustration and does not constitute a structural limitation of the electronic device. In other embodiments of the present application, the electronic device may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.
[0069] The internal memory 121 can be used to store computer executable program codes, and the executable program codes include instructions. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an application required for at least one function (such as a sound recording function, etc.), etc. The data storage area may store data created during the use of the electronic device (such as audio data, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device by running instructions stored in the internal memory 121 and / or instructions stored in a memory provided in the processor.
[0070] The USB interface 130 is an interface that complies with the USB standard specification, and specifically can be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 can be used to connect a charger to charge the electronic device, and can also be used to transmit data between the electronic device and a peripheral device. For example, in an embodiment of the present application, the USB interface 130 can be used to connect the electronic device and the microphone receiver, and to transmit audio data between the electronic device and the microphone receiver.
[0071] The electronic device can implement audio functions, such as audio playback or recording, through the audio module 160, the speaker 160A, the receiver 160B, the microphone 160C, the headphone jack 160D, and the application processor.
[0072] The audio module 160 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signal. The speaker 160A, also known as the "speaker", is used to convert audio electrical signals into sound signals. The electronic device may include 1 or N speakers 160A, where N is a positive integer greater than 1. The electronic device can listen to music, video, or hands-free calls through the speaker 160A. The receiver 160B, also known as the "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device answers a call or voice message, the voice can be answered by placing the receiver 160B close to the human ear. The microphone 160C, also known as the "microphone" or "microphone", is used to convert sound signals into electrical signals. The headphone interface 160D is used to connect wired headphones. For example, in an embodiment of the present application, when a user uses a recording application to record, the microphone 160C can be used to collect the user's voice signal and convert the sound signal into audio data of an electrical signal for transmission.
[0073] The display screen 173 is used to display images, videos, etc. The display screen 173 includes a display panel. In some embodiments, the electronic device may include 1 or N display screens 173, where N is a positive integer greater than 1. The electronic device implements the display function through a GPU, a display screen 173, and an application processor. The GPU is a microprocessor for image processing, which connects the display screen 173 and the application processor. For example, in an embodiment of the present application, a pop-up window requesting access to a USB device by a microphone mixer application may be displayed on the display screen 173 of the electronic device.
[0074] Figure 5 It is a software structure block diagram of the electronic device of the embodiment of the present application. The layered architecture divides the software into several layers, each layer has a clear role and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into five layers, from top to bottom, namely, the application layer, the application framework layer, the Android runtime (Android runtime) and the system library, the hardware abstraction layer (hardware adaptation layer, HAL), and the kernel layer.
[0075] The application layer can also be called the application layer. The application layer can include a series of applications, which can include system applications and third-party applications. Figure 5 As shown, the application programs may include a recording application, a singing application, a camera application, and the like.
[0076] The application framework layer can also be called the Framework layer. The Framework layer can provide an application programming interface (API) and a programming framework for the application layer's applications. The Framework layer can include some predefined functions.
[0077] like Figure 5 As shown, the Framework layer may include a USB framework and an audio framework, etc.
[0078] Among them, the USB framework can also be called a USB module, and the USB module can include a USB manager (UsbManager), a USB type audio device object (UsbAlsaDevice), a USB type audio device module (UsbAlsaManager), etc.
[0079] The USB manager (UsbManager) can also be called a USB management module. The UsbManager can be used to manage USB devices. For example, the UsbManager can access the status of USB devices, communicate with USB devices, etc. The UsbManager can also be used to identify whether the USB device is an audio device.
[0080] The USB type audio device object (UsbAlsaDevice) can be understood as a USB device object, and the USB device object also belongs to the audio device object. For example, in the embodiment of the present application, the USB microphone is both a USB type device and an audio device, so the USB microphone can have a corresponding UsbAlsaDevice object. It can be understood that each USB type audio device can have its own corresponding UsbAlsaDevice object, and the UsbAlsaDevice object can be used to perform data processing related to its own object.
[0081] The USB type audio device module (UsbAlsaManager) can be used to manage each UsbAlsaDevice object. Exemplarily, UsbAlsaManager can initialize the UsbAlsaDevice object, and UsbAlsaManager can also determine whether the UsbAlsaDevice object has input capability and / or output capability. For example, a USB microphone can record but cannot play sound, so UsbAlsaManager can determine that the UsbAlsaDevice object of the USB microphone has input capability but no output capability. In addition, UsbAlsaManager can also pass the UsbAlsaDevice object of the audio device to the audio manager AudioManager after identifying the audio device, and then AudioManager can update the audio device.
[0082] The audio framework may include multiple audio modules and audio services. The audio framework may also include an audio manager (AudioManager), an audio policy service (AudioPolicy), an audio processing service (AudioFlinger), etc.
[0083] The audio manager (AudioManager) can also be called an audio management module. AudioManager can be used to manage audio devices.
[0084] The Audio Policy service (AudioPolicy) can be used to decide which audio device to use for recording.
[0085] The audio processing service (AudioFlinger) can be understood as the executor of the audio strategy. AudioFlinger can be used to manage audio streams and transmit audio stream data.
[0086] Android runtime includes core libraries and virtual machines. Android runtime is responsible for the control and management of the Android system.
[0087] The core library consists of two parts: one part is the function that needs to be called by the Java language, and the other part is the Android core library.
[0088] The application layer and the framework layer run in a virtual machine. The virtual machine executes the java files of the application layer and the framework layer as binary files. The virtual machine is used to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection. For example, in the embodiment of the present application, the virtual machine can be used to perform functions such as USB device identification, audio device management, and recording device selection.
[0089] The system library can also be called the Native layer, which can include multiple functional modules, such as media libraries, function libraries, and graphics processing libraries (such as OpenGL ES).
[0090] The media library supports playback and recording of a variety of commonly used audio and video formats, as well as static image files, etc. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.
[0091] The function library provides developers with API interfaces for multiple services, making it easy for developers to quickly integrate and implement various functions.
[0092] The graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis and layer processing.
[0093] The hardware abstraction layer is an abstracted layer between the kernel layer and the Android runtime. The hardware abstraction layer can be a package of the hardware driver, providing a unified interface for the call of the upper layer application. For example, in the embodiment of the present application, the hardware abstraction layer may include a USB driver module and an audio driver module.
[0094] The kernel layer is a layer between hardware and software. For example, in the embodiment of the present application, the kernel layer may include a USB driver, a microphone driver, etc.
[0095] It should be noted that the embodiments of the present application are only illustrated using the Android system as an example. In other operating systems (such as Windows system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those in the embodiments of the present application, the solutions of the present application can also be implemented.
[0096] The following is an example of the interaction process between the various modules in the Android system layered framework, combined with the recording scenario of the recording application in the smart screen.
[0097] like Figure 5 As shown in the figure, when the microphone receiver is connected to the smart screen, the USB driver of the kernel layer can detect that a USB device is inserted, and the USB driver can pass a message indicating the insertion of the USB device to the USB driver module of the HAL layer. The USB driver module can report the driver event of the USB device insertion to the USB manager UsbManager in the USB framework of the Framework layer.
[0098] UsbManager can identify the USB device as an audio device and report the audio device to the USB type audio device module UsbAlsaManager. UsbAlsaManager can initialize the USB type audio device object UsbAlsaDevice and determine whether the UsbAlsaDevice object has input capabilities. The UsbAlsaDevice object can pass a message indicating that the UsbAlsaDevice object is in place to the audio manager AudioManager in the audio framework of the Framework layer, and then AudioManager can update the audio device based on the UsbAlsaDevice object.
[0099] When a recording application in the application layer starts recording, the audio framework in the Framework layer can obtain the recording request of the recording application, and select the recording device through the audio policy service AudioPolicy to decide which recording device to use for recording. After AudioPolicy selects the recording device, it can pass the recording device information selected by AudioPolicy to the audio processing service AudioFlinger, and then AudioFlinger can pass the message to the HAL layer to instruct the audio driver module corresponding to the recording device to be opened. The HAL layer can open the audio driver module corresponding to the recording device, and pass the message to the kernel layer to instruct the microphone driver corresponding to the recording device to be opened.
[0100] It is understandable that if the recording device selected by AudioPolicy is an onboard microphone, the microphone driver of the kernel layer can power on the onboard microphone. If the recording device selected by AudioPolicy is a USB microphone, AudioFlinger can notify the HAL layer to open the corresponding recording path and recording device.
[0101] When the microphone is powered on successfully, it can pick up the recording data and Figure 3 The relevant description in the corresponding embodiment transmits the recording data to the recording application through the smart screen system, thereby realizing the recording function.
[0102] Figure 6 A schematic diagram of module interaction of the audio processing method according to an embodiment of the present application is shown.
[0103] S601. The mixer application sets parameters setParameters(tv_loostone_mic_switch).
[0104] When the user turns on or off the switch of the USB microphone, the mixer application can detect the switch status of the USB microphone and call the parameter setting interface setParameters() provided by the audio manager AudioManager to pass the switch status of the USB microphone to the audio processing service AudioFlinger.
[0105] In a possible implementation, the mixer application can call the AudioManager.setParameters(tv_loostone_mic_switch=on / off) interface to set the switch state parameters of the USB microphone. Among them, the tv_loostone_mic_switch parameter can be used to indicate the switch state of the USB microphone. For example, when the tv_loostone_mic_switch parameter is "on", it means that the switch of the USB microphone is turned on, and when the tv_loostone_mic_switch parameter is "off", it means that the switch of the USB microphone is turned off. The data type and specific value of the tv_loostone_mic_switch parameter are not limited in the embodiments of the present application.
[0106] It can be understood that the way in which the mixer application transmits the switch status of the USB microphone to AudioFlinger is not limited to calling AudioManager.setParameters(). The mixer application can also transmit information by sending broadcasts and other methods. The specific way in which the mixer application transmits the switch status of the USB microphone to AudioFlinger is not limited in the embodiments of this application.
[0107] S602. AudioFlinger saves parameter status.
[0108] After the audio processing service AudioFlinger obtains the switch status of the USB microphone, it can save the switch status, so that subsequent related modules can query the switch status of the USB microphone.
[0109] S603: The recording application starts recording, and the system obtains the recording path getInputForAttr().
[0110] When the recording application is recording, the system side can obtain the recording path. Exemplarily, the recording application can call the getInputForAttr() interface provided by the audio policy management module AudioPolicyManager in the audio policy service AudioPolicy to enable the system side to obtain the recording path.
[0111] The recording application can specify the audio source in the getInputForAttr() interface. It is understandable that the system side can define different audio sources for different types of audio scenes, and the audio source can also be represented by AudioSource or inputsource. As shown in Table 1, the audio source can include the following types.
[0112] Table 1
[0113]
[0114] The VoIP in Table 1 is a voice transmission technology based on IP protocol (voice over internet protocol, VoIP), and VoIP can be understood as a voice call technology.
[0115] For example, a singing application or a camera application can select the AUDIO_SOURCE_MIC audio source when recording, and the camera application can select the AUDIO_SOURCE_CAMCORDER audio source when recording, etc. AudioPolicy can select the corresponding recording device and recording channel according to the audio source.
[0116] S604. The audio policy management module AudioPolicyManager obtains the recording device getInputDeviceForAttributes().
[0117] AudioPolicyManager can call the getInputDeviceForAttributes() interface provided by the audio policy engine module AudioPolicyEngine in AudioPolicy to obtain the recording device. Among them, AudioPolicyManager can pass the audio source specified by the recording application in the getInputDeviceForAttributes() interface, AudioPolicyEngine can obtain the audio devices available on the system side, and execute step S605 to select the recording device according to the audio source.
[0118] S605 . The audio policy engine module AudioPolicyEngine selects a recording device getDeviceForInputSource() through the recording source.
[0119] After obtaining the available audio devices on the system side, AudioPolicyEngine can select the recording device according to the priority policy of the audio source and microphone device.
[0120] For example, taking the audio source AUDIO_SOURCE_MIC selected by the recording application as an example, AudioPolicyEngine can first determine whether there is a synchronous connection oriented (SCO) device among the audio devices available on the system side. The SCO device can be used for recording scenarios of Bluetooth headsets. In some implementations, the SCO device can also be called a preferred device. If there is a SCO device among the available audio devices, AudioPolicyEngine will first select the SCO device.
[0121] If there is no SCO device among the available audio devices, AudioPolicyEngine can select an available device according to the following device sorting priorities: pluggable analog headset, pluggable digital headset, onboard recording device. Among them, pluggable analog headset and pluggable digital headset can be called pluggable headset, and pluggable headset can include USB microphone, wired headset, etc.
[0122] It can be understood that if there is a pluggable analog headset in the available audio devices, the AudioPolicyEngine gives priority to the pluggable analog headset; if there is no pluggable analog headset in the available audio devices, but there is a pluggable digital headset, the AudioPolicyEngine can select the pluggable digital headset; if there is no pluggable digital headset in the available audio devices, the AudioPolicyEngine can select the onboard recording device.
[0123] In summary, the priority of the SCO device is higher than that of the pluggable headset, and the priority of the pluggable headset is higher than that of the onboard recording device.
[0124] It is understandable that the priority strategy for selecting recording devices by the audio policy engine module AudioPolicyEngine may be different for different audio sources. For example, if the recording application selects the AUDIO_SOURCE_CAMCORDER audio source, the priority strategy for selecting recording devices by the audio policy engine module AudioPolicyEngine may include: the priority of the built-in back microphone of the electronic device is higher than the priority of the built-in bottom microphone of the electronic device, and the priority of the built-in bottom microphone is higher than the priority of the external microphone. In this way, the application can determine the selected audio source according to the needs of the usage scenario, so that the electronic device can provide the application with a recording device that is more suitable for the usage scenario.
[0125] After AudioPolicyEngine selects a recording device, step S606 may be executed.
[0126] S606. AudioPolicyEngine returns the available recording device inputDevice.
[0127] After AudioPolicyEngine selects an available recording device, the getDeviceForInputSource() interface can return the available recording device. In the embodiment of the present application, the available recording device can be represented by inputDevice or device.
[0128] In a possible implementation, the recording device selected by AudioPolicyEngine is a USB microphone. Since the USB microphone cannot pick up recording data when the switch is turned off, AudioPolicyEngine can execute step S607 to obtain the switch state of the USB microphone.
[0129] In another possible implementation, the recording device selected by AudioPolicyEngine is not a USB microphone, for example, the recording device is a board-mounted microphone, then AudioPolicyEngine may execute step S609 to return the recording device inputDevice to AudioPolicyManager.
[0130] S607. AudioPolicyEngine obtains the switch status of the USB microphone through getParameters().
[0131] AudioPolicyEngine can call the getParameters() interface to obtain the on / off state of the USB microphone from AudioFlinger. AudioFlinger can execute step S608 to return the on / off state of the USB microphone.
[0132] S608, AudioFlinger returns to the on / off state.
[0133] If the switch state of the USB microphone returned by AudioFlinger is on, AudioPolicyEngine can execute step S609 to return the inputDevice of the USB microphone to AudioPolicyManager. It can be understood that AudioPolicyEngine returns the USB microphone first, so that the selection of the recording device can comply with the above priority policy.
[0134] If the switch state of the USB microphone returned by AudioFlinger is off, the AudioPolicyEngine can execute step S609 and return the inputDevice of the onboard microphone to the AudioPolicyManager. It is understandable that when the USB microphone is not available, the onboard microphone can be used to pick up the recording data. In this way, the user does not need to frequently plug and unplug the microphone receiver or turn on the USB microphone, so that the recording application can obtain the recording data, thereby realizing the recording function and improving the user experience.
[0135] S609, AudioPolicyEngine returns the recording device inputDevice.
[0136] S610, AudioPolicyManager selects a recording channel getInputForDevice() according to the device.
[0137] The AudioPolicyManager may call the getInputForDevice() interface to select a corresponding recording path according to the returned recording device. Exemplarily, in the getInputForDevice() interface, the AudioPolicyManager may execute step S611 to open a corresponding recording path.
[0138] S611. AudioPolicyManager opens the recording channel openInput().
[0139] AudioPolicyManager can call the openInput() interface provided by AudioFlinger to open the recording path. AudioFlinger can execute step S612 to create a recording stream.
[0140] S612. AudioFlinger opens the HAL layer recording channel and creates a recording stream openInputStream().
[0141] AudioFlinger can call the openInputStream() interface provided by the audio module AudioHAL of the HAL layer to open the recording channel and thus create a recording stream.
[0142] S613. The audio module AudioHAL of the hardware abstraction layer returns the recording stream object halInputStream.
[0143] AudioHAL can return the recording stream object halInputStream to AudioFlinger. It can be understood that each recording stream can have its own corresponding recording stream object halInputStream, and the halInputStream object can also be understood as the carrier of the recording stream. Later in the recording stream, the recording data can be obtained through the halInputStream object.
[0144] S614. AudioFlinger creates a recording thread new RecordThread().
[0145] After AudioFlinger obtains the halInputStream object, it can create a recording thread new RecordThread(). Among them, AudioFlinger can pass the halInputStream object as a parameter. In this way, the halInputStream object can be used to determine which recording stream to obtain the recording data from.
[0146] After AudioFlinger creates the recording thread, it can execute processes such as device power-on to prepare in advance for obtaining recording data through the halInputStream object.
[0147] S615. AudioFlinger returns the input device identifier inputId.
[0148] AudioFlinger can return the input device identifier inputId to AudioPolicyManager, where the inputId can be understood as the return value of the openInput() interface.
[0149] It can be understood that each halInputStream object can have its own corresponding input device identifier inputId, through which the corresponding halInputStream object and the corresponding recording stream can be found.
[0150] S616. AudioPolicyManager returns the input device identifier inputId.
[0151] In this step, the input device identifier inputId obtained by AudioPolicyManager can be understood as the return value of the getInputForDevice() interface.
[0152] S617, AudioPolicyManager status is returned, and the application can read data.
[0153] In a possible implementation, AudioPolicyManager can return the input device identifier inputId to the audio recording class AudioRecord to indicate that a channel for recording has been created. The AudioRecord class can be used to manage audio resources, and the recording application can create an object of the AudioRecord class to read the recording data based on the object of the AudioRecord class.
[0154] Optionally, the switch status of the USB microphone can also be obtained by the smart screen system. In other words, the above steps S601 and S602 may not be performed.
[0155] In a possible implementation, when the recording application is recording, if the smart screen system determines that a microphone receiver is currently plugged in and the recording data obtained is not silent, it means that the switch state of the USB microphone is on. If the smart screen system determines that a microphone receiver is currently plugged in and the recording data obtained within a preset time period is silent, it means that the switch state of the USB microphone is off.
[0156] When the smart screen system determines that the switch state of the USB microphone is off, the smart screen system can use the onboard microphone to pick up sound; or, the smart screen system can pop up a window to ask the user whether to use the onboard microphone; or, the smart screen system can pop up a window to prompt the user to turn on the USB microphone, etc. The specific implementation of the smart screen system is not limited in the embodiments of the present application.
[0157] The following specific embodiments are used to describe the method of the present application in detail. The following embodiments may be combined with each other or implemented independently, and the same or similar concepts or processes may not be described in detail in some embodiments.
[0158] Figure 7 The audio processing method of the embodiment of the present application is shown. The method includes:
[0159] S701: At a first moment, an electronic device is connected to an external microphone, the external microphone includes a switch, the switch is in an on state, and a first application of the electronic device uses the external microphone to receive sound.
[0160] In the embodiment of the present application, the first moment can be understood as the moment when the switch state of the external microphone is on and the first application of the electronic device uses the external microphone to receive sound.
[0161] The electronic device may be any form of terminal device that can receive sound data picked up by an external microphone. For example, the electronic device may include a television, a smart screen, a large screen, etc., which is not limited in the embodiments of the present application.
[0162] The first application can be understood as an application that requires sound reception. For example, the first application can include a recording application, a singing application, a camera application, a Changlian call application, a super call application, and the like.
[0163] The external microphone can be understood as the above Figure 1 The microphone system or USB microphone in the corresponding embodiment will not be described in detail.
[0164] S702, at a second moment, the electronic device is connected to an external microphone, the switch is in an off state, the electronic device exits the first application, and the second moment is later than the first moment.
[0165] In the embodiment of the present application, the second moment can be understood as the moment when the electronic device is connected to an external microphone, the switch state of the external microphone is off, and the electronic device exits the first application.
[0166] S703, at a third moment, the electronic device is connected to an external microphone, the switch is in an off state, the electronic device starts a second application, and the third moment is later than the second moment.
[0167] In the embodiment of the present application, the third moment can be understood as the moment when the electronic device is connected to an external microphone, the switch state of the external microphone is off, and the electronic device starts the second application.
[0168] The second application can be understood as an application that needs to receive sound, for example, the first application can include a recording application, a singing application, a camera application, a smooth call application, a super call application, etc. It can be understood that the second application and the first application can be corresponding applications or different applications, which is not limited in the embodiments of the present application.
[0169] S704, at a fourth moment, the electronic device is connected to an external microphone, the switch is in an off state, and the second application uses the built-in microphone in the electronic device to receive sound. The fourth moment is later than the third moment.
[0170] In the embodiment of the present application, the fourth moment can be understood as the moment when the electronic device is connected to an external microphone, the switch state of the external microphone is off, and the second application uses the built-in microphone in the electronic device to receive sound.
[0171] The built-in microphone in the electronic device can be understood as the onboard microphone in the above embodiment, and will not be described in detail.
[0172] When an external microphone is connected to an electronic device and the external microphone switch is turned on, the application can use the external microphone to receive sound; when an external microphone is connected to an electronic device and the external microphone switch is turned off, the application can use the built-in microphone of the electronic device to receive sound. In this way, when the user uses the application to receive sound, in the scenario where the external microphone switch is turned off, the application can still obtain audio data and implement the receiving function, thereby improving the user experience.
[0173] Optional, in Figure 7 On the basis of the corresponding embodiment, at the first moment, the switch state of the external microphone stored in the electronic device is the open state, and from the second moment to the fourth moment, the switch state of the external microphone stored in the electronic device is the closed state.
[0174] In the embodiment of the present application, the electronic device can save the switch state of the external microphone by referring to the above Figure 6 The relevant descriptions in step S601 and step S602 of the corresponding embodiment are not repeated here.
[0175] The electronic device saves the switch state of the external microphone and can record the switch state of the external microphone in real time, so that it is convenient for subsequent electronic devices to query the switch state of the external microphone.
[0176] Optional, in Figure 7 On the basis of the corresponding embodiment, a third application for managing the external microphone is installed in the electronic device, and the method may also include: when the switch of the external microphone is turned on, the third application transmits the switch state of the external microphone to the electronic device as being on, and the electronic device saves the switch state of the external microphone as being on; when the switch of the external microphone is turned off, the third application transmits the switch state of the external microphone to the electronic device as being off, and the electronic device saves the switch state of the external microphone as being off.
[0177] In the embodiment of the present application, the third application can be understood as an application for managing an external microphone. The third application can be understood as the above Figure 2The microphone mixer application in the corresponding embodiment.
[0178] The specific process of the third application transmitting the switch state of the external microphone to the electronic device can refer to the above Figure 6 The relevant description in step S601 of the corresponding embodiment is not repeated here.
[0179] When the user turns on or off the switch of the external microphone, the third application can detect the switch status of the external microphone in real time and report it to the electronic device, so that the correct switch status of the external microphone can be saved in the electronic device.
[0180] Optional, in Figure 7 On the basis of the corresponding embodiment, the electronic device includes an audio management module AudioManager and an audio processing service AudioFlinger, and the third application transmits the switch state of the external microphone to the electronic device as an on state, and the electronic device saves the switch state of the external microphone as an on state, which may include: the third application calls the setParameters() interface of the audio management module AudioManager to transmit the switch state of the external microphone to the audio processing service AudioFlinger, wherein the parameters of the setParameters() interface include parameters for indicating that the switch state of the external microphone is an on state; the audio processing service AudioFlinger saves the switch state of the external microphone as an on state; the third application transmits the switch state of the external microphone to the electronic device as a closed state, and the electronic device saves the switch state of the external microphone as a closed state, which may include: the third application calls the setParameters() interface of the audio management module AudioManager to transmit the switch state of the external microphone to the audio processing service AudioFlinger, wherein the parameters of the setParameters() interface include parameters for indicating that the switch state of the external microphone is a closed state; the audio processing service AudioFlinger saves the switch state of the external microphone as a closed state.
[0181] In the embodiment of the present application, the specific process of the third application transmitting the switch state of the external microphone to the electronic device can refer to the above Figure 6 The relevant description in step S601 of the corresponding embodiment is not repeated here.
[0182] According to the switch state of the external microphone reported by the third application, the electronic device can refresh the switch state of the external microphone in real time, so that the electronic device can obtain the correct switch state of the external microphone.
[0183] Optional, in Figure 7On the basis of the corresponding embodiment, before the second application uses the built-in microphone in the electronic device to receive sound, it can also include: the electronic device determines that an external microphone is connected, and the electronic device selects the external microphone as the hardware receiving device; the electronic device obtains that the switch state of the external microphone is off, and the electronic device reselects the built-in microphone as the hardware receiving device.
[0184] In the embodiment of the present application, the hardware sound receiving device can be understood as the above Figure 6 The recording device in the corresponding embodiment.
[0185] The process of selecting an external microphone as a hardware sound receiving device for an electronic device can refer to the above Figure 6 The relevant descriptions in step S603 to step S606 of the corresponding embodiment are not repeated here.
[0186] The electronic device obtains the switch state of the external microphone as the off state, and the process of the electronic device reselecting the built-in microphone as the hardware sound receiving device can refer to the above Figure 6 The relevant descriptions in step S607 to step S608 of the corresponding embodiment are not repeated here.
[0187] When an external microphone is not available, the electronic device can use the built-in microphone to pick up the recording data. In this way, the user does not need to frequently plug and unplug the microphone receiver or frequently switch the external microphone on and off, so that the application can obtain the recording data, thereby realizing the recording function and improving the user experience.
[0188] Optional, in Figure 7On the basis of the corresponding embodiments, the electronic device includes an audio policy engine module AudioPolicyEngine and an audio policy management module AudioPolicyManager. Before the electronic device determines that an external microphone is connected and the electronic device selects the external microphone as a hardware sound receiving device, it may also include: a second application calls the getInputForAttr() interface of the audio policy management module AudioPolicyManager to obtain the hardware sound receiving device, wherein the parameters of the getInputForAttr() interface include the audio source; the audio policy engine module AudioPolicyEngine obtains the available hardware sound receiving devices in the electronic device; the electronic device determines that an external microphone is connected and the electronic device selects the external microphone as the hardware sound receiving device, which may include: the audio policy engine module AudioPolicyEngine e determines that the available hardware sound receiving devices include an external microphone, and the audio policy engine module AudioPolicyEngine selects the external microphone as the hardware sound receiving device from the available hardware sound receiving devices according to the audio source and the priority policy; the electronic device obtains that the switch state of the external microphone is in the off state, and the electronic device reselects the built-in microphone as the hardware sound receiving device, which may include: the audio policy engine module AudioPolicyEngine calls the getParameters() interface of the audio management module AudioManager to obtain the switch state of the external microphone from the audio processing service AudioFlinger; the audio policy engine module AudioPolicyEngine determines that the switch state of the external microphone is in the off state, and the audio policy engine module AudioPolicyEngine reselects the built-in microphone as the hardware sound receiving device.
[0189] In the embodiment of the present application, the process of the specific electronic device selecting the external microphone as the hardware sound receiving device, the electronic device obtaining the switch state of the external microphone as the off state, and the electronic device reselecting the built-in microphone as the hardware sound receiving device can refer to the above Figure 6 The relevant descriptions in step S603 to step S608 of the corresponding embodiment are not repeated here.
[0190] Electronic devices give priority to external microphones, which can make the selection of hardware sound receiving devices meet the above requirements. Figure 6 Priority strategy in the corresponding embodiment: When the external microphone is unavailable, the electronic device can use the built-in microphone to pick up the recording data, so that the application can obtain the recording data, thereby realizing the recording function and improving the user experience.
[0191] Optional, in Figure 7On the basis of the corresponding embodiments, the audio source is different, and the audio policy engine module AudioPolicyEngine has different priority strategies for selecting hardware audio receiving devices.
[0192] In the embodiment of the present application, the application can determine the selected audio source according to the needs of the usage scenario, so that the electronic device can provide the application with a hardware audio device that is more suitable for the usage scenario.
[0193] Optional, in Figure 7 On the basis of the corresponding embodiments, when the second application is used in a singing scene or a recording scene and the audio source of the second application is AUDIO_SOURCE_MIC, the audio policy engine module AudioPolicyEngine selects the priority strategy of the hardware sound receiving device including: the priority of the Bluetooth headset device is higher than the priority of the external microphone, and the priority of the external microphone is higher than the priority of the built-in microphone; or, when the second application is used in a recording scene and the audio source of the second application is AUDIO_SOURCE_CAMCORDER, the audio policy engine module AudioPolicyEngine selects the priority strategy of the hardware sound receiving device including: the priority of the built-in back microphone of the electronic device is higher than the priority of the built-in bottom microphone of the electronic device, and the priority of the built-in bottom microphone is higher than the priority of the external microphone.
[0194] In the embodiment of the present application, the priority strategy of the specific audio policy engine module AudioPolicyEngine to select the recording device can refer to the above Figure 6 The relevant description in step S605 of the corresponding embodiment is not repeated here.
[0195] The application can determine the selected audio source according to the needs of the usage scenario, so that the electronic device can provide the application with a recording device that is more suitable for the usage scenario.
[0196] Optional, in Figure 7On the basis of the corresponding embodiment, before the first moment, it may also include: the USB driver of the kernel layer of the electronic device determines that the external microphone is inserted, and the USB driver transmits a message to the USB driver module of the hardware abstraction layer to indicate that the external microphone is inserted; the USB driver module of the hardware abstraction layer transmits a message to the USB manager UsbManager of the application framework layer to indicate that the external microphone is inserted; the USB manager UsbManager determines that the external microphone is an audio device, and transmits a message to the USB type audio device module UsbAlsaManager to indicate that the external microphone is an audio device; the USB type audio device module UsbAlsaManager initializes the USB type audio device object UsbAlsaDevice, and the USB type audio device object UsbAlsaDevice transmits a message to the audio manager AudioManager of the application framework layer to indicate that the USB type audio device object UsbAlsaDevice is in place; the audio manager AudioManager updates the audio device based on the USB type audio device object UsbAlsaDevice.
[0197] In the embodiment of the present application, the process of the electronic device identifying the external microphone can refer to the above Figure 5 The relevant descriptions in the corresponding embodiments are not repeated here. After the electronic device recognizes the external microphone, the audio device can be updated, so that the electronic device can use the external microphone to pick up audio data.
[0198] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0199] The above mainly introduces the solution provided by the embodiment of the present application from the perspective of the method. In order to achieve the above functions, it includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should easily appreciate that, in combination with the method steps of each example described in the embodiment disclosed herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
[0200] The embodiment of the present application can divide the functional modules of the device implementing the method according to the above method example. For example, each functional module can be divided according to each function, or two or more functions can be integrated into one processing module. The integrated module can be implemented in the form of hardware or in the form of software functional modules. It should be noted that the division of modules in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.
[0201] like Figure 8 FIG. 8 is a schematic diagram of a chip structure provided by an embodiment of the present application. The chip 800 includes one or more (including two) processors 801 , a communication line 802 , a communication interface 803 and a memory 804 .
[0202] In some implementations, the memory 804 stores the following elements: executable modules or data structures, or a subset thereof, or an extended set thereof.
[0203] The method described in the above embodiment of the present application can be applied to the processor 801, or implemented by the processor 801. The processor 801 may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware or software instructions in the processor 801. The above processor 801 can be a general processor (for example, a microprocessor or a conventional processor), a digital signal processor (digital signal processing, DSP), an application specific integrated circuit (application specific integrated circuit, ASIC), a field-programmable gate array (field-programmable gate array, FPGA) or other programmable logic devices, discrete gates, transistor logic devices or discrete hardware components. The processor 801 can implement or execute the methods, steps and logic block diagrams related to each processing disclosed in the embodiment of the present application.
[0204] The steps of the method disclosed in the embodiment of the present application can be directly embodied as being executed by a hardware decoding processor, or can be executed by a combination of hardware and software modules in the decoding processor. Among them, the software module can be located in a mature storage medium in the field such as a random access memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable read only memory (EEPROM). The storage medium is located in the memory 804, and the processor 801 reads the information in the memory 804 and completes the steps of the above method in combination with its hardware.
[0205] The processor 801 , the memory 804 , and the communication interface 803 may communicate with each other via the communication line 802 .
[0206] In the above embodiments, the instructions stored in the memory for execution by the processor may be implemented in the form of a computer program product, wherein the computer program product may be pre-written in the memory, or may be downloaded and installed in the memory in the form of software.
[0207] The embodiment of the present application also provides a computer program product including one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function according to the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions may be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions may be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium may be any available medium that a computer can store or a data storage device such as a server or data center that includes one or more available media integrated. For example, the available medium may include a magnetic medium (e.g., a floppy disk, a hard disk or a tape), an optical medium (e.g., a digital versatile disc (DVD)), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0208] The present application also provides a computer-readable storage medium. The methods described in the above embodiments can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. Computer-readable media may include computer storage media and communication media, and may also include any medium that can transfer a computer program from one place to another. The storage medium may be any target medium that can be accessed by a computer.
[0209] As a possible design, the computer readable medium may include a compact disc read-only memory (CD-ROM), RAM, ROM, EEPROM or other optical disc storage; the computer readable medium may include a magnetic disk storage or other magnetic disk storage device. Moreover, any connection line may also be appropriately referred to as a computer readable medium. For example, if the software is transmitted from a website, server or other remote source using a coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology (such as infrared, radio and microwave), the coaxial cable, fiber optic cable, twisted pair, DSL or wireless technology such as infrared, radio and microwave are included in the definition of medium. Disk and disc as used herein include compact disc (CD), laser disc, optical disc, digital versatile disc (DVD), floppy disk and Blu-ray disc, where disks usually reproduce data magnetically, while optical discs reproduce data optically using lasers.
[0210] The embodiments of the present application are described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processing unit of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processing unit of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
Claims
1. An audio processing method, characterized in that: The method comprises: At a first moment, the electronic device is connected to an external microphone, the external microphone includes a switch, the switch is in an on state, and a first application of the electronic device uses the external microphone to receive sound; At a second moment, the electronic device is connected to the external microphone, the switch is in an off state, and the electronic device exits the first application, and the second moment is later than the first moment; At a third moment, the electronic device is connected to the external microphone, the switch is in an off state, and the electronic device starts a second application, and the third moment is later than the second moment; At a fourth moment, the electronic device is connected to the external microphone, the switch is in an off state, and the second application uses the built-in microphone of the electronic device to receive audio, and the fourth moment is later than the third moment; The electronic device is installed with a third application for managing the external microphone, and the method further includes: When the switch of the external microphone is turned on, the third application transmits to the electronic device that the switch state of the external microphone is on, and the electronic device saves the switch state of the external microphone as on; When the switch of the external microphone is turned off, the third application transmits to the electronic device that the switch state of the external microphone is the off state, and the electronic device saves the switch state of the external microphone as the off state.
2. The method according to claim 1, characterized in that At the first moment, the switch state of the external microphone stored in the electronic device is an on state, and from the second moment to the fourth moment, the switch state of the external microphone stored in the electronic device is an off state.
3. The method according to claim 1, characterized in that The electronic device includes an audio management module AudioManager and an audio processing service AudioFlinger. The third application transmits to the electronic device that the switch state of the external microphone is on, and the electronic device stores the switch state of the external microphone as on, including: The third application calls the setParameters() interface of the audio management module AudioManager to pass the switch state of the external microphone to the audio processing service AudioFlinger, wherein the parameters of the setParameters() interface include a parameter for indicating that the switch state of the external microphone is on; The audio processing service AudioFlinger saves the switch state of the external microphone as an on state; The third application transmits to the electronic device that the switch state of the external microphone is in the off state, and the electronic device stores the switch state of the external microphone as the off state, including: The third application calls the setParameters() interface of the audio management module AudioManager to pass the switch state of the external microphone to the audio processing service AudioFlinger, wherein the parameters of the setParameters() interface include a parameter for indicating that the switch state of the external microphone is off; The audio processing service AudioFlinger saves the switch state of the external microphone as an off state.
4. The method according to any one of claims 1 to 3, characterized in that Before the second application uses the built-in microphone of the electronic device to receive sound, the second application further includes: The electronic device determines that the external microphone is connected, and selects the external microphone as a hardware sound receiving device; The electronic device obtains that the switch state of the external microphone is off, and the electronic device reselects the built-in microphone as the hardware sound receiving device.
5. The method according to claim 4, characterized in that The electronic device includes an audio policy engine module AudioPolicyEngine and an audio policy management module AudioPolicyManager, Before the electronic device determines that the external microphone is connected and selects the external microphone as a hardware sound receiving device, the electronic device further includes: The second application calls the getInputForAttr() interface of the audio policy management module AudioPolicyManager to obtain the hardware audio device, wherein the parameters of the getInputForAttr() interface include the audio source; The audio policy engine module AudioPolicyEngine obtains the hardware audio receiving device available in the electronic device; The electronic device determines that the external microphone is connected, and selects the external microphone as a hardware sound receiving device, including: The audio policy engine module AudioPolicyEngine determines that the available hardware sound receiving devices include the external microphone, and the audio policy engine module AudioPolicyEngine selects the external microphone as the hardware sound receiving device from the available hardware sound receiving devices according to the audio source and the priority policy; The electronic device obtains that the switch state of the external microphone is off, and the electronic device reselects the built-in microphone as the hardware sound receiving device, including: The audio policy engine module AudioPolicyEngine calls the getParameters() interface of the audio management module AudioManager to obtain the switch status of the external microphone from the audio processing service AudioFlinger; The audio policy engine module AudioPolicyEngine determines that the switch state of the external microphone is off, and the audio policy engine module AudioPolicyEngine reselects the built-in microphone as the hardware sound receiving device.
6. The method according to claim 5, characterized in that The audio source is different, and the priority strategy of the audio policy engine module AudioPolicyEngine in selecting the hardware audio receiving device is different.
7. The method according to claim 5 or 6, characterized in that When the second application is used in a singing scenario or a recording scenario, and the audio source of the second application is AUDIO_SOURCE_MIC, the priority strategy for selecting the hardware audio receiving device by the audio policy engine module AudioPolicyEngine includes: the priority of the Bluetooth headset device is higher than the priority of the external microphone, and the priority of the external microphone is higher than the priority of the built-in microphone; Alternatively, when the second application is used in a recording scenario and the audio source of the second application is AUDIO_SOURCE_CAMCORDER, the audio policy engine module AudioPolicyEngine selects the priority strategy of the hardware audio receiving device, including: the priority of the built-in back microphone of the electronic device is higher than the priority of the built-in bottom microphone of the electronic device, and the priority of the built-in bottom microphone is higher than the priority of the external microphone.
8. The method according to any one of claims 1-3, 5-6, characterized in that: Before the first moment, it also includes: A USB driver of the kernel layer of the electronic device determines that the external microphone is inserted, and the USB driver transmits a message indicating that the external microphone is inserted to a USB driver module of the hardware abstraction layer; The USB driver module of the hardware abstraction layer transmits the message for indicating that the external microphone is plugged in to the USB manager UsbManager of the application framework layer; The USB manager UsbManager determines that the external microphone is an audio device, and transmits a message indicating that the external microphone is an audio device to the USB type audio device module UsbAlsaManager; The USB type audio device module UsbAlsaManager initializes the USB type audio device object UsbAlsaDevice, and the USB type audio device object UsbAlsaDevice transmits a message indicating that the USB type audio device object UsbAlsaDevice is in place to the audio manager AudioManager of the application framework layer; The audio manager AudioManager updates the audio device based on the USB type audio device object UsbAlsaDevice.
9. An electronic device, characterized in that: include: A memory and a processor, the memory being used to store a computer program, and the processor being used to execute the computer program to perform the method according to any one of claims 1 to 8.
10. A computer-readable storage medium, characterized in that The computer-readable storage medium stores instructions, which, when executed, enable a computer to perform the method according to any one of claims 1 to 8.
11. A computer program product, characterized in that The device comprises a computer program, which, when executed, causes the electronic device to perform the method according to any one of claims 1 to 8.
