Audio playing method, electronic device and chip system

By switching the data routing of the speakers in electronic devices, the sound leakage problem is solved when the headset and speakers are played simultaneously, ensuring that the audio does not leak through the first speaker after being turned off, improving the user experience and universality of the solution.

CN118900381BActive Publication Date: 2025-07-25HONOR DEVICE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202410873614.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-06-28
Publication Date
2025-07-25
Estimated Expiration
2044-06-28

AI Technical Summary

Technical Problem

In electronic devices where analog power amplifiers do not have digital-to-analog conversion capabilities, due to the software and hardware design defects of the codec chip, the speaker will multiplex the audio path of the analog headphones, causing the audio sound in the headphone path to briefly leak out of the speaker after the ringtone is turned off when the analog headphones and the speakers play at the same time, causing the electronic device to leak sound.

Method used

By determining whether it is a sound leakage scene caused by double ringing ringtones when the audio stream is turned on or switched, and switching the data route of the first speaker from the default audio path to the corresponding audio path of the second speaker is ensured that the audio does not leak through the first speaker after the audio to be played is turned off.

Benefits of technology

It effectively solves the sound leakage problem in the double ringtone scene, protects user privacy, improves user experience, and improves the versatility and practicality of the speaker sound leakage cancellation solution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118900381B_ABST
    Figure CN118900381B_ABST
Patent Text Reader

Abstract

This application is applicable to the field of audio technology, and provides an audio playback method, an electronic device, and a chip system. The method includes: when an audio stream start instruction or an audio stream device switching instruction of the electronic device is obtained, determining the type of audio component corresponding to the electronic device; when the type of audio component is a preset type, determining a target output device for the audio to be played; when the target output device includes an analog headphone and a speaker, switching the data routing of the first speaker from the default audio path to the audio path corresponding to the second speaker; outputting the audio to be played through the target output device. Thus, by switching the data routing of the first speaker from the default audio path multiplexed with the analog headphone to the audio path corresponding to the second speaker, the problem of sound leakage of the electronic device speaker after the ringtone is turned off in the ringtone double-ring scenario is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of audio technology, and in particular, relates to an audio playback method, an electronic device, a chip system, a computer-readable storage medium, and a computer program product. Background Art

[0002] In some electronic devices with audio playback functions (such as smartphones), stereo effects can be achieved through dual speakers. In some electronic devices that use an analog power amplifier (PA) to amplify audio signals, since the analog PA does not have the ability to convert digital-to-analog, a codec chip is also required to convert the digital audio signal into an analog audio signal, input the analog audio signal to the analog PA for amplification, and then output it through an audio output device (such as headphones, speakers, etc.).

[0003] In the related art, for some types of codec chips, due to design defects in their software and hardware, one speaker of the electronic device reuses the audio path of the analog headphones. Therefore, when playing audio with the analog headphones plugged in and the ringtone sounds and is played simultaneously through the analog headphones and the speaker, after turning off the ringtone, audio playback will resume in the analog headphones, but at this time, the audio in the headphone path will also leak out briefly from this speaker, resulting in sound leakage of the electronic device. Summary of the Invention

[0004] Embodiments of this application provide an audio playback method, an electronic device, a chip system, a computer-readable storage medium, and a computer program product, which can solve the problem that for some types of codec chips, due to design defects in their software and hardware, one speaker of the electronic device reuses the audio path of the analog headphones. Therefore, when playing audio with the analog headphones plugged in and the ringtone sounds and is played simultaneously through the analog headphones and the speaker, after turning off the ringtone, the audio in the headphone path will leak out briefly from the speaker, resulting in sound leakage of the electronic device.

[0005] In a first aspect, embodiments of this application provide an audio playback method, including: when an audio stream start instruction or an audio stream device switching instruction of the electronic device is obtained, determining the type of audio component corresponding to the electronic device; when the type of audio component is a preset type, determining a target output device corresponding to the audio to be played; when the target output device includes an analog headphone and a speaker, switching the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker, where the speakers include a first speaker and a second speaker, and the first speaker refers to the speaker that reuses the default audio path with the analog headphone; outputting the audio to be played through the target output device.

[0006] In this way, when the audio stream is turned on or the audio stream device is switched, according to the audio component type corresponding to the electronic device and the target output device corresponding to the audio to be played, it is determined whether the current is a sound leakage scenario caused by dual-ringing of the ringtone. If the current is a sound leakage scenario caused by dual-ringing of the ringtone, the data routing of the first speaker can be switched from the default audio path multiplexed with the analog headset to the audio path corresponding to the second speaker, so that the first speaker and the second speaker output the same audio data. Thus, after the audio to be played is turned off, other audio output through the analog headset will not leak out through the first speaker, solving the problem of sound leakage of the electronic device speaker after the ringtone is turned off in the dual-ringing ringtone scenario, protecting the user's privacy, and improving the user experience.

[0007] In a possible implementation manner of the first aspect, the above switching the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker includes:

[0008] Read the audio path configuration parameters;

[0009] When the preset string is included in the audio path configuration parameters, send a data routing switching instruction to the codec chip, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0010] In this way, by identifying whether the data routing of the first speaker needs to be switched through the preset string in the set audio path configuration parameters to avoid sound leakage of the speaker, the sound leakage elimination solution of the speaker can be applied to all types of electronic devices without modifying the code, improving the versatility and practicality of the speaker sound leakage elimination solution.

[0011] Optionally, in another possible implementation manner of the first aspect, the above sending a data routing switching instruction to the codec chip when the preset string is included in the audio path configuration parameters, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker includes:

[0012] When the preset string is included in the audio path configuration parameters, determine the audio stream type corresponding to the audio to be played;

[0013] When the audio stream type corresponding to the audio to be played is the preset audio stream type, send a data routing switching instruction to the codec chip, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0014] Thus, since the audio streams that need to be played simultaneously in the speaker and the earphone are usually several specific audio stream types, such as incoming call ringtones, alarm clock ringtones, etc., it is possible to switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker when it is determined that the audio stream type corresponding to the audio to be played is a preset audio stream type, so as to further improve the accuracy of leaky sound scenario discrimination, prevent frequent switching of the speaker's data routing in unnecessary scenarios, and affect the stability of audio playback, thereby further improving the accuracy and reliability of speaker leaky sound cancellation and further enhancing the user experience.

[0015] Optionally, in another possible implementation manner of the first aspect, the determining the audio component type corresponding to the electronic device includes:

[0016] Query the device tree file corresponding to the electronic device to determine the configuration item corresponding to the audio component type;

[0017] Determine the audio component type corresponding to the electronic device according to the configuration item corresponding to the audio component type.

[0018] Thus, by pre-defining the configuration item corresponding to the audio component type of the electronic device in the device tree file corresponding to the electronic device, to directly determine whether the audio component type corresponding to the electronic device belongs to the audio component type of the leaky sound scenario through the value of this configuration item, and then determine whether to execute the leaky sound cancellation solution of this application according to the discrimination result. Therefore, regardless of whether the audio component type corresponding to the electronic device is a preset audio component type belonging to the leaky sound scenario, the leaky sound cancellation solution of the speaker of this application can be compatible, thereby improving the versatility and practicality of the leaky sound cancellation solution of the speaker.

[0019] Optionally, in another possible implementation manner of the first aspect, the audio to be played includes the audio of the left channel to be played and the audio of the right channel to be played; correspondingly, before outputting the audio to be played through the target output device, it further includes:

[0020] Mix the audio of the left channel to be played and the audio of the right channel to be played to generate the mixed audio to be played;

[0021] Correspondingly, the outputting the audio to be played through the target output device includes:

[0022] Output the mixed audio to be played through the target output device.

[0023] Thus, since the user may adjust the audio path corresponding to the second speaker to silent in some usage scenarios, if the data routing of the first speaker is switched to the audio path corresponding to the second speaker in this case, it will cause both the first speaker and the second speaker to play silent data, resulting in the inability to play the audio to be played normally. Therefore, to prevent this situation, after switching the data routing of the first speaker, the left and right channel data of the audio to be played can be mixed. Then, the first speaker and the second speaker will output the mixed audio, preventing the situation of silent external playback when there is a double ringtone. This not only eliminates the speaker sound leakage in the double ringtone scenario but also prevents the situation of silent speakers when there is a double ringtone, further improving the reliability of sound leakage elimination and further enhancing the user experience.

[0024] Optionally, in another possible implementation manner of the first aspect, the above-mentioned mixing process of the left-channel audio to be played and the right-channel audio to be played to generate the mixed audio to be played includes:

[0025] Read the audio path configuration parameters;

[0026] When the audio path configuration parameters contain a preset string, send a speaker mixing instruction to the digital signal processing (DSP) chip, so that the DSP chip mixes the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played.

[0027] In this way, by identifying whether to switch the data routing of the first speaker through a preset string in the set audio path configuration parameters to avoid speaker sound leakage, and by sending the speaker mixing processing method through the speaker mixing instruction, the sound leakage elimination solution for speakers can be applied to all types of electronic devices without modifying the code, improving the generality and practicality of the speaker sound leakage elimination solution.

[0028] Optionally, in another possible implementation manner of the first aspect, the above-mentioned step of sending a speaker mixing instruction to the DSP chip when the audio path configuration parameters contain a preset string, so that the DSP chip mixes the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played includes:

[0029] When the audio path configuration parameters contain a preset string, determine the audio stream type corresponding to the audio to be played;

[0030] When the audio stream type corresponding to the audio to be played is a preset audio stream type, send a speaker mixing instruction to the DSP chip, so that the DSP chip mixes the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played.

[0031] In this way, since the audio streams that need to be played simultaneously in the speaker and the earphone are usually several specific audio stream types, such as incoming call ringtones, alarm clock ringtones, etc., it is possible to determine that when the audio stream type corresponding to the audio to be played is a preset audio stream type, then switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker, and perform mixing processing on the audio data of the left and right channels, so as to further improve the accuracy of leaky sound scene discrimination, prevent mixing in unnecessary scenes, affect the stability of audio playback, waste computing power, thereby further improving the accuracy and reliability of speaker leaky sound elimination, reducing the power consumption of the electronic device, and further enhancing the user experience.

[0032] In a second aspect, an embodiment of the present application provides an audio playback device, including: a first determination module, configured to determine the audio component type corresponding to the electronic device when an audio stream start instruction or an audio stream device switching instruction of the electronic device is obtained; a second determination module, configured to determine the target output device corresponding to the audio to be played when the audio component type is a preset type; a switching module, configured to switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker when the target output device includes an analog earphone and a speaker, where the speaker includes a first speaker and a second speaker, and the first speaker refers to the speaker that shares the default audio path with the analog earphone; an output module, configured to output the audio to be played through the target output device.

[0033] In this way, when the audio stream is started or the audio stream device is switched, according to the audio component type corresponding to the electronic device and the target output device corresponding to the audio to be played, it is determined whether the current is a leaky sound scene caused by double-ringing of the ringtone. If the current is a leaky sound scene caused by double-ringing of the ringtone, the data routing of the first speaker can be switched from the default audio path shared with the analog earphone to the audio path corresponding to the second speaker, so that the first speaker and the second speaker output the same audio data. Thus, after the audio to be played is turned off, other audio output through the analog earphone will not leak out through the first speaker, solving the problem of speaker leaky sound of the electronic device after the ringtone is turned off in the double-ringing ringtone scene, protecting user privacy, and enhancing the user experience.

[0034] In a possible implementation manner of the second aspect, the above switching module includes:

[0035] A first reading unit for reading audio path configuration parameters;

[0036] A first switching unit for sending a data routing switching instruction to a codec chip when a preset string is included in the audio path configuration parameters, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0037] In this way, by identifying whether the data routing of the first speaker needs to be switched through a preset string in the set audio path configuration parameters, speaker sound leakage can be avoided, so that the speaker sound leakage elimination solution can be applied to all types of electronic devices, improving the versatility and practicality of the speaker sound leakage elimination solution.

[0038] Optionally, in another possible implementation manner of the second aspect, the above-mentioned first switching unit is specifically used for:

[0039] When a preset string is included in the audio path configuration parameters, determining the audio stream type corresponding to the audio to be played;

[0040] When the audio stream type corresponding to the audio to be played is a preset audio stream type, sending a data routing switching instruction to the codec chip, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0041] In this way, since the audio streams that need to be played simultaneously in the speaker and the earphone are usually several specific audio stream types, such as incoming call ringtones, alarm clock ringtones, etc., it is possible to switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker when it is determined that the audio stream type corresponding to the audio to be played is a preset audio stream type, so as to further improve the accuracy of leaky sound scene discrimination, prevent frequent switching of the speaker data routing in unnecessary scenes, and affect the stability of audio playback, thereby further improving the accuracy and reliability of speaker sound leakage elimination and further improving the user experience.

[0042] Optionally, in yet another possible implementation manner of the second aspect, the above-mentioned first determination module includes:

[0043] A first query unit for querying the device tree file corresponding to the electronic device to determine the configuration item corresponding to the audio component type;

[0044] A first determination unit for determining the audio component type corresponding to the electronic device according to the configuration item corresponding to the audio component type.

[0045] In this way, by pre-defining configuration items corresponding to the audio component types of the electronic device in the device tree file of the electronic device, it is possible to directly determine whether the audio component type corresponding to the electronic device belongs to the audio component type in the sound leakage scenario based on the values of the configuration items, and then determine whether to execute the sound leakage elimination solution of the present application according to the determination result. Therefore, regardless of whether the audio component type corresponding to the electronic device is a preset audio component type belonging to the sound leakage scenario, the speaker sound leakage elimination solution of the present application can be compatible, thereby improving the versatility and practicality of the speaker sound leakage elimination solution.

[0046] Optionally, in another possible implementation manner of the second aspect, the to-be-played audio includes to-be-played left-channel audio and to-be-played right-channel audio; correspondingly, the above device further includes:

[0047] A mixing module, configured to perform mixing processing on the to-be-played left-channel audio and the to-be-played right-channel audio to generate to-be-played mixed audio;

[0048] Correspondingly, the above output module includes:

[0049] A first output unit, configured to output the to-be-played mixed audio through a target output device.

[0050] In this way, since in some usage scenarios, the user may adjust the audio path corresponding to the second speaker to be silent, so in this case, if the data routing of the first speaker is switched to the audio path corresponding to the second speaker, it will cause both the first speaker and the second speaker to play silent data, resulting in the to-be-played audio not being played normally. Therefore, to prevent this situation, after switching the data routing of the first speaker, the left and right channel data of the to-be-played audio can be mixed, then the first speaker and the second speaker will output the mixed audio, preventing the situation of no sound when the ringtone sounds twice, thereby not only eliminating the speaker sound leakage in the ringtone double-ring scenario, but also preventing the situation of no sound from the speaker when the ringtone sounds twice, further improving the reliability of sound leakage elimination and further enhancing the user experience.

[0051] Optionally, in another possible implementation manner of the second aspect, the above mixing module includes:

[0052] A second reading unit, configured to read audio path configuration parameters;

[0053] A first mixing unit, configured to send a speaker mixing instruction to the DSP chip when the audio path configuration parameters contain a preset string, so that the DSP chip performs mixing processing on the to-be-played left-channel audio and the to-be-played right-channel audio according to the speaker mixing instruction to generate to-be-played mixed audio.

[0054] In this way, by identifying whether it is necessary to switch the data routing of the first speaker through a preset string in the set audio path configuration parameters to avoid speaker sound leakage, and by sending the speaker mixing instruction to the DSP chip to implement the mixing processing method of the speaker, the solution for eliminating speaker sound leakage can be applied to all types of electronic devices, improving the universality and practicality of the speaker sound leakage elimination solution.

[0055] Optionally, in another possible implementation manner of the second aspect, the above first mixing unit is specifically configured to:

[0056] When a preset string is included in the audio path configuration parameters, determine the audio stream type corresponding to the audio to be played;

[0057] When the audio stream type corresponding to the audio to be played is a preset audio stream type, send a speaker mixing instruction to the DSP chip, so that the DSP chip performs mixing processing on the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played.

[0058] In this way, since the audio streams that need to be played simultaneously in the speaker and the earphone are usually several specific audio stream types, such as incoming call ringtones, alarm clock ringtones, etc., it is possible to switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker when it is determined that the audio stream type corresponding to the audio to be played is a preset audio stream type, and perform mixing processing on the audio data of the left and right channels, so as to further improve the accuracy of leaky sound scene discrimination, prevent mixing in unnecessary scenes, affect the stability of audio playback, waste computing power, thereby further improving the accuracy and reliability of speaker sound leakage elimination, reducing the power consumption of the electronic device, and further improving the user experience.

[0059] In a third aspect, an embodiment of the present application provides an electronic device, including: one or more processors, and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the electronic device to execute the audio playback method as described above.

[0060] In a fourth aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions to cause the electronic device to execute the audio playback method as described above.

[0061] In a fifth aspect, an embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium includes instructions, and when the instructions run on an electronic device, the electronic device is caused to execute the audio playback method as described above.

[0062] In a sixth aspect, an embodiment of the present application provides a computer program product. When the computer program product runs on an electronic device, the electronic device is caused to execute the audio playback method as described above.

[0063] The technical effects obtained in the above second aspect, third aspect, fourth aspect, fifth aspect, and sixth aspect are similar to the technical effects obtained by the corresponding technical means in the above first aspect, and will not be elaborated here. Description of the Drawings

[0064] To more clearly illustrate the technical solutions in the embodiments of the present application, the following will briefly introduce the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0065] Figure 1 is a schematic flowchart of an audio playback method provided by an embodiment of the present application;

[0066] Figure 2 is a schematic structural diagram of a codec chip provided by an embodiment of the present application;

[0067] Figure 3 is a schematic diagram of a multiplexed audio path for an upper speaker and a left headphone channel provided by an embodiment of the present application;

[0068] Figure 4 is a schematic diagram of routing switching for an upper speaker provided by an embodiment of the present application;

[0069] Figure 5 is a schematic diagram of an audio stream after a to-be-played audio is turned off provided by an embodiment of the present application;

[0070] Figure 6 is a schematic flowchart of an audio playback method provided by another embodiment of the present application;

[0071] Figure 7 is a flowchart block diagram of mixing the left and right channels of a speaker provided by an embodiment of the present application;

[0072] Figure 8 is a schematic flowchart of an audio playback method provided by still another embodiment of the present application;

[0073] Figure 9 is a schematic structural diagram of an audio playback device provided by an embodiment of the present application;

[0074] Figure 10It is a schematic structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0075] The audio playing method, device, electronic device, chip system, storage medium and computer program provided by the present application will be described in detail below with reference to the accompanying drawings.

[0076] Please refer to Figure 1 , Figure 1 It is a schematic flowchart of an audio playing method provided by an embodiment of the present application. The method may include the following parts or all of the content:

[0077] Step 101: When an audio stream start instruction or an audio stream device switching instruction of the electronic device is obtained, determine the audio component type corresponding to the electronic device.

[0078] It should be noted that the audio playing method of the embodiment of the present application may be executed by the audio playing device of the embodiment of the present application. The audio playing device of the embodiment of the present application may be configured in any electronic device with a display function to execute the audio playing method of the embodiment of the present application. For example, the audio playing device of the embodiment of the present application may be configured in electronic devices such as mobile phones, computers, and wearable devices to eliminate the sound leakage of the speaker.

[0079] It should be noted that the operating system installed in the electronic device in the embodiment of the present application is not limited, and may be an Android system, a Windows Phone (WP) operating system, an IOS system, etc. Exemplarily, for the convenience of description, the Android system is used for subsequent description in the embodiment of the present application.

[0080] First, the cause of the technical problem to be solved by the present application and the applicable scenarios of the present application will be described:

[0081] In some electronic devices that use an analog PA to amplify audio signals, since the analog PA does not have the ability to convert digital signals to analog signals, a codec chip is also required to convert the digital audio signal into an analog audio signal, input the analog audio signal to the analog PA for amplification, and then output it through an audio output device (such as headphones, speakers, etc.). For such an electronic device that combines a codec chip and a dual analog PA to achieve a stereo design, a speaker sound leakage problem will occur when using certain types of codec chips. For example, when playing music with an analog headphone plugged in and an alarm rings, the alarm will play simultaneously through the headphone and the speaker. After turning off the alarm, the music will resume playing through the headphone, and at this time, the music sound will briefly leak out from the upper speaker. This problem is caused by the combined limitations of hardware and software.

[0082] In terms of hardware, there are hardware design flaws in certain types of codec chips. For example, Figure 2 as shown, this codec chip has only 3 input ports: the left headphone channel input (IN1_HPHL), the right headphone channel input (IN2_HPHR), and the speaker input (IN3_AUX), but it needs to support 4 output ports: the earpiece (EAR), the left headphone channel output (HPHL), the right headphone channel output (HPHR), and the speaker output (AUX) (wherein, the earpiece in the embodiments of the present application can also be referred to as the upper speaker, and the speaker can also be referred to as the lower speaker). To achieve stereo characteristics, the upper speaker (EAR) can be multiplexed with the left headphone channel (HPHL) for the audio path as Figure 2 shown.

[0083] In terms of software, analog headphones and speakers have different backends (BE). Due to the limitations of other characteristics and framework layer customization strategies, analog headphone devices and speaker devices cannot be configured with the same BE in the DSP. Since their BEs are different and they do not compete for DSP ports, when switching between devices involving analog headphones and speakers, only the required device will be switched to, and the other device path will not be forced to close, but will automatically close after waiting for a period of time (such as 3 seconds) according to the Android mechanism.

[0084] Therefore, due to the above-mentioned software and hardware limitations, there will be a problem of leakage of the upper speaker in the ringtone double-ring scenario. For example, the alarm ringtone is played simultaneously through analog headphones and speakers. After turning off the alarm, music resumes playing on the analog headphones. At this time, there is no audio stream on the speaker, but because the BE of the upper speaker is different from that of the analog headphones, it will not be forced to close and will still be open for 3 seconds. As Figure 3 shown, during this period, since the audio path of the left headphone channel is multiplexed with the upper speaker, the audio data 310 (i.e., music) of the left headphone channel will be played simultaneously on the left headphone channel and the upper speaker, resulting in sound leakage.

[0085] Among them, the audio stream opening instruction can refer to the instruction to open the audio stream when there is no audio being played in the electronic device. For example, when the electronic device is not playing any audio, if the user opens a music software to play music, opens a video software to play a video, opens a short video software to play a short video, plays voice information or video information in a social software, or plays the recorded data stored in the electronic device, etc., it can be determined that the audio stream opening instruction of the electronic device is obtained. Or, when the electronic device is not playing any audio, if the alarm rings, the incoming call rings, or a message notification is triggered, it can also be determined that the audio stream opening instruction of the electronic device is obtained.

[0086] Among them, the audio stream device switching instruction may refer to an instruction for switching the output device of the audio stream when there is an audio being played in the electronic device. For example, when playing music through the speaker and the user connects headphones, the output device of the music is switched from the speaker to the headphones at this time, and it can be determined that an audio stream device switching instruction is obtained; another example is that when the alarm rings while playing music through the headphones, the audio stream corresponding to the alarm ringtone needs to be played through the speaker and the headphones simultaneously, that is, the output device of the audio stream is switched from the headphones to the headphones and the speaker, and it can be determined that an audio stream device switching instruction is obtained.

[0087] It should be noted that the types and triggering scenarios of the above-listed audio stream enabling instructions and audio stream device switching instructions are only exemplary and should not be regarded as a limitation to this application. In actual use, the types and triggering scenarios of the audio stream enabling instructions and audio stream device switching instructions can be determined according to actual needs and specific application scenarios, and the embodiments of this application do not make any limitations in this regard.

[0088] Among them, the audio component type may include the type of the codec chip and the type of the PA.

[0089] In the embodiments of this application, each time an audio stream enabling instruction and an audio stream device switching instruction are obtained, that is, each time audio playback is started or the audio output device is switched, the audio component type corresponding to the electronic device can be determined to determine whether the audio component type corresponding to the electronic device is the audio component type that causes speaker sound leakage, so as to determine whether subsequent processing for eliminating speaker sound leakage needs to be performed according to the subsequent steps of the embodiments of this application.

[0090] Furthermore, the configuration item corresponding to the audio component type of the electronic device can be predefined in the device tree file corresponding to the electronic device, so as to directly determine whether the audio component type corresponding to the electronic device belongs to the audio component type in the sound leakage scenario through the value of this configuration item, and then determine whether to execute the sound leakage elimination solution of this application according to the determination result. Therefore, regardless of whether the audio component type corresponding to the electronic device belongs to the preset audio component type in the sound leakage scenario, the sound leakage elimination solution of this application can be compatible, thereby improving the generality and practicability of the sound leakage elimination solution of the speaker. That is, in a possible implementation manner of the embodiments of this application, the above step 101 may include:

[0091] Query the device tree file corresponding to the electronic device to determine the configuration item corresponding to the audio component type;

[0092] Determine the audio component type corresponding to the electronic device according to the configuration item corresponding to the audio component type.

[0093] As a possible implementation, configuration items corresponding to the audio component type can be customized in the device tree file of the electronic device, and the value of the configuration item can be determined in advance according to whether the type of the audio component installed in the electronic device is a preset type that causes speaker sound leakage. For example, if the type of the audio component installed in the electronic device is the preset type, the value of the configuration item can be determined in advance as the first preset value (such as 1); if the type of the audio component installed in the electronic device is not the preset type, the value of the configuration item can be determined in advance as the first preset value (such as 0). Each time the electronic device plays audio or switches the audio output device, the value of the configuration item can be queried, and the audio component type corresponding to the electronic device can be determined according to the value of the configuration item. For example, if the value of the configuration item is the first preset value, it can be determined that the audio component type corresponding to the electronic device is the preset type, and the current situation may cause a sound leakage problem; if the value of the configuration item is the second preset value, it can be determined that the audio component type corresponding to the electronic device is not the preset type, and the current situation will not cause a sound leakage problem.

[0094] For example, Figure 2 When the codec chip of type A and the dual analog PA shown in the figure are combined to achieve speaker stereo, it will cause a speaker sound leakage problem. Then, the type of the codec chip being type A and the type of the PA being an analog PA can be used as the preset type. Thus, when the type of the codec chip installed in the electronic device is type A and the type of the PA is an analog PA, the value of the configuration item corresponding to the audio component type in the device tree file can be determined as 1; when the type of the codec chip installed in the electronic device is not type A or the type of the PA is not an analog PA, the value of the configuration item corresponding to the audio component type in the device tree file can be determined as 0.

[0095] It should be noted that the above example is only exemplary and should not be regarded as a limitation to this application. In actual use, according to actual needs and specific application scenarios, any audio component type that may cause speaker sound leakage can be determined as the preset type, and the embodiments of this application do not make any limitations in this regard.

[0096] Step 102, when the audio component type is the preset type, determine the target output device corresponding to the audio to be played.

[0097] Among them, the preset type may refer to the audio component type that may cause speaker sound leakage problems in the electronic device.

[0098] Among them, the audio to be played can refer to the audio data that needs to be output through the audio output device in the electronic device currently. For example, if the user currently opens a music player software to play music, the audio to be played can be the music currently played by the user; another example, if the electronic device currently receives an incoming call, the audio to be played can be the incoming call ringtone; another example, if the alarm clock set in the electronic device reaches the ringing time currently, the audio to be played can be the alarm clock ringtone, and so on.

[0099] Among them, the target output device can refer to the audio output device in the electronic device that is currently used to output the audio to be played. For example, if the user currently opens a music player software to play music and the electronic device is not connected to headphones, the target output device corresponding to the audio to be played can be the speaker; another example, if the user currently opens a music player software to play music and the electronic device is connected to headphones, the target output device corresponding to the audio to be played can be the headphones; another example, if the alarm clock set in the electronic device reaches the ringing time currently and the electronic device is not connected to headphones, the target output device corresponding to the audio to be played can be the speaker; another example, if the alarm clock set in the electronic device reaches the ringing time currently and the electronic device is connected to headphones, the target output device corresponding to the audio to be played can be the speaker and the headphones.

[0100] It should be noted that the above examples are only exemplary and should not be regarded as a limitation to this application. In actual use, according to actual needs and specific application scenarios, any audio that needs to be played currently in the electronic device can be determined as the audio to be played, and the embodiments of this application do not make any limitations thereto.

[0101] In the embodiments of this application, if the audio component type corresponding to the electronic device is a preset type, it can be determined that there may be a problem of speaker sound leakage in the electronic device, and the subsequent steps of the embodiments of this application can be continued to eliminate speaker sound leakage when needed; if the audio component type corresponding to the electronic device is not a preset type, it can be determined that there is no problem of speaker sound leakage in the electronic device, and the subsequent steps of the embodiments of this application can not be executed, and the default audio processing process of the electronic device can be followed for processing and outputting the audio to be played.

[0102] As a possible implementation, through the above analysis of the technical problems to be solved by this application, it can be known that when the audio component type corresponding to the electronic device is a combination of a codec chip and a dual analog PA, if the audio needs to be played through the speaker and the analog headphone simultaneously, then when the audio is turned off, it will cause the speaker that shares the audio path with the headphone to leak sound. Therefore, after determining that the audio component type corresponding to the electronic device is the preset type, the target output device corresponding to the audio to be played can be further determined to judge whether the audio to be played needs to be played through the speaker and the analog headphone simultaneously. If it is determined that the audio to be played needs to be played through the speaker and the analog headphone simultaneously, it can be determined that the speaker may leak sound when the audio to be played is turned off; if it is determined that the audio to be played does not need to be played through the speaker and the analog headphone simultaneously, it can be determined that the speaker will not leak sound when the audio to be played is turned off.

[0103] Step 103, when the target output device includes an analog headphone and a speaker, switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker, where the speakers include the first speaker and the second speaker, and the first speaker refers to the speaker that shares the default audio path with the analog headphone.

[0104] Among them, the analog headphone can include a three - segment analog headphone and a four - segment analog headphone.

[0105] Among them, the electronic device may include two speakers, the first speaker and the second speaker, and the first speaker is the speaker that shares the audio path with the analog headphone, and the default audio path is the audio path shared between the first speaker and the analog headphone. For example, as Figure 2 shown, since the upper speaker shares the audio path with the left channel of the headphone, the first speaker can be the upper speaker, the second speaker can be the lower speaker, and the default audio path can be the left channel of the headphone.

[0106] In an embodiment of the present application, if the target output device corresponding to the audio to be played is one of an analog headphone or a speaker, or although the target output device includes both a headphone and a speaker, but the headphone is a digital headphone, it can be determined that there is no speaker sound leakage problem in the electronic device, and the subsequent steps of the embodiment of the present application can be not executed, and the audio to be played can be processed and output according to the default audio processing flow of the electronic device. If the target output device corresponding to the audio to be played includes an analog headphone and a speaker, it can be determined that the audio to be played needs to be played through the analog headphone and the speaker simultaneously, which is a ringtone double-ring scenario. Then, when the audio to be played is turned off, the first speaker that multiplexes the default audio path with the analog headphone may have sound leakage. Therefore, the connection between the first speaker and the default audio path can be cut off, and the data routing of the first speaker can be switched to the audio path corresponding to the second speaker, so that the first speaker and the second speaker multiplex the audio path. Thus, after the audio to be played is turned off, since there is no data in the audio path corresponding to the second speaker, even if the device path of the first speaker is not closed, the first speaker has no audio data to output and there will be no sound leakage, thereby eliminating the speaker sound leakage in the ringtone double-ring scenario.

[0107] For example, as Figure 4 shown, since the upper speaker multiplexes the audio path with the left channel of the headphone, the first speaker is the upper speaker, the second speaker is the lower speaker, and the default audio path is the left channel of the headphone. Then, when it is determined that the target output device corresponding to the audio to be played includes an analog headphone and a speaker, the path between the upper speaker and the left channel of the headphone can be cut off and switched to multiplex the path with the second speaker, and the data routing of the lower speaker is copied to the upper speaker path. Finally, the upper speaker and the lower speaker will play the same audio. And, as Figure 5 shown, after the audio to be played ends, the device paths of the upper speaker and the lower speaker can remain open for 3 seconds. At this time, if there is an audio stream (such as music) to be played in the analog headphone, it will continue to play, and the audio stream is normally played from HPHL and HPHR; due to the change in the data routing of the upper speaker, the device paths are decoupled, and there is no data in the upper speaker path during these 3 seconds, and there will no longer be an upper speaker sound leakage problem.

[0108] Furthermore, it can be indicated whether to switch the data routing of the first speaker through a preset string in the set audio path configuration parameters to avoid speaker sound leakage, so that the speaker sound leakage elimination solution can be applicable to all types of electronic devices without modifying the code, improving the versatility and practicality of the speaker sound leakage elimination solution. That is, in a possible implementation manner of the embodiment of the present application, the above step 103 may include:

[0109] Read the audio path configuration parameters;

[0110] When a preset string is included in the audio path configuration parameter, a data routing switching instruction is sent to the codec chip, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0111] Among them, the audio path configuration parameter may refer to a parameter inherent in the electronic device system that allows customization of the audio path of the audio output device. For example, the audio path configuration parameter can be a custom key.

[0112] As a possible implementation, when it is determined that the audio component type corresponding to the electronic device is a preset type and the target output device corresponding to the audio to be played includes an analog headphone and a speaker, a preset string can be written in the audio path configuration parameter. Then, the electronic device can read the audio path configuration parameter in the hardware abstraction layer (HAL) to determine whether the preset string is included in the audio path configuration parameter; if the preset string is included in the audio path configuration parameter, it can be determined that the current is a speaker sound leakage scenario, and a data routing switching instruction can be sent to the codec chip, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker according to the data routing switching instruction.

[0113] Furthermore, since the audio streams that need to be played simultaneously in the speaker and the headphone are usually several specific audio stream types, such as incoming call ringtones, alarm clock ringtones, etc., therefore, when it is determined that the audio stream type corresponding to the audio to be played is a preset audio stream type, the data routing corresponding to the first speaker can be switched from the default audio path to the audio path corresponding to the second speaker, so as to further improve the accuracy of the sound leakage scenario discrimination, prevent the frequent switching of the speaker data routing in unnecessary scenarios, affect the stability of the audio playback, and thus further improve the accuracy and reliability of the speaker sound leakage elimination, and further improve the user experience. That is, in a possible implementation of the embodiment of the present application, the above-mentioned step of sending a data routing switching instruction to the codec chip when a preset string is included in the audio path configuration parameter, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker, may include:

[0114] When a preset string is included in the audio path configuration parameter, determine the audio stream type corresponding to the audio to be played;

[0115] When the audio stream type corresponding to the audio to be played is a preset audio stream type, send a data routing switch instruction to the codec chip, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0116] Among them, the preset audio stream type may refer to the audio stream type that will be played through the analog headset and the speaker at the same time when the electronic device is connected to the analog headset. For example, the audio stream type lowlatency corresponding to the alarm ringtone, the audio stream type deepbuffer corresponding to the incoming call ringtone, etc., but not limited to this.

[0117] As a possible implementation, if it is determined that the audio path configuration parameter contains a preset string and the audio stream type corresponding to the audio to be played is a preset audio stream type, it can be determined that the current is a double-ring scenario for the ringtone, which may cause the problem of speaker sound leakage. Then, a data routing switch instruction can be sent to the codec, and the data routing switch instruction can be made effective, so that the codec chip can switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker according to the data routing switch instruction. If the audio path configuration parameter does not contain the preset string or the audio stream type corresponding to the audio to be played is not the preset audio stream type, it can be determined that there will be no speaker sound leakage problem currently, that is, there is no need to switch the data routing corresponding to the first speaker. Then, a data routing switch instruction can not be sent to the codec chip, and the subsequent steps of the embodiments of the present application can not be executed, and the default audio processing process of the electronic device can be followed for processing and outputting the audio to be played.

[0118] Step 104, output the audio to be played through the target output device.

[0119] In the embodiments of the present application, when it is determined that there may be a problem of speaker sound leakage in the electronic device currently, after switching the data routing of the first speaker, decoupling the first speaker from the headphone path, and multiplexing the audio path of the first speaker and the second speaker, the audio to be played can be output through the target output device (such as the analog headset and the first speaker, the second speaker), so that the audio to be played is played through the analog headset and the speaker at the same time. And after the audio to be played ends, since there is no data in the audio path corresponding to the second speaker, the first speaker will not leak sound when the device path is not cut off.

[0120] The audio playback method provided by the embodiment of the present application determines whether the current is a sound leakage scenario caused by double-ringing of the ringtone when the audio stream is turned on or the audio stream device is switched, according to the audio component type corresponding to the electronic device and the target output device corresponding to the audio to be played. If the current is a sound leakage scenario caused by double-ringing of the ringtone, the data routing of the first speaker can be switched from the default audio path multiplexed with the analog headset to the audio path corresponding to the second speaker, so that the first speaker and the second speaker output the same audio data. Thus, after the audio to be played is turned off, other audio output through the analog headset will not leak out through the first speaker, solving the problem of sound leakage of the electronic device speaker after the ringtone is turned off in the double-ringing ringtone scenario, protecting the user privacy, and improving the user experience.

[0121] Please refer to Figure 6 , Figure 6 which is a schematic flowchart of the audio playback method provided by another embodiment of the present application. The method may include the following parts or all of the content:

[0122] Step 601, when an audio stream start instruction or an audio stream device switching instruction of the electronic device is obtained, determine the audio component type corresponding to the electronic device.

[0123] Step 602, when the audio component type is a preset type, determine the target output device corresponding to the audio to be played, where the audio to be played includes the left-channel audio to be played and the right-channel audio to be played.

[0124] Step 603, when the target output device includes an analog headset and a speaker, switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker, where the speaker includes the first speaker and the second speaker, and the first speaker refers to the speaker that multiplexes the default audio path with the analog headset.

[0125] For the specific implementation process and principle of the above steps 601-603, reference may be made to the detailed description of the above embodiment, which will not be elaborated here.

[0126] Step 604, perform a mixing process on the left-channel audio to be played and the right-channel audio to be played to generate a mixed audio to be played.

[0127] In the embodiments of the present application, in some usage scenarios, the user may adjust the audio path corresponding to the second speaker to silent (for example, in the channel equalization function, adjust to the most extreme situation to make the right channel silent). Therefore, in this case, if the data routing of the first speaker is switched to the audio path corresponding to the second speaker, it will cause both the first speaker and the second speaker to play silent data, resulting in the inability to play the audio to be played normally. Therefore, to prevent this situation, after switching the data routing of the first speaker, the left and right channel data of the audio to be played can be mixed. Then, the first speaker and the second speaker will output the mixed audio to be played, preventing the situation of silent external speaker when there is a double ringtone. This not only eliminates the speaker sound leakage in the double ringtone scenario but also prevents the situation of silent speakers when there is a double ringtone, further improving the reliability of sound leakage elimination and further enhancing the user experience.

[0128] As Figure 7 shown, it is a flowchart for mixing the left and right channels of the audio to be played. After mixing the left channel audio to be played and the right channel audio to be played, since the mixed audio to be played generated contains the left channel audio to be played, even if the right channel audio to be played is silent, the mixed audio to be played will not be silent data. Therefore, by playing the mixed audio to be played through the first speaker and the second speaker, the first speaker and the second speaker can emit sound normally, ensuring that the ringtone will not be silent when the channel equalization is adjusted to the most extreme situation.

[0129] Furthermore, it can be indicated whether to switch the data routing of the first speaker through a preset string in the set audio path configuration parameters to avoid speaker sound leakage, and the mixing processing method of the speaker is sent through the speaker mixing instruction, so that the sound leakage elimination solution of the speaker can be applied to all types of electronic devices without modifying the code, improving the versatility and practicality of the speaker sound leakage elimination solution. That is, in a possible implementation manner of the embodiments of the present application, step 604 above may include:

[0130] Read the audio path configuration parameters;

[0131] When the preset string is included in the audio path configuration parameters, send a speaker mixing instruction to the DSP chip, so that the DSP chip mixes the left channel audio to be played and the right channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played.

[0132] Among them, the audio path configuration parameters may refer to the parameters in the electronic device system that are inherent and allow customization for configuring the audio path of the audio output device. For example, the audio path configuration parameter may be custom key.

[0133] Among them, the speaker mixing instruction can refer to an instruction inherent in the electronic device system that allows customization of the configuration of the audio path in the DSP. For example, the speaker mixing instruction can be implemented in the form of graph key-value. As an example, in the speaker mixing instruction, a pair of key-value pairs can be used to specify that the device to be mixed is the speaker, and another pair of key-value pairs can be used to specify the specific method of mixing the audio path corresponding to the speaker, that is, specifying to mix the left-channel audio and the right-channel audio corresponding to the speaker.

[0134] As a possible implementation, when it is determined that the audio component type corresponding to the electronic device is a preset type and the target output device corresponding to the audio to be played includes an analog headphone and a speaker, a preset string can be written into the audio path configuration parameter. Then, the electronic device can read the audio path configuration parameter in the HAL layer to determine whether the preset string is included in the audio path configuration parameter; if the preset string is included in the audio path configuration parameter, it can be determined that the current is a speaker sound leakage scenario, and in the previous step, the data routing corresponding to the first speaker has been switched from the default audio path to the audio path corresponding to the second speaker, so there may be a problem of no external sound currently. Therefore, a speaker mixing instruction can be sent to the DSP chip, so that the DSP chip can mix the left-channel audio to be played and the right-channel audio to be played according to the audio output device and the mixing method specified in the speaker mixing instruction to generate the mixed audio to be played.

[0135] Furthermore, since the audio streams that need to be played simultaneously in the speaker and the headphone are usually several specific types of audio streams, such as incoming call ringtones, alarm clock ringtones, etc., therefore, when it is determined that the audio stream type corresponding to the audio to be played is a preset audio stream type, the data routing corresponding to the first speaker can be switched from the default audio path to the audio path corresponding to the second speaker, and the audio data of the left and right channels can be mixed to further improve the accuracy of the sound leakage scenario discrimination, prevent mixing in unnecessary scenarios, affect the stability of audio playback, waste computing power, thereby further improving the accuracy and reliability of speaker sound leakage elimination, reducing the power consumption of the electronic device, and further improving the user experience. That is, in a possible implementation of the embodiment of the present application, when the preset string is included in the audio path configuration parameter, sending a speaker mixing instruction to the DSP chip so that the DSP chip mixes the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played can include:

[0136] When the preset string is included in the audio path configuration parameter, determining the audio stream type corresponding to the audio to be played;

[0137] When the audio stream type corresponding to the audio to be played is a preset audio stream type, send a speaker mixing instruction to the DSP chip, so that the DSP chip mixes the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played.

[0138] Among them, the preset audio stream type may refer to the audio stream type that will be played through both the analog headset and the speaker when the electronic device is connected to the analog headset. For example, the audio stream type lowlatency corresponding to the alarm ringtone, the audio stream type deepbuffer corresponding to the incoming call ringtone, etc., but not limited to this.

[0139] As a possible implementation, if it is determined that the audio path configuration parameter contains a preset string and the audio stream type corresponding to the audio to be played is a preset audio stream type, it can be determined that the current is a double-ringing scenario for the ringtone, which may cause the problem of speaker sound leakage. And the data routing corresponding to the first speaker has been switched from the default audio path to the audio path corresponding to the second speaker in the foregoing steps, so there may be a problem of no external sound at present. Therefore, a speaker mixing instruction can be sent to the DSP chip, so that the DSP chip can mix the left-channel audio to be played and the right-channel audio to be played according to the audio output device and the mixing method specified in the speaker mixing instruction to generate the mixed audio to be played. If the audio path configuration parameter does not contain the preset string or the audio stream type corresponding to the audio to be played is not the preset audio stream type, it can be determined that there will be no speaker sound leakage problem at present, that is, there is no need to switch the data routing corresponding to the first speaker, so the speaker mixing instruction may not be sent to the DSP chip, and the audio to be played can be processed and output according to the default audio processing flow of the electronic device.

[0140] Step 605, output the mixed audio to be played through the target output device.

[0141] In an embodiment of the present application, when it is determined that the electronic device may have a speaker sound leakage problem currently, after switching the data routing of the first speaker to decouple the first speaker from the headphone path and to multiplex the audio path of the first speaker and the second speaker, and after mixing the audio to be played on the left channel and the audio to be played on the right channel, the mixed audio to be played can be output through the target output device (such as an analog headphone, the first speaker, and the second speaker), so that the audio to be played is played through the analog headphone and the speaker simultaneously. And after the audio to be played ends, since there is no data in the audio path corresponding to the second speaker, the first speaker will not have sound leakage when the device path is not cut off; moreover, since the mixed audio to be played generated contains the audio to be played on the left channel, even if the audio to be played on the right channel is silent, the mixed audio to be played will not be silent data, thus ensuring that even when the channel balance is adjusted to the most extreme situation, the ringtone played externally will not be silent.

[0142] In the audio playback method provided by the embodiment of the present application, in some usage scenarios, the user may adjust the audio path corresponding to the second speaker to be silent (for example, in the channel balance function, adjust to the most extreme situation to make the right channel silent). Therefore, in this case, if the data routing of the first speaker is switched to the audio path corresponding to the second speaker, it will cause both the first speaker and the second speaker to play silent data, resulting in the inability to play the audio to be played normally. Therefore, to prevent this situation, after switching the data routing of the first speaker, the left and right channel data of the audio to be played can be mixed, and then the first speaker and the second speaker will output the mixed audio to be played, preventing the situation of silent external playback when the ringtone rings twice. Thus, not only the speaker sound leakage in the ringtone double-ring scenario is eliminated, but also the situation of silent speakers when the ringtone rings twice is prevented, further improving the reliability of sound leakage elimination and further enhancing the user experience.

[0143] Please refer to Figure 8 , Figure 8 which is a schematic flowchart of the audio playback method provided by another embodiment of the present application, including the following steps:

[0144] Step 801, obtaining an audio stream start instruction or an audio stream device switching instruction;

[0145] Step 802, checking the configuration item to determine whether the audio component type corresponding to the electronic device is a preset type; if so, execute Step 803; otherwise, end.

[0146] Step 803, checking whether the target output device corresponding to the audio to be played includes an analog headphone and a speaker; if so, execute Step 804; otherwise, end.

[0147] Step 804: Send a data routing switch instruction and a speaker mixing instruction;

[0148] Step 805: Check whether the audio stream type corresponding to the audio to be played is a preset audio stream type; if so, execute Steps 806 and 807; otherwise, end;

[0149] Step 806: Switch the data routing corresponding to the first speaker to the audio path corresponding to the second speaker through the codec chip;

[0150] Step 807: Mix the left channel audio to be played and the right channel audio to be played through the DSP chip to generate the mixed audio to be played;

[0151] Step 808: Play the mixed audio to be played through the speaker.

[0152] It should be noted that Figure 8 For the other specific implementation processes and principles of the illustrated embodiments, reference may be made to the detailed descriptions of the above embodiments, which will not be elaborated herein.

[0153] It should be understood that the magnitudes of the sequence numbers of the steps in the above embodiments do not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation to the implementation process of the embodiments of the present application.

[0154] Corresponding to the audio playback method described in the above embodiments, Figure 9 The block diagram of the audio playback device provided by the embodiments of the present application is shown. For the sake of convenience of description, only the parts related to the embodiments of the present application are shown.

[0155] Referring to Figure 9 , the device 90 includes:

[0156] A first determination module 91, configured to determine the audio component type corresponding to the electronic device when an audio stream start instruction or an audio stream device switch instruction of the electronic device is obtained;

[0157] A second determination module 92, configured to determine the target output device corresponding to the audio to be played when the audio component type is a preset type;

[0158] A switching module 93, configured to switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker when the target output device includes an analog headphone and a speaker, where the speaker includes a first speaker and a second speaker, and the first speaker refers to the speaker that shares the default audio path with the analog headphone;

[0159] An output module 94, configured to output the audio to be played through the target output device.

[0160] In actual use, the audio playback device provided by the embodiments of the present application can be configured in any electronic device to execute the foregoing audio playback method.

[0161] The audio playback device provided by the embodiments of the present application determines whether the current is a leakage sound scenario caused by double-ringing of the ringtone when the audio stream is turned on or the audio stream device is switched, according to the audio component type corresponding to the electronic device and the target output device corresponding to the audio to be played. If the current is a leakage sound scenario caused by double-ringing of the ringtone, the data routing of the first speaker can be switched from the default audio path multiplexed with the analog headset to the audio path corresponding to the second speaker, so that the first speaker and the second speaker output the same audio data. Thus, after the audio to be played is turned off, other audio output through the analog headset will not leak out through the first speaker, solving the problem of leakage sound of the electronic device speaker after the ringtone is turned off in the double-ringing ringtone scenario, protecting the user privacy and improving the user experience.

[0162] In a possible implementation manner of the present application, the above switching module 93 includes:

[0163] A first reading unit, configured to read audio path configuration parameters;

[0164] A first switching unit, configured to send a data routing switching instruction to the codec chip when the audio path configuration parameters include a preset string, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0165] In this way, whether to switch the data routing of the first speaker is identified by a preset string in the set audio path configuration parameters to avoid speaker leakage sound, so that the speaker leakage sound elimination solution can be applicable to all types of electronic devices, improving the versatility and practicality of the speaker leakage sound elimination solution.

[0166] Further, in another possible implementation manner of the present application, the above first switching unit is specifically configured to:

[0167] Determine the audio stream type corresponding to the audio to be played when the audio path configuration parameters include a preset string;

[0168] Send a data routing switching instruction to the codec chip when the audio stream type corresponding to the audio to be played is a preset audio stream type, so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

[0169] Thus, since the audio streams that need to be played simultaneously in the speaker and the earphone are usually several specific types of audio streams, such as incoming call ringtones, alarm clock ringtones, etc., it is possible to switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker when it is determined that the audio stream type corresponding to the audio to be played is a preset audio stream type, so as to further improve the accuracy of leaky sound scenario discrimination, prevent frequent switching of the data routing of the speaker in unnecessary scenarios, and affect the stability of audio playback, thereby further improving the accuracy and reliability of speaker leaky sound cancellation and further enhancing the user experience.

[0170] Further, in another possible implementation manner of the present application, the above-mentioned first determination module 91 includes:

[0171] The first query unit is used to query the device tree file corresponding to the electronic device to determine the configuration item corresponding to the audio component type;

[0172] The first determination unit is used to determine the audio component type corresponding to the electronic device according to the configuration item corresponding to the audio component type.

[0173] In this way, by pre-defining the configuration item corresponding to the audio component type of the electronic device in the device tree file corresponding to the electronic device, to directly determine whether the audio component type corresponding to the electronic device belongs to the audio component type of the leaky sound scenario through the value of this configuration item, and then determine whether to execute the leaky sound cancellation solution of the present application according to the determination result. Therefore, no matter whether the audio component type corresponding to the electronic device belongs to the preset audio component type of the leaky sound scenario, the leaky sound cancellation solution of the speaker of the present application can be compatible, thereby improving the versatility and practicability of the leaky sound cancellation solution of the speaker.

[0174] Further, in another possible implementation manner of the present application, the above-mentioned audio to be played includes the left channel audio to be played and the right channel audio to be played; correspondingly, the above-mentioned device 90 further includes:

[0175] The mixing module is used to perform mixing processing on the left channel audio to be played and the right channel audio to be played to generate the mixed audio to be played;

[0176] Correspondingly, the above-mentioned output module 94 includes:

[0177] The first output unit is used to output the mixed audio to be played through the target output device.

[0178] Thus, since the user may adjust the audio path corresponding to the second speaker to silent in some usage scenarios, if the data routing of the first speaker is switched to the audio path corresponding to the second speaker in this case, it will cause both the first speaker and the second speaker to play silent data, resulting in the inability to play the audio to be played normally. Therefore, to prevent this situation from occurring, after switching the data routing of the first speaker, the left and right channel data of the audio to be played can be mixed, and then the first speaker and the second speaker will output the mixed audio, preventing the situation of silent external speaker when the ringtone sounds twice. This not only eliminates the speaker sound leakage in the ringtone double - sound scenario but also prevents the situation of silent speakers when the ringtone sounds twice, further improving the reliability of sound leakage elimination and further enhancing the user experience.

[0179] Further, in another possible implementation manner of the present application, the above - mentioned mixing module includes:

[0180] A second reading unit, configured to read audio path configuration parameters;

[0181] A first mixing unit, configured to send a speaker mixing instruction to the DSP chip when the audio path configuration parameters contain a preset string, so that the DSP chip mixes the left - channel audio to be played and the right - channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played.

[0182] Thus, by identifying whether the data routing of the first speaker needs to be switched through a preset string in the set audio path configuration parameters to avoid speaker sound leakage, and by sending the speaker mixing instruction to implement the mixing processing method of the speaker, the sound leakage elimination solution for the speaker can be applied to all types of electronic devices, improving the generality and practicability of the speaker sound leakage elimination solution.

[0183] Further, in another possible implementation manner of the present application, the above - mentioned first mixing unit is specifically configured to:

[0184] Determine the audio stream type corresponding to the audio to be played when the audio path configuration parameters contain a preset string;

[0185] Send a speaker mixing instruction to the DSP chip when the audio stream type corresponding to the audio to be played is a preset audio stream type, so that the DSP chip mixes the left - channel audio to be played and the right - channel audio to be played according to the speaker mixing instruction to generate the mixed audio to be played.

[0186] Thus, since the audio streams that need to be played simultaneously in the speaker and the earphone are usually several specific types of audio streams, such as incoming call ringtones, alarm clock ringtones, etc., it is possible to switch the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker when it is determined that the audio stream type corresponding to the audio to be played is a preset audio stream type, and perform mixing processing on the audio data of the left and right channels, so as to further improve the accuracy of leaky sound scenario discrimination, prevent mixing in unnecessary scenarios, affect the stability of audio playback, and waste computing power, thereby further improving the accuracy and reliability of speaker leaky sound cancellation, reducing the power consumption of the electronic device, and further enhancing the user experience.

[0187] It should be noted that for the information interaction, execution process, etc. between the above-mentioned devices / units, since they are based on the same concept as the method embodiment of the present application, their specific functions and the technical effects brought can be specifically referred to in the method embodiment part, and will not be elaborated here.

[0188] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the above-mentioned division of each functional unit and module is used as an example. In actual application, the above functions can be allocated to different functional units and modules according to needs, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. Each functional unit and module in the embodiment can be integrated in a processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. In addition, the specific names of each functional unit and module are only for the convenience of mutual distinction and do not limit the protection scope of the present application. The specific working process of the units and modules in the above system can refer to the corresponding process in the foregoing method embodiment and will not be elaborated here.

[0189] To implement the above embodiment, the present application also proposes an electronic device.

[0190] Figure 10 It is a schematic structural diagram of an electronic device according to an embodiment of the present application.

[0191] See Figure 10, 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, a headphone 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. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, a barometric 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.

[0192] It can be understood that the structure illustrated in the embodiments of the present application 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 those shown in the figure, or combine certain components, or split certain components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0193] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modulation and demodulation processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Among them, different processing units may be independent devices or integrated in one or more processors.

[0194] Among them, the controller may be the nerve center and command center of the electronic device 100. The controller may generate operation control signals according to the instruction operation code and timing signal to complete the control of fetching instructions and executing instructions.

[0195] A memory may also be provided in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can hold the instructions or data that the processor 110 has just used or recycled. If the processor 110 needs to use the instruction or data again, it can directly call it from this memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.

[0196] In some embodiments, the processor 110 may include one or more interfaces, such as 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.

[0197] It can be understood that the interface connection relationships between the modules illustrated in the embodiments of the present application are only illustrative descriptions and do not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods in the above embodiments, or a combination of multiple interface connection methods.

[0198] The charging management module 140 is used to receive a charging input from a charger. The charger can be a wireless charger or a wired charger. In some embodiments of wired charging, the charging management module 140 can receive the charging input from a wired charger through the USB interface 130. In some embodiments of wireless charging, the charging management module 140 can receive the wireless charging input through the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also supply power to the electronic device 100 through the power management module 141.

[0199] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives the inputs from the battery 142 and / or the charging management module 140, and supplies power to the processor 110, the internal memory 121, the external memory, the display screen 194, the camera 193, the wireless communication module 160, etc. The power management module 141 can also be used to monitor parameters such as the battery capacity, the number of battery cycles, and the battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be disposed in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 can also be disposed in the same device.

[0200] The wireless communication function of the electronic device 100 can be implemented by the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modulation and demodulation processor, and the baseband processor, etc.

[0201] The antenna 1 and the antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be multiplexed to improve the utilization rate of the antennas. For example: The antenna 1 can be multiplexed as the diversity antenna of the wireless local area network. In some other embodiments, the antenna can be used in combination with a tuning switch.

[0202] The mobile communication module 150 can provide solutions for wireless communications such as 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 can include at least one filter, switch, power amplifier, low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves by the antenna 1, filter, amplify, etc. the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves through the antenna 1 and radiate it out. In some embodiments, at least some functional modules of the mobile communication module 150 can be disposed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 and at least some modules of the processor 110 can be disposed in the same device.

[0203] The modulation and demodulation processor may include a modulator and a demodulator. Among them, the modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. Subsequently, the demodulator transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is transmitted to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.), or displays an image or video through the display screen 194. In some embodiments, the modulation and demodulation processor may be an independent device. In other embodiments, the modulation and demodulation processor may be independent of the processor 110 and be disposed in the same device as the mobile communication module 150 or other functional modules.

[0204] The wireless communication module 160 may provide solutions for wireless communications applied to the electronic device 100, including wireless local area networks (WLANs) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite systems (GNSS), frequency modulation (FM), near field communication (NFC), infrared technology (IR), etc. The wireless communication module 160 may be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering processing on the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may also receive the signals to be transmitted from the processor 110, perform frequency modulation and amplification on them, and convert them into electromagnetic waves through the antenna 2 and radiate them out.

[0205] 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, enabling electronic device 100 to communicate with a network and other devices through wireless communication technologies. The wireless communication technologies may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology, etc. GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).

[0206] Electronic device 100 implements a display function through a GPU, display screen 194, and an application processor, etc. The GPU is a microprocessor for image processing, connected to display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs, which execute program instructions to generate or change display information.

[0207] The display screen 194 is used to display images, videos, etc. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-oLed, a quantum dot light-emitting diode (QLED), etc. In some embodiments, the electronic device 100 may include one or N display screens 194, where N is an integer greater than 1.

[0208] The electronic device 100 can implement the shooting function through the ISP, the camera 193, the video codec, the GPU, the display screen 194, and the application processor, etc.

[0209] The ISP is used to process the data fed back by the camera 193. For example, when taking a photo, the shutter is opened, and the light passes through the lens and is transmitted to the camera sensor. The light signal is converted into an electrical signal, and the camera sensor transmits the electrical signal to the ISP for processing and converts it into an image visible to the naked eye. The ISP can also optimize the noise, brightness, and skin color of the image through algorithms. The ISP can also optimize parameters such as the exposure and color temperature of the shooting scene. In some embodiments, the ISP can be set in the camera 193.

[0210] The digital signal processor is used to process digital signals. In addition to being able to process digital image signals, it can also process other digital signals. For example, when the electronic device 100 is selecting a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy, etc.

[0211] The video codec is used to compress or decompress digital videos. The electronic device 100 can support one or more video codecs. In this way, the electronic device 100 can play or record videos in multiple coding formats, such as: Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0212] The NPU is a neural-network (NN) computing processor. By drawing on the structure of biological neural networks, such as the transmission pattern between human brain neurons, it can quickly process input information and can also continuously self-learn. Through the NPU, applications such as intelligent cognition of the electronic device 100 can be realized, such as image recognition, face recognition, voice recognition, text understanding, etc.

[0213] The external memory interface 120 can be used to connect to an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 through the external memory interface 120 to achieve the data storage function. For example, files such as music and videos are saved in the external memory card.

[0214] The internal memory 121 can be used to store computer-executable program code, and the computer-executable program code includes instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 can include a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.). The data storage area can store data created during the use of the electronic device 100 (such as audio data, phone book, etc.). In addition, the internal memory 121 can include high-speed random access memory, and can also include non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0215] The electronic device 100 can achieve audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor, etc.

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

[0217] A distance sensor 180F is used to measure distance. The electronic device 100 can measure distance through infrared or laser. In some embodiments, in a shooting scenario, the electronic device 100 can use the distance sensor 180F to measure distance for quick focusing.

[0218] The button 190 includes a power-on button, volume buttons, etc. The button 190 can be a mechanical button or a touch button. The electronic device 100 can receive button inputs and generate key signal inputs related to the user settings and function control of the electronic device 100.

[0219] It should be noted that for the implementation process and technical principle of the electronic device in this embodiment, refer to the foregoing explanation of the audio playback method of the embodiments of the present application, which will not be elaborated here.

[0220] The embodiments of the present application further provide a chip system applied to an electronic device. The chip system includes one or more processors, and the one or more processors are used to call computer instructions to enable the electronic device to implement the steps in the foregoing method embodiments.

[0221] The embodiments of the present application further provide a computer-readable storage medium. The computer-readable storage medium includes instructions that, when running on the electronic device, enable the electronic device to implement the steps in the foregoing method embodiments.

[0222] The embodiments of the present application further provide a computer program product that, when running on the electronic device, enables the electronic device to implement the steps in the foregoing method embodiments.

[0223] When 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, to implement all or part of the processes in the above-described embodiment methods of this application, a computer program can be used to instruct relevant hardware to complete. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-described various method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can at least include: any entity or device that can carry the computer program code to the device / electronic device, recording medium, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signal, telecommunication signal, and software distribution medium. For example, a USB flash drive, a mobile hard disk, a magnetic disk, or an optical disc, etc. In some jurisdictions, according to legislation and patent practice, the computer-readable medium cannot be an electrical carrier signal and a telecommunication signal.

[0224] In the above embodiments, the descriptions of the various embodiments each have their own emphases. For the parts not detailed or recorded in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0225] In the above embodiments, for the purpose of illustration rather than limitation, specific details such as specific system structures and technologies are presented to thoroughly understand the embodiments of this application. However, those skilled in the art should clearly understand that this application can 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 avoid unnecessary details from interfering with the description of this application.

[0226] It should be understood that when used in the specification of this application and the appended claims, the term "comprising" indicates the presence of the 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 their combinations.

[0227] It should also be understood that the term "and / or" used in the specification of this application and the appended claims refers to any combination and all possible combinations of one or more of the associated listed items, and includes these combinations.

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

[0229] In addition, in the description of the specification of this application and the appended claims, the terms "first", "second", "third", etc. are only used for differentiating descriptions and shall not be construed as indicating or implying relative importance.

[0230] The reference to "one embodiment" or "some embodiments" or the like described in the specification of this application means that a specific feature, structure, or characteristic described in connection with that embodiment is included in one or more embodiments of this application. Thus, statements such as "in one embodiment", "in some embodiments", "in other some embodiments", "in still other embodiments", etc. that appear in different places in this specification do not necessarily all refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "comprising", "including", "having", and their variants all mean "including but not limited to", unless otherwise specifically emphasized in other ways.

[0231] Those of ordinary skill in the art can realize that the units and algorithm steps of each example described in connection with the embodiments disclosed herein can be implemented by electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are executed in a hardware or software manner depends on the specific application and design constraints of the technical solution. A professional technician can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of this application.

[0232] In the embodiments provided in this application, it should be understood that the disclosed device / electronic device and method can be implemented in other ways. For example, the device / electronic device embodiments described above are merely illustrative. For example, the division of the modules or units is only a logical function division, and there may be other division methods in actual implementation. For example, 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 displayed or discussed coupling or direct coupling or communication connection to each other can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be in an electrical, mechanical, or other form.

[0233] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or distributed over multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0234] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions described in the foregoing embodiments, or perform equivalent replacements for some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate 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 playback method, characterized in that, Including: When an audio stream start instruction or an audio stream device switching instruction of an electronic device is obtained, determining the audio component type corresponding to the electronic device; When the audio component type is a preset type, determining a target output device corresponding to the audio to be played, where the preset type refers to an audio component type that causes a speaker sound leakage problem in the electronic device; When the target output device includes an analog headphone and a speaker, switching the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker, where the speaker includes the first speaker and the second speaker, and the first speaker is the speaker that shares the default audio path with the analog headphone; Outputting the audio to be played through the target output device.

2. The method according to claim 1, characterized in that, The switching the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker includes: Reading audio path configuration parameters; When the audio path configuration parameters contain a preset string, sending a data routing switching instruction to the codec chip so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

3. The method according to claim 2, wherein The when the audio path configuration parameters contain a preset string, sending a data routing switching instruction to the codec chip so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker includes: When the audio path configuration parameters contain the preset string, determining the audio stream type corresponding to the audio to be played; When the audio stream type corresponding to the audio to be played is a preset audio stream type, sending a data routing switching instruction to the codec chip so that the codec chip switches the data routing corresponding to the first speaker from the default audio path to the audio path corresponding to the second speaker.

4. The method according to any one of claims 1-3, characterized in that, The determining the audio component type corresponding to the electronic device includes: Querying the device tree file corresponding to the electronic device to determine the configuration item corresponding to the audio component type; Determining the audio component type corresponding to the electronic device according to the configuration item corresponding to the audio component type.

5. The method according to any one of claims 1 to 3, characterized in that, The audio to be played includes a left-channel audio to be played and a right-channel audio to be played. Before outputting the audio to be played through the target output device, it further includes: Performing a mixing process on the left-channel audio to be played and the right-channel audio to be played to generate a mixed audio to be played; The outputting the audio to be played through the target output device includes: Outputting the mixed audio to be played through the target output device.

6. The method according to claim 5, characterized in that The performing a mixing process on the left-channel audio to be played and the right-channel audio to be played to generate a mixed audio to be played includes: Reading audio path configuration parameters; When a preset string is included in the audio path configuration parameters, a speaker mixing instruction is sent to a digital signal processing (DSP) chip, so that the DSP chip performs mixing processing on the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction, to generate the mixed audio to be played.

7. The method according to claim 6, characterized in that, The step of, when a preset string is included in the audio path configuration parameters, sending a speaker mixing instruction to a DSP chip, so that the DSP chip performs mixing processing on the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction, to generate the mixed audio to be played, includes: When the preset string is included in the audio path configuration parameters, determining the audio stream type corresponding to the audio to be played; When the audio stream type corresponding to the audio to be played is a preset audio stream type, sending the speaker mixing instruction to the DSP chip, so that the DSP chip performs mixing processing on the left-channel audio to be played and the right-channel audio to be played according to the speaker mixing instruction, to generate the mixed audio to be played.

8. An electronic device, characterized in that, The electronic device includes: one or more processors, and a memory; the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to cause the electronic device to execute the method according to any one of claims 1-7.

9. A chip system, characterized in that, The chip system is applied to an electronic device, the chip system includes one or more processors, and the one or more processors are used to call computer instructions to cause the electronic device to execute the method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions, and when the instructions run on an electronic device, the electronic device is caused to execute the method according to any one of claims 1-7.

Citation Information

Patent Citations

  • Earphone interface reusing method and apparatus

    CN106231460A

  • Audio output method and device, mobile terminal and storage medium

    CN114567840A