Audio control method, electronic equipment and readable storage medium

By introducing audio control methods into electronic devices, detecting the wearing status of Bluetooth headsets and switching the audio streaming channel, the problem of interruption of sound output after the user takes off and puts on the Bluetooth headset again is solved, and the user experience is improved.

CN119497059APending Publication Date: 2025-02-21HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311051393.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-08-18
Publication Date
2025-02-21

AI Technical Summary

Technical Problem

When using Bluetooth headsets to make calls, after the user takes off and puts on the Bluetooth headset again, some instant messaging software cannot re-establish the communication link, resulting in the inability to output the sound and poor user experience.

Method used

By introducing an audio control method in electronic devices, the Bluetooth module and the audio module work together to detect the wearing status of the Bluetooth headset, and switch the audio streaming channel to the earpiece or speaker after the headset is removed, and re-establish it after the headset is worn again. SCO link between Bluetooth headset and electronic devices.

Benefits of technology

Ensure that the sound output channel can be switched normally after the Bluetooth headset is taken off and re-weared, solving the problem of sound output interruption and improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119497059A_ABST
    Figure CN119497059A_ABST
Patent Text Reader

Abstract

The invention discloses an audio control method, electronic equipment and a readable storage medium, relates to the technical field of communication, and aims to provide an audio control method for a virtual call when a Bluetooth headset is taken off and worn in the process of using the Bluetooth headset to carry out the virtual call. In the embodiment of the invention, the Bluetooth module of the electronic equipment can send the first information and then send the second information to the application performing the virtual call, so that after the Bluetooth earphone is worn again, the application performing the virtual call can determine that the HFP connection is a process from disconnection to establishment according to the received first information and the received second information; the electronic device can send a first instruction to the audio module and start to establish an SCO link, so that the electronic device can switch a channel for outputting an audio stream to the Bluetooth headset after the Bluetooth headset is taken off and worn again in the process of using the Bluetooth headset to carry out a call, and the audio stream of a voice call or a video call is output through the Bluetooth headset. The switching of the sound channel accords with the expectation of the user, and the user experience is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

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

[0002] With the development of technology, applications installed on electronic devices usually include instant messaging software, which has functions such as video calls or voice calls. Users can use instant messaging software to talk with colleagues and friends. When using instant messaging software to make calls, users can wear Bluetooth headsets to communicate with the other party and hear the other party's voice through the Bluetooth headset.

[0003] During a call, the user may take off the Bluetooth headset and put it back on. After the user puts on the Bluetooth headset again, the instant messaging software needs to establish a communication link with the Bluetooth headset so that the other party's voice can be output from the Bluetooth headset. However, in actual applications, it is found that after the user takes off the Bluetooth headset and puts it back on, some third-party instant messaging software cannot establish a communication link with the Bluetooth headset, resulting in the other party's voice not being output from the Bluetooth headset after the user puts on the Bluetooth headset again, which does not meet the user's expectations and leads to a poor user experience. Summary of the invention

[0004] The present application provides an audio control method, an electronic device and a readable storage medium, which can enable the sound to be output from the Bluetooth headset after the user takes off the Bluetooth headset and puts it on again during a call using the Bluetooth headset. The technical solution is as follows:

[0005] In a first aspect, an embodiment of the present application provides an audio control method, wherein an electronic device is connected to a Bluetooth headset through wireless communication, and the electronic device includes a Bluetooth module and an audio module, the method comprising: the electronic device is currently making a voice call or a video call, and outputs an audio stream in the voice call or the video call through the Bluetooth headset in a worn state; after the Bluetooth headset is taken off, the electronic device receives information that the Bluetooth headset is in an unworn state, and in response to receiving the information that the Bluetooth headset is in an unworn state, the audio module switches the channel for outputting the audio stream from the Bluetooth headset to an earpiece or a speaker in the electronic device, and outputs the audio stream in the voice call or the video call through the earpiece or the speaker; after receiving the information that the Bluetooth headset is in an unworn state, after the Bluetooth headset is worn again, the electronic device receives information that the Bluetooth headset is in a worn state, and in response to receiving the information that the Bluetooth headset is in a worn state, the Bluetooth module sends a second information to an application making a voice call or a video call; before this, in response to receiving the information that the Bluetooth headset is in an unworn state or receiving the information that the Bluetooth headset is in a worn state after receiving the information that the Bluetooth headset is in an unworn state, the Bluetooth module sends a first information to the application making the voice call or the video call, wherein the first information indicates a Bluetooth hands-free protocol (Hands-Free) between the Bluetooth headset and the electronic device. The second information indicates that the HFP connection between the Bluetooth headset and the electronic device has been established.

[0006] The audio module receives a first instruction, which is sent to the audio module by an application for making a voice call or a video call in response to receiving a first message and a second message, and the first instruction is used to start establishing a synchronous connection oriented (SCO) link between the Bluetooth headset and the electronic device; in response to receiving the first instruction, the audio module sends a second instruction to the Bluetooth module, and the second instruction is used to instruct the Bluetooth module to start the SCO link for the voice call or the video call; in response to receiving the second instruction, the Bluetooth module establishes a SCO link with the Bluetooth headset; after the SCO link is successfully established, the audio module switches the channel for outputting the audio stream from the earpiece or the speaker to the Bluetooth headset, and outputs the audio stream in the voice call or the video call through the Bluetooth headset.

[0007] Based on the above technical solution, in the scenario where the Bluetooth headset is taken off and then worn again during a voice call or video call, compared to after the Bluetooth headset is worn again, the Bluetooth module only sends the second information to the application for the voice call or video call, and the application for the voice call or video call only receives the second information and cannot start to establish the SCO link. In the method provided in the embodiment of the present application, the Bluetooth module can first send the first information to the application for the voice call or video call and then send the second information, so that after the Bluetooth headset is worn again, the application for the voice call or video call can determine whether the HFP connection is from disconnection to establishment according to the first information and the second information received, and then can send the first instruction to the audio module to start to establish the SCO link, so that in the process of using the Bluetooth headset for a call, after the Bluetooth headset is taken off and worn again, the electronic device can switch the channel of the output audio stream to the Bluetooth headset, and output the audio stream of the voice call or video call through the Bluetooth headset, so that the switching of the sound channel meets the user's expectations and improves the user experience. In combination with the first aspect, in some implementations of the first aspect, the first instruction is an instruction for calling the startbluetoothsco interface.

[0008] In combination with the first aspect and the above implementations, in some implementations of the first aspect, the second instruction is an instruction for calling a startsCusingVirtualCall interface.

[0009] In combination with the first aspect and the above-mentioned implementation methods, in some implementation methods of the first aspect, after receiving information that the Bluetooth headset is not worn, in response to receiving the information that the Bluetooth headset is not worn, the Bluetooth module may send first information to the application for making a voice call or a video call; after receiving information that the Bluetooth headset is not worn, after receiving information that the Bluetooth headset is worn, in response to receiving the information that the Bluetooth headset is worn, the Bluetooth module sends second information to the application for making a voice call or a video call.

[0010] The Bluetooth module sends the second information to the application for the voice call or video call, and may send the second information to multiple applications in the electronic device, and the multiple applications include the application for the voice call or video call. In this way, if the voice call or video call of the application has ended before the Bluetooth headset is worn again after being taken off, if other applications are making calls after the Bluetooth headset is worn again, the audio stream can also be output through the Bluetooth headset, which can reduce the impact on other applications.

[0011] After receiving the information that the Bluetooth headset is not being worn, before sending the first information to the application making the voice call or video call, in response to receiving the information that the Bluetooth headset is not being worn, the Bluetooth module can determine whether the voice call or video call is in progress. Specifically, the Bluetooth module can obtain the output audio stream by calling the interface of the audio module, and determine whether the voice call or video call is in progress according to the type of the audio stream. If the voice call or video call is in progress, the identifier of the application making the voice call or video call is obtained, so as to send the first information to the application making the voice call or video call.

[0012] In combination with the first aspect and the above-mentioned implementation methods, in some implementation methods of the first aspect, in a case where information that the Bluetooth headset is in a worn state is received after information that the Bluetooth headset is not worn is received, in response to receiving the information that the Bluetooth headset is in a worn state, the Bluetooth module first sends the first information to the application for the voice call or video call, and then sends the second information.

[0013] In some implementations, before sending the first information to the application for the voice call or video call, the Bluetooth module may first determine the application for the voice call or video call, and determine whether the application for the voice call or video call is an application in the blacklist, and if it is an application in the blacklist, send the first information to the application for the voice call or video call. The blacklist is pre-set, and the applications in the blacklist cannot start to establish a SCO link after the Bluetooth headset is taken off and put on again.

[0014] In combination with the first aspect and the above implementations, in some implementations of the first aspect, after the Bluetooth module sends the second information to the application for the voice call or video call, it can determine whether the second instruction is received within a preset time; when the second instruction is not received within the preset time, the Bluetooth module automatically establishes a SCO link with the Bluetooth headset. In this way, it can be avoided that the SCO link is not established due to unexpected problems.

[0015] In the second aspect, the embodiment of the present application provides an audio control method, in which the electronic device and the Bluetooth headset are connected through wireless communication, and the electronic device includes a Bluetooth module and an audio module. The electronic device is currently making a voice call or a video call, and the audio stream in the voice call or the video call is output through the Bluetooth headset in the wearing state; after the Bluetooth headset is taken off, the electronic device receives information that the Bluetooth headset is in an unworn state, and in response to receiving the information that the Bluetooth headset is in an unworn state, the audio module switches the channel for outputting the audio stream from the Bluetooth headset to the handset or speaker in the electronic device, and outputs the audio stream in the voice call or the video call through the handset or the speaker. After receiving the information that the Bluetooth headset is in an unworn state, after the Bluetooth headset is worn again, the electronic device receives the information that the Bluetooth headset is in a wearing state, and in response to receiving the information that the Bluetooth headset is in a wearing state, the Bluetooth module sends a second information to multiple applications in the electronic device, and the second information indicates that the HFP connection between the Bluetooth headset and the electronic device has been established.

[0016] When the audio module does not receive the first instruction and a voice call or a video call is in progress, or when the Bluetooth module does not receive the second instruction and a voice call or a video call is in progress, the Bluetooth module establishes a SCO link with the Bluetooth headset; wherein the first instruction is used to start establishing a SCO link between the Bluetooth headset and the electronic device, and the second instruction is used to instruct the Bluetooth module to start the SCO link for the voice call or the video call; after the SCO link is successfully established, the audio module switches the channel for outputting the audio stream from the earpiece or the speaker to the Bluetooth headset, and outputs the audio stream in the voice call or the video call through the Bluetooth headset.

[0017] Based on the above technical solution, in the scenario of wearing a Bluetooth headset for a voice call or a video call, after the Bluetooth headset is taken off and put on again, the Bluetooth module responds to receiving the information that the Bluetooth headset is in the wearing state, and sends the second information to multiple applications in the electronic device. If a voice call or a video call is in progress, the application that is making the voice call or the video call can receive the second information, and the audio module does not receive the first instruction or the Bluetooth module does not receive the second instruction, indicating that the application making the voice call or the video call does not start to establish a SCO link after receiving the second information, then the Bluetooth module or the audio module of the electronic device itself can establish a SCO link by itself, and after the SCO link is successfully established, the channel for outputting the audio stream is switched to the Bluetooth headset, and the audio stream of the voice call or the video call is output through the Bluetooth headset, so that the switching of the sound channel meets the user's expectations and improves the user experience.

[0018] In conjunction with the second aspect, in some implementations of the second aspect, the first instruction is an instruction for calling a startbluetoothsco interface. In conjunction with the second aspect and the above implementations, in some implementations of the first aspect, the second instruction is an instruction for calling a startscousingvirtualcall interface.

[0019] In combination with the second aspect, in certain implementations of the second aspect, when the audio module does not receive the first instruction and a voice call or video call is in progress, the audio module may send a second instruction to the Bluetooth module, and in response to receiving the second instruction, the Bluetooth module establishes a SCO link with the Bluetooth headset.

[0020] Specifically, when the audio module does not receive the first instruction, the audio module can determine whether a voice call or a video call is in progress. When the voice call or the video call is in progress, the audio module sends a second instruction to the Bluetooth module. In response to receiving the second instruction, the Bluetooth module establishes a SCO link with the Bluetooth headset. The audio module can determine whether a voice call or a video call is in progress according to the type of the audio stream.

[0021] In combination with the second aspect and the above-mentioned implementation manner, in some implementation manners of the second aspect, when the audio module does not receive the first instruction and a voice call or a video call is in progress, the audio module sends a second instruction to the Bluetooth module, including: when the audio module does not receive the first instruction and a voice call or a video call is in progress, and the application for the voice call or the video call is a preset application, the audio module sends the second instruction to the Bluetooth module. Specifically, when a voice call or a video call is in progress, the audio module can determine whether the application for the voice call or the video call is a preset application, and the preset application is an application that does not send the first instruction to the audio module when the second information is received; when the application for the voice call or the video call is a preset application, the audio module sends the second instruction to the Bluetooth module.

[0022] In one implementation, when the audio module does not receive the first instruction and a voice call or video call is in progress, or when the audio module does not receive the first instruction and a voice call or video call is in progress and the application for the voice call or video call is a preset application, the audio module may also determine whether the priority of the earpiece or speaker is lower than that of the Bluetooth headset; when the priority of the earpiece or speaker is lower than that of the Bluetooth headset, the audio module sends a second instruction to the Bluetooth module.

[0023] In combination with the second aspect and the above-mentioned implementation methods, in some implementation methods of the second aspect, when the Bluetooth module does not receive the second instruction, the Bluetooth module determines whether a voice call or a video call is in progress. If a voice call or a video call is in progress, the Bluetooth module establishes a SCO link with the Bluetooth headset.

[0024] In one implementation, when a voice call or video call is in progress and the application for the voice call or video call is a preset application, the Bluetooth module establishes a SCO link with the Bluetooth headset. That is, when the Bluetooth module determines that a voice call or video call is in progress, it can determine whether the application for the voice call or video call is a preset application, and the preset application is an application that does not send the first instruction to the audio module when receiving the second information; when the application for the voice call or video call is the preset application, the Bluetooth module establishes a SCO link with the Bluetooth headset.

[0025] In one implementation, when the application for making a voice call or a video call is a preset application, the Bluetooth module may also determine whether the priority of the earpiece or the speaker is lower than that of the Bluetooth headset; when the priority of the earpiece or the speaker is lower than that of the Bluetooth headset, the Bluetooth module establishes a SCO link with the Bluetooth headset.

[0026] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; one or more memories; the memory stores one or more programs, and when one or more programs are executed by the processor, the electronic device executes any possible method of the first and second aspects above.

[0027] In a fourth aspect, an embodiment of the present application provides a device, which is included in an electronic device, and the device has the function of realizing the above-mentioned aspects and the behavior of the electronic device in the possible implementation methods of the above-mentioned aspects. The function can be implemented by hardware, or the corresponding software can be implemented by hardware. The hardware or software includes one or more modules or units corresponding to the above-mentioned functions. For example, a display module or unit, a detection module or unit, a processing module or unit, etc.

[0028] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the computer-readable storage medium is run on a computer, the computer executes the method described in the first aspect or the method described in the second aspect.

[0029] In a sixth aspect, an embodiment of the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute the method described in the first aspect or the method described in the second aspect.

[0030] The technical effects obtained by the third, fourth, fifth and sixth aspects are similar to those obtained by the corresponding technical means in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0031] Figure 1 A schematic diagram of a scenario of using a Bluetooth headset to make a video call provided in an embodiment of the present application is shown;

[0032] Figure 2 A schematic diagram of another scenario of using a Bluetooth headset for a video call provided in an embodiment of the present application is shown;

[0033] Figure 3 A schematic diagram of another scenario of using a Bluetooth headset for a video call provided in an embodiment of the present application is shown;

[0034] Figure 4 A schematic diagram of the structure of a Bluetooth headset 300 provided in an embodiment of the present application is shown;

[0035] Figure 5 A schematic diagram of a flow chart of an audio control method provided in an embodiment of the present application is shown;

[0036] Figure 6 A flowchart of another audio control method provided in an embodiment of the present application is shown;

[0037] Figure 7 A flowchart of another audio control method provided in an embodiment of the present application is shown;

[0038] Figure 8 A flowchart of another audio control method provided in an embodiment of the present application is shown;

[0039] Fig. 9 A flowchart showing another example of an audio control method provided in an embodiment of the present application is shown.

[0040] Fig.10 A schematic diagram of the structure of an electronic device 100 provided in an embodiment of the present application is shown;

[0041] Fig.11 An example of a software structure block diagram provided in an embodiment of the present application is shown;

[0042] Fig.12 A structural schematic diagram of another example of a Bluetooth headset 300 provided in an embodiment of the present application is shown. DETAILED DESCRIPTION

[0043] In order to make the purpose, technical scheme and advantages of the present application clearer, the implementation mode of the present application will be further described in detail below with reference to the accompanying drawings. Hereinafter, the terms "first" and "second" are used for descriptive purposes only and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the present embodiment, unless otherwise specified, the meaning of "multiple" is two or more.

[0044] Electronic devices generally have a variety of applications installed, such as social applications (such as WeChat, QQ), game applications, office applications (such as DingTalk), etc. These third-party applications usually have functions such as video calls or voice calls, and users can use these third-party applications to talk with colleagues and friends. Among them, video calls or voice calls made through third-party applications can be called virtual calls. Different from virtual calls, video calls or voice calls based on operators and subscriber identification modules (SIM) can be called ordinary calls.

[0045] When making a virtual call, the user can wear a Bluetooth headset and use it to communicate with the other party and hear the other party's voice through the Bluetooth headset. The Bluetooth headset supports the wearing recognition function, that is, the Bluetooth headset can detect whether the user is wearing the Bluetooth headset. During a call, the user may take off the Bluetooth headset and put it on again, and the sound output channel will change depending on whether the Bluetooth headset is worn. However, in actual use, it is found that in some scenarios, the change of the sound output channel does not meet the user's expectations.

[0046] For example, Figure 1 FIG. 1 shows a schematic diagram of a scenario of using a Bluetooth headset to make a video call provided by an embodiment of the present application, taking a mobile phone as an example. Figure 1 As shown, the same application, such as QQ, is installed on the electronic device 100 and the electronic device 200. When using the electronic device 100, user 1 can initiate a video call request to user 2 who is using the electronic device 200. After user 2 accepts the video call request, user 1 and user 2 can use QQ to make a video call. Alternatively, when using the electronic device 100, user 1 can receive a video call request from user 2. After user 1 accepts the video call request, user 1 and user 2 can use QQ to make a video call. Before establishing a video call, the electronic device 100 may or may not be connected to the Bluetooth headset 300, and the user may or may not be wearing the Bluetooth headset 300.

[0047] If the electronic device 100 is not connected to the Bluetooth headset 300, after the video call is established, the other party's voice will be output through the receiver. During the video call, the user can turn on the Bluetooth headset 300, and the electronic device 100 and the Bluetooth headset 300 are connected through wireless communication technology. After the electronic device 100 and the Bluetooth headset 300 are connected, if the user wears the Bluetooth headset, the sound output channel changes from the receiver to the Bluetooth headset, and the other party's voice is output through the Bluetooth headset.

[0048] In another scenario, before the video call is established, the electronic device 100 has established a connection with the Bluetooth headset 300. If the user has worn the Bluetooth headset 300, the voice of the other party will be output through the Bluetooth headset 300 after the video call is established. If the user does not wear the Bluetooth headset 300 (for example, the Bluetooth headset is placed on the table and not stored in the headset box), the voice of the other party will be output through the receiver after the video call is established. If the user wears the Bluetooth headset 300 afterwards, the output channel of the sound changes from the receiver to the Bluetooth headset, and the voice of the other party is output through Bluetooth 300. It should be noted that the above is only an exemplary description. When the Bluetooth headset is taken off, the sound output channel can be a speaker or other device that can output sound in addition to the receiver.

[0049] Figure 2 A schematic diagram of a scenario of putting on and taking off a Bluetooth headset during a video call provided by an embodiment of the present application is shown. The current user is using a Bluetooth headset for a video call, and the sound is output from the Bluetooth headset. If the user takes off the Bluetooth headset during the video call (for example, takes off the Bluetooth headset and places the Bluetooth headset at hand, not stored in the headset box), the output channel of the sound will be changed from the Bluetooth headset to the earpiece of the electronic device, and the other party's voice will be output through the earpiece. If the user puts on the Bluetooth headset again before the video call ends, the output channel of the sound is expected to change from the earpiece of the electronic device to the Bluetooth headset, but in actual situations, the sound may be output through the earpiece instead of the Bluetooth headset.

[0050] Among them, a synchronous connection oriented (SCO) link needs to be established between the application and the Bluetooth headset in order to use the Bluetooth headset for virtual calls. The SCO link is used for synchronous voice transmission and supports two-way transmission of audio data. For example, when the electronic device sends audio data to the Bluetooth headset via the SCO link, the Bluetooth headset can also send audio data to the electronic device via the SCO link.

[0051] After the user takes off the Bluetooth headset, the SCO link between the application and the Bluetooth headset will be disconnected. When the user puts on the Bluetooth headset again, the application needs to actively establish a SCO link with the Bluetooth headset. Specifically, after the Bluetooth headset is put on again, the application needs to monitor the broadcasts sent by the Bluetooth of the electronic device and respond to the monitored broadcasts to actively establish a SCO link. In other words, if the user takes off the Bluetooth headset and then puts on the Bluetooth headset before the virtual call ends, whether the sound output channel can be changed from the earpiece of the electronic device to the Bluetooth headset depends on the implementation of the application.

[0052] However, in actual situations, the applications installed in electronic devices usually include third-party applications, and the implementation logic of each third-party application is often different. Due to some factors, for example, some third-party applications may not respond to the broadcasts sent by Bluetooth due to internal reasons, or some third-party applications do not support monitoring the broadcasts sent by Bluetooth, or some third-party applications cannot identify the broadcasts sent by Bluetooth, etc., after the user takes off the Bluetooth headset and puts on the Bluetooth headset again, the third-party application does not establish a SCO link with the Bluetooth headset, which further causes the electronic device to be unable to output the other party's voice in the virtual call through the Bluetooth headset. In short, for some third-party applications, during the virtual call, after the user takes off the Bluetooth headset and puts on the Bluetooth headset again, the sound output channel cannot be switched from the earpiece of the electronic device to the Bluetooth headset, which cannot meet the user's expectations, resulting in a poor user experience.

[0053] In view of this, an embodiment of the present application provides an audio control method, wherein an electronic device and a Bluetooth headset are connected via wireless communication, and the electronic device includes a Bluetooth module and an audio module, and the Bluetooth headset supports a wearing recognition function and can identify whether it is being worn. The user wears a Bluetooth headset and a virtual call is in progress, and the electronic device outputs the audio stream in the virtual call through the Bluetooth headset; during the virtual call, the user can take off and put on the headset, and after the Bluetooth headset is taken off, the electronic device receives information that the Bluetooth headset is not worn, and in response to receiving the information that the Bluetooth headset is not worn, the audio module switches the channel for outputting the audio stream from the Bluetooth headset to the earpiece or speaker in the electronic device, and outputs the audio stream in the virtual call through the earpiece or speaker; after the Bluetooth headset is worn again, the electronic device receives information that the Bluetooth headset is in a worn state, and in response to receiving the information that the Bluetooth headset is in a worn state, the Bluetooth module sends second information to the application making the virtual call; before this, in response to receiving the information that the Bluetooth headset is not worn or receiving the information that the Bluetooth headset is worn after receiving the information that the Bluetooth headset is not worn, the Bluetooth module sends first information to the application making the virtual call, the first information indicating that the Bluetooth Hands-Free Profile (HFP) connection between the Bluetooth headset and the electronic device is disconnected, and the second information indicating that the HFP connection between the Bluetooth headset and the electronic device has been established. The audio module receives a first instruction, which is sent to the audio module by the application for making a virtual call in response to receiving the first information and receiving the second information, and the first instruction is used to start establishing a SCO link between the Bluetooth headset and the electronic device; in response to receiving the first instruction, the audio module sends a second instruction to the Bluetooth module, and the second instruction is used to instruct the Bluetooth module to start the SCO link for a voice call or a video call; in response to receiving the second instruction, the Bluetooth module establishes a SCO link with the Bluetooth headset; after the SCO link is successfully established, the audio module switches the channel for outputting the audio stream from the handset or the speaker to the Bluetooth headset, and outputs the audio stream in the virtual call through the Bluetooth headset. After the SCO link is established, the Bluetooth module or the audio module provides a routing function to transfer audio data between the Bluetooth headset and the third-party application.

[0054] In the method provided in the embodiment of the present application, after the Bluetooth headset is worn again, the application for the virtual call can determine that the HFP connection is in the process of being disconnected and established based on the first information received and the second information received, and then can send a first instruction to the audio module to start establishing the SCO link. Therefore, in the process of using the Bluetooth headset for the virtual call, after the Bluetooth headset is taken off and worn again, the electronic device can switch the channel for outputting the audio stream to the Bluetooth headset, and output the audio stream of the virtual call through the Bluetooth headset, so that the switching of the sound channel meets the user's expectations and improves the user experience.

[0055] In some implementations, if the Bluetooth headset is taken off and then worn again, after receiving information that the Bluetooth headset is not worn, in response to receiving information that the Bluetooth headset is worn, the Bluetooth module can send second information to multiple applications. If a voice call or video call is in progress, and the application making the voice call or video call has not started to establish a SCO link, the electronic device's own Bluetooth module or audio module can establish a SCO link by itself. After the SCO link is successfully established, the audio module switches the channel for outputting the audio stream to the Bluetooth headset, and outputs the audio stream of the voice call or video call through the Bluetooth headset, so that the switching of the sound channel meets the user's expectations, thereby improving the user experience.

[0056] Based on the audio control method provided in the embodiment of the present application, Figure 3 A schematic diagram of a scenario of using a Bluetooth headset for a video call provided by an embodiment of the present application is shown. The same application, such as QQ, is installed on the electronic device 100 and the electronic device 200. User 1 and user 2 can use QQ to make a video call. When the video call has been established, the electronic device 100 has established a connection with the Bluetooth headset 300, and the user wears the Bluetooth headset 300, and the other party's voice is output through the Bluetooth headset 300. If the user takes off the Bluetooth headset 300 (not stored in the headset box) during the video call, the output channel of the sound is changed from the Bluetooth headset 300 to the earpiece of the electronic device 100, and the other party's voice is output through the earpiece. When the video call is not over, the user puts on the Bluetooth headset 300 again, and the output channel of the sound is changed from the earpiece of the electronic device to the Bluetooth headset 300.

[0057] In addition, the electronic device can also display a video call interface, which can display a user image and some operation controls. A status bar can also be displayed above the video call interface, which can include: one or more signal strength indicators of mobile communication signals (or cellular signals), one or more signal strength indicators of wireless high fidelity (Wi-Fi) signals, a battery indicator of the mobile phone, a time indicator, a sound output channel indicator, etc. Figure 3 In the illustrated case, when the other party's voice is output through the Bluetooth headset 300, the indicator of the voice output channel displayed in the status bar is the Bluetooth headset. When the other party's voice is output through the receiver, the indicator of the voice output channel displayed in the status bar is the receiver.

[0058] The method provided in the embodiments of the present application can be applied to any electronic device that can install third-party applications, such as smart phones, tablet computers, laptops, ultra-mobile personal computers (UMPCs), personal digital assistants (PDAs), smart TVs, smart watches, vehicle-mounted devices, etc., and the type of electronic device is not limited here.

[0059] In the embodiment of the present application, the Bluetooth headset is a Bluetooth headset that supports wearing recognition, such as a true wireless stereo (TWS) headset. In order to better understand the audio control method provided in the embodiment of the present application, the following is an introduction taking a TWS headset as an example. Figure 4 A schematic diagram of a TWS headset is shown.

[0060] like Figure 4 As shown, the TWS headset includes an earphone body 401 for wearing on the user's left ear, an earphone body 402 for wearing on the user's right ear, and an earphone box 403. Bluetooth modules are provided in both the earphone body 401 and the earphone body 402, and data can be transmitted between the two through the Bluetooth protocol. The earphone body 401 can also be called the left earplug or the left earphone. The earphone body 402 can also be called the right earplug or the right earphone. From the appearance, there is no connecting wire between the earphone body 401 and the earphone body 402, which has the advantages of being easy to carry and easy to use. At least one touch control can be provided on the side of the earphone box 403, which can be used to trigger the TWS headset to reset pairing or charge the TWS headset.

[0061] TWS earphones support one of the left earphone or the right earphone to be used alone, and also support the left and right earphones to be used at the same time. Among them, the mode in which the left earphone or the right earphone is used alone can be called monaural mode, and the mode in which the left and right earphones are used at the same time can be called binaural mode. That is to say, the user can wear the left earphone alone for virtual calls or listen to music or answer / make calls and other audio services, or the user can wear the right earphone alone for virtual calls or listen to music or answer / make calls and other audio services. Alternatively, the user can also wear both the left and right earphones for virtual calls or listen to music or answer / make calls and other audio services.

[0062] TWS earphones support the wearing recognition function. When the user wears only the left earphone or only the right earphone, or wears both the left and right earphones, the TWS earphones can recognize that the current earphone is in the wearing state. When the user takes off both the left and right earphones, the TWS earphones can recognize that the current earphone is not in the wearing state. In some implementations, when a change in the wearing state of the Bluetooth earphone is detected, the Bluetooth earphone can send to the electronic device whether the current Bluetooth earphone is in the wearing state or not in the wearing state, so that the sound output channel can be adjusted inside the electronic device according to whether the Bluetooth earphone is worn.

[0063] Before using a Bluetooth headset for a virtual call, the Bluetooth headset and the electronic device need to be paired and connected. The Bluetooth headset and the electronic device can establish a connection through wireless communication technology. The following embodiments of this application take the establishment of a Bluetooth connection between an electronic device and a Bluetooth headset through Bluetooth technology in wireless communication technology as an example. The following is a brief introduction to the Bluetooth pairing process between an electronic device and a TWS headset.

[0064] Exemplarily, the user can turn on the Bluetooth of the electronic device by pulling down the notification bar, setting the entrance provided by the application, or other shortcuts. When the electronic device receives the user's instruction to turn on Bluetooth, the electronic device turns on the Bluetooth function, and then the electronic device can search and find nearby Bluetooth devices that can be paired. The user opens the lid of the earphone box where the TWS earphones are placed, and the electronic device can find the TWS earphones that can be paired, and displays the scanned TWS earphones in the "Available Devices" list. The user clicks on the TWS earphones in the "Available Devices" list. After the electronic device detects the user's click operation, it will pair with the TWS earphones selected by the user. After the pairing is successful, a Bluetooth connection for transmitting data can be established between the electronic device and the TWS earphone, for example, an asynchronous connectionless (ACL) connection, an HFP connection, etc.

[0065] In some implementations, the electronic device and the TWS headset have been successfully paired and connected. After the TWS headset is placed in the headset box and the headset box is closed, if the headset box is reopened, the electronic device and the TWS headset can establish a Bluetooth connection for transmitting data, eliminating the pairing process.

[0066] For example, Figure 5 A flow chart of an audio control method provided by an embodiment of the present application is shown. The scenario is that the TWS headset and the electronic device have been paired, and the user connects to a virtual call after wearing the TWS headset, wherein the third-party application is third-party application A as an example for explanation.

[0067] S501, the Bluetooth headset sends information that the Bluetooth headset is in a wearing state to the Bluetooth module.

[0068] It should be understood that, generally when not in use, the Bluetooth headset can be placed in the headset box and the headset box is in a closed state. When the Bluetooth headset needs to be used, the user can open the headset box and take out the Bluetooth headset to wear.

[0069] After the user opens the headset box, the Bluetooth headset can establish an HFP connection with the electronic device. Specifically, an ACL link is first established between the Bluetooth headset and the electronic device. The ACL link is used to send data packets in a directional manner. Based on the ACL link, the electronic device and the Bluetooth headset can interact with AT commands to establish an HFP connection.

[0070] In addition, after the user opens the earphone box, he can take out the Bluetooth earphone and wear it, for example, he can wear the left earphone or the right earphone, or wear the left earphone and the right earphone. After the Bluetooth earphone detects that it is worn by the user, it can send information that the Bluetooth earphone is in the wearing state to the electronic device.

[0071] It should be understood that the interaction between the electronic device and the Bluetooth headset can be achieved through the Bluetooth module of the electronic device, and the subsequent interaction between the Bluetooth module and the Bluetooth headset is the interaction between the electronic device and the Bluetooth headset.

[0072] S502: The Bluetooth module marks the Bluetooth headset as an active device.

[0073] After the Bluetooth module of the electronic device receives the wearing status information sent by the Bluetooth headset, the Bluetooth headset can be marked as an active device, so that the Bluetooth headset can be used to output the audio stream.

[0074] S503: The Bluetooth module sends a first broadcast to the audio module, indicating that the ACL is connected, the HFP is connected, and the Bluetooth headset is an active device.

[0075] After the Bluetooth headset establishes a connection with the Bluetooth module, the Bluetooth module can send a first broadcast to the audio module of the electronic device, and the first broadcast can include information such as ACL connection status, HFP connection status, Bluetooth device status, etc. The ACL connection status can be divided into disconnected state and connected state, which can be represented by "acl 0" and "acl1" respectively. The HFP connection status can be divided into disconnected state, connecting state and connected state, which can be represented by "hfp ​​0", "hfp ​​1" and "hfp ​​2" respectively. The Bluetooth device status can be divided into active and inactive, which can be represented by "true" and "flase" respectively. Active means that the Bluetooth device is an available device.

[0076] Among them, the ACL connection status, HFP connection status, and Bluetooth device status can be sent to the audio module respectively through broadcast. Exemplarily, after the ACL connection is successfully established, the Bluetooth module can send a first sub-broadcast to the audio module, carrying the "acl 1" information, indicating that the ACL is connected. After the HFP connection is successfully established, the Bluetooth module can send a second sub-broadcast to the audio, carrying the "hfp ​​2" information, indicating that the HFP is connected. After the Bluetooth module receives the information that the Bluetooth headset is in the wearing state, it can send a third sub-broadcast to the audio module, carrying the information that the Bluetooth headset is an active device.

[0077] S504: The Bluetooth module sends a second broadcast to the third-party application A, indicating that the HFP is connected.

[0078] A third-party application A is installed on the electronic device. For example, the third-party application A may be an application such as DingTalk or QQ. After the HFP connection is successfully established, the Bluetooth module may send a broadcast to the audio device indicating that the HFP connection has been established.

[0079] It should be noted that, in addition to the third-party application A, other applications in the electronic device can also monitor the HFP connected broadcast.

[0080] S505: The audio module initializes the available sound output channels of the native service layer.

[0081] The sound output channel is the channel for outputting sound and the channel for outputting audio stream, which can also be called the sound output channel or audio device. The sound output channel can include Bluetooth devices (such as Bluetooth headsets, Bluetooth speakers), wired headsets, speakers, receivers, etc. The audio module can manage the sound output channels of the electronic device, initialize the available sound output channels when receiving the broadcast, and select the available sound output channels to output the audio stream when the audio stream needs to be output.

[0082] It should be noted that after the audio module receives the HFP connected broadcast, it can initialize the available sound output channels of the local service (native) layer.

[0083] S506: The third-party application A makes a virtual call.

[0084] For example, when a user is using an electronic device, third-party application A receives a request for a virtual call (such as a voice call). The electronic device can display an interface for the voice call request on the screen, and the user can click an answer button on the interface to answer the voice call. The electronic device responds to the user's click operation and establishes communication with the electronic device used by the other party who initiated the voice call, so that the user and the other party who initiated the voice call can conduct a virtual call through third-party application A.

[0085] It should be understood that the above process of establishing a virtual call is only an example, and in other implementations, the user may also actively initiate a virtual call request. In other implementations, step S506 may also occur before step S501.

[0086] S507: The third-party application A sends a first instruction to the audio module, instructing to start establishing a SCO link between the Bluetooth headset and the electronic device.

[0087] S508: The audio module sends a second instruction to the Bluetooth module, instructing the Bluetooth module to start the SCO link for the virtual call.

[0088] After the virtual call is connected, the third-party application A can send a first instruction to the audio module to instruct the start of establishing a SCO link between the Bluetooth headset and the electronic device. Further, the audio module can send a second instruction to the Bluetooth module to instruct the Bluetooth module to start the SCO link for the virtual call. The first instruction can be an instruction for calling the startbluetoothsco interface, and the second instruction can be an instruction for calling the startscousingvirtualcall interface.

[0089] Third-party application A can call the startbluetoothsco interface to the audio module, and the audio module further calls the startscousingvirtualcall interface to the bluetooth module. After calling the startscousingvirtualcall interface, the bluetooth module can further call the phoneStateChange function, simulate an outgoing call (a call is dialed by an electronic device) by calling phoneStateChange, and send the change of the call state to the bluetooth bottom layer, and then to the bluetooth headset. For example, phoneStateChange can be called three times, indicating that the current call state is dialing, ringing, connected and idle, respectively. These three changes in call state can be carried in a message and sent to the bluetooth headset. The message carrying the call state is used to request the establishment of a SCO link. After receiving the change in the call state, the bluetooth headset accepts the SCO link connection request, so that the bluetooth headset and the bluetooth establish a SCO link. After calling the phoneStateChange function, the electronic device can generate a call log to record the call action, time, etc. executed by each module.

[0090] It should be noted that, during the interface calling process, the audio module can obtain the application identifier, and the Bluetooth module can obtain the application identifier from the audio module, so that the Bluetooth module and the audio module can distinguish different applications.

[0091] S509: The Bluetooth headset establishes a SCO link with the Bluetooth module.

[0092] It can also be understood that the third-party application A and the Bluetooth headset successfully establish a SCO link, and the Bluetooth module and the audio module provide a routing function in the SCO link.

[0093] S510: The Bluetooth module sends information to the audio module that a SCO link with the Bluetooth headset has been established.

[0094] S511, the audio module switches the sound output channel to the Bluetooth headset.

[0095] It should be noted that before switching to a Bluetooth headset, the sound output channel can be an earpiece, a speaker or other device, and the subsequent embodiments of this application take the earpiece as an example.

[0096] S512, based on the SCO link, outputs the audio stream during the virtual call through the Bluetooth headset.

[0097] Based on the SCO link, when a virtual call is made, the Bluetooth headset can collect the audio stream of the virtual call local end and send it to the Bluetooth module of the electronic device, which is then sent to the audio module, and then to the third-party application A, which is then transmitted to the other end of the virtual call. Third-party application A receives the audio stream from the other end, transmits it to the audio module, which is then transmitted to the Bluetooth module by the audio module, and then to the Bluetooth headset, which outputs the audio stream of the other end through the Bluetooth headset, and the user hears the other party's voice through the Bluetooth headset.

[0098] When using a Bluetooth headset for a virtual call, the user may take off the Bluetooth headset and put it on again. Figure 5 Based on the illustrated embodiment, the process of switching the sound output channel of the electronic device after the user takes off the Bluetooth headset and puts on the Bluetooth headset again during a call is described in detail.

[0099] Figure 6 The flowchart of an audio control method provided by an embodiment of the present application is shown. In this method, the Bluetooth module sends a broadcast of HFP disconnection and a broadcast of HFP establishment to a third-party application A. After receiving the broadcast, the third-party application A sends a first instruction to the audio module, and the audio module sends a second instruction to the Bluetooth module. The Bluetooth module establishes a SCO link with the Bluetooth headset. Figure 6 As shown, the method includes S601-S6019.

[0100] S601, outputting the audio stream during the virtual call through the Bluetooth headset.

[0101] The details of step S601 may refer to the content of step S512.

[0102] S602, the Bluetooth headset sends information to the Bluetooth module indicating that the Bluetooth headset is not being worn.

[0103] After the user takes off the Bluetooth headset in the virtual process, the Bluetooth headset can recognize that the user has taken off the Bluetooth headset based on the wearing recognition function. The Bluetooth headset then sends information that the Bluetooth headset has been taken off (not worn) to the Bluetooth module of the electronic device. For example, the information can be in the form of an AT command. It should be noted that after the user takes off the Bluetooth headset, he does not put it in the headset box and close the headset box.

[0104] S603, the Bluetooth module calls an interface to close the SCO channel.

[0105] S604: The SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0106] After the Bluetooth module receives the information that the Bluetooth headset has been removed, it can call the stopScoUsingVirtualVoiceCall interface and send an AT command to tell the Bluetooth headset that the virtual call has ended and disconnect the SCO link between the Bluetooth headset and the Bluetooth module. In addition, the Bluetooth module can also call the removeActiveDevice function to remove the Bluetooth headset from the active device and update the active device information.

[0107] S605: The Bluetooth module sends a message to the audio module indicating that the SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0108] The Bluetooth module can send an AUDIO_STATE_CHANGED broadcast to the audio module to indicate that the SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0109] S606: The Bluetooth module sends a message to the third-party application A that the SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0110] It should be noted that the information may be in the form of a broadcast, and any third-party application installed in the electronic device may monitor the broadcast of the disconnection of the SCO link between the Bluetooth headset and the Bluetooth module.

[0111] S607: The audio module switches the sound output channel to the earpiece.

[0112] After the audio module switches the sound output channel to the receiver, the electronic device outputs sound through the receiver during the virtual call. In other implementations, the audio module can also switch the sound output channel to a speaker, a Bluetooth speaker, etc., which can be selected according to actual conditions.

[0113] It should be noted that after receiving the broadcast of the SCO link disconnection, the audio module can switch the sound output channel to the earpiece. In the embodiment of the present application, the order of step S606 and step S607 is not limited.

[0114] S608: The Bluetooth module requests the audio module to obtain the virtual call status.

[0115] It should be noted that in the embodiment of the present application, there is no limitation on the order between step S607 and steps S608-S611, and step S607 can be executed after any one of steps S608-S611.

[0116] S609: The Bluetooth module receives a virtual call status indicating that the call is in progress.

[0117] S610: The Bluetooth module determines that the application in the ongoing call is a third-party application A.

[0118] In the embodiment of the present application, the virtual call status can be divided into call in progress and no virtual call.

[0119] In one implementation, the Bluetooth module can obtain the virtual call status by calling the interface of the audio module. Specifically, the Bluetooth module queries whether an audio stream is output within a preset time period (such as 100 milliseconds) before calling the interface. If an audio stream is output, it is determined whether the output audio stream is generated during the virtual call process. If it is generated during the virtual call process, it can be determined that the virtual call status is call in progress; if no audio stream is output, or the output audio stream is not generated during the virtual call process, the virtual call status is no virtual call.

[0120] The types of audio streams can be divided into audio streams (call sounds) during virtual calls, system audio streams, key audio streams, alarm audio streams, incoming call ringtones, media audio streams, etc. Different audio stream types have different sound output rules. The Bluetooth module can determine whether the audio stream is generated during a virtual call based on the type of the audio stream.

[0121] When the Bluetooth module obtains that the virtual call state is a call in progress, the Bluetooth module can obtain an identifier (such as a package name) of the application in the call in progress, and determine that the application in the call in progress is a third-party application A according to the identifier.

[0122] In another implementation, the Bluetooth module may send a request to the audio module to obtain the virtual call status, and the audio module determines whether the virtual call status is a call in progress based on the type of audio stream. If the virtual call status is a call in progress, the audio module may further obtain the identifier (such as the package name) of the application in the call in progress. Then, the audio module sends the virtual call status as a call in progress and the identifier of the application in the call in progress to the Bluetooth module. After receiving the information from the audio module, the Bluetooth module determines that the virtual call status is a call in progress and that the application in the call in progress is a third-party application A. If the virtual call status is no virtual call, the audio module sends the virtual call status as no virtual call to the Bluetooth module.

[0123] S611, the Bluetooth module sends a first message to the third-party application A, indicating that the HFP connection with the Bluetooth headset is disconnected.

[0124] Specifically, after the Bluetooth module obtains the virtual call status from the audio module, if the virtual call is in progress, the Bluetooth module sends a first message to the third-party application A according to the identifier of the third-party application A, and the first message indicates that the Bluetooth module (that is, the electronic device) is disconnected from the HFP connection of the Bluetooth headset. The first message can be in the form of a broadcast, and the broadcast is directional, that is, the first message is only sent to the third-party application A.

[0125] It should be noted that, in fact, the HFP connection between the Bluetooth headset and the Bluetooth module is not disconnected during the entire virtual call process. Here, the HFP connection is simulated to be disconnected.

[0126] The Bluetooth module sends the first information to the third-party application A. After receiving the first information, the third-party application A resets the relevant information of Bluetooth and restores the stored state of the Bluetooth device to the initial value call state, so that after the Bluetooth headset is put on again, the third-party application A can resend the first instruction to the audio module to establish the SCO link with the Bluetooth headset. In the embodiment of the present application, the first information is sent after the Bluetooth headset is taken off, and there is no need to wait for the third-party application A to be initialized before the second information is subsequently sent, so the sound output speed of the Bluetooth headset after it is put on again can be improved.

[0127] In one implementation, a blacklist is pre-set, and the applications in the blacklist cannot start to establish a SCO link after the Bluetooth headset is removed or put on, that is, the SCO link cannot be started to be established after only receiving the second information. After determining that the application for the virtual call is a third-party application A, it is determined whether the third-party application A is an application in the blacklist. If it is an application in the blacklist, the first information is sent to the third-party application A.

[0128] S612, the Bluetooth headset sends information that the Bluetooth headset is in a wearing state to the Bluetooth module.

[0129] When the virtual call conducted by the third-party application A is not disconnected, the user puts on the Bluetooth headset again, and the Bluetooth headset can recognize that the user is wearing the headset based on the wearing recognition function. Then the Bluetooth headset sends information that the Bluetooth headset is in the wearing state to the Bluetooth module.

[0130] It should be noted that during the period from when the user takes off the Bluetooth headset to when the user puts on the Bluetooth headset again, the distance between the Bluetooth headset and the electronic device does not exceed the HFP connection range.

[0131] S613: The Bluetooth module sends second information to the third-party application A, indicating that the HFP connection with the Bluetooth headset has been established.

[0132] In one implementation, the Bluetooth module obtains the virtual call status. If the third-party application A is still making a virtual call, the Bluetooth module sends second information to the third-party application A. The second information can be in the form of a broadcast, and the broadcast is directional, that is, it is only sent to the third-party application A.

[0133] In another implementation, the Bluetooth module sends the second information to multiple applications (including the third-party application A) in the electronic device.

[0134] It should be noted that the second information indicates that the HFP connection between the Bluetooth headset and the electronic device has been established. Here, the HFP connection re-establishment is simulated. In fact, since the HFP is not disconnected, there is no process of establishing the HFP connection.

[0135] S614, the third-party application A sends a first instruction to the audio module, instructing to start establishing a SCO link between the Bluetooth headset and the electronic device.

[0136] S615: The audio module sends a second instruction to the Bluetooth module, instructing the Bluetooth module to start the SCO link for the virtual call.

[0137] After receiving the second information, the third-party application A actively initiates the establishment of a SCO link with the Bluetooth headset. Specific steps S614-S615 may refer to steps S507-S508.

[0138] S616: The Bluetooth module establishes a SCO link with the Bluetooth headset.

[0139] S617: The Bluetooth module sends information to the audio module that the SCO link with the Bluetooth headset has been established.

[0140] S618: The audio module switches the sound output channel to the Bluetooth headset.

[0141] S619, based on the SCO link, outputs the audio stream during the virtual call through the Bluetooth headset.

[0142] In the embodiments of the present application, the details not described above can be referred to Figure 5 The contents of the illustrated embodiment will not be repeated here.

[0143] In another implementation, after step S610, if it is determined that the application in the call is a third-party application A, the Bluetooth module determines whether the third-party application A is an application in the blacklist. If so, step S611 is not performed, that is, the Bluetooth module does not send the first information to the third-party application A. After step S612, it is determined again whether the state of the virtual call is still in progress and whether the application in the call is still the third-party application A. If so, the Bluetooth module can actively establish a SCO link with the Bluetooth headset. At this time, the Bluetooth module can send the second information to the third-party application A, or it can not send the second information.

[0144] Figure 7 FIG. 1 is a flow chart of another audio control method provided by an embodiment of the present application. In this method, the broadcast of HFP disconnection is sent after the Bluetooth headset is worn again. Figure 7 As shown, the method includes S701-S719.

[0145] S701, outputting the audio stream during the virtual call through the Bluetooth headset.

[0146] S702, the Bluetooth headset sends information to the Bluetooth module indicating that the Bluetooth headset is not being worn.

[0147] S703, the Bluetooth module calls an interface to close the SCO channel.

[0148] S704: The SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0149] S705: The Bluetooth module sends information to the audio module indicating that the SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0150] S706: The Bluetooth module sends a message to the third-party application A that the SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0151] S707: The audio module switches the sound output channel to the earpiece.

[0152] Among them, the specific details of steps S701-S707 can refer to the contents of steps S601-S607, and the embodiments of the present application will not be repeated here.

[0153] S708, the Bluetooth headset sends information that the Bluetooth headset is in a wearing state to the Bluetooth module.

[0154] The specific details of step S708 may refer to step S612 and will not be repeated here.

[0155] S709: The Bluetooth module requests the audio module to obtain the virtual call status.

[0156] S710: The Bluetooth module receives a virtual call status indicating that the call is in progress.

[0157] S711: The Bluetooth module determines that the application in the ongoing call is third-party application A.

[0158] The specific details of steps S709-S711 may refer to steps S608-S610 and will not be repeated here.

[0159] S712: The Bluetooth module sends a first message to the third-party application A, indicating that the HFP connection with the Bluetooth headset is disconnected.

[0160] In an embodiment of the present application, after the user puts on the Bluetooth headset again, the Bluetooth module obtains the virtual call status. If the virtual call status is that the call is in progress, the identifier of the application in the call is further obtained, and it is determined that the application in the call is a third-party application A. The Bluetooth module sends a first message to the third-party application A, instructing the Bluetooth module to disconnect the HFP connection with the Bluetooth headset.

[0161] In one implementation, when it is determined that the third-party application A is an application in the blacklist, the Bluetooth module sends the first information to the third-party application A in a targeted manner.

[0162] S713, the Bluetooth module sends second information to the third-party application A, indicating that the HFP connection with the Bluetooth headset has been established.

[0163] After the Bluetooth module sends the first information to the third-party application A and waits for a period of time (e.g., 5ms), the Bluetooth module continues to send the second information to the third-party application A, wherein the second information indicates that the HFP connection between the Bluetooth module and the Bluetooth headset has been established. During the waiting period, the third-party application A can reset the relevant information of Bluetooth and restore the stored state of the Bluetooth device to the initial value call state.

[0164] It should be noted that, in fact, the HFP connection between the Bluetooth headset and the Bluetooth module is not disconnected during the entire virtual call process. Here, the disconnection and establishment of the HFP connection are simulated.

[0165] S714, the third-party application A sends a first instruction to the audio module, instructing to start establishing a SCO link between the Bluetooth headset and the electronic device.

[0166] S715: The audio module sends a second instruction to the Bluetooth module, instructing the Bluetooth module to start the SCO link for the virtual call.

[0167] S716: The Bluetooth module establishes a SCO link with the Bluetooth headset.

[0168] S717, the Bluetooth module sends information to the audio module that the SCO link with the Bluetooth headset has been established.

[0169] S718: The audio module switches the sound output channel to the Bluetooth headset.

[0170] S719, based on the SCO link, outputs the audio stream during the virtual call through the Bluetooth headset.

[0171] For details not described above, please refer to Figure 5 and Figure 6 The contents of the illustrated embodiment will not be repeated here.

[0172] For the above Figure 6 and Figure 7 In the illustrated embodiment, in another implementation, after the Bluetooth module sends the second information to the third-party application A, the Bluetooth module determines whether a second instruction is received within a preset time. If the second instruction is not received within the preset time, the Bluetooth module actively establishes a SCO link with the Bluetooth headset.

[0173] In another implementation, after the Bluetooth module sends the second information to the third-party application A, it is determined whether the third-party application A is an application in the blacklist. If the third-party application A is an application in the blacklist, the Bluetooth module can actively establish a SCO link with the Bluetooth headset. In this implementation, the Bluetooth module does not need to wait for the second instruction, and the processing speed can be optimized.

[0174] Based on the above scheme, the Bluetooth module sends a broadcast of HFP connection disconnection before sending a broadcast of HFP connection establishment to the third-party application A. This allows the third-party application A to determine the process of HFP connection from disconnection to establishment based on the two received broadcasts after the Bluetooth headset is worn again. Then, the third-party application A can start to establish the SCO link, so that after the Bluetooth headset is taken off and put on again during the virtual call, the call sound is output from the Bluetooth headset, which meets the user's expectations.

[0175] Figure 8 The flowchart of another audio control method provided by the embodiment of the present application is shown. The method describes the process in which the audio module actively establishes a SCO link after the Bluetooth headset is taken off and put on again (referred to as taking off and putting on the headset) during a virtual call. Figure 8 As shown, the method includes S801-S814.

[0176] S801, outputting the audio stream during the virtual call through the Bluetooth headset.

[0177] S802, the Bluetooth headset sends information to the Bluetooth module indicating that the Bluetooth headset is not being worn.

[0178] After the user takes off the headset, the Bluetooth headset can recognize that the user has taken off the headset based on the wearing recognition function. The Bluetooth headset then sends information that the Bluetooth headset has been taken off (not worn) to the Bluetooth module of the electronic device. Exemplarily, the information can be in the form of an AT command.

[0179] S803, the Bluetooth module calls an interface to close the SCO channel.

[0180] S804: The SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0181] After the Bluetooth module receives the information that the Bluetooth headset has been removed, it can call the stopScoUsingVirtualVoiceCall interface and send an AT command to tell the Bluetooth headset that the virtual call has ended and disconnect the SCO link between the Bluetooth headset and the Bluetooth module. In addition, the Bluetooth module can also call the removeActiveDevice function to remove the Bluetooth headset from the active device and update the active device information.

[0182] S805: The Bluetooth module sends a message to the audio module indicating that the SCO link is disconnected and the Bluetooth headset is not an active device.

[0183] After the SCO link is disconnected, the Bluetooth module may send information to the audio module that the SCO link between the Bluetooth headset and the Bluetooth module is disconnected. Specifically, the Bluetooth module may send an AUDIO_STATE_CHANGED broadcast to the audio module, and the broadcast content may be "audio disconnected".

[0184] In addition, the Bluetooth module may send information to the audio module that the Bluetooth headset is not an active device. Specifically, the Bluetooth module may send an ACTIVE_DEVICE_CHANGED broadcast to the audio module. The specific broadcast content may be "activedevice null", indicating that the Bluetooth headset is not an active device.

[0185] The information that the SCO link is disconnected and the information that the Bluetooth headset is not an active device may be sent separately.

[0186] S806: The audio module switches the sound output channel to the earpiece.

[0187] After the audio module receives the information that the Bluetooth headset is not an active device, it can update the active status of the Bluetooth headset. Whether the virtual call of third-party application A ends has nothing to do with whether the Bluetooth headset is worn. In other words, after the Bluetooth headset is taken off, the virtual call of third-party application A may or may not end. If the virtual call does not end, the audio module switches the sound output channel from the Bluetooth headset to the earpiece of the electronic device.

[0188] S807, the Bluetooth headset sends information that the Bluetooth headset is in a wearing state to the Bluetooth module.

[0189] When the virtual call conducted by the third-party application A is not disconnected, the user puts on the Bluetooth headset again, and the Bluetooth headset can recognize that the user is wearing the headset based on the wearing recognition function. Then the Bluetooth headset sends information that the Bluetooth headset is in the wearing state to the Bluetooth module.

[0190] It should be noted that during the period from when the user takes off the Bluetooth headset to when the user puts on the Bluetooth headset again, the distance between the Bluetooth headset and the electronic device does not exceed the HFP connection range.

[0191] S808: The Bluetooth module sends information to the audio module indicating that the Bluetooth headset is an active device.

[0192] After the Bluetooth module receives the information that the Bluetooth headset is in the wearing state, the active device information can be updated. For example, the Bluetooth module can add the Bluetooth headset as an active device through the setActiveDevice function.

[0193] In one implementation, the Bluetooth module broadcasts to the audio module that the Bluetooth headset is an active device.

[0194] In another implementation, in addition to sending a broadcast that the Bluetooth headset is an active device to the audio module, the Bluetooth module can also send a broadcast that the HFP connection has been established to the audio module. It should be noted that, in fact, during the virtual call process, the HFP connection between the Bluetooth headset and the Bluetooth module is not disconnected throughout the virtual call process, and the broadcast sent by the Bluetooth module is a simulation state.

[0195] In another implementation, step S808 may also be that the Bluetooth module sends a broadcast to the audio module that the HFP connection has been established.

[0196] S809: The audio module determines whether to establish a SCO link with the Bluetooth headset.

[0197] In one implementation, after the audio receives the broadcast that the Bluetooth headset is an active device, the virtual call status is obtained, and whether to initiate the establishment of a SCO link is determined according to the virtual call status. In the case of a virtual call in progress, the audio module initiates the establishment of a SCO link. If there is no virtual call, the audio module does not initiate the establishment of a SCO link.

[0198] Among them, the virtual call status is divided into call in progress and no virtual call. The audio module can determine whether the audio stream is output within the preset time period. If the audio stream is not output, there is no virtual call at present. If the audio stream is output, it is further determined according to the type of the audio stream whether the output audio stream is generated during the virtual call process. If the output audio stream is generated during the virtual call process, it can be determined that the virtual call state is in progress. If the output audio stream is not generated during the virtual call process, there is no virtual call at present.

[0199] When determining that the virtual call state is a call in progress, the audio module obtains an identifier of an application in the call in progress and determines that the application in the call in progress is a third-party application A.

[0200] In another implementation, the audio module can further determine whether the virtual call of the third-party application A is disconnected during the process of taking off and putting on the earphone. If the virtual call of the third-party application A is not disconnected during the process of taking off and putting on the earphone, the audio module initiates the establishment of the SCO link. If the virtual call of the third-party application A is disconnected during the process of taking off and putting on the earphone, the audio module does not initiate the establishment of the SCO link.

[0201] In another implementation, after the audio module receives the broadcast that the Bluetooth headset is an active device, it obtains the virtual call state and the current sound output channel, and determines whether to initiate the establishment of a SCO link based on the virtual call state and the current sound output channel. Specifically, the audio module determines whether the virtual call state is a call in progress. If the virtual call state is a call in progress, it determines whether the priority of the current sound output channel is lower than that of the Bluetooth headset. If the priority of the current sound output channel is lower than that of the Bluetooth headset, the audio module determines to initiate the establishment of a SCO link, otherwise it does not initiate the establishment of a SCO link.

[0202] The audio module can maintain and manage audio devices and record the current sound output channel. Priorities can be set between audio devices, and the audio module can select the audio device with a higher priority as the sound output channel. For example, the priority of a Bluetooth headset is higher than that of a receiver. When the audio device includes a receiver and a Bluetooth headset, the audio module selects the Bluetooth headset as the sound output channel.

[0203] In another implementation, after the audio receives the broadcast that the Bluetooth headset is an active device, the virtual call state, the first identifier and the current sound output channel are obtained, and whether to initiate the establishment of a SCO link is determined according to the virtual call state, the first identifier and the current sound output channel.

[0204] The first identifier is used to record the change of the wearing process of the Bluetooth headset during a virtual call, and the first identifier can be represented by a flag value. For example, the flag value of no virtual call or the end of the virtual call is recorded as 0, the flag value of putting on the Bluetooth headset is recorded as 1, and the flag value of taking off the Bluetooth headset is recorded as 2.

[0205] Determine whether to initiate the establishment of a SCO link based on the virtual call state, the first identifier, and the current sound output channel. Specifically, the audio module determines whether the virtual call state is a call in progress. If the virtual call state is a call in progress, determine whether the Bluetooth headset is taken off before wearing the Bluetooth headset this time based on the first identifier, that is, determine whether it is a scene of taking off and wearing the headset during a virtual call. In the case of taking off and wearing the headset, determine whether the priority of the current sound output channel is lower than that of the Bluetooth headset. If the priority of the current sound output channel is lower than that of the Bluetooth headset, the audio module determines to initiate the establishment of a SCO link, otherwise, the establishment of a SCO link is not initiated.

[0206] In another implementation, a whitelist may be pre-set in the electronic device, and the applications in the whitelist (preset applications) are obtained through testing and screening. Exemplarily, the applications in the whitelist are applications that require the audio module to establish a SCO link on behalf of the audio module, that is, after taking off and putting on the headphones, the applications in the whitelist cannot start to establish a SCO link after only receiving the broadcast of the HFP connection establishment. After the audio module receives the broadcast that the Bluetooth headset is an active device, it obtains the virtual call status. If there is no virtual call, the audio module does not establish a SCO link. If the virtual call status is a call in progress, the audio module obtains the identifier of the application in progress. The application identifier can be an application id, a package name, a process name pid, etc.

[0207] The audio module can determine whether the application in the call is in the whitelist. If it is an application in the whitelist, the audio module initiates the establishment of a SCO link. Alternatively, if it is an application in the whitelist, the audio module determines whether to initiate the establishment of a SCO link based on the current sound output channel. Alternatively, if it is an application in the whitelist, the audio module determines whether to initiate the establishment of a SCO link based on the first identifier and the current sound output channel. If it is not an application in the whitelist, the audio module does not initiate the establishment of a SCO link.

[0208] Optionally, the applications in the whitelist may also be applications that do not require the audio module to establish a SCO link. After the audio module receives the information that the Bluetooth headset is an active device, it obtains the virtual call status. If the call is in progress, the audio module obtains the identifier of the application in the call. If the application in the call is an application in the whitelist, the application initiates the establishment of the SCO link. If the application in the call is not an application in the whitelist, the audio module initiates the establishment of the SCO link, or further determines whether to initiate the establishment of the SCO link based on the first identifier and / or the current sound output channel.

[0209] S810: The audio module sends a second instruction to the Bluetooth module, instructing the Bluetooth module to start a SCO link for the virtual call.

[0210] When it is determined to establish the SCO link, the audio module sends a second instruction to the Bluetooth module, and the second instruction may be an instruction for calling the startscousingvirtual interface.

[0211] S811: The Bluetooth module establishes a SCO link with the Bluetooth headset.

[0212] S812: The Bluetooth module sends information to the audio module indicating that the SCO link with the Bluetooth headset has been successfully established.

[0213] S813, the audio module switches the sound output channel to the Bluetooth headset.

[0214] S814, based on the SCO link, outputs the audio stream during the virtual call through the Bluetooth headset.

[0215] The details not described in steps S810-S814 can be referred to Figures 5 to 7 The illustrated embodiments will not be described in detail here.

[0216] It should be noted that between step S808 and step S809, the Bluetooth module may send a broadcast that the HFP connection has been established (simulated state) to multiple applications (including third-party application A) of the electronic device. In some implementations, the audio module determines whether the first instruction is received within the preset time after step S808 and before step S809. If the audio module does not receive the first instruction within the preset time, steps S809-S814 are executed. If the audio module receives the first instruction within the preset time, steps S810-S814 are executed. Among them, the first instruction indicates the start of the SCO link between the Bluetooth headset and the electronic device, which may be an instruction for calling the startbluetoothsco interface.

[0217] In some implementations, after the audio module determines in step S809 that the third-party application A is making a virtual call and the third-party application A is an application that requires the audio module to act as a proxy, it determines whether a first instruction of the third-party application A is received within a preset time. If the audio module does not receive the first instruction within the preset time, steps S810-S814 are executed. If the first instruction is received within the preset time, steps S810-S814 are executed after the first instruction is received.

[0218] Fig. 9 FIG. 2 is a flow chart of another audio control method provided by an embodiment of the present application. The method describes the process in which the Bluetooth module actively establishes a SCO link after the Bluetooth headset is taken off and put on again during a virtual call, such as Fig. 9 As shown, the method includes S901-S916.

[0219] S901, output the audio stream during the virtual call through the Bluetooth headset.

[0220] S902, the Bluetooth headset sends information to the Bluetooth module indicating that the Bluetooth headset is not being worn.

[0221] S903, the Bluetooth module calls an interface to close the SCO channel.

[0222] S904: The SCO link between the Bluetooth headset and the Bluetooth module is disconnected.

[0223] S905: The Bluetooth module sends information to the audio module indicating that the SCO link is disconnected and the Bluetooth headset is not an active device.

[0224] S906: The audio module switches the sound output channel to the earpiece.

[0225] S907, the Bluetooth headset sends information that the Bluetooth headset is in a wearing state to the Bluetooth module.

[0226] S908: The Bluetooth module sends information to the audio module indicating that the Bluetooth headset is an active device.

[0227] In another implementation, step S908 may also be that the Bluetooth module sends a broadcast to the audio module that the HFP connection has been established.

[0228] S909: The audio module determines the virtual call state.

[0229] S910: The audio module sends a virtual call status to the Bluetooth module.

[0230] S911: The Bluetooth module determines whether to establish a SCO link with the Bluetooth headset.

[0231] In one implementation, after obtaining the current virtual call status, the audio module sends the current virtual call status to the Bluetooth module. The Bluetooth module determines whether to establish a SCO link with the Bluetooth headset according to the virtual call status. If the virtual call status is a call in progress, the Bluetooth module initiates the establishment of a SCO link. If there is no virtual call, the establishment of a SCO link is not initiated. If the virtual call status is a call in progress, the Bluetooth module also obtains the identifier of the application in progress and determines that the application in progress is a third-party application A.

[0232] In another implementation, the audio module sends the virtual call state and the current sound output channel to the Bluetooth module. The Bluetooth module determines whether to initiate the establishment of a SCO link based on the virtual call state and the sound output channel. Specifically, when the virtual call state is a call in progress, the Bluetooth module determines whether the priority of the current sound output channel is lower than the priority of the Bluetooth headset. If the priority of the current sound output channel is lower than that of the Bluetooth headset, the Bluetooth module determines to initiate the establishment of a SCO link, otherwise, the establishment of a SCO link is not initiated.

[0233] In another implementation, the audio module sends the virtual call status, the first identifier, and the current sound output channel to the Bluetooth module. The Bluetooth module determines whether to initiate the establishment of a SCO link based on the virtual call status, the first identifier, and the sound output channel. If the virtual call status is that the call is in progress, the Bluetooth module determines whether it is a scene of taking off and putting on headphones based on the first identifier. In the case of a scene of taking off and putting on headphones, it is determined whether the priority of the current sound output channel is lower than that of the Bluetooth headset. If the priority of the current sound output channel is lower than that of the Bluetooth headset, the Bluetooth module determines to initiate the establishment of a SCO link, otherwise it does not initiate the establishment of a SCO link.

[0234] In another implementation, the Bluetooth module determines whether the third-party application A is in the whitelist according to the application identifier. The applications in the whitelist are applications that require the Bluetooth module to establish a SCO link on behalf of the application. For example, if the third-party application A is an application in the whitelist, the Bluetooth module initiates the establishment of the SCO link, or determines whether to initiate the establishment of the SCO link according to the current sound output channel and the first identifier. If the third-party application A is not an application in the whitelist, the third-party application A initiates the establishment of the SCO link.

[0235] In some implementations, steps S910 and S911 may also be that the Bluetooth module queries the virtual call status and other information through an interface, and then determines whether to establish a SCO link according to the queried information.

[0236] S912: When it is determined to establish the SCO link, the Bluetooth module calls the startscousingvirtual interface.

[0237] S913: The Bluetooth module establishes a SCO link with the Bluetooth headset.

[0238] S914, the Bluetooth module sends information to the audio module that the SCO link with the Bluetooth headset is successfully established.

[0239] S915: The audio module switches the sound output channel to the Bluetooth headset.

[0240] S916, based on the SCO link, outputs the audio stream during the virtual call through the Bluetooth headset.

[0241] Among them, the details not described can refer to the above Figure 8 The contents of the illustrated embodiment will not be repeated here.

[0242] It should be noted that the Bluetooth module can send a broadcast that the HFP connection has been established (simulated state) to multiple applications (including third-party application A) of the electronic device. In some implementations, between step S908 and step S909, the audio module determines whether the first instruction is received within the preset time. If the audio module does not receive the first instruction within the preset time, steps S909-S915 are executed. If the audio module receives the first instruction within the preset time, the audio module sends a second instruction to the Bluetooth module, and then steps S913-S914 are executed.

[0243] In some implementations, the Bluetooth module may send a broadcast that the HFP connection has been established (simulated state) to multiple applications (including third-party application A) of the electronic device, and then the Bluetooth module determines whether the second instruction is received within a preset time. If the Bluetooth module does not receive the second instruction within the preset time, steps S911-S915 are executed. If the Bluetooth module receives the second instruction within the preset time, steps S912-S915 are executed. Or after step S910, it is determined that the third-party application A is making a virtual call, and the third-party application A is an application that requires a Bluetooth module agent, and a broadcast that the HFP connection has been established is sent to the third-party application A. If the Bluetooth module does not receive the second instruction within the preset time, steps S912-S915 are executed.

[0244] In summary, the method provided in the embodiment of the present application can, after the user takes off the Bluetooth headset and puts on the Bluetooth headset again, actively establish a SCO link between the electronic device and the Bluetooth headset by the Bluetooth module or audio module of the electronic device itself, without relying on a third-party application to actively establish a SCO link. Therefore, after putting on the Bluetooth headset again, the SCO link can be established, so that the third-party application can output the audio stream through the Bluetooth headset when making a virtual call, which meets the user's expectations and improves the user experience.

[0245] Above through Figures 1 to 9 The audio control method provided in the embodiment of the present application is described in detail. Figures 10 to 12 The software and hardware structures of the electronic device and Bluetooth headset provided in the embodiments of the present application are described.

[0246] In an embodiment of the present application, the electronic device supports the Bluetooth communication protocol. Among them, the Bluetooth communication protocol can be a classic Bluetooth (bluetooth, BT) protocol, or a low-power (Bluetooth low energy, BLE) Bluetooth protocol. With the evolution of the Bluetooth protocol, it can also be other Bluetooth protocols to be launched in the future. From the perspective of the version of the Bluetooth protocol, the version of the Bluetooth communication protocol can be any of the following: 1.0 series version, 2.0 series version, 3.0 series version, 4.0 series version, and other series versions based on the future.

[0247] The following is a schematic diagram of the hardware structure of an electronic device 100 that can implement the above method. Fig.10 A hardware structure diagram of an electronic device 100 provided in an embodiment of the present application is shown.

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

[0249] 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 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0250] 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. Different processing units may be independent devices or integrated into one or more processors.

[0251] Among them, the controller can generate an operation control signal according to the instruction operation code and the timing signal to complete the control of instruction fetching and execution.

[0252] 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.

[0253] 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, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface, etc.

[0254] The charging management module 140 is used to receive charging input from the charger. The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0255] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, modulates the frequency of the electromagnetic wave signal and performs filtering, and sends the processed signal to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, modulate the frequency of it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0256] In some embodiments, antenna 1 of electronic device 100 is coupled to mobile communication module 150, and antenna 2 is coupled to wireless communication module 160, so that electronic device 100 can communicate with the network and other devices through wireless communication technology.

[0257] The electronic device 100 implements a display function through a GPU, a display screen 194, and an application processor. The display screen 194 is used to display images, videos, etc. The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor. The ISP is used to process data fed back by the camera 193. The camera 193 is used to capture static images or videos.

[0258] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100 .

[0259] The internal memory 121 can be used to store computer executable program codes, which 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 playback function, an image playback function, etc.), etc. The data storage area may store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc. The processor 110 executes various functional applications and data processing of the electronic device 100 by running instructions stored in the internal memory 121, and / or instructions stored in a memory provided in the processor.

[0260] The electronic device 100 can implement audio functions such as music playing, recording, voice calls, video calls, etc. through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0261] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110. The audio module 170 can also be connected to the wireless communication module 160 to achieve audio playback or recording through a third-party device wirelessly connected to the electronic device 100. For example, play music, make calls, answer voice calls, etc. through a Bluetooth headset connected to the electronic device 100 by Bluetooth.

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

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

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

[0265] The headphone jack 170D is used to connect a wired headset. The pressure sensor 180A is used to sense the pressure signal and can convert the pressure signal into an electrical signal. The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. The air pressure sensor 180C is used to measure the air pressure. The magnetic sensor 180D includes a Hall sensor. The acceleration sensor 180E can detect the magnitude of the acceleration of the electronic device 100 in various directions (generally three axes). The distance sensor 180F is used to measure the distance. The proximity light sensor 180G can include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The ambient light sensor 180L is used to sense the brightness of the ambient light. The ambient light sensor 180L can also be used to automatically adjust the white balance when taking pictures. The ambient light sensor 180L can also cooperate with the proximity light sensor 180G to detect whether the electronic device 100 is in a pocket to prevent accidental touch. The fingerprint sensor 180H is used to collect fingerprints. The temperature sensor 180J is used to detect the temperature. The touch sensor 180K is used to detect touch operations acting on or near it. Bone conduction sensor 180M can obtain vibration signals.

[0266] The buttons 190 include a power button, a volume button, etc. The motor 191 can generate a vibration prompt. The motor 191 can be used for an incoming call vibration prompt, or for touch vibration feedback. The indicator 192 can be an indicator light, which can be used to indicate the charging status, power change, message, missed call, notification, etc.

[0267] The software system of the electronic device 100 may adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system of the layered architecture is taken as an example to exemplify the software structure of the electronic device 100.

[0268] Fig.11 It is a software structure block diagram of the electronic device 100 provided in an embodiment of the present invention.

[0269] The layered architecture divides the software into several layers, each with clear roles and division of labor. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided from top to bottom into the application layer, the application framework layer, the Bluetooth protocol stack, the Android runtime and the system library, as well as the kernel layer and the hardware layer.

[0270] The application layer can include a series of application packages. Fig.11 As shown, the application package may include system built-in applications, such as Bluetooth, music, calls, camera, gallery, calendar, WLAN, short messages, etc. It may also include third-party applications, such as WeChat, QQ, etc.

[0271] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0272] like Fig.11 As shown, the application framework layer may include an audio service, a Bluetooth system service, a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, etc. The audio service is used to implement the function of the audio module in the aforementioned method embodiment. The Bluetooth system service is used to implement the function of the Bluetooth module in the aforementioned method embodiment. The audio module and the Bluetooth module in the aforementioned method embodiment are software function modules.

[0273] The audio service is mainly responsible for audio data stream transmission and control functions, volume control, audio device management, sound output channel selection, etc. Audio devices include Bluetooth devices (such as Bluetooth headsets, Bluetooth speakers), wired headsets, speakers, receivers, etc. The audio service can monitor information related to the use of audio devices such as plugging in and unplugging headsets, connecting Bluetooth headsets, and disconnecting Bluetooth headsets, so as to manage the audio devices connected to the electronic device. In addition, the audio service can determine the priority of the audio device and select the sound output channel according to the priority of the audio device. For example, the Bluetooth headset has the highest priority among all audio devices. Then when the electronic device is connected to the Bluetooth headset, the audio service gives priority to the Bluetooth headset as the sound output channel. The priority of the audio device can be determined according to the factory settings or according to the user settings.

[0274] Audio services can be used to provide basic audio-related services for applications in the upper layer, such as the application layer, including application permission judgment, for example, whether the application has permission to use the microphone for recording; audio status collection, for example, whether the application currently has an audio stream, and through audio status collection it can be determined whether the application is in a virtual call; data delivery; volume control; selection of sound output channels; voice triggering, etc.

[0275] The audio service includes a series of audio interfaces, such as the interface function startBluetoothSco() for Bluetooth synchronous directional connection. The function of startBluetoothSco() is to request the use of Bluetooth headset for communication. Third-party applications can call the startBluetoothSco() function when making a virtual call. The audio service can also monitor the calling behavior of applications in the application layer calling the audio interface, and make logical judgments and responses to the calling behavior of the application.

[0276] The Bluetooth system service can provide all upper-layer services. For example, the upper-layer Bluetooth application displays the relevant information of the connected Bluetooth headset on the relevant interface (for example, in the status bar of the display interface, or in the notification bar, or on the Bluetooth management interface, or on the negative 1 screen, etc.), such as power, whether it is worn, service status, connection status, device name, device model, device icon, connection logo, etc. For example, turn Bluetooth on and off, set and get the local Bluetooth name, scan and cancel the scan of surrounding Bluetooth devices for traditional Bluetooth, get and remove the Bluetooth devices or lists that the local Bluetooth has paired with, etc.

[0277] The Bluetooth system service can also interact with the Bluetooth protocol stack by calling the interface, and implement the logical capabilities of the Bluetooth business by calling the Bluetooth protocol stack to support various functions in different Bluetooth scenarios.

[0278] The Bluetooth system service can receive information from Bluetooth devices, such as whether the Bluetooth headset is connected, whether it is worn, etc., and can determine whether the Bluetooth device is active based on the received information. For example, if the Bluetooth headset is normally connected to the electronic device and the Bluetooth headset is worn, the Bluetooth headset can be considered an active device. If the Bluetooth headset is not connected to the electronic device, or the Bluetooth headset is not worn, the Bluetooth headset can be considered an inactive device.

[0279] The Bluetooth system service can also communicate with the audio service and send relevant information about the Bluetooth device to the audio service, including device identification, whether it is active, etc., so that the audio service can manage the audio device connected to the electronic device. For example, if the Bluetooth headset is an active device, the Bluetooth headset can be used to output audio, and if the Bluetooth headset is an inactive device, the Bluetooth headset cannot be used to output audio.

[0280] In some implementations, after receiving the relevant information of the Bluetooth device, the audio service can determine whether to select the Bluetooth headset as the sound output channel according to the virtual call status of the third-party application, the current sound output channel, and whether the Bluetooth headset is active. After selecting the Bluetooth headset as the sound output channel, the audio service can call the interface (startscousingvirtualcall) in the Bluetooth system service to establish a SCO link with the Bluetooth headset.

[0281] In some implementations, after receiving relevant information of the Bluetooth device, the audio service can send the virtual call status of the third-party application to the Bluetooth system service, and the Bluetooth system service can determine whether to establish a SCO link with the Bluetooth headset based on information such as the virtual call status of the third-party application, the current sound output channel, and whether the Bluetooth headset is active.

[0282] In some implementations, when the Bluetooth system service receives the signal that the Bluetooth headset is taken off and put on, it sends a broadcast of simulated HFP connection disconnection and a broadcast of simulated HFP connection establishment to the third-party application. After receiving the broadcast of simulated HFP connection disconnection and the broadcast of simulated HFP connection establishment, the third-party application can send a first instruction to the audio service, and then the audio service sends a second instruction to the Bluetooth system service, instructing to establish a SCO link with the Bluetooth headset.

[0283] The window manager is used to manage window programs. The window manager can obtain the size of the display screen, determine whether there is a status bar, lock the screen, capture the screen, etc. The content provider is used to store and obtain data and make the data accessible to the application. The data may include video, images, audio, calls made and received, browsing history and bookmarks, phone books, etc. The view system includes visual controls, such as controls for displaying text, controls for displaying pictures, etc. The view system can be used to build applications. The display interface can be composed of one or more views. For example, a display interface including a text message notification icon may include a view for displaying text and a view for displaying pictures. The phone manager is used to provide communication functions for the electronic device 100. For example, the management of call status (including connected, hung up, etc.). The resource manager provides various resources for the application, such as localized strings, icons, pictures, layout files, video files, etc. The notification manager enables the application to display notification information in the status bar, which can be used to convey notification-type messages and can disappear automatically after a short stay without user interaction.

[0284] The Bluetooth protocol stack (Bluedroid) mainly includes the Bluetooth host (Host) protocol stack, which implements Bluetooth protocol packet parsing, packaging and processing of Bluetooth protocol flows, implements the use of Bluetooth protocols and Bluetooth links, and finally sends and receives Bluetooth raw data by using the Bluetooth hardware driver.

[0285] The Bluetooth protocol stack defines multiple application protocols (profiles) and core protocols (protocols) in the Bluetooth framework. Each profile defines its own corresponding message format and application rules. Profiles can also be called application specifications or configuration files. In order to achieve interoperability between different devices on different platforms, the Bluetooth protocol has formulated specifications for various possible and universal application scenarios, such as serial port profile (SPP), generic access profile (Generic Access Profile), Bluetooth audio transmission model protocol (Advanced Audio Distribution Profile, A2DP), headset specification (Headset Profile, HSP) and Bluetooth hands-free protocol (Hands-Free Profile, HFP) and so on.

[0286] The core protocols include but are not limited to the basic Bluetooth service protocol (service discovery protocol, SDP), logical link control, serial port linear simulation protocol (Radio Frequency Communication, RFCOMM) and adaptation protocol (logical link control and adaptation protocol, L2CAP), etc. The core protocol is indispensable in the Bluetooth protocol stack.

[0287] Among them, the HFP protocol is a protocol for realizing voice communication between Bluetooth devices, so that electronic devices can use Bluetooth headsets for voice calls. HFP defines two roles: audio gateway (AG) and hands-free unit (HF). The audio gateway is a gateway for audio input / output, such as a mobile phone. The hands-free unit is the remote audio input / output of the audio gateway and can provide several remote control functions, such as Bluetooth headsets. The implementation of virtual calls depends on the SCO link under the HFP protocol.

[0288] Android Runtime includes core libraries and virtual machines. Android runtime is responsible for scheduling and management of the Android system.

[0289] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.

[0290] The application layer and the application framework layer run in a virtual machine. The virtual machine executes the Java files of the application layer and the application 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.

[0291] The system library may include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0292] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications. The media library supports playback and recording of multiple common audio and video formats, as well as static image files. The media library can support multiple audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc. The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, synthesis, and layer processing. The 2D graphics engine is a drawing engine for 2D drawing.

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

[0294] The hardware layer includes display, camera, speaker (also called loudspeaker) and Bluetooth chip. The Bluetooth chip can include hardware units for realizing Bluetooth connection and data interaction: wireless radio unit (Radio), baseband (BB) or link controller (LC) unit, link management (LM) unit, etc. The wireless radio unit is used to realize the sending / receiving of data and voice. The baseband is responsible for frequency hopping and the transmission of Bluetooth data and information frames. The link management unit is used to convert radio frequency signals and digital or voice signals to each other, and realize baseband protocols and other underlying connection procedures; the link control unit is responsible for managing the communication between Bluetooth devices and realizing operations such as link establishment, verification, and link configuration.

[0295] In the embodiment of the present application, the Bluetooth headset 300 is a headset that supports the Bluetooth communication protocol. Specifically, the Bluetooth headset 300 can support the Headset Profile (HSP), the Hands-Free Profile (HFP), the Advanced Audio Distribution Profile (A2DP), and the Audio / Video Remote Control Profile (AVRCP).

[0296] For example, Fig.12 As shown, it is a schematic diagram of the structure of a Bluetooth headset 300 provided in an embodiment of the present application. The Bluetooth headset 300 may include at least one processor 301, at least one memory 302, a wireless communication module 303, an audio module 304, a power module 305, an input / output interface 306, a sensor 307, etc. The processor may include one or more interfaces for connecting to other components of the Bluetooth headset 300. In some embodiments, the Bluetooth headset 300 may be stored in an earphone box. Among them, the memory 302 may be used to store program codes. The processor 301 may be used to execute the above program code and call related modules to implement the functions of the Bluetooth headset 300 in the embodiment of the present application. The wireless communication module 303 may provide a Bluetooth communication solution for supporting communication between the Bluetooth headset 100 and the electronic device 100 or the earphone box. The audio management module 304 may be used to manage audio data and implement the input and output of audio signals by the Bluetooth headset 300. The power module 305 may be used to provide system power for the Bluetooth headset 300, power each module of the Bluetooth headset 300; support the Bluetooth headset 300 to receive charging input, etc. The input / output interface 306 may be a USB interface. In addition, the Bluetooth headset 300 may further include a sensor 307. For example, the sensor 307 may include a capacitive sensor, a distance sensor, and an infrared proximity sensor, which is used to determine whether the Bluetooth headset 300 is worn by the user.

[0297] It is understandable that the structure shown in the embodiment of the present application does not constitute a specific limitation on the Bluetooth headset 300. Fig.12More or fewer components shown may be combined with two or more components, or may have different component configurations. For example, the outer surface of the Bluetooth headset 300 may also include a button 308, an indicator light (which may indicate battery level, incoming / outgoing call, pairing mode, etc.), a display screen (which may prompt the user with relevant information), a dust screen (which may be used in conjunction with a handset), and other components. Among them, the button 308 may be a physical button or a virtual button (used in conjunction with a touch sensor), etc., which is used to trigger operations such as power on, power off, pause, play, record, start pairing, share audio, and reset.

[0298] The electronic device provided in this embodiment is used to execute the above method, so the same effect as the above implementation method can be achieved. In the case of an integrated unit, the electronic device may include a processing module, a storage module and a communication module. Among them, the processing module can be used to control and manage the actions of the electronic device, for example, it can be used to support the electronic device to execute the steps performed by the processing unit. The storage module can be used to support the electronic device to execute stored program codes and data, etc. The communication module can be used to support the communication between the electronic device and other devices.

[0299] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps in the above-mentioned method embodiments can be implemented.

[0300] An embodiment of the present application provides a computer program product. When the computer program product runs on a mobile terminal, the electronic device can implement the steps in the above-mentioned method embodiments when executing the computer program product.

[0301] In addition, an embodiment of the present application also provides a device, which may specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor may execute the computer-executable instructions stored in the memory so that the chip executes the methods in the above-mentioned method embodiments.

[0302] In the embodiments provided in the present application, it should be understood that the disclosed devices / electronic devices and methods can be implemented in other ways. For example, the device / electronic device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0303] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0304] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, which can be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may at least include: any entity or device that can carry the computer program code to the camera / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electric carrier signal, a telecommunication signal, and a software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk or an optical disk. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electric carrier signals and telecommunication signals.

[0305] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0306] In the above description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0307] It should be understood that when used in the present specification and the appended claims, the term "comprising" indicates the presence of described features, wholes, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, wholes, steps, operations, elements, components and / or combinations thereof.

[0308] It should also be understood that the "multiple" mentioned in the specification and the appended claims of this application refers to two or more. In the description of this application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of associated objects, which means any combination of one or more of the items listed in the association and all possible combinations, and includes these combinations, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone.

[0309] As used in the specification and appended claims of this application, the term "if" can be interpreted as "when" or "uponce" or "in response to determining" or "in response to detecting", depending on the context. Similarly, the phrase "if it is determined" or "if [described condition or event] is detected" can be interpreted as meaning "uponce it is determined" or "in response to determining" or "uponce [described condition or event] is detected" or "in response to detecting [described condition or event]", depending on the context.

[0310] In addition, in order to facilitate the clear description of the technical solution of the present application, the words "first", "second" and the like are used to distinguish the same items or similar items with substantially the same functions and effects. Those skilled in the art will understand that the words "first", "second" and the like do not limit the quantity and execution order, and cannot be understood as indicating or implying relative importance, and the words "first", "second" and the like do not necessarily limit differences. The terms "include", "comprise", "have" and their variations all mean "include but are not limited to", unless otherwise specifically emphasized.

[0311] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. An audio control method, characterized in that: The electronic device is connected to the Bluetooth headset via wireless communication, and the electronic device includes a Bluetooth module and an audio module. The method includes: Outputting the audio stream of the voice call or video call through the Bluetooth headset in the wearing state; In response to receiving the information that the Bluetooth headset is not worn, the audio module switches the channel of the output audio stream from the Bluetooth headset to the earpiece or speaker in the electronic device; In the case of receiving information that the Bluetooth headset is not worn and receiving information that the Bluetooth headset is worn after receiving the information that the Bluetooth headset is not worn, the Bluetooth module sends first information and second information to the application for the voice call or the video call in sequence, wherein the first information indicates that the Bluetooth hands-free protocol HFP connection between the Bluetooth headset and the electronic device is disconnected, and the second information indicates that the HFP connection between the Bluetooth headset and the electronic device is established; The audio module receives a first instruction, wherein the first instruction is sent to the audio module by the application for the voice call or the video call in response to receiving the first information and the second information, and the first instruction is used to instruct to start establishing a synchronous directional connection (SCO) link between the Bluetooth headset and the electronic device; In response to receiving the first instruction, the audio module sends a second instruction to the Bluetooth module, wherein the second instruction is used to instruct the Bluetooth module to start the SCO link for the voice call or the video call; In response to receiving the second instruction, the Bluetooth module establishes the SCO link with the Bluetooth headset; After the SCO link is successfully established, the audio module switches the channel for outputting the audio stream from the receiver or the speaker to the Bluetooth headset, and outputs the audio stream in the voice call or the video call through the Bluetooth headset.

2. The method according to claim 1, characterized in that The first instruction is an instruction for calling the startbluetoothsco interface.

3. The method according to claim 1 or 2, characterized in that: The second instruction is an instruction for calling the startscousingvirtualcall interface.

4. The method according to any one of claims 1 to 3, characterized in that In the case where the information that the Bluetooth headset is not worn is received and the information that the Bluetooth headset is worn is received after the information that the Bluetooth headset is not worn is received, the Bluetooth module sends the first information and the second information to the application for the voice call or the video call in sequence, including: In response to receiving the information that the Bluetooth headset is in an unworn state, the Bluetooth module sends the first information to an application for performing the voice call or the video call; After sending the first information, in response to receiving the information that the Bluetooth headset is in a wearing state, the Bluetooth module sends the second information to the application for conducting the voice call or the video call.

5. The method according to claim 4, characterized in that After sending the first information, in response to receiving information that the Bluetooth headset is in a wearing state, the Bluetooth module sends the second information to an application for the voice call or the video call, including: After sending the first information, in response to receiving information that the Bluetooth headset is in a wearing state, the Bluetooth module sends the second information to multiple applications in the electronic device, and the multiple applications include an application for conducting the voice call or the video call.

6. The method according to any one of claims 1 to 3, characterized in that In the case where the information that the Bluetooth headset is not worn is received and the information that the Bluetooth headset is worn is received after the information that the Bluetooth headset is not worn is received, the Bluetooth module sends the first information and the second information to the application for the voice call or the video call in sequence, including: After receiving the information that the Bluetooth headset is not worn, in response to receiving the information that the Bluetooth headset is worn, the Bluetooth module sends the first information and the second information successively to the application for the voice call or the video call.

7. The method according to any one of claims 3 to 6, characterized in that After the Bluetooth module sends the second information to the application for the voice call or the video call, the method further includes: The Bluetooth module determines whether the second instruction is received within a preset time; When the second instruction is not received within a preset time, the Bluetooth module automatically establishes the SCO link with the Bluetooth headset.

8. An audio control method, characterized in that: The electronic device is connected to the Bluetooth headset via wireless communication, and the electronic device includes a Bluetooth module and an audio module. The method includes: Outputting the audio stream of the voice call or video call through the Bluetooth headset in the wearing state; In response to receiving the information that the Bluetooth headset is not worn, the audio module switches the channel of the output audio stream from the Bluetooth headset to the earpiece or speaker in the electronic device; After receiving the information that the Bluetooth headset is in the unworn state, in response to receiving the information that the Bluetooth headset is in the worn state, the Bluetooth module sends second information to multiple applications in the electronic device, wherein the second information indicates that a Bluetooth hands-free protocol HFP connection between the Bluetooth headset and the electronic device has been established; When the audio module does not receive the first instruction and the voice call or the video call is in progress, or when the Bluetooth module does not receive the second instruction and the voice call or the video call is in progress, the Bluetooth module establishes a synchronous directional connection SCO link with the Bluetooth headset, wherein the first instruction is used to start establishing a SCO link between the Bluetooth headset and the electronic device, and the second instruction is used to instruct the Bluetooth module to start the SCO link for the voice call or the video call; After the SCO link is successfully established, the audio module switches the channel for outputting the audio stream from the receiver or the speaker to the Bluetooth headset, and outputs the audio stream in the voice call or the video call through the Bluetooth headset.

9. The method according to claim 8, characterized in that The first instruction is an instruction for calling the startbluetoothsco interface.

10. The method according to claim 8 or 9, characterized in that: The second instruction is an instruction for calling the startscousingvirtualcall interface.

11. The method according to any one of claims 8 to 10, characterized in that When the audio module does not receive the first instruction and the voice call or the video call is in progress, the Bluetooth module establishes a SCO link with the Bluetooth headset, including: When the audio module does not receive the first instruction and the voice call or the video call is in progress, the audio module sends the second instruction to the Bluetooth module; In response to receiving the second instruction, the Bluetooth module establishes the SCO link with the Bluetooth headset.

12. The method according to claim 11, characterized in that When the audio module does not receive the first instruction and the voice call or the video call is in progress, the audio module sends the second instruction to the Bluetooth module, including: When the voice call or the video call is in progress and the application for conducting the voice call or the video call is a preset application, the audio module sends the second instruction to the Bluetooth module, and the preset application is an application that does not send the first instruction to the audio module when receiving the second information.

13. The method according to claim 11, characterized in that When the audio module does not receive the first instruction and the voice call or the video call is in progress, the audio module sends the second instruction to the Bluetooth module, including: When the voice call or the video call is in progress and the priority of the receiver or the speaker is lower than that of the Bluetooth headset, the audio module sends the second instruction to the Bluetooth module.

14. The method according to any one of claims 8 to 10, characterized in that When the Bluetooth module does not receive the second instruction and the voice call or the video call is in progress, the Bluetooth module establishes the SCO link with the Bluetooth headset, including: When the voice call or the video call is in progress and the application for the voice call or the video call is a preset application, the Bluetooth module establishes the SCO link with the Bluetooth headset, and the preset application is an application that does not send a first instruction to the audio module when the second information is received.

15. The method according to claim 14, characterized in that In a case where the application for conducting the voice call or the video call is a preset application, the Bluetooth module and the Bluetooth headset establish the SCO link, including: In a case where the application for conducting the voice call or the video call is a preset application and the priority of the receiver or the speaker is lower than that of the Bluetooth headset, the Bluetooth module establishes the SCO link with the Bluetooth headset.

16. An electronic device, characterized in that: include: one or more processors; one or more memories; The memory stores one or more programs, and when the one or more programs are executed by the processor, the electronic device executes the method of any one of claims 1 to 7, or the method of any one of claims 8 to 15.

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