Audio playing method, related device, equipment and storage medium
By adaptively adjusting the threshold for the number of audio streams, the problem of audio playback stuttering was solved, improving the user experience and device performance utilization, and enabling more audio streams to play simultaneously.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2026-05-08
AI Technical Summary
Existing technologies are prone to playback stuttering when the number of audio streams exceeds a threshold, especially under high device load or poor performance, resulting in a poor listening experience for users and failing to fully utilize the advantages of high-performance devices.
By receiving N audio streams from the server, the number of audio streams is dynamically adjusted based on the total number of stutters in the first time period to determine the number of audio streams in the second time period. Audio is then played within this period, and the number of audio streams is adaptively adjusted based on the stuttering situation and performance of the audio streams.
It enhances the user's listening experience, fully leverages the performance advantages of the terminal, and can play more audio streams simultaneously, improving the smoothness and stability of audio playback.
Smart Images

Figure CN122002073A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of multimedia technology, and in particular to an audio playback method, related apparatus, device, and storage medium. Background Technology
[0002] With the rapid development of computer and internet technology, online audio chat has become a common form of entertainment. In practical use, if the number of audio streams exceeds a threshold, playback stuttering will occur because the processing of playback data cannot keep up with the data consumption. This stuttering is even more noticeable when the device is under heavy load or has poor performance.
[0003] To mitigate playback stuttering to some extent, a common industry practice is to implement routing strategies. This involves receiving audio streams from multiple remote users during a live chat. Then, based on a preset threshold for the number of audio streams allowed to play simultaneously, the system selects which streams to play. Finally, these selected audio streams are decoded and played.
[0004] However, the inventors discovered that the current solution has at least the following problem: in order to accommodate the performance of different devices, the threshold for the number of audio streams allowed to play simultaneously is set to a relatively small value. This prevents the full utilization of the advantages of high-performance devices, resulting in a poor listening experience for users. Therefore, an effective method is urgently needed to solve this problem. Summary of the Invention
[0005] This application provides an audio playback method, related apparatus, device, and storage medium, which can not only fully utilize the performance advantages of the terminal, but also play more audio streams simultaneously, thereby improving the user experience.
[0006] In view of this, this application provides a method for audio playback, comprising:
[0007] Receive N audio streams sent by the server, where N is an integer greater than 1;
[0008] Based on the audio stream quantity threshold corresponding to the first time period, N audio streams are played within the first time period. The audio stream quantity threshold corresponding to the first time period represents the maximum number of audio streams that the terminal can play within the first time period.
[0009] Get the total number of stutters in the first time period for N audio streams;
[0010] Based on the total number of stutters in the first time period, the threshold for the number of audio streams corresponding to the second time period is determined, where the threshold for the number of audio streams corresponding to the second time period represents the maximum number of audio streams that the terminal can play within the second time period.
[0011] Based on the audio stream quantity threshold corresponding to the second time period, audio is played on M of the N audio streams within the second time period, where M is an integer greater than or equal to 1 and less than or equal to N.
[0012] This application also provides an audio playback device, comprising:
[0013] The receiving module is used to receive N audio streams sent by the server, where N is an integer greater than 1;
[0014] The playback module is used to play N audio streams within a first time period based on the audio stream quantity threshold corresponding to the first time period. The audio stream quantity threshold corresponding to the first time period represents the maximum number of audio streams that the terminal can play within the first time period.
[0015] The acquisition module is used to obtain the total number of stutters in the first time period for N audio streams;
[0016] The determination module is used to determine the audio stream quantity threshold corresponding to the second time period based on the total number of stutters in the first time period, wherein the audio stream quantity threshold corresponding to the second time period represents the maximum number of audio streams that the terminal can play within the second time period.
[0017] The playback module is also used to play audio from M of the N audio streams within the second time period, based on the audio stream quantity threshold corresponding to the second time period, where M is an integer greater than or equal to 1 and less than or equal to N.
[0018] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0019] The acquisition module is specifically used to acquire the number of stutters for each of the N audio streams in the first time period through N cache threads, where the number of stutters is an integer greater than or equal to 0;
[0020] The total number of stutters for each audio stream in the first time period is summed to obtain the total number of stutters for the N audio streams in the first time period.
[0021] or,
[0022] The acquisition module is specifically used to obtain the total number of stutters in the first time period of N audio streams through the target cache thread, where the total number of stutters is an integer greater than or equal to 0.
[0023] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0024] The determination module is specifically used to reduce the audio stream quantity threshold corresponding to the first time period if the total number of stutters is greater than the number threshold, so as to obtain the audio stream quantity threshold corresponding to the second time period.
[0025] If the total number of stutters is less than or equal to the number of stutters threshold, then the audio stream number threshold corresponding to the first time period is increased or maintained to obtain the audio stream number threshold corresponding to the second time period.
[0026] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0027] The determination module is specifically used to calculate the average reading time based on the actual reading time of N audio streams within the first time period, wherein the actual reading time is greater than the base reading time;
[0028] The target value is obtained by quotienting the base read time and the average read time;
[0029] The threshold for the number of audio streams corresponding to the second time period is determined based on the target value, wherein the threshold for the number of audio streams corresponding to the second time period is less than the threshold for the number of audio streams corresponding to the first time period.
[0030] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0031] The determination module is specifically used to obtain the audio stream quantity threshold corresponding to the second time period by subtracting the audio stream quantity threshold corresponding to the first time period from the preset quantity, wherein the preset quantity is an integer greater than or equal to 1.
[0032] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0033] The determination module is specifically used to calculate the average reading time based on the actual reading time of N audio streams within the first time period, where the actual reading time is less than the base reading time.
[0034] The target value is obtained by quotienting the base read time and the average read time;
[0035] The threshold for the number of audio streams corresponding to the second time period is determined based on the target value, wherein the threshold for the number of audio streams corresponding to the second time period is greater than or equal to the threshold for the number of audio streams corresponding to the first time period.
[0036] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0037] The determining module is specifically used to obtain the audio stream quantity threshold corresponding to the second time period by summing the audio stream quantity threshold corresponding to the first time period with a preset quantity, wherein the preset quantity is an integer greater than or equal to 1.
[0038] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0039] The playback module is specifically used to obtain the average audio energy corresponding to each of the N audio streams;
[0040] The N audio streams are sorted by importance according to the audio stream sorting rules, resulting in N audio streams sorted from high to low importance. The audio stream sorting rules are as follows: sorting is done in order of average audio energy from high to low, and when the average audio energy is similar, sorting is done in order of audio duration from long to short.
[0041] Extract the top M audio streams from the N audio streams sorted by importance from high to low, where M is equal to the threshold number of audio streams corresponding to the second time period;
[0042] During the second time period, audio is played from M audio streams.
[0043] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0044] The playback module is specifically used to decode each audio stream acquired in the second time period through M buffer threads to obtain M decoded audio streams.
[0045] The M-buffer thread stores the decoded M audio streams into their respective buffer spaces.
[0046] Mix the M decoded audio streams stored in M buffer spaces to obtain the target audio stream;
[0047] Play audio from the target audio stream.
[0048] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0049] The playback module is specifically used to decode each audio stream acquired in the second time period through the target cache thread to obtain M decoded audio streams;
[0050] The target cache thread stores the decoded M audio streams into the cache space;
[0051] The M decoded audio streams stored in the buffer space are mixed to obtain the target audio stream;
[0052] Play audio from the target audio stream.
[0053] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0054] The determination module is also used to determine the playback callback interval based on the current time and the previous audio data reading when reading audio data from the cache space during audio playback. The playback callback interval is the difference between the current time and the time of the previous audio data reading.
[0055] The determination module is also used to obtain the interval multiple to be updated by quoting the playback callback interval with a preset base value;
[0056] The acquisition module is also used to acquire the current statistical count corresponding to each of the K interval multiples based on the interval multiple to be updated, wherein the K interval multiples include the interval multiple to be updated;
[0057] The determination module is also used to determine the target interval multiple based on the current statistical count corresponding to each interval multiple, wherein the cumulative proportion of the count corresponding to the target interval multiple is greater than or equal to the proportion threshold, and the cumulative proportion of the count is the percentage of the sum of the current statistical counts corresponding to each interval multiple that is less than or equal to the target interval multiple in the total statistical count.
[0058] The determination module is also used to obtain the size of the buffer space by multiplying the target interval multiple by the preset base value. The buffer space is used to buffer the decoded audio stream for audio playback.
[0059] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0060] The acquisition module is specifically used to acquire the number of periodic statistics corresponding to each of the K interval multiples, wherein the number of periodic statistics is the number of statistics within a preset time period;
[0061] Increment the periodic count corresponding to the interval multiple to be updated by 1 to obtain the current count corresponding to each of the K interval multiples.
[0062] In one possible design, in another implementation of another aspect of the embodiments of this application,
[0063] The acquisition module is specifically used to acquire the historical statistical count corresponding to each of the K interval multiples;
[0064] When the historical statistical duration is greater than or equal to the decay duration, the decay statistical count corresponding to each of the K interval multiples is obtained by multiplying the historical statistical count corresponding to each interval multiple by the decay coefficient.
[0065] Increment the decay statistics count corresponding to the interval multiple to be updated by 1 to obtain the current statistics count corresponding to the interval multiple to be updated;
[0066] The decay count corresponding to each of the K interval multiples, excluding the interval multiple to be updated, is taken as the current count.
[0067] In another aspect, this application provides a computer device including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the methods described above.
[0068] Another aspect of this application provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the methods described above.
[0069] Another aspect of this application provides a computer program product, including a computer program that, when executed by a processor, implements the methods described above.
[0070] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0071] This application provides an audio playback method whereby a server pushes N audio streams to a terminal, and the terminal plays the N audio streams based on an audio stream quantity threshold corresponding to a first time period. By combining the total number of stutters in the N audio streams during the first time period, the audio stream quantity threshold for the next time period (i.e., the second time period) can be determined. Therefore, based on the audio stream quantity threshold corresponding to the second time period, M audio streams are played within the second time period. This method allows for adaptive adjustment of the audio stream quantity threshold based on the total number of stutters during audio stream playback. Since the total number of stutters is often related to terminal performance, flexibly adjusting the audio stream quantity threshold not only fully utilizes the terminal's performance advantages but also allows for the simultaneous playback of more audio streams, thereby improving the user's listening experience. Attached Figure Description
[0072] Figure 1 This is a schematic diagram of an interface of an online chorus application in an embodiment of this application;
[0073] Figure 2 This is a schematic diagram of an interface of an online meeting application in this application embodiment;
[0074] Figure 3 This is a schematic diagram of an interface of an online education application in an embodiment of this application;
[0075] Figure 4 This is a schematic diagram of an interface of a live streaming application in an embodiment of this application;
[0076] Figure 5 This is a schematic diagram of an implementation environment for the audio playback method in this application.
[0077] Figure 6 This is a flowchart illustrating an audio playback method in an embodiment of this application;
[0078] Figure 7 This is a schematic diagram of an interactive flow of the audio playback method in an embodiment of this application;
[0079] Figure 8 This is a schematic diagram illustrating the total number of stutters based on a multi-threaded structure in an embodiment of this application.
[0080] Figure 9 This is a schematic diagram illustrating the total number of stutters based on a single-threaded structure in an embodiment of this application.
[0081] Figure 10 This is a schematic diagram of a multi-threaded processing architecture in an embodiment of this application;
[0082] Figure 11 This is a schematic diagram of a single-threaded processing architecture in an embodiment of this application;
[0083] Figure 12 This is a schematic diagram of an audio playback device in an embodiment of this application;
[0084] Figure 13 This is a schematic diagram of the structure of a terminal in an embodiment of this application. Detailed Implementation
[0085] This application provides an audio playback method, related apparatus, device, and storage medium, which can not only fully utilize the performance advantages of the terminal, but also play more audio streams simultaneously, thereby improving the user experience.
[0086] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “corresponding,” and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0087] It is understood that, in the specific embodiments of this application, when data such as audio streams and audio data are used in specific products or technologies, user permission or consent is required. That is, before collecting user data, users may be prompted through interfaces, pop-ups, or voice prompts to indicate that their data needs to be collected. The process of collecting user data only begins after obtaining user permission or consent. In other words, all user data collected in this application is collected with the user's consent, and the collection, use, and processing of this data must comply with the relevant laws, regulations, and standards of the relevant countries and regions.
[0088] With the widespread adoption of the internet, network audio technology is being used more and more extensively. It not only transmits audio signals over the network but also performs audio encoding, decoding, processing, and storage. In recent years, online audio chat has become a common form of entertainment. However, in practical use, when the number of audio streams exceeds a threshold, the playback will run under low load (underrun) because the processing of playback data cannot keep up with the data consumption, resulting in playback stuttering. This stuttering is more pronounced under high device load or with poor device performance.
[0089] Based on this, this application provides an audio playback method that enriches usage scenarios, supports simultaneous playback of audio streams from as many remote users as possible, and enhances the live streaming experience. Furthermore, it offers high flexibility, dynamically determining the number of remote user audio streams that can be played based on device performance, without requiring user intervention.
[0090] Before introducing the specific methods of this application, the application scenarios of this application will be illustrated by example. It should be understood that the following application scenarios are merely illustrative and are not limited to these examples.
[0091] (1) Online chorus scenario;
[0092] The terminal runs processes related to online choral singing, sending the real-time audio data captured by the microphone to these processes for processing. For easier understanding, please refer to [link to relevant documentation]. Figure 1 , Figure 1 This is a schematic diagram of an interface for an online chorus application in this embodiment of the application. As shown in the figure, "User 1" enters the live broadcast room of "Host A" and participates in the online chorus. At this time, there are 15 users in "Host A's" live broadcast room who have joined the online chorus, that is, there are 15 audio streams from remote users. Therefore, the terminal used by "User 1" first plays 15 audio streams simultaneously. If there is a buffering issue, the number of audio streams played is reduced (for example, 13 audio streams are played simultaneously). If there is no buffering issue, the 15 audio streams are played simultaneously.
[0093] (2) Online meeting scenarios;
[0094] The terminal runs processes related to online conferencing, sending the real-time audio data captured by the microphone to these processes for processing. For easier understanding, please refer to [link to relevant documentation]. Figure 2 , Figure 2 This is a schematic diagram of an online meeting application in this embodiment of the application. As shown in the figure, "User 1" enters the online meeting and participates in the communication. At this time, there are 8 users participating in the remote meeting and communicating in real time, that is, there are 8 audio streams from remote users. Therefore, the terminal used by "User 1" first plays 8 audio streams simultaneously. If there is a buffering issue, the number of audio streams played is reduced (for example, 7 audio streams are played simultaneously). If there is no buffering issue, the 8 audio streams continue to be played simultaneously.
[0095] (3) Online education scenarios;
[0096] The terminal runs online education-related processes, sending real-time audio data collected by the microphone to these processes for processing. Online education enables real-time interaction between teachers and students, providing a better learning experience. Students can connect with teachers via voice or video to ask questions, discuss learning content, and enhance learning outcomes. For easier understanding, please refer to [link to relevant documentation]. Figure 3 , Figure 3 This is a schematic diagram of an interface for an online education application in this application embodiment. "User 1" enters the class livestream room and participates in the interaction. At this time, 50 students have joined the online classroom and enabled the voice function, meaning there are 50 audio streams from remote users. Therefore, the terminal used by "User 1" initially plays all 50 audio streams simultaneously. If buffering occurs, the number of audio streams played is reduced (e.g., playing 48 audio streams simultaneously). If no buffering occurs, the simultaneous playback of all 50 audio streams continues.
[0097] (4) Live streaming with multiple participants;
[0098] The terminal runs processes related to live streaming and interactive chat. The terminal sends the live chat data captured in real-time by the microphone to the online chorus-related processes for processing. Live streaming and interactive chat can be used in scenarios such as multiplayer online games and esports events to enhance the social and entertainment experience. For easier understanding, please refer to... Figure 4 , Figure 4 This is a schematic diagram of a live-streaming multiplayer application in this embodiment. As shown in the figure, "User 1" enters "Host A's" live-streaming room and participates in a voice multiplayer session. At this time, there are 6 users participating in the multiplayer session in "Host A's" live-streaming room, that is, there are 6 audio streams from remote users. Therefore, the terminal used by "User 1" initially plays 6 audio streams simultaneously. If there is a buffering issue, the number of audio streams played is reduced (for example, 5 audio streams are played simultaneously). If there is no buffering issue, the 6 audio streams continue to be played simultaneously.
[0099] It should be noted that the above application scenarios are merely examples, and the audio playback method provided in this embodiment can also be applied to other scenarios, which are not limited here.
[0100] The method provided in this application can be applied to... Figure 5 The illustrated implementation environment includes a terminal 501, a network 502, and a server 503. The terminal 501 and the server 503 can communicate via the network 502. The network 502 uses standard communication technologies and / or protocols, typically the Internet, but can also be any network, including but not limited to Bluetooth, a local area network (LAN), a metropolitan area network (MAN), a wide area network (WAN), mobile, private networks, or any combination of virtual private networks. In some embodiments, customized or dedicated data communication technologies may be used to replace or supplement the aforementioned data communication technologies.
[0101] The terminal 501 involved in this application includes, but is not limited to, mobile phones, tablets, laptops, desktop computers, smart voice interaction devices, virtual reality devices, smart home appliances, vehicle terminals, and aircraft. The client 5011 is deployed on the terminal 501. The client 5011 can run on the terminal 501 via a browser, or as a standalone application (APP) or mini-program. Users can use the terminal 501 to push real-time audio streams to the server 503.
[0102] The server 503 involved in this application can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDN), and big data and artificial intelligence (AI) platforms.
[0103] In the above implementation environment, in step A1, server 503 pushes real-time audio streams to user terminal 501 via network 502, i.e., pushes N audio streams. In step A2, terminal 501 plays all received audio streams (i.e., N audio streams) within a first time period. In step A3, terminal 501 obtains the total number of stutters for the first time period. In step A4, terminal 501 updates the audio stream quantity threshold corresponding to the second time period using the total number of stutters. In step A5, based on the audio stream quantity threshold corresponding to the second time period, terminal 501 plays M audio streams out of the N audio streams within the second time period.
[0104] Based on the above introduction, the audio playback method in this application will be described below. Please refer to [link / reference]. Figure 6 The audio playback method in this application embodiment can be completed independently by the terminal, or it can be completed in cooperation with the server. The method provided in this application includes:
[0105] S601. Receive N audio streams sent by the server, where N is an integer greater than 1;
[0106] In one or more embodiments, the terminal receives N audio streams pushed by the server. These audio streams are used to transmit and process audio data in a continuous stream, representing a real-time audio data transmission method that allows audio data to flow continuously between networks or devices. The audio streams are stored or transmitted using Pulse Code Modulation (PCM) encoding, which is digitally converted audio information and represents the most basic audio format; essentially, it is a series of digitally converted audio signals.
[0107] Specifically, N audio streams typically originate from N different terminals. Taking multi-person live streaming as an example, each user participating in the live stream uploads an audio stream to the server through their terminal. Correspondingly, each user participating in the live stream can also receive audio streams uploaded from different terminals through the server.
[0108] S602. Based on the audio stream quantity threshold corresponding to the first time period, N audio streams are played within the first time period, wherein the audio stream quantity threshold corresponding to the first time period represents the maximum number of audio streams that the terminal can play within the first time period.
[0109] In one or more embodiments, when audio playback begins, the terminal plays all received audio streams (i.e., N audio streams) within a first time period based on an audio stream quantity threshold corresponding to a first time period (e.g., within the first second of audio playback). Here, the audio stream quantity threshold for the first time period is an initial audio stream quantity threshold, and in the initial stage, the terminal is allowed to play all received audio streams, thereby enabling the playback of as many audio streams as possible. Therefore, the audio stream quantity threshold corresponding to the first time period is the value N.
[0110] S603. Obtain the total number of stutters in the first time period for N audio streams;
[0111] In one or more embodiments, network fluctuations, insufficient terminal performance, or other reasons may cause the amount of data decoded for audio to be insufficient to meet the amount of data required for audio playback, resulting in playback stuttering.
[0112] Specifically, during audio playback, the playback thread needs to continuously read audio data from the cache thread. Ideally, the cache should contain audio data each time the playback thread reads it. However, if the cache is empty when the playback thread reads audio data, a stutter occurs, meaning the cached data cannot keep up with the playback thread's consumption. The terminal can periodically count these stutters to obtain the total number of stutters in a given time period.
[0113] It should be noted that the total number of stutters reflects the smoothness of the currently playing audio stream and the terminal's ability to process the audio stream. The total number of stutters is obtained by statistically analyzing the underrun information of N audio streams within the first time period. The underrun information includes, but is not limited to, stutter duration and the identifiers of the audio streams involved.
[0114] S604. Based on the total number of stutters in the first time period, determine the audio stream quantity threshold corresponding to the second time period, wherein the audio stream quantity threshold corresponding to the second time period represents the maximum number of audio streams that the terminal can play within the second time period.
[0115] In one or more embodiments, the terminal can adjust the audio stream quantity threshold based on the total number of stutters in the first time period. For example, it can increase the audio stream quantity threshold corresponding to the second time period, or decrease the audio stream quantity threshold corresponding to the second time period, or maintain the audio stream quantity threshold corresponding to the second time period.
[0116] Specifically, if the total number of stutters is high, it indicates that the number of audio streams currently being played may exceed the terminal's processing capacity. In this case, the audio stream count threshold needs to be reduced in subsequent time periods to alleviate the terminal's processing burden and improve playback smoothness. Conversely, if the total number of stutters is low or there are no stutters, the audio stream count threshold can be appropriately increased to fully utilize the terminal's performance and play more audio streams.
[0117] S605. Based on the audio stream quantity threshold corresponding to the second time period, play audio for M audio streams out of N audio streams within the second time period, where M is an integer greater than or equal to 1 and less than or equal to N.
[0118] In one or more embodiments, the terminal acquires M audio streams from N audio streams based on an audio stream quantity threshold corresponding to a second time period, and plays the M audio streams. The audio stream quantity threshold corresponding to the second time period can be set to the value M.
[0119] Specifically, if the threshold for the number of audio streams in the second time period is greater than or equal to the threshold for the number of audio streams in the first time period, then M = N, meaning that N audio streams will continue to be played within the second time period. If the threshold for the number of audio streams in the second time period is less than the threshold for the number of audio streams in the first time period, then M audio streams need to be selected from the N audio streams for playback based on the attributes corresponding to each audio stream (e.g., audio energy, duration, etc.).
[0120] It should be noted that if there is a sudden increase in the number of audio streams during the second time period, the corresponding number of audio streams will be selected for playback based on the audio stream quantity threshold corresponding to the second time period.
[0121] For easier understanding, please refer to Figure 7 , Figure 7This is a schematic diagram of an interactive flow of the audio playback method in an embodiment of this application. As shown in the figure, in step B1, the server continuously pushes N audio streams to the terminal. In step B2, the terminal plays audio composed of the N audio streams. In step B3, the terminal counts the number of stutters during audio playback to obtain the total number of stutters for a first time period. In step B4, the terminal updates the audio stream quantity threshold based on the total number of stutters for the first time period. In step B5, the terminal selects M audio streams from the N audio streams based on the updated audio stream quantity threshold. In step B6, the terminal plays audio composed of the M audio streams. In step B7, the terminal continues to count the number of stutters during audio playback to obtain the total number of stutters for a second time period. In step B8, the terminal updates the audio stream quantity threshold based on the total number of stutters for the second time period. This process continues to achieve audio playback.
[0122] This application provides an audio playback method. Using this method, the number of audio streams can be adaptively adjusted based on the total number of stutters during audio stream playback on the terminal. Since the total number of stutters is often related to the terminal's performance, flexibly adjusting the audio stream number threshold not only fully utilizes the terminal's performance advantages but also allows for the simultaneous playback of more audio streams, thereby improving the user's listening experience.
[0123] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, obtaining the total number of stutters in N audio streams during the first time period may specifically include:
[0124] The number of stutters for each of the N audio streams within the first time period is obtained through N cache threads, where the number of stutters is an integer greater than or equal to 0;
[0125] The total number of stutters for each audio stream in the first time period is summed to obtain the total number of stutters for the N audio streams in the first time period.
[0126] or,
[0127] To obtain the total number of stutters in the first time period for N audio streams, specifically, this can include:
[0128] The total number of stutters in the first time period is obtained by the target cache thread, where the total number of stutters is an integer greater than or equal to 0.
[0129] In one or more embodiments, two methods for capturing the total number of stutters are described. As can be seen from the foregoing embodiments, the terminal can store each decoded audio stream in a buffer. When there are multiple audio streams, each audio stream can correspond to a buffer thread, or all audio streams can correspond to a single buffer thread.
[0130] The following sections will introduce methods for counting the total number of stutters based on multiple cache threads and a single cache thread, respectively.
[0131] I. Based on multiple caching threads;
[0132] Specifically, let's take the example of playing four audio streams within the first time period (i.e., N=4). For easier understanding, please refer to [link to relevant documentation]. Figure 8 , Figure 8 This is a schematic diagram illustrating the total number of stutters based on a multi-threaded structure in an embodiment of this application. As shown in the figure, the terminal allocates a corresponding cache thread for each audio stream. It can be seen that within the first time period, cache thread 1 counts 2 stutters for audio stream 1, cache thread 2 counts 0 stutters for audio stream 2, cache thread 3 counts 1 stutter for audio stream 3, and cache thread 4 counts 3 stutters for audio stream 4. Summing the stutter counts obtained from these four cache threads, the total number of stutters for the four audio streams within the first time period is 6.
[0133] II. Based on a single cache thread;
[0134] Specifically, let's take the example of playing four audio streams within the first time period (i.e., N=4). For easier understanding, please refer to [link to relevant documentation]. Figure 9 , Figure 9 This is a schematic diagram illustrating the total number of stutters based on a single-threaded structure in an embodiment of this application. As shown in the figure, the terminal allocates a corresponding cache thread (i.e., the target cache thread) for N audio streams. It can be seen that within the first time period, the target cache thread performs statistics on the overall stuttering situation of the four audio streams, obtaining a total of 6 stutters for the four audio streams within the first time period.
[0135] Secondly, this application provides two methods for collecting the total number of stutters. Using the above methods, counting the number of stutters for each audio stream based on multiple cache threads enables parallel statistics, thereby fully utilizing system resources and improving statistical efficiency. Counting the number of stutters for all audio streams based on a single cache thread reduces system resource consumption and the complexity of thread management.
[0136] Optionally, in the above Figure 6Based on one or more corresponding embodiments, in another optional embodiment provided by this application, the threshold for the number of audio streams corresponding to the second time period is determined according to the total number of stutters in the first time period, which may specifically include:
[0137] If the total number of stutters exceeds the threshold, the threshold for the number of audio streams corresponding to the first time period is reduced to obtain the threshold for the number of audio streams corresponding to the second time period.
[0138] If the total number of stutters is less than or equal to the number of stutters threshold, then the audio stream number threshold corresponding to the first time period is increased or maintained to obtain the audio stream number threshold corresponding to the second time period.
[0139] In one or more embodiments, a method for updating an audio stream quantity threshold based on the total number of stutters is described. As described in the foregoing embodiments, the terminal compares the total number of stutters read over a time period with a threshold value to determine whether the current audio playback stuttering exceeds an acceptable range. The threshold value is a reference value set based on factors such as terminal performance and playback quality.
[0140] Specifically, if the total number of stutters in the first time period exceeds a threshold, it indicates that the number of audio streams currently being played may be excessive, exceeding the terminal's current load. Therefore, the audio stream number threshold for the first time period needs to be reduced to obtain the audio stream number threshold for the second time period. Conversely, if the total number of stutters in the first time period is less than or equal to the threshold, it indicates that the number of audio streams currently being played is within an acceptable range, meaning that the terminal's current processing capacity meets the playback requirements. Thus, depending on the terminal's performance, the audio stream number threshold for the first time period can be increased or maintained to obtain the audio stream number threshold for the second time period.
[0141] It should be noted that increasing the audio stream count threshold can fully utilize the device's performance advantages, allowing more audio streams to be played and improving the user experience. Maintaining the audio stream count threshold is suitable for situations where the current playback is just right and no adjustment is needed.
[0142] Secondly, this application provides a method for updating the audio stream quantity threshold based on the total number of stutters. Through this method, the terminal can adaptively adjust the number of audio streams allowed to play, fully leveraging the device's advantages and adapting to changes in device performance and network environment, thereby improving the stability and smoothness of audio playback.
[0143] Optionally, in the above Figure 6Based on one or more corresponding embodiments, in another optional embodiment provided by this application, reducing the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period may specifically include:
[0144] The average reading time is calculated based on the actual reading time of N audio streams in the first time period, where the actual reading time is greater than the base reading time.
[0145] The target value is obtained by quotienting the base read time and the average read time;
[0146] The threshold for the number of audio streams corresponding to the second time period is determined based on the target value, wherein the threshold for the number of audio streams corresponding to the second time period is less than the threshold for the number of audio streams corresponding to the first time period.
[0147] In one or more embodiments, a method for reducing the audio stream quantity threshold is described. As described in the foregoing embodiments, the terminal reads a certain duration of audio data each time it plays, and this duration is used as the "basic reading duration." Reading audio data includes decoding the audio stream and accelerating / decelerating the audio. Taking a 20ms audio data read per session as an example (i.e., the basic reading duration is set to 20ms), the actual reading duration represents the actual time spent by the terminal reading 20ms of audio data. If the actual reading duration exceeds the basic reading duration, it indicates that the terminal has a reading latency, and in this case, the audio stream quantity threshold needs to be reduced.
[0148] Specifically, the average read time can be calculated as follows:
[0149]
[0150] in, T represents the average reading time. S represents the actual reading time. S represents the total number of audio streams played within a time period. Taking the first time period as an example, if 10 audio streams are played (i.e., N=10) and the actual reading time of these 10 audio streams is 25ms, the average reading time can be calculated as 2.5ms based on formula (1).
[0151] Based on this, the target value can be calculated in the following way;
[0152]
[0153] Where A represents the target value, and t represents the base read time. This indicates the average read time. This indicates rounding down. Taking a base reading time of 20ms and an average reading time of 2.5ms as an example, the target value can be calculated as 8 based on formula (2). Therefore, the target value can be directly used as the threshold for the number of audio streams corresponding to the second time period, or, based on the value range where the target data is located, the value corresponding to that value range can be used as the threshold for the number of audio streams corresponding to the second time period.
[0154] Furthermore, this application provides a method for reducing the audio stream quantity threshold. By combining this method with the actual reading of the audio streams, the audio stream quantity threshold is reduced, making the threshold adjustment a reliable basis, thereby improving the feasibility and operability of the solution.
[0155] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, reducing the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period may specifically include:
[0156] The audio stream quantity threshold corresponding to the second time period is obtained by subtracting the audio stream quantity threshold corresponding to the first time period from the preset quantity, where the preset quantity is an integer greater than or equal to 1.
[0157] In one or more embodiments, another method for reducing the audio stream quantity threshold is introduced. As can be seen from the foregoing embodiments, the audio stream quantity threshold corresponding to the first time period can be obtained by directly subtracting a preset number from the audio stream quantity threshold corresponding to the first time period. For example, if the audio stream quantity threshold for the first time period is 10 and the preset number is 2, then if the total number of stutters exceeds the threshold, the audio stream quantity threshold for the second time period is set to 8.
[0158] Specifically, by adjusting the preset quantity, the reduction rate of the audio stream quantity threshold can be controlled. If the preset quantity is set large, the audio stream quantity threshold corresponding to the second time period will be significantly reduced. This is suitable for situations where the terminal experiences severe stuttering during the first time period, thus requiring a rapid and substantial reduction in the number of audio streams played. Conversely, if the preset quantity is set small, the audio stream quantity threshold corresponding to the second time period will be slightly reduced. This is suitable for situations where the terminal experiences fewer stutters during the first time period, thus requiring an appropriate reduction in the number of audio streams played.
[0159] Furthermore, this application provides another method for reducing the audio stream quantity threshold. Using this method, when the terminal's processing performance is insufficient, the audio stream quantity threshold can be reduced by a preset amount. This allows for the playback of as many audio streams as possible, improving the user experience.
[0160] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, increasing or maintaining the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period may specifically include:
[0161] The average reading time is calculated based on the actual reading time of N audio streams in the first time period, where the actual reading time is less than the base reading time.
[0162] The target value is obtained by quotienting the base read time and the average read time;
[0163] The threshold for the number of audio streams corresponding to the second time period is determined based on the target value, wherein the threshold for the number of audio streams corresponding to the second time period is greater than or equal to the threshold for the number of audio streams corresponding to the first time period.
[0164] In one or more embodiments, a method for increasing the audio stream quantity threshold is described. As can be seen from the foregoing embodiments, taking a terminal reading 20ms of audio data each time as an example (i.e., the basic reading duration is set to 20ms), the actual reading duration represents the actual time spent by the terminal reading 20ms of audio data. When the actual reading duration is less than the basic reading duration, it indicates that the terminal's processing pressure is relatively low, and in this case, the audio stream quantity threshold can be increased or maintained.
[0165] Specifically, taking the playback of 10 audio streams within the first time period (i.e., N=10), and the actual reading time of these 10 audio streams being 15ms as an example, the average reading time can be calculated as 1.5ms based on formula (1). Here, A represents the target value. t represents the base reading time. This indicates the average read time. This indicates rounding down. Based on this, taking a base reading time of 20ms and an average reading time of 1.5ms as an example, the target value can be calculated as 13 based on formula (2). Therefore, the target value can be directly used as the threshold for the number of audio streams corresponding to the second time period, or, based on the value range where the target data is located, the value corresponding to that value range can be used as the threshold for the number of audio streams corresponding to the second time period.
[0166] Furthermore, this application provides a method for increasing the audio stream quantity threshold. By increasing the audio stream quantity threshold in conjunction with the actual audio stream reading situation, the threshold adjustment has a reliable basis, thereby improving the feasibility and operability of the solution.
[0167] Optionally, in the above Figure 6Based on one or more corresponding embodiments, in another optional embodiment provided by this application, increasing or maintaining the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period may specifically include:
[0168] The audio stream quantity threshold corresponding to the second time period is obtained by summing the audio stream quantity threshold corresponding to the first time period with a preset quantity, where the preset quantity is an integer greater than or equal to 1.
[0169] In one or more embodiments, another method for increasing the audio stream quantity threshold is described. As can be seen from the foregoing embodiments, the audio stream quantity threshold corresponding to the first time period can be obtained by directly adding a preset number to the audio stream quantity threshold corresponding to the first time period. For example, if the audio stream quantity threshold for the first time period is 10 and the preset number is 3, then if the total number of stutters is less than the threshold, the audio stream quantity threshold for the second time period is set to 13.
[0170] Specifically, by adjusting the preset quantity, the increase in the audio stream quantity threshold can be controlled. If the terminal has a high configuration, the preset quantity can be set larger to quickly and fully utilize the terminal's performance to play more audio streams. If the terminal has a low configuration, the preset quantity can be set smaller to reduce stuttering. It should be noted that in practical applications, an optimal preset quantity can be set by testing the performance of different terminals in different application scenarios.
[0171] Furthermore, this application embodiment provides another method for increasing the audio stream quantity threshold. Using this method, if the terminal processing performance is sufficient, the audio stream quantity threshold can be increased incrementally by a preset number. This allows for the playback of as many audio streams as possible, improving the user experience.
[0172] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, according to the audio stream quantity threshold corresponding to the second time period, audio playback is performed on M audio streams out of N audio streams within the second time period, which may specifically include:
[0173] Obtain the average audio energy for each of the N audio streams;
[0174] The N audio streams are sorted by importance according to the audio stream sorting rules, resulting in N audio streams sorted from high to low importance. The audio stream sorting rules are as follows: sorting is done in order of average audio energy from high to low, and when the average audio energy is similar, sorting is done in order of audio duration from long to short.
[0175] Extract the top M audio streams from the N audio streams sorted by importance from high to low, where M is equal to the threshold number of audio streams corresponding to the second time period;
[0176] During the second time period, audio is played from M audio streams.
[0177] In one or more embodiments, a method for selecting an audio stream for playback is described. As described in the foregoing embodiments, the terminal can calculate the average audio energy corresponding to each audio stream. The average audio energy is obtained by averaging the audio energy corresponding to each audio frame in the audio stream. It can be understood that the audio energy is the maximum integer value in an audio frame, with a maximum value of 32767 and a minimum value of 0.
[0178] Specifically, each audio frame includes a header and a payload. The header contains descriptive information, including but not limited to sequence number, timestamp, audio energy, and data volume. This descriptive information in the header can be obtained without decoding the audio frame; therefore, the importance of the audio stream can be determined based on the audio energy and data volume. Generally, the higher the average audio energy and the longer the audio duration, the more important the audio stream.
[0179] For ease of understanding, taking N equal to 10 as an example, please refer to Table 1, which is a schematic diagram of the average audio energy and audio duration corresponding to N audio streams.
[0180] Table 1
[0181] Audio stream identifier Average audio energy Audio duration Audio Stream 1 2000 12 seconds Audio Stream 2 3000 14 seconds Audio Stream 3 2800 9 seconds Audio Stream 4 2200 3 seconds Audio Stream 5 1800 1 second Audio Stream 6 1500 7 seconds Audio Stream 7 1100 10 seconds Audio Stream 8 2800 15 seconds Audio Stream 9 1100 12 seconds Audio Stream 10 600 10 seconds
[0182] Referring to Table 1, the audio streams are first arranged in descending order of average audio energy. For audio streams with similar average audio energy, they are then sorted in descending order of audio duration. This results in the importance ranking as shown in Table 2. It should be noted that "similar average audio energy" can mean that the difference between the average audio energies of the two audio streams is less than a threshold (e.g., 100), or that the difference between the two average audio energies is less than a threshold (e.g., 2%).
[0183] Table 2
[0184] Audio stream identifier Average audio energy Audio duration Audio Stream 2 3000 14 seconds Audio Stream 8 2800 15 seconds Audio Stream 3 2800 9 seconds Audio Stream 4 2200 3 seconds Audio Stream 1 2000 12 seconds Audio Stream 5 1800 1 second Audio Stream 6 1500 7 seconds Audio Stream 9 1100 12 seconds Audio Stream 7 1100 10 seconds Audio Stream 10 600 10 seconds
[0185] Referring to Table 2, assuming the threshold for the number of audio streams corresponding to the second time period is 6, then "Audio Stream 2", "Audio Stream 8", "Audio Stream 3", "Audio Stream 4", "Audio Stream 1", and "Audio Stream 5" will be the M audio streams played within the second time period. Therefore, "Audio Stream 6", "Audio Stream 9", "Audio Stream 7", and "Audio Stream 10", which do not need to be played, will be marked as not allowed to play. The audio streams that do need to be played will be marked as allowed to play.
[0186] Secondly, this application embodiment provides a method for selecting audio streams for playback. This method prioritizes the playback of audio streams with higher importance, improving audio playback quality and ensuring that key content is highlighted. This, in turn, enhances the user experience.
[0187] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, audio playback is performed on M audio streams within a second time period, which may specifically include:
[0188] The M-buffered thread decodes each audio stream acquired in the second time period to obtain M decoded audio streams.
[0189] The M-buffer thread stores the decoded M audio streams into their respective buffer spaces.
[0190] Mix the M decoded audio streams stored in M buffer spaces to obtain the target audio stream;
[0191] Play audio from the target audio stream.
[0192] In one or more embodiments, a method for implementing audio stream caching based on multiple buffer threads is described. As can be seen from the foregoing embodiments, since the audio stream is encoded, the terminal also needs to call the buffer thread to decode the audio stream. The decoded audio stream is stored in the buffer space corresponding to the buffer thread. The buffer space is used to temporarily store the decoded audio data. When the audio stream needs to be played, the data can be directly retrieved from the buffer space.
[0193] Specifically, for ease of understanding, please refer to Figure 10 , Figure 10This is a schematic diagram of the multi-threaded processing architecture in an embodiment of this application. As shown in the figure, taking N audio streams pushed by the server to the terminal as an example, firstly, the adaptive routing module predicts the number of audio streams that can be played simultaneously through routing estimation, and then determines which audio streams can be played through routing decisions. Taking the playback of M audio streams out of N audio streams as an example, each buffer thread decodes the playable audio streams through the decoding module and then stores them in the corresponding remote buffer module. The remote buffer module stores the decoded audio data through buffer management and obtains the underrun information of the corresponding audio stream through state control. Based on this, the playback thread only needs to read the decoded audio stream from the remote buffer module for mixing to form a single signal, i.e., obtain the target audio stream. The playback module then calls the playback device (e.g., speaker, headphones, etc.) to convert the target audio stream into sound output.
[0194] It should be noted that the remote caching module reads the playback callback interval from the playback jitter estimation module as a reference for the cache size. Meanwhile, the adaptive routing module refers to the underrun information provided by the remote caching module to determine the audio stream quantity threshold.
[0195] It can be seen that, utilizing Figure 10 The architecture shown implements asynchronous decoding and playback, thereby minimizing the impact of decoding on playback callbacks and increasing the number of audio streams that can be played simultaneously. The adaptive routing module can dynamically decide the number of audio streams to support by obtaining real-time underrun information, allowing as many audio streams as possible to play while avoiding audio stuttering issues that occur when low-end devices play too much audio.
[0196] Furthermore, this application provides a method for implementing audio stream caching based on multiple cache threads. By calling multiple cache threads to decode the audio stream, parallel processing can be achieved, thereby saving processing time and improving processing efficiency. Storing the decoded audio data in the corresponding cache space can also improve data access speed and reduce network transmission burden.
[0197] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, audio playback is performed on M audio streams within a second time period, which may specifically include:
[0198] The target cache thread decodes each audio stream acquired in the second time period to obtain M decoded audio streams.
[0199] The target cache thread stores the decoded M audio streams into the cache space;
[0200] The M decoded audio streams stored in the buffer space are mixed to obtain the target audio stream;
[0201] Play audio from the target audio stream.
[0202] In one or more embodiments, a method for implementing audio stream caching based on a single buffer thread is described. As can be seen from the foregoing embodiments, since the audio stream is encoded, the terminal also needs to call the caching thread to decode the audio stream and store the decoded audio stream in the buffer space corresponding to the caching thread.
[0203] Specifically, for ease of understanding, please refer to Figure 11 , Figure 11 This is a schematic diagram of a single-threaded processing architecture in an embodiment of this application. Figure 11 The diagram in Figure (A) illustrates one implementation architecture. Taking N audio streams pushed by a server to a terminal as an example, firstly, the adaptive routing module filters out M audio streams. The target buffer thread decodes the M audio streams using the decoding module and then stores them in the remote buffer module. The remote buffer module stores the decoded audio data and obtains the underrun information of the M audio streams. Based on this, the playback thread only needs to read the decoded M audio streams from the remote buffer module and mix them to form a single signal, i.e., obtain the target audio stream. The playback module then calls the playback device to convert the target audio stream into sound output.
[0204] Figure 11 The diagram in Figure (B) illustrates another implementation architecture. Taking the terminal receiving N audio streams pushed by the server as an example, firstly, the adaptive routing module filters out M audio streams. The target buffer thread decodes the M audio streams using the decoding module, and then mixes the decoded M audio streams to form a single signal, i.e., the target audio stream. The target audio stream is then stored in the remote buffer module. Based on this, the playback thread only needs to read the target audio stream from the remote buffer module for playback.
[0205] It is evident that adopting Figure 11 The real-time architecture shown in Figure (A) facilitates the management of individual audio streams. And adopting... Figure 11 The real-time architecture shown in Figure (B) can reduce the need for cache space, thereby saving storage resources. In practical applications, the appropriate architecture can be selected according to the specific circumstances.
[0206] Furthermore, this application provides a method for implementing audio stream caching based on a single cache thread. By using this method, a single cache thread is invoked to decode the audio stream, reducing resource overhead and management complexity.
[0207] Optionally, in the above Figure 6 In addition to one or more corresponding embodiments, another optional embodiment provided in this application may further include:
[0208] During audio playback, when reading audio data from the buffer space, the playback callback interval is determined based on the current time and the previous audio data reading time. The playback callback interval is the difference between the current time and the time of the previous audio data reading.
[0209] The interval multiple to be updated is obtained by quoting the playback callback interval with the preset base value;
[0210] Based on the interval multiple to be updated, obtain the current count corresponding to each of the K interval multiples, where the K interval multiples include the interval multiple to be updated;
[0211] Based on the current number of statistics corresponding to each interval multiple, the target interval multiple is determined. The cumulative proportion of the number of statistics corresponding to the target interval multiple is greater than or equal to the proportion threshold. The cumulative proportion of the number of statistics is the percentage of the sum of the current number of statistics corresponding to each interval multiple that is less than or equal to the target interval multiple in the total number of statistics.
[0212] The size of the buffer space is obtained by multiplying the target interval multiple by the preset base value. The buffer space is used to buffer the decoded audio stream for audio playback.
[0213] In one or more embodiments, a method for setting the buffer size based on playback jitter estimation is described. As can be seen from the foregoing embodiments, due to the existence of a certain amount of jitter, the playback module may not necessarily read audio data at a fixed period. For example, each playback may read 20ms of audio data, but in reality, it may take 60ms to read this audio data. Based on this, buffering the audio data can reduce playback latency.
[0214] It's important to note that the buffer size should be neither too large nor too small. If the buffer is too large, latency will increase significantly; if it's too small, stuttering may occur when all the audio data in the buffer is read. Therefore, ideally, the buffer size should be set to the maximum jitter value of the playback callback. The following example will illustrate how to calculate the maximum jitter value of the playback callback.
[0215] Specifically, during audio playback, each time audio data is read during a playback callback (i.e., when reading audio data from the buffer), the difference between the current time and the time of the previous audio data read needs to be calculated to obtain the playback callback interval. Based on this, the interval multiple to be updated can be calculated as follows:
[0216] R = T0 / T base ;Formula (3)
[0217] Where R represents the interval multiple to be updated. T0 represents the playback callback interval. T base This indicates the preset base value.
[0218] For ease of understanding, taking K equal to 3 as an example, please refer to Table 3, which is a schematic diagram of the current statistical counts corresponding to the K interval multiples.
[0219] Table 3
[0220] Interval multiple Current number of statistics 1x 10 2 times 19 3 times 15
[0221] With a preset base value of 20ms and assuming a playback callback interval of 40ms, the interval multiple to be updated is calculated to be 2 times based on formula (3). Thus, the data corresponding to Table 3 is updated, that is, the results shown in Table 4 are obtained.
[0222] Table 4
[0223] Interval multiple Current number of statistics 1x 10 2 times 20 3 times 15
[0224] As can be seen, the current count corresponding to the 2x interval multiplier increases by 1, while the current count corresponding to other interval multipliers remains unchanged.
[0225] Based on Table 4, summing the current statistical counts corresponding to each interval multiple yields a total of 45 counts. The current statistical counts are then accumulated in ascending order of the interval multiples. Specifically, 10 counts are accumulated based on the current statistical counts corresponding to a 1x interval multiple. 30 counts are accumulated based on the current statistical counts corresponding to 1x and 2x interval multiples respectively. Finally, 45 counts are accumulated based on the current statistical counts corresponding to 1x, 2x, and 3x interval multiples respectively.
[0226] Assuming the proportion threshold is 0.7, the sum of the current statistical counts obtained by accumulating based on a 1x interval multiple accounts for approximately 0.22% of the total statistical counts (i.e., 10 / 45). Therefore, the cumulative proportion of counts is 0.22, which is less than the proportion threshold. Thus, a 1x interval multiple is not suitable as the target interval multiple.
[0227] The sum of the current number of counts obtained by adding the 1-times interval multiple and the 2-times interval multiple accounts for approximately 0.75% of the total number of counts (i.e., 30 / 45). In other words, the cumulative count ratio is 0.75. At this point, the cumulative count ratio is greater than the ratio threshold. Therefore, the 2-times interval multiple can be used as the target interval multiple.
[0228] Therefore, by multiplying the target interval multiple by the preset base value, the maximum jitter value of the playback callback can be obtained. This maximum jitter value is then used as the size of the buffer space. In the example above, with a target interval multiple of 2 and a preset base value of 20ms, the product of the two yields a maximum jitter value of 40ms for the playback callback.
[0229] Secondly, this application embodiment provides a method for setting the cache size based on playback jitter estimation. By using the above method, the maximum jitter value of the playback callback is used as the size of the cache space. This not only precisely counteracts playback jitter but also minimizes latency. At the same time, it avoids consuming excessive cache resources.
[0230] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, according to the interval multiple to be updated, the current statistical count corresponding to each of the K interval multiples is obtained, which may specifically include:
[0231] Obtain the periodic statistics count corresponding to each of the K interval multiples, where the periodic statistics count is the number of statistics within a preset time period;
[0232] Increment the periodic count corresponding to the interval multiple to be updated by 1 to obtain the current count corresponding to each of the K interval multiples.
[0233] In one or more embodiments, a method for obtaining the current statistical count corresponding to each interval multiple is described. As can be seen from the foregoing embodiments, the terminal can count the occurrences of each interval multiple every certain period of time (i.e., within a preset time period), thereby obtaining the periodic statistical count corresponding to each interval multiple.
[0234] Specifically, taking a preset time period of 5 seconds as an example, the terminal performs a statistical analysis of the interval multiple every 5 seconds to obtain the number of times the period statistics are performed for each interval multiple. For ease of understanding, let's take K equal to 3 as an example. Please refer to Table 5, which shows an illustration of the current number of times the statistics are performed for each of the K interval multiples.
[0235] Table 5
[0236] Interval multiple Periodic statistics frequency 1x 5 2 times 8 3 times 6
[0237] Taking an interval multiple of 2 as an example, the number of period statistics corresponding to the interval multiple to be updated is increased by 1, resulting in the results shown in Table 6.
[0238] Table 6
[0239] Interval multiple Current number of statistics 1x 5 2 times 9 3 times 6
[0240] As can be seen, the number of periodic statistics corresponding to a 2x interval increases by 1, resulting in a current number of 9. The number of periodic statistics corresponding to other intervals remains unchanged. Therefore, we can directly use the number of periodic statistics corresponding to these intervals as the current number of statistics.
[0241] Furthermore, this application embodiment provides a method for obtaining the current statistical count corresponding to each interval multiple. Through this method, the terminal periodically counts the number of times for each interval multiple and uses the data from the most recent period as the basis for subsequent calculations. This improves the timeliness of the data, thereby helping to improve the accuracy of playback jitter estimation.
[0242] Optionally, in the above Figure 6 Based on one or more corresponding embodiments, in another optional embodiment provided by this application, according to the interval multiple to be updated, the current statistical count corresponding to each of the K interval multiples is obtained, which may specifically include:
[0243] Obtain the historical statistical count for each of the K interval multiples;
[0244] When the historical statistical duration is greater than or equal to the decay duration, the decay statistical count corresponding to each of the K interval multiples is obtained by multiplying the historical statistical count corresponding to each interval multiple by the decay coefficient.
[0245] Increment the decay statistics count corresponding to the interval multiple to be updated by 1 to obtain the current statistics count corresponding to the interval multiple to be updated;
[0246] The decay count corresponding to each of the K interval multiples, excluding the interval multiple to be updated, is taken as the current count.
[0247] In one or more embodiments, a method for obtaining the current statistical count corresponding to each interval multiple is described. As can be seen from the foregoing embodiments, the terminal obtains the historical statistical count for each interval multiple within the historical statistical duration. If the historical statistical duration is greater than or equal to the decay duration (e.g., 10 seconds), then the historical statistical count corresponding to each interval multiple needs to be decayed. The following will describe the method for decaying the historical statistical count with examples.
[0248] Specifically, the number of attenuation statistics corresponding to each interval multiple can be calculated as follows:
[0249] C i =α*W i ;Formula (4)
[0250] Among them, Ci This represents the number of attenuation statistics corresponding to the i-th interval multiple. α represents the attenuation coefficient (e.g., 0.2). W i This represents the number of historical statistics corresponding to the i-th interval multiple.
[0251] For ease of understanding, taking K equal to 3 as an example, please refer to Table 7, which is a schematic diagram of the historical statistical frequency corresponding to K interval multiples.
[0252] Table 7
[0253] Interval multiple Historical statistics 1x 10 2 times 20 3 times 15
[0254] Based on Table 7, taking an attenuation coefficient of 0.2 as an example, the attenuation statistics corresponding to each interval multiple are calculated based on formula (4). Thus, the data corresponding to Table 7 is updated, and the results are shown in Table 8.
[0255] Table 8
[0256] Interval multiple Attenuation statistics count 1x 2 2 times 4 3 times 3
[0257] Taking an interval multiple of 2 as an example, the number of decay statistics corresponding to the interval multiple to be updated is incremented by 1, resulting in the results shown in Table 9.
[0258] Table 9
[0259] Interval multiple Current number of statistics 1x 2 2 times 5 3 times 3
[0260] As can be seen, the attenuation statistics count increases by 1 for the 2x interval multiple, resulting in a current count of 5. The attenuation statistics counts for other interval multiples remain unchanged. Therefore, we can directly use the attenuation statistics counts for these interval multiples as the current count.
[0261] Furthermore, this application provides a method for obtaining the current statistical count corresponding to each interval multiple. By attenuating the historical statistical count corresponding to each interval multiple, the influence of historical data on the current calculation can be weakened, thereby avoiding the impact caused by callback anomalies during a certain period.
[0262] The audio playback device in this application is described in detail below. Please refer to [link / reference]. Figure 12 , Figure 12 This is a schematic diagram of one embodiment of the audio playback device in this application. The audio playback device 120 includes:
[0263] The receiving module 1201 is used to receive N audio streams sent by the server, where N is an integer greater than 1;
[0264] The playback module 1202 is used to play audio to N audio streams within a first time period according to the audio stream number threshold corresponding to the first time period, wherein the audio stream number threshold corresponding to the first time period represents the maximum number of audio streams that the terminal can play within the first time period.
[0265] Module 1203 is used to obtain the total number of stutters in the first time period for N audio streams;
[0266] The determining module 1204 is used to determine the audio stream quantity threshold corresponding to the second time period based on the total number of stutters in the first time period, wherein the audio stream quantity threshold corresponding to the second time period represents the maximum number of audio streams that the terminal can play within the second time period.
[0267] The playback module 1202 is also used to play audio for M audio streams out of N audio streams within the second time period according to the audio stream quantity threshold corresponding to the second time period, where M is an integer greater than or equal to 1 and less than or equal to N.
[0268] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0269] The acquisition module 1203 is specifically used to acquire the number of stutters in the first time period for each of the N audio streams through N cache threads, where the number of stutters is an integer greater than or equal to 0;
[0270] The total number of stutters for each audio stream in the first time period is summed to obtain the total number of stutters for the N audio streams in the first time period.
[0271] or,
[0272] The acquisition module 1203 is specifically used to obtain the total number of stutters in the first time period of N audio streams through the target cache thread, where the total number of stutters is an integer greater than or equal to 0.
[0273] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0274] The determination module 1204 is specifically used to reduce the audio stream number threshold corresponding to the first time period if the total number of stutters is greater than the number threshold, so as to obtain the audio stream number threshold corresponding to the second time period.
[0275] If the total number of stutters is less than or equal to the number of stutters threshold, then the audio stream number threshold corresponding to the first time period is increased or maintained to obtain the audio stream number threshold corresponding to the second time period.
[0276] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0277] The determination module 1204 is specifically used to calculate the average reading time based on the actual reading time of N audio streams within the first time period, wherein the actual reading time is greater than the base reading time;
[0278] The target value is obtained by quotienting the base read time and the average read time;
[0279] The threshold for the number of audio streams corresponding to the second time period is determined based on the target value, wherein the threshold for the number of audio streams corresponding to the second time period is less than the threshold for the number of audio streams corresponding to the first time period.
[0280] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0281] The determination module 1204 is specifically used to obtain the audio stream quantity threshold corresponding to the second time period by subtracting the audio stream quantity threshold corresponding to the first time period from the preset quantity, wherein the preset quantity is an integer greater than or equal to 1.
[0282] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0283] The determination module 1204 is specifically used to calculate the average reading time based on the actual reading time of N audio streams within the first time period, wherein the actual reading time is less than the base reading time;
[0284] The target value is obtained by quotienting the base read time and the average read time;
[0285] The threshold for the number of audio streams corresponding to the second time period is determined based on the target value, wherein the threshold for the number of audio streams corresponding to the second time period is greater than or equal to the threshold for the number of audio streams corresponding to the first time period.
[0286] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0287] The determining module 1204 is specifically used to obtain the audio stream quantity threshold corresponding to the second time period by summing the audio stream quantity threshold corresponding to the first time period with a preset quantity, wherein the preset quantity is an integer greater than or equal to 1.
[0288] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0289] The playback module 1202 is specifically used to obtain the average audio energy corresponding to each of the N audio streams;
[0290] The N audio streams are sorted by importance according to the audio stream sorting rules, resulting in N audio streams sorted from high to low importance. The audio stream sorting rules are as follows: sorting is done in order of average audio energy from high to low, and when the average audio energy is similar, sorting is done in order of audio duration from long to short.
[0291] Extract the top M audio streams from the N audio streams sorted by importance from high to low, where M is equal to the threshold number of audio streams corresponding to the second time period;
[0292] During the second time period, audio is played from M audio streams.
[0293] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0294] The playback module 1202 is specifically used to decode each audio stream acquired in the second time period through the M buffer thread to obtain M decoded audio streams.
[0295] The M-buffer thread stores the decoded M audio streams into their respective buffer spaces.
[0296] Mix the M decoded audio streams stored in M buffer spaces to obtain the target audio stream;
[0297] Play audio from the target audio stream.
[0298] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0299] The playback module 1202 is specifically used to decode each audio stream acquired in the second time period through the target buffer thread to obtain M decoded audio streams;
[0300] The target cache thread stores the decoded M audio streams into the cache space;
[0301] The M decoded audio streams stored in the buffer space are mixed to obtain the target audio stream;
[0302] Play audio from the target audio stream.
[0303] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0304] The determination module 1204 is also used to determine the playback callback interval based on the current time and the previous audio data reading when reading audio data from the buffer space during audio playback, wherein the playback callback interval is the difference between the current time and the time of the previous audio data reading.
[0305] The determination module 1204 is also used to obtain the interval multiple to be updated by quoting the playback callback interval with a preset base value;
[0306] The acquisition module 1203 is also used to acquire the current statistical count corresponding to each of the K interval multiples according to the interval multiple to be updated, wherein the K interval multiples include the interval multiple to be updated;
[0307] The determining module 1204 is also used to determine the target interval multiple based on the current statistical count corresponding to each interval multiple, wherein the cumulative proportion of the count corresponding to the target interval multiple is greater than or equal to the proportion threshold, and the cumulative proportion of the count is the percentage of the sum of the current statistical counts corresponding to each interval multiple that is less than or equal to the target interval multiple in the total statistical count.
[0308] The determination module 1204 is also used to obtain the size of the buffer space by multiplying the target interval multiple by the preset base value, wherein the buffer space is used to buffer the decoded audio stream for audio playback.
[0309] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0310] The acquisition module 1203 is specifically used to acquire the number of periodic statistics corresponding to each of the K interval multiples, wherein the number of periodic statistics is the number of statistics within a preset time period;
[0311] Increment the periodic count corresponding to the interval multiple to be updated by 1 to obtain the current count corresponding to each of the K interval multiples.
[0312] Optionally, in the above Figure 12 Based on the corresponding embodiments, in another embodiment of the audio playback device 120 provided in this application,
[0313] The acquisition module 1203 is specifically used to acquire the historical statistical count corresponding to each of the K interval multiples;
[0314] When the historical statistical duration is greater than or equal to the decay duration, the decay statistical count corresponding to each of the K interval multiples is obtained by multiplying the historical statistical count corresponding to each interval multiple by the decay coefficient.
[0315] Increment the decay statistics count corresponding to the interval multiple to be updated by 1 to obtain the current statistics count corresponding to the interval multiple to be updated;
[0316] The decay count corresponding to each of the K interval multiples, excluding the interval multiple to be updated, is taken as the current count.
[0317] This application also provides a terminal, such as... Figure 13 As shown, for ease of explanation, only the parts related to the embodiments of this application are shown. For specific technical details not disclosed, please refer to the method section of the embodiments of this application. In the embodiments of this application, a mobile phone is used as an example for illustration:
[0318] Figure 13 This is a block diagram illustrating a portion of the structure of a mobile phone related to the terminal provided in the embodiments of this application. (Reference) Figure 13 The mobile phone includes components such as a radio frequency (RF) circuit 1310, a memory 1320, an input unit 1330, a display unit 1340, a sensor 1350, an audio circuit 1360, a wireless fidelity (WiFi) module 1370, a processor 1380, and a power supply 1390. Those skilled in the art will understand that... Figure 13 The mobile phone structure shown does not constitute a limitation on the mobile phone and may include more or fewer components than shown, or combine certain components, or have different component arrangements.
[0319] The following is combined Figure 13 A detailed introduction to each component of a mobile phone:
[0320] RF circuit 1310 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink information from the base station and processes it with processor 1380; additionally, it transmits uplink data to the base station. Typically, RF circuit 1310 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier (LNA), a duplexer, etc. Furthermore, RF circuit 1310 can also communicate wirelessly with networks and other devices. The aforementioned wireless communication can use any communication standard or protocol, including but not limited to Global System for Mobile Communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Message Service (SMS), etc.
[0321] The memory 1320 can be used to store software programs and modules. The processor 1380 executes various mobile phone functions and data processing by running the software programs and modules stored in the memory 1320. The memory 1320 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the mobile phone (such as audio data, phonebook, etc.). In addition, the memory 1320 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.
[0322] The input unit 1330 can be used to receive input numerical or character information, and to generate key signal inputs related to user settings and function control of the mobile phone. Specifically, the input unit 1330 may include a touch panel 1331 and other input devices 1332. The touch panel 1331, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near the touch panel 1331), and drive the corresponding connection devices according to a pre-set program. Optionally, the touch panel 1331 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 1380, and can also receive and execute commands sent by the processor 1380. In addition, the touch panel 1331 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the touch panel 1331, the input unit 1330 may also include other input devices 1332. Specifically, other input devices 1332 may include, but are not limited to, one or more of the following: a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a mouse, and a joystick.
[0323] The display unit 1340 can be used to display information input by the user or information provided to the user, as well as various menus of the mobile phone. The display unit 1340 may include a display panel 1341, which may optionally be configured as a liquid crystal display (LCD), organic light-emitting diode (OLED), or similar form. Further, a touch panel 1331 may cover the display panel 1341. When the touch panel 1331 detects a touch operation on or near it, it transmits the information to the processor 1380 to determine the type of touch event. Subsequently, the processor 1380 provides corresponding visual output on the display panel 1341 according to the type of touch event. Although in Figure 13 In this embodiment, the touch panel 1331 and the display panel 1341 are two separate components to realize the input and output functions of the mobile phone. However, in some embodiments, the touch panel 1331 and the display panel 1341 can be integrated to realize the input and output functions of the mobile phone.
[0324] The mobile phone may also include at least one sensor 1350, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 1341 according to the ambient light level, and the proximity sensor can turn off the display panel 1341 and / or the backlight when the phone is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used for applications that recognize the phone's posture (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition-related functions (such as pedometer, tapping), etc. Other sensors that may be configured in the mobile phone, such as gyroscopes, barometers, hygrometers, thermometers, and infrared sensors, will not be described in detail here.
[0325] Audio circuit 1360, speaker 1361, and microphone 1362 provide an audio interface between the user and the mobile phone. Audio circuit 1360 converts received audio data into electrical signals and transmits them to speaker 1361, where speaker 1361 converts them into sound signals for output. On the other hand, microphone 1362 converts collected sound signals into electrical signals, which are received by audio circuit 1360, converted into audio data, and then processed by processor 1380 before being transmitted via RF circuit 1310 to, for example, another mobile phone, or the audio data can be output to memory 1320 for further processing.
[0326] WiFi is a short-range wireless transmission technology. Mobile phones, through the WiFi module 1370, can help users send and receive emails, browse web pages, and access streaming media, providing users with wireless broadband internet access. Although Figure 13 WiFi module 1370 is shown, but it is understood that it is not an essential component of a mobile phone and can be omitted as needed without changing the essence of the invention.
[0327] The processor 1380 is the control center of the mobile phone, connecting various parts of the phone through various interfaces and lines. It executes various functions and processes data by running or executing software programs and / or modules stored in the memory 1320, and by calling data stored in the memory 1320. Optionally, the processor 1380 may include one or more processing units; optionally, the processor 1380 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the aforementioned modem processor may also not be integrated into the processor 1380.
[0328] The mobile phone also includes a power supply 1390 (such as a battery) that supplies power to various components. Optionally, the power supply can be logically connected to the processor 1380 through a power management system, thereby enabling functions such as charging, discharging, and power consumption management through the power management system.
[0329] Although not shown, mobile phones may also include a camera, Bluetooth module, etc., which will not be described in detail here.
[0330] The steps performed by the terminal in the above embodiments can be based on this Figure 13 The terminal structure shown.
[0331] This application also provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the methods described in the foregoing embodiments.
[0332] This application also provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the methods described in the foregoing embodiments.
[0333] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the methods described in the foregoing embodiments.
[0334] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0335] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0336] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.
[0337] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0338] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0339] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a server or terminal device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing computer programs, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0340] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for playing audio, characterized in that, include: Receive N audio streams sent by the server, where N is an integer greater than 1; Based on the audio stream quantity threshold corresponding to the first time period, audio is played on the N audio streams within the first time period, wherein the audio stream quantity threshold corresponding to the first time period represents the maximum number of audio streams that the terminal can play within the first time period. Obtain the total number of stutters in the N audio streams during the first time period; Based on the total number of stutters in the first time period, a threshold for the number of audio streams corresponding to the second time period is determined, wherein the threshold for the number of audio streams corresponding to the second time period represents the maximum number of audio streams that the terminal can play within the second time period; Based on the audio stream quantity threshold corresponding to the second time period, audio is played on M of the N audio streams within the second time period, where M is an integer greater than or equal to 1 and less than or equal to N.
2. The method according to claim 1, characterized in that, The step of obtaining the total number of stutters in the N audio streams during the first time period includes: The N cache threads obtain the number of stutters for each of the N audio streams within the first time period, wherein the number of stutters is an integer greater than or equal to 0; The total number of stutters for each audio stream within the first time period is obtained by summing the number of stutters for the N audio streams within the first time period. or, The step of obtaining the total number of stutters in the N audio streams during the first time period includes: The total number of stutters in the N audio streams during the first time period is obtained through the target cache thread, wherein the total number of stutters is an integer greater than or equal to 0.
3. The method according to claim 1 or 2, characterized in that, The step of determining the audio stream quantity threshold corresponding to the second time period based on the total number of stutters in the first time period includes: If the total number of stutters is greater than the number threshold, then the audio stream number threshold corresponding to the first time period is reduced to obtain the audio stream number threshold corresponding to the second time period. If the total number of stutters is less than or equal to the number threshold, then the audio stream quantity threshold corresponding to the first time period is increased or maintained to obtain the audio stream quantity threshold corresponding to the second time period.
4. The method according to claim 3, characterized in that, The step of reducing the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period includes: The average reading time is calculated based on the actual reading time of the N audio streams within the first time period, wherein the actual reading time is greater than the base reading time. The target value is obtained by quoting the base read time and the average read time. The threshold for the number of audio streams corresponding to the second time period is determined based on the target value, wherein the threshold for the number of audio streams corresponding to the second time period is less than the threshold for the number of audio streams corresponding to the first time period.
5. The method according to claim 3, characterized in that, The step of reducing the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period includes: The audio stream quantity threshold corresponding to the second time period is obtained by subtracting the audio stream quantity threshold corresponding to the first time period from the preset quantity, wherein the preset quantity is an integer greater than or equal to 1.
6. The method according to claim 3, characterized in that, The step of increasing or maintaining the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period includes: The average reading time is calculated based on the actual reading time of the N audio streams within the first time period, wherein the actual reading time is less than the base reading time. The target value is obtained by quoting the base read time and the average read time. The audio stream quantity threshold corresponding to the second time period is determined based on the target value, wherein the audio stream quantity threshold corresponding to the second time period is greater than or equal to the audio stream quantity threshold corresponding to the first time period.
7. The method according to claim 3, characterized in that, The step of increasing or maintaining the audio stream quantity threshold corresponding to the first time period to obtain the audio stream quantity threshold corresponding to the second time period includes: The audio stream quantity threshold corresponding to the second time period is obtained by summing the audio stream quantity threshold corresponding to the first time period with a preset quantity, wherein the preset quantity is an integer greater than or equal to 1.
8. The method according to any one of claims 1 to 7, characterized in that, The step of playing audio from M of the N audio streams within the second time period according to the audio stream quantity threshold corresponding to the second time period includes: Obtain the average audio energy corresponding to each of the N audio streams; The N audio streams are sorted by importance according to the audio stream sorting rules to obtain N audio streams sorted from high to low importance. The audio stream sorting rules are as follows: sorting is based on average audio energy from high to low, and when the average audio energy is similar, sorting is based on audio duration from long to short. The top M audio streams are obtained from the N audio streams sorted from high to low importance, where M is equal to the threshold number of audio streams corresponding to the second time period; During the second time period, the M audio streams are played.
9. The method according to claim 8, characterized in that, Playing audio from the M audio streams within the second time period includes: Each audio stream acquired in the second time period is decoded by M cache threads to obtain M decoded audio streams; The M-buffer thread stores the decoded M audio streams into their respective buffer spaces. The decoded M audio streams stored in M buffer spaces are mixed to obtain the target audio stream; Play the audio from the target audio stream.
10. The method according to claim 8, characterized in that, Playing audio from the M audio streams within the second time period includes: The target cache thread decodes each audio stream acquired within the second time period to obtain M decoded audio streams. The target cache thread stores the decoded M audio streams into the cache space. The M decoded audio streams stored in the buffer space are mixed to obtain the target audio stream; Play the audio from the target audio stream.
11. The method according to any one of claims 1 to 10, characterized in that, The method further includes: During audio playback, when reading audio data from the cache space, the playback callback interval is determined based on the current time and the previous audio data reading, wherein the playback callback interval is the difference between the current time and the time of the previous audio data reading; The interval multiple to be updated is obtained by quoting the playback callback interval with a preset base value; Based on the interval multiple to be updated, obtain the current statistical count corresponding to each of the K interval multiples, wherein the K interval multiples include the interval multiple to be updated; Based on the current number of statistics corresponding to each interval multiple, a target interval multiple is determined, wherein the cumulative proportion of the number of statistics corresponding to the target interval multiple is greater than or equal to a proportion threshold, and the cumulative proportion of the number of statistics is the percentage of the sum of the current number of statistics corresponding to each interval multiple that is less than or equal to the target interval multiple in the total number of statistics. The size of the buffer space is obtained by multiplying the target interval multiple by the preset base value, wherein the buffer space is used to buffer the decoded audio stream for audio playback.
12. The method according to claim 11, characterized in that, The step of obtaining the current statistical count corresponding to each of the K interval multiples based on the interval multiple to be updated includes: Obtain the periodic statistics count corresponding to each of the K interval multiples, wherein the periodic statistics count is the number of statistics within a preset time period; Increment the periodic statistics count corresponding to the interval multiple to be updated by 1 to obtain the current statistics count corresponding to each of the K interval multiples.
13. The method according to claim 11, characterized in that, The step of obtaining the current statistical count corresponding to each of the K interval multiples based on the interval multiple to be updated includes: Obtain the historical statistical count corresponding to each of the K interval multiples; When the historical statistical duration is greater than or equal to the attenuation duration, the attenuation statistical count corresponding to each of the K interval multiples is obtained by multiplying the historical statistical count corresponding to each interval multiple by the attenuation coefficient. Increment the decay statistics count corresponding to the interval multiple to be updated by 1 to obtain the current statistics count corresponding to the interval multiple to be updated; The decay count corresponding to each of the K interval multiples, excluding the interval multiple to be updated, is taken as the current count.
14. An audio playback device, characterized in that, include: A receiving module is used to receive N audio streams sent by the server, where N is an integer greater than 1; The playback module is used to play audio to the N audio streams within the first time period according to the audio stream number threshold corresponding to the first time period, wherein the audio stream number threshold corresponding to the first time period represents the maximum number of audio streams that the terminal can play within the first time period. The acquisition module is used to acquire the total number of stutters in the N audio streams during the first time period; The determining module is used to determine the audio stream quantity threshold corresponding to the second time period based on the total number of stutters in the first time period, wherein the audio stream quantity threshold corresponding to the second time period represents the maximum number of audio streams that the terminal can play within the second time period; The playback module is further configured to play audio for M audio streams out of the N audio streams within the second time period according to the audio stream quantity threshold corresponding to the second time period, wherein M is an integer greater than or equal to 1 and less than or equal to N.
15. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 13.
16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 13.
17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 13.