Audio playing control method and device, electronic equipment and storage medium
When the terminal device detects the target application status switching event, it sends playback control instructions to the audio output device, adjusts the audio playback rate to adjust the spatial size of the audio buffer area, and solves the audio delay and lag problems and improves the audio playback effect.
Patent Information
- Application Number
- CN202311136661.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-04
- Publication Date
- 2025-03-04
AI Technical Summary
There is a problem of large audio delay between the existing audio output device and the terminal device, which causes the screen displayed by the terminal device to be inconsistent with the sound heard by the user using the audio output device, affecting the user's use.
When the terminal device detects that a state switching event occurs in the target application, a playback control command is sent to the audio output device, and the audio playback rate is adjusted to adjust the audio buffer area to the spatial size corresponding to the state switching event.
It effectively reduces the audio delay between the audio output device and the terminal device, avoids the situation of stuttering in audio playback, and improves the audio playback effect.
Smart Images

Figure CN119556876A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of communication technology, and in particular to an audio playback control method, device, electronic device and storage medium. Background Art
[0002] With the development of audio and communication technology, users have higher and higher requirements for audio playback. When the user establishes a communication connection between an audio output device (such as headphones, speakers, etc.) and a terminal device, and uses the audio output device to play audio data, there is a high demand for audio delay in certain usage scenarios. However, there is still a problem of large audio delay between the current audio output device and the terminal device, resulting in the situation where the picture displayed by the terminal device is inconsistent with the sound heard by the user using the audio output device, affecting user use. Therefore, how to effectively reduce the audio delay between the audio output device and the terminal device has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present application disclose an audio playback control method, device, electronic device and storage medium, which can effectively reduce the audio delay between the audio output device and the terminal device, avoid the audio playback from being stuck, and improve the audio playback effect.
[0004] The present application embodiment discloses an audio playback control method, which is applied to a terminal device, and the method includes:
[0005] When a state switching event is detected in the target application, if the first audio data is being sent to the audio output device, a playback control instruction is sent to the audio output device, and the playback control instruction is used to instruct the audio output device to adjust the audio playback rate to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0006] The present application embodiment discloses an audio playback control method, which is applied to an audio output device, and the method includes:
[0007] Receiving a playback control instruction sent by a terminal device; the playback control instruction is sent by the terminal device when it detects that a state switching event occurs in a target application and the terminal device is sending first audio data to an audio output device;
[0008] The audio playback rate is adjusted according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0009] The present application embodiment discloses an audio playback control device, which is applied to a terminal device, and the device includes:
[0010] The first instruction sending module is used to send a playback control instruction to the audio output device when a state switching event is detected in the target application, if the first audio data is being sent to the audio output device, and the playback control instruction is used to instruct the audio output device to adjust the audio playback rate to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0011] The present application embodiment discloses an audio playback control device, which is applied to an audio output device, and the device includes:
[0012] A first instruction receiving module, configured to receive a playback control instruction sent by a terminal device; the playback control instruction is sent by the terminal device when it detects that a state switching event occurs in a target application and the terminal device is sending first audio data to an audio output device;
[0013] The rate adjustment module is used to adjust the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0014] An embodiment of the present application discloses an electronic device, including a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the method described in any of the above embodiments.
[0015] An embodiment of the present application discloses a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the method described in any of the above embodiments is implemented.
[0016] The embodiment of the present application discloses an audio playback control method, device, electronic device and storage medium. When the terminal device detects that a state switching event occurs in the target application, if the first audio data is being sent to the audio output device, the terminal device sends a playback control instruction to the audio output device. The audio output device receives the playback control instruction and can adjust the audio playback rate according to the playback control instruction to adjust the audio buffer to the spatial size corresponding to the state switching event. In the embodiment of the present application, when a state switching event occurs in the target application on the terminal device, if the first audio data is sent at the same time, the audio output device can be controlled to indirectly adjust the spatial size of the audio buffer by adjusting the audio playback rate, so that the spatial size of the audio buffer meets the audio delay requirement, effectively reducing the audio delay between the audio output device and the terminal device, and does not directly adjust the spatial size of the audio buffer, which can avoid the situation of audio playback jamming and improve the audio playback effect. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0018] Figure 1 A schematic diagram of reducing audio delay in the related art;
[0019] Figure 2 An application scenario diagram of an audio playback control method in an embodiment;
[0020] Figure 3 is a timing diagram of an audio playback control method in one embodiment;
[0021] Figure 4 is a flowchart of an audio playback control method in one embodiment;
[0022] Figure 5 is a flowchart of an audio playback control method in another embodiment;
[0023] Fig. 6A is a timing diagram of an audio playback control method in another embodiment;
[0024] Figure 6B is a timing diagram of an audio playback control method in another embodiment;
[0025] Figure 7 is a flowchart of an audio playback control method in another embodiment;
[0026] Fig. 8A is a timing diagram of an audio playback control method in another embodiment;
[0027] Figure 8B is a timing diagram of an audio playback control method in another embodiment;
[0028] Fig. 9 is a flowchart of an audio playback control method in another embodiment;
[0029] Fig.10 is a block diagram of an audio playback control device in one embodiment;
[0030] Fig.11 is a block diagram of an audio playback control device in another embodiment;
[0031] Fig.12 FIG. 4 is a structural block diagram of a terminal device in an embodiment. DETAILED DESCRIPTION
[0032] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0033] It should be noted that the terms "including" and "having" and any variations thereof in the embodiments of the present application and the accompanying drawings are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device including a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices.
[0034] It is understood that the terms "first", "second", etc. used in this application can be used to describe various elements in this article, but these elements are not limited by these terms. These terms are only used to distinguish the first element from another element. For example, without departing from the scope of this application, the first audio codec can be referred to as the second audio codec, and similarly, the second audio codec can be referred to as the first audio codec. Both the first audio codec and the second audio codec are audio codecs, but they are not the same audio codec. The term "plurality" used in this application refers to two or more. The term "and / or" used in this application refers to one of the schemes, or any combination of multiple schemes.
[0035] In scenarios such as terminal devices running game applications, the audio delay between the audio output device (such as headphones, etc.) and the terminal device has always been a major pain point affecting user use. Audio delay refers to the total time it takes for the audio stream to be output to the audio output device and played through the speaker. When the audio delay is too large, the picture displayed by the terminal device will be inconsistent with the sound heard by the user using the audio output device, affecting user use. In related technologies, audio output devices generally set corresponding modes for scenarios such as games, that is, the delay of the entire audio transmission link from the terminal device to the audio output device or the delay of the audio output device is reduced in this mode, thereby improving the user experience.
[0036] At present, in scenarios such as running game applications on terminal devices, in order to provide users with a better audio delay and stability experience, the terminal device will switch the Bluetooth encoding method, adjust the delay of its own audio path, and notify the audio output device to reduce the audio playback delay. For example, Figure 1 As shown, Figure 1It is a schematic diagram of reducing audio delay in related technologies. Take the terminal device as a mobile phone and the audio output device as headphones as an example. The mobile phone is connected to the headphones and the mobile phone enters the game mode. The mobile phone can switch the Bluetooth encoding, such as switching from AAC (Advanced Audio Coding) to SBC (Subband Coding), and send a notification command to the headphones to notify the headphones to enter the low-latency mode. The mobile phone can also adjust the audio path delay, such as reducing the buffer of the audio path. After receiving the notification command sent by the mobile phone, the headphones enter the low-latency mode and adjust the space size of the buffer (buffer), such as reducing the buffer. The mobile phone sends audio data to the headphones, and the headphones wait for the buffer to be full of audio data before playing the audio data in the buffer.
[0037] Although the above method can reduce audio delay and meet users' low-latency needs by adjusting path delay and switching Bluetooth encoding, when the terminal device is running low-latency applications such as game applications and playing music and other audio (that is, the audio in the game application and the music and other audio are played at the same time), when switching Bluetooth encoding, the audio output device will directly adjust the space size of the buffer. Therefore, the audio output device will discard the original audio data in the buffer, and after adjusting the space size of the buffer, it is necessary to wait for the adjusted buffer to store full audio data before playing the audio. Therefore, there will be a brief freeze, affecting user use.
[0038] Similarly, when the terminal device is running low-latency applications such as games and is also playing music and other audio, when you exit the running application and need to restore the Bluetooth encoding (such as restoring from SBC to AAC), the audio output device will also discard the original audio data in the buffer and restore the buffer space size. It still needs to wait for the restored buffer to store full audio data before playing the audio. Therefore, there will be a brief freeze, affecting user usage.
[0039] The embodiments of the present application disclose an audio playback control method, device, electronic device and storage medium, which can effectively reduce the audio delay between the audio output device and the terminal device, avoid the audio playback from being stuck, and improve the audio playback effect.
[0040] Figure 2 FIG. 1 is an application scenario diagram of an audio playback control method in an embodiment. Figure 2As shown, the terminal device 10 can establish a communication connection with the audio output device 20. The terminal device 10 may include but is not limited to mobile phones, wearable devices, vehicle-mounted terminals, tablet computers, PCs (Personal Computers), PDAs (Personal Digital Assistants), etc. The audio output device 20 may include but is not limited to headphones, speakers, etc. Further, the audio output device 20 may be TWS (True Wireless Stereo) headphones, etc., but is not limited to this.
[0041] The way in which the terminal device 10 establishes a communication connection with the audio output device 20 may be a wireless communication connection such as a Bluetooth communication connection, or a wired communication connection such as a connection via a USB (Universal Serial Bus) interface. The Bluetooth communication connection may include, but is not limited to, a classic Bluetooth connection, a BLE Audio (Bluetooth Low Energy Audio) connection, etc. The embodiment of the present application does not specifically limit the communication connection method between the terminal device 10 and the audio output device 20.
[0042] When the terminal device 10 detects that a state switching event occurs in the target application, if the terminal device 10 is sending the first audio data to the audio output device 20, the terminal device 10 may send a playback control instruction to the audio output device 20. The audio output device 20 receives the playback control instruction sent by the terminal device 10 and may adjust the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0043] Figure 3 FIG. 1 is a timing diagram of an audio playback control method in an embodiment. Figure 3 As shown, the audio playback control method may include the following steps:
[0044] Step 1: When the terminal device detects that a state switching event occurs in the target application, if the terminal device is sending first audio data to the audio output device, it sends a play control instruction to the audio output device.
[0045] Step 2: The audio output device receives the playback control instruction sent by the terminal device and can adjust the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0046] In some embodiments, the state switching event may include a startup event or a first foreground-background switching event, and the first foreground-background switching event refers to an event that switches from background operation to foreground operation. When the terminal device detects that a startup event or a first foreground-background switching event occurs in the target application, if the first audio data is being sent to the audio output device, a first playback control instruction may be sent to the audio output device. The audio output device receives the first playback control instruction sent by the terminal device, and may increase the audio playback rate according to the first playback control instruction to reduce the audio buffer area from the first spatial size to the second spatial size.
[0047] In some embodiments, the state switching event may include an exit event or a second foreground-background switching event, where the second foreground-background switching event refers to an event that switches from foreground operation to background operation. When the terminal device detects that an exit event or a second foreground-background switching event occurs in the target application, if the first audio data is being sent to the audio output device, a second playback control instruction may be sent to the audio output device. When the audio output device receives the second playback control instruction sent by the terminal device, it may reduce the audio playback rate according to the second playback control instruction to increase the audio buffer area from the second spatial size to the first spatial size.
[0048] like Figure 4 As shown, in one embodiment, an audio playback control method is provided, which can be applied to the above-mentioned terminal device, and the method may include the following steps:
[0049] Step 410, when a state switching event is detected in the target application, if the first audio data is being sent to the audio output device, a playback control instruction is sent to the audio output device, and the playback control instruction is used to instruct the audio output device to adjust the audio playback rate to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0050] The target application may refer to an application that has low latency requirements during runtime. The target application may be an application that requires audio and video synchronization. Audio and video synchronization refers to the synchronization of the sound output by the audio output device with the picture displayed by the terminal device. For example, the target application may include but is not limited to game applications, live broadcast applications, etc.
[0051] A state switching event occurs in the target application, which means that the life cycle state of the target application has changed or switched. The state switching event may include but is not limited to one or more of a startup event, a first foreground-background switching event, a second foreground-background switching event, and an exit event. Among them, a startup event refers to an event in which a terminal device starts the target application, a first foreground-background switching event refers to an event in which the target application switches from background operation to foreground operation, a second foreground-background switching event refers to an event in which the target application switches from foreground operation to background operation, and an exit event refers to an event in which a terminal device closes the target application.
[0052] In some embodiments, a list of applications to be monitored may be pre-stored in the terminal device. The list of applications to be monitored may include application information of one or more target applications (such as application name, application installation package name, application number, application version number, etc., but not limited to this). Based on the application information of each target application included in the list of applications to be monitored, the life cycle status of each target application may be monitored to detect whether a state switching event occurs in each target application.
[0053] As an implementation method, the terminal device may create a listening thread, and add the application information of each target application included in the list of applications to be monitored in the listening thread, and monitor whether the life cycle state of each target application has changed through the listening thread, and when a change in the life cycle state of any target application is detected, a state change notification of the target application is generated, and the state change notification can be used to notify the state switching event that has occurred in the target application, so that the state switching event that has occurred in the target application can be determined based on the state change notification. For example, the installation package name A of game application A can be added to the listening thread, and the life cycle state of game application A can be monitored through the listening thread. When the listening thread detects that a startup event has occurred in game application A, a corresponding state change notification can be generated, and it can be determined that a startup event has occurred.
[0054] Furthermore, since the application needs to call the corresponding interface implementation when the life cycle state changes, the calling situation of each interface used to realize the life cycle state change can be monitored through the monitoring thread. If it is detected that any monitored interface is called and the caller is any target application, it can be determined that the life cycle state of the target application has changed, and the state switching event that occurred can be determined according to the called interface. For example, if the application needs to call the onStar() interface to start, the onStar() interface can be monitored through the monitoring thread. If the application needs to call the onStop() interface to exit the operation, the onStop() interface can be monitored through the monitoring thread, but it is not limited to this. It should be noted that the onStar() interface and onStop() interface involved in this embodiment are only used as an example to illustrate the scheme, and it does not mean that the scheme must monitor these two interfaces during the actual implementation process. The monitored interface can be adjusted according to the actual situation. By monitoring whether the state switching event occurs in the target application by monitoring the calling situation of the interface, the state switching event occurring in the target application can be detected more timely and accurately, thereby improving the detection efficiency.
[0055] When the terminal device detects a state switching event of the target application, it can determine whether the first audio data is currently being sent to the audio output device. Whether the first audio data is currently being sent to the audio output device may be that the first audio data is being sent to the audio output device at the current moment when the state switching event of the target application is detected, or that the first audio data is being sent to the audio output device within a certain period of time after the state switching event of the target application is detected. It does not necessarily mean that the first audio data is sent to the audio output device at the same moment when the state switching event of the target application is detected.
[0056] When a state switching event occurs in the target application, if the terminal detects that the first audio data is being sent to the audio output device, if the audio delay is adjusted by switching Bluetooth encoding in the relevant technology, the audio output device will pause for a period of time without playing audio data during this process, which will cause a stuttering experience for the user. In an embodiment of the present application, when the terminal device detects that a state switching event occurs in the target application, if the first audio data is being sent to the audio output device, a playback control instruction can be sent to the audio output device, and the playback control instruction can be used to instruct the audio output device to adjust the audio playback rate. After receiving the playback control instruction, the audio output device can adjust the audio playback rate, and by adjusting the audio playback rate, the audio buffer area is adjusted to the spatial size corresponding to the state switching event. The audio buffer area can be used to cache the audio data to be played, and the effect of adjusting the audio delay can be achieved by adjusting the spatial size of the audio buffer area.
[0057] The audio playback rate refers to the speed at which audio data is output through the audio output device through the speaker, etc. The higher the audio playback rate, the faster the audio output device reads audio data from the audio buffer, and the lower the audio playback rate, the slower the audio output device reads audio data from the audio buffer. When there is no need to adjust the spatial size of the audio buffer, the audio output device can play audio data at the default audio playback rate, which can be consistent with the speed at which the audio output device receives audio data and stores it in the audio buffer, that is, consistent with the speed at which the terminal device sends audio data, thereby ensuring that the amount of data in the audio buffer remains consistent during the audio playback process.
[0058] After the audio output device receives the playback control instruction, it can adjust the audio playback rate according to the playback control instruction, and output the data in the audio buffer at a faster or slower speed, thereby indirectly adjusting the spatial size of the audio buffer. For example, when it is necessary to reduce the audio delay, that is, to reduce the spatial size of the audio buffer, the audio output device can increase the audio playback rate and output the data in the audio buffer at a faster speed. Since the amount of data stored in the audio buffer is less than the amount of data read out, the spatial size of the audio buffer will gradually decrease to the required spatial size; for another example, when it is necessary to increase or restore the audio delay, that is, to increase the spatial size of the audio buffer, the audio output device can reduce the audio playback rate and output the data in the audio buffer at a slower speed. The amount of data stored in the audio buffer will be greater than the amount of data read out, and the spatial size of the audio buffer will gradually increase to the required spatial size. While adjusting the spatial size of the audio buffer, the playback of the first audio data is not affected, and the jamming phenomenon can be avoided.
[0059] The audio output device can determine the required spatial size of the audio buffer area according to the state switching event of the target application to adapt to the audio delay requirement. In some embodiments, when the target application has a startup event or a first foreground and background switching event, it means that the terminal device runs a target application with a low delay requirement, so the audio delay needs to be reduced. The startup event and the first foreground and background switching event can correspond to the second spatial size; when the target application has an exit event or a second foreground and background switching event, the terminal device does not run the target application and has no low delay requirement, so the audio delay can be increased. The exit event or the second foreground and background switching event can correspond to the first spatial size, and the first spatial size is greater than the second spatial size. Optionally, for different target applications, the requirements for audio delay are different, and different second spatial sizes can also be corresponding. For example, compared with the live broadcast application, the game application requires lower-delay audio playback, then the game application has a startup event or a first foreground and background switching event, and the second spatial size corresponding to the audio buffer area can be smaller than the second spatial size corresponding to the audio buffer area when the live broadcast application has a startup event or the first foreground and background switching event. The embodiment of the present application is not limited to this.
[0060] In some embodiments, when the audio output device determines that the audio buffer is adjusted to a spatial size corresponding to a state switching event, the audio playback rate can be restored to the audio playback rate before the adjustment so that the audio buffer maintains the adjusted spatial size to meet the audio delay requirements.
[0061] In an embodiment of the present application, when a state switching event occurs in the target application on the terminal device, if the first audio data is sent at the same time, the audio output device can be controlled to indirectly adjust the spatial size of the audio buffer area by adjusting the audio playback rate, so that the spatial size of the audio buffer area meets the audio delay requirement, effectively reducing the audio delay between the audio output device and the terminal device, and without directly adjusting the spatial size of the audio buffer area, it is possible to avoid audio playback jams and improve the audio playback effect.
[0062] like Figure 5 As shown, in another embodiment, an audio control method is provided, which can be applied to the above-mentioned terminal device, and the method may include the following steps:
[0063] Step 502, when a startup event or a first foreground-background switching event is detected in the target application, if the first audio data is being sent to the audio output device, a first playback control instruction is sent to the audio output device, and the first playback control instruction is used to instruct the audio output device to increase the audio playback rate to reduce the audio buffer area from the first spatial size to the second spatial size.
[0064] When the terminal device detects that a startup event or a first foreground-background switching event occurs in the target application, it indicates that there is a low-latency requirement, and it can be determined whether the first audio data is being sent to the audio output device. As a specific implementation, the terminal device can establish a Bluetooth communication connection with the audio output device. When a startup event or a first foreground-background switching event occurs in the target application, before the target application runs the audio playback process, it can be determined whether the A2DP (Advanced Audio Distribution Profile, Bluetooth audio transmission model protocol) link between the audio output device and the audio output device is transmitting the first audio data. The first audio data can be any audio data other than the audio data of the target application, such as music, video sound, etc.
[0065] If the first audio data is being sent to the audio output device, in order to avoid a jamming phenomenon, the spatial size of the audio buffer of the audio output device can be adjusted by adjusting the audio playback rate of the audio output device. The terminal device can send a first playback control instruction to the audio output device, and the audio output device can increase the audio playback rate after receiving the first playback control instruction.
[0066] In some embodiments, the first control instruction may be a private instruction agreed upon between the terminal device and the audio output device. The first control instruction may carry a notification of entering the first low-latency mode. After receiving the first control instruction, the audio output device may parse the first control instruction to obtain a notification of entering the first low-latency mode, and enter the first low-latency mode according to the notification of entering the first low-latency mode. The first low-latency mode is a mode in which audio delay is reduced by increasing the audio playback rate. After the audio output device enters the first low-latency mode, the audio playback rate may be increased to reduce the audio buffer from the first spatial size to the second spatial size.
[0067] It should be noted that increasing the audio playback rate does not change the sampling rate of the audio data to be played in the audio buffer, but consumes more data in the audio buffer by playing the audio data at a faster speed. For example, the sampling rate of the audio data to be played (such as the first audio data) is 48kHz (kilohertz), that is, 48,000 sampling points are played per second at the normal playback rate, then the audio playback rate can be increased to 48,500 sampling points per second.
[0068] The second spatial size can match the audio delay required when the target application is running. For example, if the audio delay required when the target application is running is 200ms (milliseconds), the second spatial size can be the size of the space used to store 200ms of audio data to be played. After the audio output device increases the audio playback rate, the data in the audio buffer will be consumed at a faster rate, that is, the speed of reading data from the audio buffer will be greater than the speed of writing data to the audio buffer, so the amount of data in the audio buffer will gradually decrease until the amount of data in the audio buffer matches the required audio delay, so as to reduce the audio buffer from the first spatial size to the second spatial size. It should be noted that reducing the audio buffer from the first spatial size to the second spatial size may refer to the physical storage space of the audio buffer gradually decreasing from the first spatial size to the second spatial size, or may refer to the physical storage space of the audio buffer remaining unchanged, but the amount of data stored is consistent with the amount of data that can be stored in the second spatial size, that is, the amount of data stored in the audio buffer remains matched with the required audio delay.
[0069] In some embodiments, when the audio output device determines that the audio buffer is adjusted to the second spatial size, the audio playback rate can be restored to the audio playback rate before the adjustment. For example, if the audio output device previously increases the audio playback rate from 48,000 samples per second to 48,500 samples per second, then when the audio buffer is adjusted to the second spatial size, the audio playback rate can be restored from 48,500 samples per second to 48,000 samples per second. If the audio playback rate is restored to the audio playback rate before the adjustment, the amount of data stored in the audio buffer can be kept matching the required audio delay (i.e., the audio buffer maintains the second spatial size), thereby meeting the low latency requirement during the operation of the target application.
[0070] In some embodiments, before the terminal device detects a startup event or a first foreground-background switching event of the target application, the terminal device may compress the first audio data according to the first bit rate, and encode the first audio data using the first audio codec. The first audio data corresponds to the first bit rate, and the first audio data is encoded using the first audio codec. The first audio codec may be an audio codec with higher sound quality but greater latency, for example, an AAC audio codec, etc., but is not limited thereto. When the terminal device detects a startup event or a first foreground-background switching event of the target application, if the first audio data is still being sent to the audio output device, the terminal device may compress the audio data to be sent according to the second bit rate, encode the compressed audio data based on the first audio codec, and send the encoded audio data to the audio output device.
[0071] The audio data to be sent may include first audio data and second audio data corresponding to the target application, and the second audio data includes but is not limited to background sound, interactive prompt sound, etc. in the target application.
[0072] When the terminal device detects a startup event or a first foreground-background switching event of the target application, if the first audio data is still being sent to the audio output device, the terminal device can keep the audio codec unchanged and still use the first audio codec, and can reduce the bit rate of the audio data. During the operation of the target application, if the first audio data is played at the same time, the audio data to be sent can be compressed according to the second bit rate, and the second bit rate is less than the first bit rate. By reducing the bit rate of the audio data, the anti-interference ability of the audio data during transmission can be improved, and the transmission stability can be improved.
[0073] It should be noted that the second bit rate can be set according to actual needs or experiments. The second bit rate can be a fixed bit rate or can be dynamically adjusted according to the actual data transmission environment. For example, if the retransmission rate between the terminal device and the audio transmission device is high and the environmental interference is large, a smaller second bit rate can be set to improve the anti-interference ability of the audio data during transmission. If the retransmission rate between the terminal device and the audio transmission device is small and the environmental interference is small, a larger second bit rate can be set to reduce the audio delay while ensuring the audio quality as much as possible.
[0074] In some embodiments, the terminal device may also reduce its own audio buffer, and the spatial size of the audio buffer of the terminal device may be the same as the spatial size of the audio buffer of the audio output device. Then, when the terminal device detects that a startup event or a first foreground-background switching event occurs in the target application, if it is determined that the first audio data is being sent to the audio output device, the terminal device may reduce its own audio buffer from the first spatial size to the second spatial size. Optionally, since the terminal device directly adjusts the spatial size of the audio buffer, it will not cause a freeze to the user. Therefore, the terminal device may directly adjust its own audio buffer to the second spatial size to reduce the overall audio path delay. It should be noted that the spatial size of the audio buffer of the terminal device may be different from that of the audio buffer of the audio output device, and this is not limited in the embodiments of the present application.
[0075] For example, Fig. 6A FIG. 1 is a timing diagram of an audio playback control method in another embodiment. Fig. 6AAs shown, the terminal device can establish a communication connection with the audio output device. When the terminal device starts the target application, or the target application switches from background operation to foreground operation, if it is determined that the first audio data is being sent to the audio output device, the audio output device can be notified to enter the first low-latency mode and send the first control instruction to the audio output device. After receiving the first control instruction, the audio output device can enter the first low-latency mode according to the first control instruction, increase the audio playback rate for audio playback, and determine whether the audio buffer is reduced to the second spatial size, such as whether the amount of data stored in the audio buffer is reduced to the amount of data matched by the required audio delay. If the audio buffer is reduced to the second spatial size, the audio playback rate can be restored for audio playback. The terminal device can keep the audio codec unchanged, reduce the bit rate, compress the audio data to be sent according to the second bit rate, encode the compressed audio data based on the first audio codec, and then send the encoded audio data to the audio output device. Since the audio buffer of the audio output device is reduced to the second spatial size, the audio delay is effectively reduced.
[0076] Step 504, when an exit event or a second foreground / background switching event of the target application is detected, if the first audio data is being sent to the audio output device, a second playback control instruction is sent to the audio output device, wherein the second playback control instruction is used to instruct the audio output device to reduce the audio playback rate to increase the audio buffer area from the second spatial size to the first spatial size.
[0077] When the terminal device detects that the target application has an exit event or a second foreground or background switching event, it means that there is no low latency requirement and the audio delay needs to be restored to normal audio playback. The terminal device can determine whether the first audio data is being sent to the audio output device. As a specific implementation, when the terminal device detects that the target application has an exit event or a second foreground or background switching event, after closing or suspending the audio playback process of the target application, it can determine whether the A2DP link between the audio output device and the audio output device is transmitting the first audio data. If the A2DP link between the audio output device and the audio output device is transmitting the first audio data, in order to avoid stuttering, the spatial size of the audio buffer area of the audio output device can be adjusted by adjusting the audio playback rate of the audio output device.
[0078] The terminal device may send a second playback control instruction to the audio output device, and the audio output device may reduce the audio playback rate after receiving the second playback control instruction. In some embodiments, the second control instruction may be a private instruction agreed upon between the terminal device and the audio output device, and the second control instruction may carry a notification of exiting the first low-latency mode. After receiving the second control instruction, the audio output device may parse the second control instruction to obtain a notification of exiting the first low-latency mode, and exit the first low-latency mode according to the notification of exiting the first low-latency mode, and reduce the audio playback rate to increase the audio buffer area from the second spatial size to the first spatial size, that is, to restore the audio buffer area to the spatial size before entering the first low-latency mode.
[0079] It should be noted that lowering the audio playback rate does not change the sampling rate of the audio data to be played in the audio buffer, but rather consumes less data in the audio buffer by playing the audio data at a slower speed. For example, the sampling rate of the audio data to be played (such as the first audio data) is 48kHz (kilohertz), that is, 48,000 sampling points are played per second at the normal playback rate, then the audio playback rate can be increased to 47,500 sampling points per second.
[0080] After the audio output device reduces the audio playback rate, the data in the audio buffer will be consumed at a slower speed, that is, the speed of reading data from the audio buffer will be lower than the speed of writing data to the audio buffer, so the amount of data in the audio buffer will gradually increase until the amount of data in the audio buffer is restored to the amount of data in the normal playback condition (matching the first spatial size), so as to increase the audio buffer from the second spatial size to the first spatial size. It should be noted that increasing the audio buffer from the second spatial size to the first spatial size may refer to the physical storage space of the audio buffer gradually increasing from the second spatial size to the first spatial size, or may refer to the physical storage space of the audio buffer remaining unchanged, but the amount of data stored is consistent with the amount of data that can be stored in the first spatial size.
[0081] In some embodiments, when the audio output device determines that the audio buffer is adjusted to the first spatial size, the audio playback rate can be restored to the audio playback rate before the adjustment. For example, the audio output device previously reduced the audio playback rate from 48,000 samples per second to 47,500 samples per second. When the audio buffer is adjusted to the first spatial size, the audio playback rate can be restored from 47,500 samples per second to 48,000 samples per second. When the audio playback rate is restored to the audio playback rate before the adjustment, the audio buffer can maintain the first spatial size and be in a full cache state, meeting normal audio playback requirements.
[0082] In some embodiments, when the terminal device detects that the target application has an exit event or a second foreground or background switching event, if the first audio data is still being sent to the audio output device, the terminal device can keep the audio codec used unchanged and still use the first audio codec, and restore the bit rate of the audio data, compress the first audio data according to the first bit rate, and encode the compressed first audio data based on the currently used first audio codec, and send the encoded first audio data to the audio output device, thereby ensuring audio quality and improving audio playback effects without low latency requirements.
[0083] In some embodiments, the terminal device may also increase its own audio buffer. When the terminal device detects an exit event or a second foreground-background switching event of the target application, if it is determined that the first audio data is being sent to the audio output device, the terminal device may increase its own audio buffer from the second spatial size to the first spatial size. Optionally, the terminal device may directly adjust its own audio buffer to the first spatial size to meet the needs of audio transmission.
[0084] For example, Figure 6B FIG. 1 is a timing diagram of an audio playback control method in another embodiment. Figure 6B As shown, the terminal device establishes a communication connection with the audio output device. When the terminal device exits the target application, or the target application switches from the foreground to the background, if it is determined that the first audio data is being sent to the audio output device, the audio output device can be notified to exit the first low-latency mode and send a second control instruction to the audio output device. After receiving the second control instruction, the audio output device can exit the first low-latency mode according to the first control instruction, reduce the audio playback rate for audio playback, and determine whether the audio buffer is increased to the first spatial size, such as determining whether the amount of data stored in the audio buffer is increased to the amount of data matched by the first spatial size. If the audio buffer is increased to the first spatial size, the audio playback rate can be restored for audio playback. The terminal device can keep the audio codec unchanged, restore the bit rate, compress the first audio data according to the first bit rate, and encode the compressed first audio data based on the first audio codec, and then send the encoded first audio data to the audio output device. Since the audio buffer of the audio output device is increased and restored to the first spatial size, the requirements of normal audio playback are met.
[0085] In an embodiment of the present application, when a target application on a terminal device is started, exited, or switched between the foreground and background, if the terminal device is sending first audio data to an audio output device, the audio output device indirectly adjusts the spatial size of the audio buffer by adjusting the audio playback rate, so that the spatial size of the audio buffer meets the audio delay requirement, and can effectively reduce the audio delay between the audio output device and the terminal device during the operation of the target application, and maintain audio playback during the adjustment of the spatial size of the audio buffer, without causing any lag, thereby improving the audio playback effect.
[0086] like Figure 7 As shown, in another embodiment, an audio playback control method is provided, which can be applied to the above-mentioned terminal device, and the method may include the following steps:
[0087] Step 702: Detect a state switching event of the target application.
[0088] Step 704 , determining whether the first audio data is being sent to the audio output device, if so, executing step 706 , if not, executing step 708 .
[0089] Step 706: Send a play control instruction to the audio output device, where the play control instruction is used to instruct the audio output device to adjust the audio play rate so as to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0090] The description of steps 702 to 706 may refer to the relevant description in the above embodiments, and will not be repeated here.
[0091] Step 708: Switch the audio codec to be used according to the state switching event.
[0092] Step 710, sending a configuration instruction to the audio output device; the configuration instruction carries configuration parameters corresponding to the switched audio codec, and the configuration instruction is used to instruct the audio output device to switch the audio codec according to the configuration parameters and adjust the audio buffer area to the spatial size corresponding to the state switching event.
[0093] When the terminal device detects that a state switching event occurs in the target application, if the first audio data is not sent to the audio output device, the terminal device can switch the audio codec used according to the audio delay requirement corresponding to the state switching event, and control the audio output device to directly adjust the spatial size of the audio buffer area to meet the audio delay requirement. The audio output device receives the configuration instruction sent by the terminal device, and can switch the audio codec used according to the configuration parameters carried in the configuration instruction, and adjust the audio buffer area to the spatial size corresponding to the state switching event.
[0094] In some embodiments, when the state switching event is a start event or a first foreground-background switching event, the terminal device may switch the currently used first audio codec to a second audio codec, and send a first configuration instruction to the audio output device, where the first configuration instruction carries configuration parameters corresponding to the second audio codec. The first configuration instruction is used to instruct the audio output device to switch to the second audio codec according to the configuration parameters corresponding to the second audio codec, and reduce the audio buffer area from the first spatial size to the second spatial size.
[0095] When the target application in the terminal device is started or switched from the background to the foreground, if the first audio data is not sent to the audio output device, the terminal device can switch the currently used first audio codec to the second audio codec, and the delay of the second audio codec is less than that of the first audio codec. The audio data encoded and decoded by the second audio codec can be transmitted and played faster, and the overall audio delay is lower. For example, the first audio codec can be an AAC codec, and the second audio codec can be an SBC codec, etc., but it is not limited to this. The first audio codec and the second audio codec can also be other audio codecs.
[0096] After the terminal device switches the currently used first audio codec to the second audio codec, it can send a first configuration instruction to the audio output device, and the first configuration instruction can carry the configuration parameters corresponding to the second audio codec. After receiving the first configuration instruction, the audio output device can switch to the second audio codec according to the configuration parameters corresponding to the second audio codec, and reduce the audio buffer area from the first space size to the second space size.
[0097] The first configuration instruction may be an instruction in the Bluetooth standard protocol or an agreed private instruction. As a specific implementation, the first configuration instruction may be a reconfiguration instruction in the Bluetooth standard protocol, and the first configuration instruction may carry configuration parameters of the second audio codec, and the configuration parameters may be specified parameter values, and the specified parameter values may be different from the parameter values of the second audio codec in the Bluetooth standard protocol, or different from the parameter values used by the second audio codec in normal audio playback. For example, the first configuration instruction may carry the min bitpool (minimum bit pool) parameter and the max bitpool (maximum bit pool) parameter corresponding to the SBC codec, and the min bitpool parameter and the max bitpool parameter may be pre-set values, such as the min bitpool parameter is 19, the max bitpool parameter is 37, etc., but is not limited to this.
[0098] After the audio output device receives the first configuration instruction sent by the terminal device, it can parse the first configuration instruction to obtain the configuration parameters corresponding to the second audio codec, recognize that the configuration parameters corresponding to the second audio codec are the specified parameter values, and enter the second low-latency mode. The second low-latency mode is a mode that directly reduces the spatial size of the audio buffer to reduce audio delay. When the audio output device enters the second low-latency mode, the audio codec used can be switched to the second audio codec, and the audio buffer can be reduced from the first spatial size to the second spatial size. Furthermore, if audio data is stored in the audio buffer, the audio output device can discard the audio data stored in the audio buffer and reduce the audio buffer from the first spatial size to the second spatial size.
[0099] In some embodiments, the terminal device may also reduce its own audio buffer, for example, it may reduce its own audio buffer from a first spatial size to a second spatial size to reduce the overall audio path delay.
[0100] After the terminal device switches to the second audio codec, while the target application is running in the foreground, the second audio data corresponding to the target application can be encoded based on the second audio codec, and the encoded second audio data can be sent to the audio output device. After the audio output device reduces the audio buffer from the first space size to the second space size, it can store the received second audio data in the audio buffer, and wait for the audio buffer to be in a full cache state (that is, the audio buffer is full of audio data). When the audio buffer is in a full cache state, the second audio data is played. It should be noted that the audio buffer being in a full cache state can mean that all storage space of the audio buffer is occupied, or that the occupied storage space in the audio buffer reaches a preset percentage of the total storage space (such as 90%, 95%, etc., but not limited to this).
[0101] For example, Fig. 8A FIG. 1 is a timing diagram of an audio playback control method in another embodiment. Fig. 8AAs shown, taking the terminal device as a mobile phone and the audio output device as a headset as an example, the mobile phone can establish a communication connection with the headset. When the mobile phone enters the game mode (such as starting the game application or switching the game application from the background to the foreground, etc.), it can determine whether the A2DP link is playing audio data. If the A2DP link is playing audio data, the mobile phone can keep the codec (such as the AAC codec) unchanged, and send a first control instruction to the headset to notify the headset to enter low latency (such as notifying the headset to enter the first low latency mode). The mobile phone can reduce the audio bit rate (such as from the first bit rate to the second bit rate) and compress the audio data to be sent according to the reduced bit rate (such as the second bit rate), and use the original codec (such as the AAC codec) to encode the audio data, and send the encoded audio data to the headset.
[0102] If the A2DP link does not play audio data, the mobile phone can switch to the SBC codec and send a first configuration instruction to the headset to notify the headset to enter low latency (such as notifying the headset to enter the second low latency mode). The mobile phone can encode the audio data using the SBC codec and send the encoded audio data to the headset.
[0103] After the headset receives the instruction sent by the mobile phone, it can parse the instruction and determine whether to enter the low-latency mode and whether it is an SBC specific parameter based on the information carried in the instruction. If the headset determines to enter the low-latency mode and the instruction does not carry SBC specific parameters, that is, it enters the first low-latency mode, the headset can increase the audio playback rate and play the audio data at the increased audio playback rate. It can determine whether the buffer reaches the set value (such as the buffer is reduced to the second spatial size). If the buffer reaches the set value, the normal playback rate (that is, the audio playback rate before the increase) can be restored for audio playback. If the headset determines to enter the low-latency mode and the instruction carries SBC specific parameters, that is, it enters the second low-latency mode, the headset can reduce the spatial size of the buffer (such as reducing it to the second spatial size), and determine whether the buffer is full after the spatial size is reduced. If the buffer is full after the spatial size is reduced, audio playback can be performed.
[0104] In an embodiment of the present application, when the target application is started or switched from the background to the foreground, if the first audio data is not sent to the audio output device, it can be switched to a second audio codec with lower latency. The audio output device directly reduces the spatial size of the audio buffer area, which can quickly and effectively reduce the audio delay and improve the efficiency of reducing the audio delay.
[0105] In some embodiments, when the state switching event is an exit event or a second foreground-background switching event, the terminal device may switch the currently used second audio codec to the first audio codec, and send a second configuration instruction to the audio output device; the second configuration instruction carries the configuration parameters corresponding to the first audio codec, and the second configuration instruction is used to instruct the audio output device to switch to the first audio codec according to the configuration parameters corresponding to the first audio codec, and increase the audio buffer area from the second spatial size to the first spatial size.
[0106] When the target application in the terminal device exits or switches from the foreground to the background, if the first audio data is not sent to the audio output device, the terminal device can switch the currently used second audio codec to the first audio codec, the audio quality of the first audio codec is better than that of the second audio codec, and restore the audio codec to the first audio codec with higher audio delay but better audio quality to meet the user's audio playback needs.
[0107] After the terminal device switches the currently used second audio codec to the first audio codec, it can send a second configuration instruction to the audio output device, and the second configuration instruction can carry the configuration parameters corresponding to the first audio codec. After receiving the second configuration instruction, the audio output device can switch to the first audio codec according to the configuration parameters corresponding to the first audio codec, and increase the audio buffer area from the second space size to the first space size.
[0108] The second configuration instruction may be an instruction in the Bluetooth standard protocol or an agreed private instruction. As a specific implementation, the second configuration instruction may be a reconfiguration instruction in the Bluetooth standard protocol, and the second configuration instruction may carry configuration parameters of the first audio codec, and the configuration parameters may be specified parameter values, which may be different from the parameter values of the first audio codec in the Bluetooth standard protocol, or different from the parameter values used by the first audio codec in normal audio playback. For example, the second configuration instruction may carry a frequency range corresponding to the AAC codec, and the frequency range may be a preset value, such as 40kHz to 45kHz, but is not limited thereto.
[0109] After the audio output device receives the second configuration instruction sent by the terminal device, it can parse the second configuration instruction to obtain the configuration parameters corresponding to the first audio codec, recognize that the configuration parameters corresponding to the first audio codec are the specified parameter values, and exit the second low-latency mode. When the audio output device exits the second low-latency mode, the used audio codec can be switched to the first audio codec, and the audio buffer area can be increased from the second spatial size to the first spatial size. Furthermore, if audio data is stored in the audio buffer area, the audio output device can discard the audio data stored in the audio buffer area, and increase the audio buffer area from the second spatial size to the first spatial size.
[0110] In some embodiments, the terminal device may also increase its own audio buffer, for example, it may increase its own audio buffer from the second spatial size to the first spatial size, and restore the audio buffer to the spatial size before the target application runs.
[0111] For example, Figure 8B FIG. 1 is a timing diagram of an audio playback control method in another embodiment. Figure 8B As shown, taking the terminal device as a mobile phone and the audio output device as a headset as an example, the mobile phone can establish a communication connection with the headset. When the mobile phone exits the game mode (such as exiting the game application or switching the game application from the foreground to the background, etc.), it can determine whether the A2DP link is playing audio data. If the A2DP link is playing audio data, the mobile phone can keep the codec (such as the AAC codec) unchanged, and send a second control instruction to the headset to notify the headset to exit low latency (such as notifying the headset to exit the first low latency mode). The mobile phone can restore the audio bit rate to the default first bit rate, compress the audio data according to the first bit rate, and use the current codec (such as the AAC codec) to encode the audio data, and send the encoded audio data to the headset.
[0112] If the A2DP link does not play audio data, the mobile phone can switch from the SBC codec to the default codec (such as the AAC codec), and send a second configuration instruction to the headset to notify the headset to exit low latency (such as notifying the headset to exit the second low latency mode). The mobile phone can encode the audio data using the AAC codec and send the encoded audio data to the headset.
[0113] After the headset receives the instruction sent by the mobile phone, it can parse the instruction and determine whether to exit the low-latency mode and whether it is a non-SBC specific parameter (such as an AAC specific parameter, but not limited to this) based on the information carried in the instruction. If the headset determines to exit the low-latency mode and the instruction does not carry a non-SBC specific parameter, that is, exit the first low-latency mode, the headset can reduce the audio playback rate and play the audio data at the reduced audio playback rate. It can determine whether the buffer reaches the set value (such as the buffer is increased to the first spatial size). If the buffer reaches the set value, the normal playback rate (that is, the audio playback rate before the reduction) can be restored for audio playback. If the headset determines to exit the low-latency mode and the instruction carries a non-SBC specific parameter, that is, exit the second low-latency mode, the headset can increase the spatial size of the buffer (such as increasing it to the first spatial size), and determine whether the buffer is full after the increased spatial size. If the buffer is full after the increased spatial size, audio playback can be performed.
[0114] In an embodiment of the present application, when the target application exits or switches from the foreground to the background, if the first audio data is not sent to the audio output device, the used audio codec can be restored to the first audio codec with better audio quality, and the audio output device directly increases the space size of the audio buffer area to meet the user's audio playback needs.
[0115] In some embodiments, when an exit event or a second foreground-background switching event is detected in the target application, it can be detected within a first time period whether the first audio data is sent to the audio output device. If it is detected within the first time period that the first audio data is sent to the audio output device, a second playback control instruction is sent to the audio output device.
[0116] When the target application exits or switches from the foreground to the background, the terminal device needs to close or suspend the audio playback process of the target application before it can accurately determine whether the first audio data is being sent to the audio output device. Therefore, the terminal device can detect whether the first audio data is being sent to the audio output device within the first duration after detecting that the target application exits or switches from the foreground to the background. The first duration can be set according to actual needs or experiments, for example, the first duration can be 1 second, 2 seconds, 3 seconds, etc., but is not limited to this. Optionally, the first duration can be greater than the duration of closing or suspending the audio playback process of the target application and less than the duration of the user triggering audio playback after exiting the target application or switching the target application to the background, thereby reducing the probability of false detection and improving the accuracy of judgment.
[0117] When the terminal device detects an exit event or a second foreground or background switching event of the target application, if it is detected that the first audio data is sent to the audio output device within the first time period, the terminal device can compress the first audio data according to the first bit rate, encode the compressed first audio data based on the currently used audio codec, and send the encoded first audio data to the audio output device.
[0118] In some embodiments, if the first audio data is not sent to the audio output device when the target application is started or switched from the background to the foreground, the audio codec used by the terminal device is switched to the second audio codec. Since it is necessary to detect whether the first audio data is sent to the audio output device within a first time period when the target application exits or switches from the foreground to the background, there is still a possibility of misjudgment. For example, the user triggers audio playback very quickly after exiting the target application or switching the target application to the background, resulting in the detection of the first audio data being sent to the audio output device within the first time period. Therefore, when an exit event or a second foreground-background switching event of the target application is detected, if the sending of the first audio data to the audio output device is detected within the first time period, if the audio codec currently used by the terminal device is the second audio codec, the audio codec used may not be switched first, the bit rate may be restored to the first bit rate first, and when it is detected that the first audio data is stopped from being sent to the audio output device, the second audio codec may be switched to the first audio codec.
[0119] It should be noted that if the first bit rate exceeds the maximum bit rate supported by the second audio codec, the terminal device may compress the first audio data according to the maximum bit rate supported by the second audio codec, encode the compressed first audio data based on the currently used audio codec, and send the encoded first audio data to the audio output device. After switching the second audio codec to the first audio codec, the audio bit rate is adjusted to the first bit rate.
[0120] Optionally, the terminal device stops sending the first audio data to the audio output device when the user triggers a pause playback operation, and the terminal device stops sending the first audio data to the audio output device in response to the user-triggered pause playback operation; it can also be a pause output when switching between two different audio sources, such as pausing the output of the first audio data during the switching between two songs. In the case of stopping sending the first audio data to the audio output device, the terminal device switches the second audio codec to the first audio codec, and sends a second configuration instruction to the audio output device. The audio output device switches to the first audio codec according to the configuration parameters corresponding to the first audio codec carried by the second configuration instruction, and increases the audio buffer from the second space size to the first space size. In the case of stopping sending the first audio data to the audio output device, the audio codec is switched and the audio buffer is adjusted, which can avoid the situation of freezing caused by switching the audio codec and adjusting the audio buffer during the audio playback process, thereby improving the audio playback effect.
[0121] In an embodiment of the present application, when the terminal device detects a state switching event in the target application, it can determine whether to switch the audio codec based on whether there is a need to play the first audio data at the same time, thereby avoiding the freeze caused by the audio codec switching process, and can achieve adjustment of the audio delay to meet the different needs of users.
[0122] like Fig. 9 As shown, in one embodiment, another audio playback control method is provided, which can be applied to the above-mentioned audio output device, and the method may include the following steps:
[0123] Step 910, receiving a playback control instruction sent by a terminal device; the playback control instruction is sent by the terminal device when it detects that a state switching event occurs in a target application and the terminal device is sending first audio data to an audio output device.
[0124] Step 920: Adjust the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0125] In one embodiment, the playback control instruction includes a first playback control instruction, which is sent by the terminal device when it detects that a startup event or a first foreground-background switching event occurs in the target application and the first audio data is being sent to the audio output device; step 920 includes: increasing the audio playback rate according to the first playback control instruction to reduce the audio buffer area from the first spatial size to the second spatial size.
[0126] In one embodiment, the playback control instruction includes a second playback control instruction, which is sent by the terminal device when it detects that an exit event or a second foreground or background switching event occurs in the target application and the first audio data is being sent to the audio output device; step 920 includes: reducing the audio playback rate according to the second playback control instruction to increase the audio buffer area from the second spatial size to the first spatial size.
[0127] In one embodiment, after step 920, the method further includes: in case it is determined that the audio buffer area is adjusted to a spatial size corresponding to the state switching event, restoring the audio playback rate to the audio playback rate before the adjustment.
[0128] In one embodiment, the method further includes: receiving a configuration instruction sent by a terminal device, the configuration instruction being sent by the terminal device after switching the audio codec used when detecting a state switching event of a target application and not sending the first audio data to an audio output device; the configuration instruction carrying configuration parameters corresponding to the audio codec after the terminal device has switched; switching the audio codec used according to the configuration parameters, and adjusting the audio buffer area to a spatial size corresponding to the state switching event.
[0129] In one embodiment, the configuration instruction includes a first configuration instruction, which is sent by the terminal device after switching the currently used first audio codec to the second audio codec when detecting that a startup event or a first foreground-background switching event occurs in the target application and the first audio data is not sent to the audio output device; the first configuration instruction carries configuration parameters corresponding to the second audio codec;
[0130] The step switches the audio codec used according to the configuration parameters and adjusts the audio buffer area to the spatial size corresponding to the state switching event, including: switching to the second audio codec according to the configuration parameters corresponding to the second audio codec, and reducing the audio buffer area from the first spatial size to the second spatial size; the delay of the second audio codec is less than the delay of the first audio codec.
[0131] In one embodiment, the configuration instruction includes a second configuration instruction, which is sent by the terminal device after switching the currently used second audio codec to the first audio codec when detecting that an exit event or a second foreground-background switching event occurs in the target application and the first audio data is not sent to the audio output device; the second configuration instruction carries configuration parameters corresponding to the first audio codec;
[0132] The step switches the audio codec used according to the configuration parameters and adjusts the audio buffer area to the spatial size corresponding to the state switching event, including: switching to the first audio codec according to the configuration parameters corresponding to the first audio codec, and increasing the audio buffer area from the second spatial size to the first spatial size.
[0133] It should be noted that the description of the audio playback control method applied to the audio output device provided in the embodiment of the present application can refer to the relevant description of the audio playback control method applied to the terminal device provided in the above embodiments, and will not be repeated here.
[0134] In an embodiment of the present application, when a state switching event occurs in the target application on the terminal device, if the first audio data is sent at the same time, the audio output device can indirectly adjust the spatial size of the audio buffer by adjusting the audio playback rate, so that the spatial size of the audio buffer meets the audio delay requirement, effectively reducing the audio delay between the audio output device and the terminal device, and not directly adjusting the spatial size of the audio buffer, which can avoid the situation of audio playback jamming and improve the audio playback effect. In addition, when the terminal device detects that the target application has a state switching event, it can determine whether to switch the audio codec based on whether there is a need to play the first audio data at the same time, thereby avoiding the jamming caused by the audio codec switching process, and can achieve the adjustment of audio delay, meet the different needs of users, and improve the user experience.
[0135] like Fig.10 As shown, in one embodiment, an audio playback control device 1000 is provided, which can be applied to the above-mentioned terminal device. The audio playback control device 1000 may include a first instruction sending module 1010.
[0136] The first instruction sending module 1010 is used to send a playback control instruction to the audio output device when a state switching event is detected in the target application, if the first audio data is being sent to the audio output device. The playback control instruction is used to instruct the audio output device to adjust the audio playback rate to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0137] In one embodiment, the state switching event includes a start event or a first foreground-background switching event, and the first foreground-background switching event refers to an event that switches from background operation to foreground operation; the first instruction sending module 1010 is also used to send a first playback control instruction to the audio output device, and the first playback control instruction is used to instruct the audio output device to increase the audio playback rate to reduce the audio buffer area from the first spatial size to the second spatial size.
[0138] In one embodiment, the first audio data corresponds to a first bit rate, and the first audio data is encoded using a first audio codec; the audio playback control device 1000 further includes an audio processing module.
[0139] An audio processing module is used to compress the audio data to be sent according to a second bit rate, encode the compressed audio data based on a first audio codec, and send the encoded audio data to the audio output device when a startup event or a first foreground-background switching event occurs in the target application and the first audio data is being sent to the audio output device; wherein the audio data to be sent includes the first audio data and the second audio data corresponding to the target application, and the second bit rate is less than the first bit rate.
[0140] In one embodiment, the state switching event includes an exit event or a second foreground-background switching event, and the second foreground-background switching event refers to an event of switching from foreground operation to background operation; the first instruction sending module 1010 is also used to send a second playback control instruction to the audio output device, and the second playback control instruction is used to instruct the audio output device to reduce the audio playback rate to increase the audio buffer area from the second spatial size to the first spatial size.
[0141] In an embodiment of the present application, when a target application on a terminal device is started, exited, or switched between the foreground and background, if the terminal device is sending first audio data to an audio output device, the audio output device indirectly adjusts the spatial size of the audio buffer by adjusting the audio playback rate, so that the spatial size of the audio buffer meets the audio delay requirement, and can effectively reduce the audio delay between the audio output device and the terminal device during the operation of the target application, and maintain audio playback during the adjustment of the spatial size of the audio buffer, without causing any lag, thereby improving the audio playback effect.
[0142] In one embodiment, the audio playback control device 1000 further includes a switching module and a second instruction sending module.
[0143] The switching module is used to switch the audio codec used according to the state switching event when a state switching event occurs in the target application and if the first audio data is not sent to the audio output device.
[0144] The second instruction sending module is used to send a configuration instruction to the audio output device; the configuration instruction carries the configuration parameters corresponding to the switched audio codec, and the configuration instruction is used to instruct the audio output device to switch the audio codec according to the configuration parameters and adjust the audio buffer area to the spatial size corresponding to the state switching event.
[0145] In one embodiment, the switching module is further configured to switch the currently used first audio codec to the second audio codec when the state switching event is a start event or a first foreground-background switching event.
[0146] The second instruction sending module is also used to send a first configuration instruction to the audio output device; the first configuration instruction carries configuration parameters corresponding to the second audio codec, and the first configuration instruction is used to instruct the audio output device to switch to the second audio codec according to the configuration parameters corresponding to the second audio codec, and reduce the audio buffer area from the first spatial size to the second spatial size; the delay of the second audio codec is less than the delay of the first audio codec.
[0147] The audio processing module is also used to encode the second audio data corresponding to the target application based on the second audio codec and send the encoded second audio data to the audio output device when a startup event or a first foreground or background switching event occurs in the target application and the first audio data is not sent to the audio output device.
[0148] In one embodiment, the switching module is further configured to switch the currently used second audio codec to the first audio codec when the state switching event is an exit event or a second foreground-background switching event.
[0149] The second instruction sending module is also used to send a second configuration instruction to the audio output device; the second configuration instruction carries configuration parameters corresponding to the first audio codec, and the second configuration instruction is used to instruct the audio output device to switch to the first audio codec according to the configuration parameters corresponding to the first audio codec, and increase the audio buffer area from the second spatial size to the first spatial size.
[0150] In one embodiment, the first instruction sending module 1010 is also used to detect whether to send the first audio data to the audio output device within a first time period when an exit event or a second foreground-background switching event occurs in the target application; if it is detected that the first audio data is sent to the audio output device within the first time period, a second playback control instruction is sent to the audio output device.
[0151] In one embodiment, the audio processing module is also used to compress the first audio data at a first bit rate when an exit event or a second foreground / background switching event occurs in the target application and the first audio data is being sent to the audio output device, encode the compressed first audio data based on the currently used audio codec, and send the encoded first audio data to the audio output device.
[0152] In one embodiment, the switching module is also used to, when an exit event or a second foreground-background switching event occurs in the target application and the first audio data is being sent to the audio output device, if the audio codec currently used by the audio processing module is the second audio codec, then when it is detected that the sending of the first audio data to the audio output device has stopped, switch the second audio codec to the first audio codec.
[0153] In an embodiment of the present application, when the terminal device detects a state switching event in the target application, it can determine whether to switch the audio codec based on whether there is a need to play the first audio data at the same time, thereby avoiding the freeze caused by the audio codec switching process, and can achieve adjustment of the audio delay to meet the different needs of users.
[0154] like Fig.11 As shown, in one embodiment, another audio playback control device 1100 is provided, which can be applied to the above-mentioned audio output device. The audio playback control device 1100 may include a first instruction receiving module 1110 and a rate adjustment module 1120.
[0155] The first instruction receiving module 1110 is used to receive a playback control instruction sent by a terminal device; the playback control instruction is sent by the terminal device when it detects that a state switching event occurs in the target application and the terminal device is sending the first audio data to the audio output device.
[0156] The rate adjustment module 1120 is used to adjust the audio playback rate according to the playback control instruction, so as to adjust the audio buffer area to a spatial size corresponding to the state switching event.
[0157] In one embodiment, the playback control instruction includes a first playback control instruction, which is sent by the terminal device when it detects that a startup event or a first foreground-background switching event occurs in the target application and the terminal device is sending first audio data to the audio output device.
[0158] The rate adjustment module 1120 is further configured to increase the audio playback rate according to the first playback control instruction, so as to reduce the audio buffer area from the first spatial size to the second spatial size.
[0159] In one embodiment, the playback control instruction includes a second playback control instruction, which is sent by the terminal device when it detects that an exit event or a second foreground-background switching event occurs in the target application and the terminal device is sending first audio data to the audio output device.
[0160] The rate adjustment module 1120 is further configured to reduce the audio playback rate according to the second playback control instruction, so as to increase the audio buffer area from the second spatial size to the first spatial size.
[0161] In one embodiment, the rate adjustment module 1120 is further configured to restore the audio playback rate to the audio playback rate before adjustment when it is determined that the audio buffer area is adjusted to a spatial size corresponding to the state switching event.
[0162] In one embodiment, the audio playback control device 1100 further includes a second instruction receiving module and a cache adjustment module.
[0163] The second instruction receiving module is used to receive a configuration instruction sent by a terminal device, which is sent by the terminal device after switching the audio codec used when detecting a state switching event of a target application and not sending the first audio data to the audio output device; the configuration instruction carries configuration parameters corresponding to the audio codec after the terminal device switches.
[0164] The cache adjustment module is used to switch the audio codec used according to the configuration parameters and adjust the audio cache area to a spatial size corresponding to the state switching event.
[0165] In one embodiment, the configuration instructions include a first configuration instruction, which is sent by the terminal device after switching the currently used first audio codec to the second audio codec when the terminal device detects a startup event or a first foreground-background switching event of the target application and does not send the first audio data to the audio output device; the first configuration instruction carries the configuration parameters corresponding to the second audio codec.
[0166] The cache adjustment module is also used to switch to the second audio codec according to the configuration parameters corresponding to the second audio codec, and reduce the audio cache area from the first spatial size to the second spatial size; the delay of the second audio codec is less than the delay of the first audio codec.
[0167] In one embodiment, the configuration instruction includes a second configuration instruction, which is sent by the terminal device after switching the currently used second audio codec to the first audio codec when the terminal device detects an exit event or a second foreground-background switching event of the target application and does not send the first audio data to the audio output device; the second configuration instruction carries the configuration parameters corresponding to the first audio codec.
[0168] The cache adjustment module is further used to switch to the first audio codec according to the configuration parameters corresponding to the first audio codec, and increase the audio cache area from the second spatial size to the first spatial size.
[0169] In an embodiment of the present application, when a state switching event occurs in the target application on the terminal device, if the first audio data is sent at the same time, the audio output device can indirectly adjust the spatial size of the audio buffer by adjusting the audio playback rate, so that the spatial size of the audio buffer meets the audio delay requirement, effectively reducing the audio delay between the audio output device and the terminal device, and not directly adjusting the spatial size of the audio buffer, which can avoid the situation of audio playback jamming and improve the audio playback effect. In addition, when the terminal device detects that the target application has a state switching event, it can determine whether to switch the audio codec based on whether there is a need to play the first audio data at the same time, thereby avoiding the jamming caused by the audio codec switching process, and can achieve the adjustment of audio delay, meet the different needs of users, and improve the user experience.
[0170] Fig.12 FIG. 1 is a block diagram of a terminal device in an embodiment. Fig.12 As shown, the terminal device 1200 may include one or more of the following components: a processor 1210, and a memory 1220 coupled to the processor 1210, wherein the memory 1220 may store one or more computer programs, and the one or more computer programs may be configured to implement the audio playback control method applied to the terminal device as described in the above embodiments when executed by one or more processors 1210.
[0171] The processor 1210 may include one or more processing cores. The processor 1210 uses various interfaces and lines to connect various parts of the entire terminal device 1200, and executes various functions and processes data of the terminal device 1200 by running or executing instructions, programs, code sets or instruction sets stored in the memory 1220, and calling data stored in the memory 1220. Optionally, the processor 1210 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 1210 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU), and a modem. Among them, the CPU mainly processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing display content; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 1210, but may be implemented separately through a communication chip.
[0172] The memory 1220 may include a random access memory (RAM) or a read-only memory (ROM). The memory 1220 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 1220 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc. The data storage area may also store data created by the terminal device 1200 during use, etc.
[0173] It is understandable that the terminal device 1200 may include more or fewer structural elements than those in the above structural block diagram, for example, a power module, physical buttons, a WiFi (Wireless Fidelity) module, a speaker, a Bluetooth module, a sensor, etc., and is not limited here.
[0174] An embodiment of the present application discloses an audio output device, including a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor implements the audio playback control method applied to the audio output device as described in the above embodiments.
[0175] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the audio playback control method applied to a terminal device as described in the above embodiments.
[0176] An embodiment of the present application discloses a computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the audio playback control method applied to an audio output device as described in the above embodiments.
[0177] An embodiment of the present application discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program can be executed by a processor to implement the audio playback control method applied to a terminal device as described in the above embodiments.
[0178] An embodiment of the present application discloses a computer program product, which includes a non-transitory computer-readable storage medium storing a computer program, and the computer program can be executed by a processor to implement the audio playback control method applied to an audio output device as described in the above embodiments.
[0179] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the program can be stored in a non-volatile computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. The storage medium can be a disk, an optical disk, a ROM, etc.
[0180] As used herein, any reference to memory, storage, database, or other medium may include nonvolatile and / or volatile memory. Suitable nonvolatile memory may include ROM, programmable ROM (Programmable ROM, PROM), erasable PROM (Erasable PROM, EPROM), electrically erasable PROM (Electrically Erasable PROM, EEPROM), or flash memory. Volatile memory may include random access memory (RAM), which is used as an external cache memory. By way of illustration and not limitation, RAM may be in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDR SDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), memory bus direct RAM (RDRAM) and direct memory bus dynamic RAM (DRDRAM).
[0181] It should be understood that the "one embodiment" or "an embodiment" mentioned throughout the specification means that the specific features, structures or characteristics related to the embodiment are included in at least one embodiment of the present application. Therefore, "in one embodiment" or "in an embodiment" appearing throughout the specification does not necessarily refer to the same embodiment. In addition, these specific features, structures or characteristics can be combined in one or more embodiments in any suitable manner. Those skilled in the art should also be aware that the embodiments described in the specification are all optional embodiments, and the actions and modules involved are not necessarily required for the present application.
[0182] In the various embodiments of the present application, it should be understood that the size of the serial numbers of the above-mentioned processes does not necessarily 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 on the implementation process of the embodiments of the present application.
[0183] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0184] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0185] The technical features of the above-described embodiments may be arbitrarily combined. To make the description concise, not all possible combinations of the technical features in the above-described embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0186] The above is a detailed introduction to an audio playback control method, device, electronic device and storage medium disclosed in the embodiments of the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core ideas of the present application. At the same time, for those of ordinary skill in the art, according to the ideas of the present application, there will be changes in the specific implementation methods and application scopes. In summary, the content of this specification should not be understood as limiting the present application.
Claims
1. An audio playback control method, characterized in that: Applied to a terminal device, the method comprises: When a state switching event is detected in the target application, if the first audio data is being sent to the audio output device, a playback control instruction is sent to the audio output device, and the playback control instruction is used to instruct the audio output device to adjust the audio playback rate to adjust the audio buffer area to a spatial size corresponding to the state switching event.
2. The method according to claim 1, characterized in that The state switching event includes a start event or a first foreground-background switching event, wherein the first foreground-background switching event refers to an event that switches from background operation to foreground operation; The sending of a playback control instruction to the audio output device, wherein the playback control instruction is used to instruct the audio output device to adjust the audio playback rate so as to adjust the audio buffer area to a spatial size corresponding to the state switching event, includes: A first playback control instruction is sent to the audio output device, where the first playback control instruction is used to instruct the audio output device to increase the audio playback rate so as to reduce the audio buffer area from a first spatial size to a second spatial size.
3. The method according to claim 2, characterized in that The first audio data corresponds to a first bit rate, and the first audio data is encoded using a first audio codec; the method further includes: The audio data to be sent is compressed according to a second bit rate, and the compressed audio data is encoded based on the first audio codec, and the encoded audio data is sent to the audio output device; wherein the audio data to be sent includes the first audio data and second audio data corresponding to the target application, and the second bit rate is less than the first bit rate.
4. The method according to claim 1, characterized in that: The state switching event includes an exit event or a second foreground-background switching event, wherein the second foreground-background switching event refers to an event of switching from foreground operation to background operation; The sending of a playback control instruction to the audio output device, wherein the playback control instruction is used to instruct the audio output device to adjust the audio playback rate so as to adjust the audio buffer area to a spatial size corresponding to the state switching event, includes: A second playback control instruction is sent to the audio output device, where the second playback control instruction is used to instruct the audio output device to reduce the audio playback rate so as to increase the audio buffer area from the second spatial size to the first spatial size.
5. The method according to claim 4, characterized in that When detecting that a state switching event occurs in the target application, if the first audio data is being sent to the audio output device, sending a play control instruction to the audio output device includes: When detecting that the exit event or the second foreground / background switching event occurs in the target application, detecting whether to send the first audio data to the audio output device within a first duration; If it is detected that the first audio data is sent to the audio output device within the first duration, a second play control instruction is sent to the audio output device.
6. The method according to claim 4, characterized in that The method further comprises: The first audio data is compressed according to a first bit rate, the compressed first audio data is encoded based on a currently used audio codec, and the encoded first audio data is sent to the audio output device.
7. The method according to claim 6, characterized in that The method further comprises: If the currently used audio codec is the second audio codec, then in the case where it is detected that the sending of the first audio data to the audio output device stops, the second audio codec is switched to the first audio codec.
8. The method according to any one of claims 1 to 7, characterized in that: The method further comprises: When a state switching event is detected in the target application, if the first audio data is not sent to the audio output device, the audio codec used is switched according to the state switching event, and a configuration instruction is sent to the audio output device; the configuration instruction carries configuration parameters corresponding to the switched audio codec, and the configuration instruction is used to instruct the audio output device to switch the audio codec used according to the configuration parameters, and adjust the audio buffer area to the spatial size corresponding to the state switching event.
9. The method according to claim 8, characterized in that The switching of the adopted audio codec according to the state switching event and sending a configuration instruction to the audio output device comprises: In the case where the state switching event is a start event or a first foreground-background switching event, the currently used first audio codec is switched to the second audio codec, and a first configuration instruction is sent to the audio output device; the first configuration instruction carries configuration parameters corresponding to the second audio codec, and the first configuration instruction is used to instruct the audio output device to switch to the second audio codec according to the configuration parameters corresponding to the second audio codec, and reduce the audio buffer area from the first spatial size to the second spatial size; the delay of the second audio codec is less than the delay of the first audio codec; The second audio data corresponding to the target application is encoded based on the second audio codec, and the encoded second audio data is sent to the audio output device.
10. The method according to claim 8, characterized in that The switching of the adopted audio codec according to the state switching event and sending a configuration instruction to the audio output device comprises: When the state switching event is an exit event or a second foreground-background switching event, the currently used second audio codec is switched to the first audio codec, and a second configuration instruction is sent to the audio output device; the second configuration instruction carries configuration parameters corresponding to the first audio codec, and the second configuration instruction is used to instruct the audio output device to switch to the first audio codec according to the configuration parameters corresponding to the first audio codec, and increase the audio buffer area from the second spatial size to the first spatial size.
11. An audio playback control method, characterized in that: Applied to an audio output device, the method comprises: Receiving a playback control instruction sent by a terminal device; the playback control instruction is sent by the terminal device when it detects that a state switching event occurs in a target application and the terminal device is sending first audio data to an audio output device; The audio playback rate is adjusted according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event.
12. The method according to claim 11, characterized in that The playback control instruction includes a first playback control instruction, which is sent by the terminal device when detecting that a startup event or a first foreground-background switching event occurs in the target application and the terminal device is sending first audio data to the audio output device; The step of adjusting the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event includes: The audio playback rate is increased according to the first playback control instruction to reduce the audio buffer area from a first spatial size to a second spatial size.
13. The method according to claim 11, characterized in that The playback control instruction includes a second playback control instruction, which is sent by the terminal device when detecting that an exit event or a second foreground-background switching event occurs in the target application and the terminal device is sending the first audio data to the audio output device; The step of adjusting the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event includes: The audio playback rate is reduced according to the second playback control instruction to increase the audio buffer area from the second spatial size to the first spatial size.
14. The method according to any one of claims 11 to 13, characterized in that: After adjusting the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event, the method further includes: When it is determined that the audio buffer area is adjusted to a spatial size corresponding to the state switching event, the audio playback rate is restored to the audio playback rate before the adjustment.
15. The method according to claim 11, characterized in that The method further comprises: receiving a configuration instruction sent by the terminal device, wherein the configuration instruction is sent by the terminal device after switching the audio codec used when detecting that a state switching event occurs in the target application and the first audio data is not sent to the audio output device; the configuration instruction carries configuration parameters corresponding to the audio codec after the terminal device switches; The audio codec used is switched according to the configuration parameters, and the audio buffer is adjusted to a spatial size corresponding to the state switching event.
16. The method according to claim 15, characterized in that The configuration instruction includes a first configuration instruction, which is sent by the terminal device after switching the currently used first audio codec to the second audio codec when detecting that a startup event or a first foreground-background switching event occurs in the target application and the first audio data is not sent to the audio output device; the first configuration instruction carries configuration parameters corresponding to the second audio codec; The switching of the audio codec according to the configuration parameters and adjusting the audio buffer to a spatial size corresponding to the state switching event includes: switching to the second audio codec according to configuration parameters corresponding to the second audio codec, and reducing the audio buffer from the first spatial size to the second spatial size; The delay of the second audio codec is smaller than the delay of the first audio codec.
17. The method according to claim 15, characterized in that The configuration instruction includes a second configuration instruction, which is sent by the terminal device after switching the currently used second audio codec to the first audio codec when detecting that the target application has an exit event or a second foreground-background switching event and has not sent the first audio data to the audio output device; the second configuration instruction carries configuration parameters corresponding to the first audio codec; The switching of the audio codec according to the configuration parameters and adjusting the audio buffer to a spatial size corresponding to the state switching event includes: The first audio codec is switched to according to configuration parameters corresponding to the first audio codec, and the audio buffer is increased from the second spatial size to the first spatial size.
18. An audio playback control device, characterized in that: Applied to a terminal device, the device comprises: The first instruction sending module is used to send a playback control instruction to the audio output device when a state switching event is detected in the target application, if the first audio data is being sent to the audio output device, and the playback control instruction is used to instruct the audio output device to adjust the audio playback rate to adjust the audio buffer area to a spatial size corresponding to the state switching event.
19. An audio playback control device, characterized in that: Applied to an audio output device, the device comprises: A first instruction receiving module, configured to receive a playback control instruction sent by a terminal device; the playback control instruction is sent by the terminal device when it detects that a state switching event occurs in a target application and the terminal device is sending first audio data to an audio output device; The rate adjustment module is used to adjust the audio playback rate according to the playback control instruction to adjust the audio buffer area to a spatial size corresponding to the state switching event.
20. An electronic device, characterized in that: The method comprises a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor implements the method according to any one of claims 1 to 10 or 11 to 17.
21. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 10 or 11 to 17 is implemented.