An audio clock rendering method, device, storage medium and audio receiving terminal

By using timestamps and write cursors on the receiving end for differentiated processing of audio data blocks, the problem of audio playback timeline deviation caused by network jitter and sampling rate changes is solved, achieving stable audio rendering effects.

CN123145245APending Publication Date: 2026-11-20LANGYUAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611299485.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-08-26
Publication Date
2026-11-20

AI Technical Summary

Technical Problem

During screen mirroring, streaming media playback, or remote audio playback, network jitter, out-of-order arrival of audio data, and changes in sampling rate can cause the audio playback timeline at the receiving end to deviate from the media timeline at the sending end, resulting in mixed playback times and abnormalities.

Method used

The receiver uses the timestamps of audio data blocks to establish playback anchor timestamps and write cursors, and performs differential processing based on time differences, including discarding late-arriving data, resetting the time axis, waiting for short intervals, filling in silence or normal writing, and reconstructing the playback state in the event of boundary events and sampling rate changes.

Benefits of technology

It reduces the impact of network jitter and sampling rate variations on the audio playback timeline, decreases latency accumulation and playback interruptions, and ensures that audio data is rendered according to the correct time base.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123145245A_ABST
    Figure CN123145245A_ABST
Patent Text Reader

Abstract

The application discloses an audio clock rendering method, device, storage medium and audio receiving terminal. The method receives a pulse code modulation audio data block carrying a timestamp and adds the timestamp into a priority queue, establishes a playback anchor point timestamp according to a head audio data block, and determines a playback write cursor in combination with a number of written frames; a time difference value between the head timestamp and the playback write cursor is calculated, late-arrival discarding, time axis resetting, short-interval waiting or mute filling and normal write processing are performed according to the time difference value. The playback state can also be reset and a playback time axis can be re-established when a boundary event or a sampling rate change is detected. The application can reduce the influence of network jitter, timestamp abnormality and sampling rate change on continuous audio rendering.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the fields of audio data processing and audio rendering technology, and in particular to an audio clock rendering method, apparatus, storage medium and audio receiving terminal. Background Technology

[0002] In scenarios such as screen mirroring, streaming media playback, or remote audio playback, the sending end can send audio data to the receiving end, and the receiving end can write the received audio data into the audio playback device for rendering through the audio output interface.

[0003] One existing implementation involves the receiving end directly sending the audio data to the audio output interface after receiving it, thus executing playback according to the network arrival order of the audio data. In this method, the audio playback timing is mainly affected by network transmission latency, data arrival order, and the internal buffering and scheduling mechanism of the audio output interface.

[0004] In cases of network jitter or out-of-order audio data arrival, the network arrival interval between different audio data points may not match the actual time interval of the audio data on the sending end's media timeline. Therefore, if the audio data is played directly according to the network arrival order, the audio playback timeline formed at the receiving end may gradually deviate from the corresponding media timeline at the sending end.

[0005] Furthermore, in cases where the sending end experiences pause, resumption, media switching, or temporary network connection interruption, significant time jumps may occur between the timestamps of adjacent audio data, or new audio data timestamps may appear that are shorter than the previous audio data timestamps. If the receiving end continues to use the previously established playback state, it may result in the old audio data continuing to be output or new audio data being rendered according to an incorrect time base.

[0006] In some applications, the sending end may change the audio sampling rate during the same session. If the receiving end continues to calculate the audio playback time offset according to the original sampling rate after the sampling rate change, it may cause the playback time calculated based on the number of audio frames to be inaccurate.

[0007] Therefore, there is a need for an audio rendering solution that can establish an audio playback timeline based on the media time information corresponding to the audio data itself, and can perform differentiated processing for abnormal situations of different timelines. Summary of the Invention

[0008] This application provides an audio clock rendering method, apparatus, storage medium, and audio receiving terminal to reduce the impact of audio data network arrival timing on the audio playback timeline at the receiving end, and to perform corresponding scheduling processing on the audio data to be played based on the time relationship between the audio data to be played and the current playback write position. When boundary events such as timestamp rollback, prolonged absence of audio data, transmission recovery, or continuous decoding failure occur, the previous audio playback state is reset. When the audio sampling rate changes, the audio rendering state corresponding to the new sampling rate is reconstructed to reduce the mixing of time bases corresponding to different sampling rates.

[0009] To achieve the above objectives, this application adopts the following technical solution:

[0010] Firstly, an audio clock rendering method is provided.

[0011] The receiving end receives pulse code modulated audio data blocks carrying timestamps and adds the audio data blocks to a priority queue according to the timestamps.

[0012] When the playback anchor timestamp has not yet been established and there are audio data blocks to be processed in the priority queue, the playback anchor timestamp is established based on the timestamp of the audio data block at the head of the priority queue.

[0013] In conjunction with the first aspect described above, in one possible implementation, the timestamp is used to characterize the time position of the corresponding audio data block in the media timeline at the sending end.

[0014] The receiving end determines the playback write cursor based on the playback anchor timestamp and the number of frames already written. The playback write cursor represents the write position on the media timeline corresponding to the amount of audio data currently written to the audio output interface.

[0015] In conjunction with the first aspect mentioned above, in one possible implementation, the playback write cursor satisfies:

[0016] Playback write cursor = playback anchor timestamp + time offset.

[0017] The time offset is determined based on the number of frames written and the sampling rate corresponding to the current audio data.

[0018] When the timestamp uses microseconds as the unit, the time offset can be expressed as:

[0019] Time offset = number of frames written × 1,000,000 ÷ sampling rate.

[0020] The receiving end determines the time difference between the timestamp of the first audio data block and the time difference between the playback and writing cursor.

[0021] In conjunction with the first aspect mentioned above, one possible implementation is as follows:

[0022] The time difference Δ = timestamp of the first audio data block - playback write cursor.

[0023] Different processing is performed on the first audio data block based on the time interval in which the time difference Δ lies.

[0024] When the time difference meets the late arrival condition, it indicates that the media time position corresponding to the first audio data block in the queue has fallen behind the current playback write position by more than the allowed range, and the receiving end discards the first audio data block in the queue.

[0025] When the time difference meets the timeline break condition, it indicates that the media time position corresponding to the first audio data block has undergone a significant positive jump relative to the current playback write position. The receiving end resets the playback anchor timestamp based on the timestamp of the first audio data block and resets the number of written frames to zero.

[0026] When the time difference meets the short interval condition, the receiving end chooses to wait or write a silence frame to the audio output interface based on the output buffer level of the audio output interface.

[0027] When the time difference meets the normal playback conditions, the receiving end writes the pulse code modulation data in the first audio data block into the audio output interface, and updates the number of written frames according to the actual number of audio frames written.

[0028] In conjunction with the first aspect mentioned above, in one possible implementation, after the pulse code modulation data in the head-of-line audio data block has been written, the corresponding head-of-line audio data block can be removed from the priority queue.

[0029] In conjunction with the first aspect above, in one possible implementation, the late arrival condition includes:

[0030] Δ < -TL.

[0031] Where TL represents the late arrival threshold.

[0032] The late arrival threshold can be a configurable parameter. For example, the late arrival threshold can be set from 50 milliseconds to 150 milliseconds. In one example, the late arrival threshold is 80 milliseconds.

[0033] In conjunction with the first aspect mentioned above, in one possible implementation, the timeline breakage condition includes:

[0034] Δ>TG.

[0035] Where TG represents the interval reset threshold.

[0036] The interval reset threshold can be a configurable parameter, for example, it can be set from 200 milliseconds to 1000 milliseconds.

[0037] In some embodiments, short interval conditions include:

[0038] 0 < Δ < TG.

[0039] Under the condition of short interval, the receiving end obtains the current output buffer level of the audio output interface.

[0040] When the output buffer level is higher than the preset low water level threshold, the receiver will not add any additional audio data to the audio output interface and will wait for the next scheduling cycle.

[0041] When the output buffer level is not higher than the preset low water level threshold, the receiver can write a silence frame to the audio output interface to reduce the possibility of underload or playback interruption of the audio output device.

[0042] In conjunction with the first aspect mentioned above, in one possible implementation, normal playback conditions may include:

[0043] -TL≤Δ≤0.

[0044] The different time intervals mentioned above are only used to illustrate one implementation method. In other embodiments, the boundary values ​​of each interval and the processing interval to which the boundary values ​​belong can be set according to the characteristics of the audio output interface and the system scheduling strategy, as long as it can distinguish between late-arriving data, normally played data, short-interval data, and data with obvious jumps in the timeline.

[0045] Secondly, this application provides a boundary restoration mechanism.

[0046] The receiving end detects boundary events and triggers the boundary recovery process when a boundary event is detected.

[0047] Boundary events can include at least one of the following:

[0048] First, the timestamp rollback event.

[0049] A timestamp rollback event can be determined when the timestamp of the first audio data block in the current queue is less than the difference between the playback anchor timestamp and the preset rollback tolerance.

[0050] Second, the audio data arrival interval exceeds the limit event.

[0051] It can record the arrival time of the most recent audio data block. When the difference between the arrival time of the current audio data block and the arrival time of the most recent audio data block exceeds a preset interval threshold, a boundary event of no audio data arrival for a long period of time can be determined.

[0052] Third, the sending end recovers boundary events.

[0053] The receiving end can receive the recovery boundary event signal sent by the sending end through the audio receiving interface or the communication interface. The recovery boundary event signal is used to indicate that the sending end has resumed from the paused state or started a new media playback phase.

[0054] Fourth, decoding failure timeout event.

[0055] When the duration of consecutive audio decoding failures exceeds a preset failure threshold, boundary recovery can be triggered.

[0056] Upon detecting any of the aforementioned boundary events, the receiving end can release the current underlying audio output resources, clear the priority queue, set the playback anchor timestamp to an invalid value, and reset the number of written frames to zero.

[0057] After new audio data blocks arrive, the playback anchor timestamp is re-established based on the timestamp of the new audio data blocks, so as to re-form the audio playback timeline based on the new media time position.

[0058] In conjunction with the second aspect mentioned above, in one possible implementation, if the underlying audio output resource is closed or released during the boundary recovery process, the corresponding audio output resource can be recreated or reinitialized before the audio output is restored.

[0059] Thirdly, this application provides a sampling rate change processing mechanism.

[0060] The receiving end detects the sampling rate corresponding to the currently received audio data block.

[0061] When the sampling rate of the currently received audio data block is inconsistent with the sampling rate used by the current audio renderer, the current audio renderer is closed and a new audio renderer is created based on the new sampling rate.

[0062] At the same time, the playback status corresponding to the original sampling rate is reset, including clearing the original priority queue, setting the playback anchor timestamp to an invalid value, and resetting the number of written frames to zero.

[0063] After a new audio data block enters a new playback cycle, the playback anchor timestamp is re-established based on the timestamp of the new audio data block.

[0064] This allows the time offset calculated subsequently based on the number of frames written and the sampling rate to correspond to the current actual audio sampling rate.

[0065] Fourthly, this application provides an audio clock rendering apparatus. The apparatus may include at least some of the following modules: an audio receiving interface, an enqueue module, a playback clock module, an exception handling module, a boundary recovery module, a sampling rate monitoring unit, an output module, and an audio output interface.

[0066] Fifthly, this application provides a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, it can cause the processor to perform the aforementioned audio clock rendering method.

[0067] Sixthly, this application provides an audio receiving terminal. The audio receiving terminal may include a processor, a memory, an audio receiving interface, and an audio output interface. The processor executes a program in the memory to implement the aforementioned audio clock rendering method.

[0068] Beneficial effects:

[0069] First, by using the timestamps carried by the audio data blocks to establish playback anchor timestamps and combining them with the number of frames already written to determine the playback write cursor, the writing scheduling of audio data can be based more on the media time position corresponding to the audio data, rather than simply on the network arrival time of the audio data, thereby reducing the impact of network jitter or changes in network arrival intervals on the audio playback timeline.

[0070] Secondly, by performing late-arrival discard, timeline reset, short-interval wait or silent filling, and normal writing based on the time difference between the timestamp of the first audio data block and the playback write cursor, differentiated processing can be performed for different types of timeline deviations, reducing the accumulation of delays or playback interruptions caused by using a single processing strategy.

[0071] Third, by clearing the queue and playback clock state when boundary events such as timestamp rollback, long periods without data arrival, sender recovery, or continuous decoding failure occur, the possibility of the audio state of the previous playback stage affecting the next playback stage can be reduced.

[0072] Fourth, by reconstructing the audio renderer and the corresponding playback state when the sampling rate changes, the time offset calculated from the number of written frames can be matched with the current audio sampling rate, reducing audio playback abnormalities caused by mixing time bases of different sampling rates. Attached Figure Description

[0073] Figure 1 This is a schematic diagram of the overall flow of an audio clock rendering method provided in one embodiment of this application.

[0074] Figure 2 This is a schematic diagram of a multi-level processing flow based on time difference, provided as an embodiment of this application.

[0075] Figure 3 This is a schematic diagram of an audio clock rendering device and an audio receiving terminal provided in one embodiment of this application.

[0076] Figure 4This is a schematic diagram of the boundary restoration and sampling rate switching process provided in one embodiment of this application.

[0077] Reference numerals: 100, Audio clock rendering device; 110, Audio receiving interface; 120, Enqueue module;

[0078] 130. Playback clock module; 140. Anomaly handling module; 141. Late arrival detection unit; 142. Time axis breakage detection unit; 143. Short interval processing unit; 150. Boundary recovery module; 160. Sampling rate monitoring unit; 170. Output module; 180. Audio output interface; 200. Audio receiving terminal; 210. Processor; 220. Memory; 230. Communication interface. Detailed Implementation

[0079] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.

[0080] It should be understood that the described embodiments are merely some, not all, of the embodiments in this application. All other embodiments obtained by those skilled in the art based on the embodiments in this application without inventive effort are within the scope of protection of this application.

[0081] The terminology used in the embodiments of this application is for the purpose of describing particular embodiments only and is not intended to limit the embodiments of this application. The singular forms “a,” “the,” and “the” used in the embodiments of this application and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used herein refers to and includes any or all possible combinations of one or more of the associated listed items.

[0082] In the following description, when referring to the accompanying drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims. In the description of this application, it should be understood that the terms "first," "second," "third," etc., are used only to distinguish similar objects and are not necessarily used to describe a specific order or sequence, nor should they be construed as indicating or implying relative importance. Those skilled in the art can understand the specific meaning of the above terms in this application according to the specific circumstances.

[0083] Furthermore, in the description of this application, unless otherwise stated, "multiple" means two or more. "And / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. The character " / " generally indicates that the preceding and following related objects have an "or" relationship.

[0084] The audio clock rendering method provided in this embodiment can be executed by an audio clock rendering device. The audio clock rendering device can be implemented through software and / or hardware, and can consist of two or more physical entities, or a single physical entity. The audio clock rendering device can be located in a screen projection sending end, a screen projection receiving end, or other electronic devices communicatively connected to the screen projection sending end. The electronic devices can be mobile phones, tablets, laptops, desktop computers, interactive whiteboards, conference terminals, screen projectors, or other intelligent devices with data processing and communication functions.

[0085] For ease of understanding, this application uses a screen projector as an application carrier for an audio clock rendering device in its embodiments for illustrative description. The screen projector can be an electronic device used to establish a communication connection between the screen projector and the display device, and to transmit image data, audio data, video data, control data, or other data to be projected from the screen projector to the display device. The screen projector can be set up independently or integrated into a monitor, television, interactive whiteboard, conference terminal, projection device, or other display device.

[0086] A screen mirroring device can function as a screen mirroring sender, transmitting locally generated or acquired data from other devices to a screen mirroring receiver. It can also function as a screen mirroring receiver, receiving screen mirroring data from mobile phones, tablets, laptops, or other screen mirroring senders, and outputting that data to a display device connected to the screen mirroring device. Furthermore, a screen mirroring device can simultaneously perform both screen mirroring sending and receiving functions.

[0087] Generally, a screen mirroring device may include at least one of a processor, memory, communication module, and display interface. The communication module may include a wireless communication module and / or a wired communication module. The wireless communication module may support wireless LAN, Bluetooth, ultra-wideband, near-field communication, mobile communication, acoustic communication, or other wireless communication methods; the wired communication module may support Ethernet, Universal Serial Bus, or other wired communication methods. The display interface may include a high-definition multimedia interface, a DisplayPort interface, a Universal Serial Bus interface, a video graphics array interface, or other interfaces capable of transmitting image and / or audio data.

[0088] The screen mirroring device can access a local area network (LAN) via Wi-Fi and search for available screen mirroring receivers within the LAN using a network service discovery mechanism. The device can receive device discovery messages broadcast by one or more screen mirroring receivers within the LAN and, based on these messages, obtain at least one of the following: device name, device identifier, network address, service type, port number, connection status, and device capabilities, thereby generating or updating the list of available screen mirroring devices.

[0089] The screen mirroring device can also be equipped with a microphone, a sound wave receiving module, or other sound acquisition modules to collect sound wave signals sent by the screen mirroring receiver. The screen mirroring device can demodulate and analyze the collected sound wave signals to obtain sound wave candidate information. The sound wave candidate information may include at least one of the following: screen mirroring code, network address, device identifier, device name, timestamp, verification information, and sound wave signal strength. The screen mirroring device can associate the sound wave candidate information with the corresponding device in the list of eligible screen mirroring devices based on the matching relationship between the sound wave candidate information and the device information obtained through a network service discovery mechanism.

[0090] The screen mirroring device can establish an association between candidate acoustic wave information and screen-sharing devices based on a device identifier, network address, screen mirroring code, device name, or a combination of at least two of the above information. This association can be stored independently of the list row objects in the screen-sharing device list, so that even when the screen-sharing device list is refreshed, the list row objects are rebuilt, or the device display order changes, the candidate acoustic wave information can still be re-associated to the corresponding screen-sharing device based on the combined identifier.

[0091] Typically, the screen mirroring device can install at least one operating system, including but not limited to Android, Linux, Windows, HarmonyOS, or an embedded real-time operating system. The screen mirroring device can run at least one screen mirroring application based on the operating system. The screen mirroring application can be an application that comes pre-installed with the operating system, or an application downloaded and installed from a server or other electronic device. The audio clock rendering device can be a standalone application or implemented as a functional module within the screen mirroring application.

[0092] The screen mirroring application can perform at least one of the following operations: device discovery, device list generation, acoustic signal parsing, candidate information caching, device matching, connection request sending, screen mirroring code verification, screen mirroring link establishment, and screen mirroring status update. For example, a user can select a target screen mirroring device from the list of available devices. The screen mirroring device obtains the corresponding network address and / or screen mirroring code based on the selected target device, sends a connection request to the target device, and establishes a screen mirroring communication link after successful connection verification.

[0093] Understandably, users can select a target projection device or initiate a projection operation via touchscreen, keyboard, mouse, remote control, physical buttons, voice commands, or other input methods. After receiving the user's operation, the projection device can determine the target projection device and its corresponding connection parameters based on the user's selected device information, acoustic wave candidate information, and the current network connection status, and then execute the projection connection operation.

[0094] The projection device may include one or more processing cores. The processing core can implement the audio clock rendering method provided in this application embodiment using pure software, or it can be implemented using a combination of software and hardware. For example, it can be implemented using at least one hardware form selected from digital signal processors, field-programmable gate arrays, application-specific integrated circuits, and programmable logic arrays. The projection device may also integrate one or more of a central processing unit, a graphics processor, a network processor, an audio processor, and a modem.

[0095] The memory of the screen projector can be used to store at least one of the following: computer program, list of projectable devices, device discovery information, sound wave candidate information, device association relationships, screen projecting connection parameters, and screen projecting status information. The processor can call and execute the computer program stored in the memory to cause the screen projector to execute the audio clock rendering method provided in the embodiments of this application.

[0096] The computer program can be presented in a form suitable for the screen projector to run, such as an application, system service, background process, system plugin, software development kit, firmware program, or web page plugin. In some embodiments, the audio clock rendering method can also be executed collaboratively by multiple software modules in the screen projector, which may include at least one of a device discovery module, a sound wave analysis module, a candidate information management module, a device matching module, a list update module, and a connection control module.

[0097] Example 1

[0098] Figure 1 This illustrates an overall process for rendering audio clocks.

[0099] First, step S101 is executed, where the audio receiving interface 110 receives a pulse code modulated audio data block from the transmitting end.

[0100] Each audio data block carries a corresponding timestamp. In some embodiments, the audio data block may also carry sampling rate, number of channels, data length, or other audio format information.

[0101] The enqueue module 120 receives audio data blocks output by the audio receiving interface 110 and adds the audio data blocks to the priority queue according to the timestamp of the audio data blocks.

[0102] In one implementation, the priority queue can use a min-heap structure with timestamps as the sorting key, so that audio data blocks that have entered the priority queue can be read in ascending order of timestamps.

[0103] It should be noted that priority queues are primarily used to sort audio data blocks that have already arrived at the receiving end. In actual systems where there is significant out-of-order transmission, pre-buffering mechanisms or scheduling cycle control mechanisms can be combined to ensure that multiple arriving audio data blocks have some sorting space before entering playback processing.

[0104] In step S102, the playback clock module 130 determines whether the current playback anchor timestamp is valid.

[0105] When the playback anchor timestamp is invalid and there is an audio data block in the priority queue, the playback clock module 130 reads the audio data block at the head of the priority queue and establishes the playback anchor timestamp based on the timestamp of the audio data block at the head of the queue.

[0106] For example, it can be:

[0107] anchorPts = headPts.

[0108] Here, anchorPts represents the playback anchor timestamp, and headPts represents the timestamp of the current head audio data block.

[0109] Once the playback anchor timestamp is established, it can remain unchanged within the current playback cycle unless a timeline break or boundary restoration occurs.

[0110] In step S103, the playback clock module 130 determines the playback write cursor based on the playback anchor timestamp, the number of frames written, and the current sampling rate.

[0111] For example, when the unit of time is microseconds:

[0112] writeCursor=anchorPts+writtenFrames×1000000÷sampleRate.

[0113] in:

[0114] writeCursor indicates that playback is written to the cursor;

[0115] writtenFrames represents the number of audio sample frames that have been written to the audio output interface 180 during the current playback cycle;

[0116] sampleRate represents the sampling rate of the current audio renderer.

[0117] In this way, the playback clock module 130 can map the current writing position of the receiving end to the media timeline based on the amount of data actually submitted to the audio output link.

[0118] Execute step S104, exception handling module 140 calculates:

[0119] Δ = headPts - writeCursor.

[0120] Where Δ represents the time difference between the current head audio data block and the time difference between the playback and writing cursor.

[0121] The exception handling module 140 determines the corresponding audio processing strategy based on the time interval in which Δ is located.

[0122] For detailed processing procedures, please refer to [link / reference]. Figure 2 .

[0123] Example 2

[0124] See Figure 2 The exception handling module 140 may include a late arrival detection unit 141, a time axis breakage detection unit 142, and a short interval processing unit 143.

[0125] The aforementioned units are used to represent different processing functions, and it is not required that they be set up as independent physical units in the actual software or hardware. For example, the above functions can be completed by the same processor 210 executing different decision branches in the same program.

[0126] Let the late arrival threshold be TL and the interval reset threshold be TG.

[0127] Scenario 1: Late-arriving audio data

[0128] when:

[0129] Δ < -TL

[0130] At that time, the late arrival detection unit 141 determines that the audio data block at the head of the current queue belongs to the late arrival data.

[0131] In this case, the current audio playback write position has exceeded the media time position corresponding to the audio data block to a certain extent.

[0132] The exception handling module 140 removes the current head audio data block from the priority queue.

[0133] In one example, TL can be set from 50 milliseconds to 150 milliseconds, such as 80 milliseconds.

[0134] By setting a certain tolerance range for late arrivals, the premature discarding of audio data due to slight network jitter can be reduced, while preventing obviously expired audio data from continuing to enter the playback chain.

[0135] The second scenario: Normal playback

[0136] when:

[0137] -TL≤Δ≤0

[0138] At this time, it can be assumed that the media time position of the current head audio data block is within the allowed normal write range.

[0139] The output module 170 reads the pulse code modulation data from the first audio data block of the queue and writes the pulse code modulation data to the audio output interface 180.

[0140] The audio output interface 180 can be an audio playback interface provided by the operating system, a low-latency native audio interface, or other interfaces that can receive pulse code modulation data and output audio signals.

[0141] The output module 170 updates writtenFrames based on the number of audio sample frames that are actually successfully written to the audio output interface 180.

[0142] For example:

[0143] writtenFrames=writtenFrames+writtenFrameCount.

[0144] Here, writtenFrameCount represents the number of audio sample frames successfully written this time.

[0145] When the pulse code modulation data in the current audio data block has been completely written, the current audio data block is removed from the priority queue.

[0146] If the audio output interface 180 supports partial writing, it can record the position of the data that has not yet been written in the current audio data block and continue to write the remaining data in the subsequent scheduling process.

[0147] The third scenario: short interval

[0148] when:

[0149] 0 < Δ < TG

[0150] At this time, it can be assumed that there is a certain positive time interval between the current head audio data block and the playback write cursor, but this interval has not yet reached the degree of time axis breakage.

[0151] The short interval processing unit 143 obtains the output buffer level of the audio output interface 180.

[0152] In some embodiments, the output buffer level can be represented by the number of audio sample frames that have not yet been played in the current audio output interface 180, or it can be converted into the corresponding audio duration.

[0153] When the output buffer level is higher than the preset low water level threshold, it indicates that there is still a certain amount of audio data to be played inside the audio output interface 180. Therefore, the short interval processing unit 143 can temporarily suspend writing new audio data to the audio output interface 180 and wait for the next scheduling cycle.

[0154] In the next scheduling cycle, the playback write cursor and time difference Δ are recalculated, and the subsequent processing method is determined based on the new Δ.

[0155] When the output buffer level is not higher than the preset low water level threshold, in order to reduce the probability of underload of the audio output interface 180, the output module 170 can write a mute frame to the audio output interface 180.

[0156] In some embodiments, the silence frame may employ pulse code modulation data with an amplitude of zero.

[0157] In other embodiments, comfortable noise data or gradually decaying audio data may be used for short-term filling according to the requirements of audio output smoothness.

[0158] Fourth scenario: Timeline breakage

[0159] when:

[0160] Δ>TG

[0161] At that time, the time axis break detection unit 142 determines that there is a large time jump between the media time position corresponding to the current head audio data block and the current playback write cursor.

[0162] At this point, continuing to write a large amount of mute data according to the original playback anchor timestamp may cause a long wait.

[0163] Therefore, the playback clock module 130 resets the timestamp of the current head audio data block to the new playback anchor timestamp and resets writtenFrames to zero.

[0164] Right now:

[0165] anchorPts = headPts;

[0166] writtenFrames = 0.

[0167] After completing the above reset, the playback write cursor is recalculated based on the new anchorPts, and audio rendering continues from the new media time position.

[0168] In one example, TG can be set from 200 milliseconds to 1000 milliseconds.

[0169] Through the above multi-level processing method, obviously late data will no longer enter the playback output link, small positive time intervals can be processed by waiting or filling in for a short time, and large media timeline jumps can be processed directly by rebuilding the playback anchor point.

[0170] Example 3

[0171] See Figure 4 In addition to real-time audio data scheduling based on Δ execution, the boundary recovery module 150 can also monitor boundary events throughout the entire audio playback session.

[0172] Boundary events can include at least one of the following.

[0173] 1. Timestamp rollback

[0174] The boundary recovery module 150 can compare the timestamp of the current head audio data block with the timestamp of the current playback anchor point.

[0175] For example, when:

[0176] headPts < anchorPts - TR

[0177] At that time, it is determined that a timestamp rollback has occurred.

[0178] TR represents the preset rollback tolerance.

[0179] A timestamp rollback may indicate that the sender has switched to a new media playback stage, or that the sender's media timeline has been reinitialized.

[0180] 2. Data arrival interval exceeds limit.

[0181] The enqueue module 120 or the boundary recovery module 150 can record the arrival time of the most recent audio data block at the receiver.

[0182] When a new audio data block arrives, record the current arrival time, arrivalNow.

[0183] if:

[0184] arrivalNow-arrivalLast>TI

[0185] If the arrival interval of the audio data exceeds the preset interval threshold TI, then it is determined that the arrival interval exceeds the preset interval threshold TI.

[0186] This situation could be caused by a prolonged pause at the sending end, a prolonged network interruption, or a change in the media playback session.

[0187] 3. Sender recovers boundary event

[0188] The audio receiving interface 110 or the communication interface 230 can receive the recovery boundary event signal sent by the transmitting end.

[0189] The recovery boundary event signal can be transmitted through control messages, message fields, or session event notifications to notify the receiving end that audio transmission is about to resume from the new media time position.

[0190] 4. Decoding failed and timed out.

[0191] In implementations where audio data needs to be decoded to form pulse code modulation data, the decoding status of the audio decoder can also be monitored.

[0192] When the duration of continuous decoding failures exceeds the preset failure threshold, it can be determined that the current playback state is no longer suitable for continuing to use the original audio timeline.

[0193] Upon detecting any of the above boundary events, the boundary recovery module 150 executes the boundary recovery process.

[0194] Boundary recovery module 150 can stop or release the currently used underlying audio output resources and clear the priority queue maintained by enqueue module 120.

[0195] Then set anchorPts to an invalid value and writtenFrames to zero.

[0196] Right now:

[0197] anchorPts = INVALID;

[0198] writtenFrames = 0.

[0199] For audio output resources that have been released, the audio rendering resources corresponding to the audio output interface 180 can be reinitialized according to the sampling rate, number of channels, or audio format required for subsequent audio playback.

[0200] When a new audio data block arrives, the enqueue module 120 adds the new audio data block to the priority queue.

[0201] Since anchorPts is invalid at this time, the playback clock module 130 re-establishes the playback anchor timestamp based on the timestamp of the new head audio data block.

[0202] Therefore, subsequent new audio playback stages will no longer use the writtenFrames and anchorPts from the previous playback cycle.

[0203] Example 4

[0204] See also Figure 4 .

[0205] The sampling rate monitoring unit 160 can detect the sampling rate corresponding to the currently received audio data block.

[0206] In some embodiments, the sampling rate may be transmitted along with the pulse-code modulation data as an attribute of the audio data block or an audio format parameter.

[0207] Suppose that the current audio renderer uses a sampling rate of sampleRateOld, while the newly received audio data block uses a sampling rate of sampleRateNew.

[0208] when:

[0209] sampleRateNew ≠ sampleRateOld

[0210] At that time, the sampling rate monitoring unit 160 determines that a change in the sampling rate has occurred.

[0211] The current audio renderer can be stopped or turned off in response to changes in the sampling rate.

[0212] Then create or configure a new audio renderer based on sampleRateNew.

[0213] At the same time, clear the priority queue state corresponding to the original sampling rate, set anchorPts to an invalid value, and reset writtenFrames to zero.

[0214] Once the new audio renderer is available, when a new audio data block enters the playback processing flow, a new anchorPts is created based on the timestamp of the new head audio data block.

[0215] Subsequent playback is written to the cursor according to:

[0216] writeCursor=anchorPts+writtenFrames×1000000÷sampleRateNew

[0217] Perform the calculation.

[0218] For example, when the sampling rate switches from 48000 Hz to 44100 Hz, after the playback state reset is completed, 44100 Hz is used as the sampling rate parameter when converting subsequent written frames to time offset.

[0219] Therefore, it avoids directly mixing the frame count already accumulated at 48000 Hz with the 44100 Hz sampling rate.

[0220] Example 5

[0221] See Figure 3 The audio clock rendering device 100 may include an audio receiving interface 110, an enqueue module 120, a playback clock module 130, an exception handling module 140, a boundary recovery module 150, a sampling rate monitoring unit 160, an output module 170, and an audio output interface 180.

[0222] The audio receiving interface 110 is used to receive audio data blocks and audio format parameters or control messages related to the audio data blocks.

[0223] The enqueue module 120 interacts with the audio receiving interface 110 to manage the priority queue according to the timestamps corresponding to the audio data blocks.

[0224] The playback clock module 130 is used to manage the playback anchor timestamp, the number of frames written, and the playback write cursor.

[0225] The exception handling module 140 is used to select the corresponding audio processing strategy based on the time difference between the timestamp of the first audio data block and the playback write cursor.

[0226] The exception handling module 140 may logically include a late arrival detection unit 141, a time axis breakage detection unit 142, and a short interval processing unit 143.

[0227] It should be noted that 141, 142, and 143 above are used to describe different processing functions and do not require that they be implemented by independent hardware. In a software implementation, late arrival detection, timeline break detection, and short interval processing can be completed by the processor 210 executing different decision branches in the same program.

[0228] The boundary recovery module 150 is used to detect boundary events and reset the status of priority queue, playback anchor timestamp, and number of written frames.

[0229] The sampling rate monitoring unit 160 is used to detect changes in the audio sampling rate and control the audio renderer and playback state to switch when a change in sampling rate occurs.

[0230] The output module 170 is used to write pulse code modulation audio data or mute data to be played to the audio output interface 180.

[0231] The audio output interface 180 is used to submit the audio data provided by the output module 170 to the underlying audio playback resources.

[0232] In one implementation, one or more of the above-mentioned enqueue module 120, playback clock module 130, exception handling module 140, boundary recovery module 150, sampling rate monitoring unit 160, and output module 170 can be implemented by the processor executing program instructions.

[0233] Example

[0234] See also Figure 3 The audio receiving terminal 200 can be a screen projection receiving device, a smart display device, a set-top box, a computer, a mobile terminal, an audio playback device, or other electronic devices capable of receiving remote audio data and performing audio output.

[0235] The audio receiving terminal 200 may include a processor 210, a memory 220, a communication interface 230, and an audio output interface 180.

[0236] The processor 210 is communicatively connected to the memory 220, the communication interface 230, and the audio output interface 180.

[0237] The audio clock rendering program can be stored in memory 220.

[0238] The communication interface 230 can be used to establish a communication connection with the sending end and receive audio data blocks.

[0239] In one implementation, the audio receiving interface 110 can be jointly implemented by the communication interface 230 and the data receiving program in the processor 210.

[0240] When processor 210 executes the audio clock rendering program stored in memory 220, it can achieve the following:

[0241] Receive and sort audio data blocks;

[0242] Establish playback anchor timestamp;

[0243] Calculate the playback write cursor based on the number of frames already written;

[0244] Calculate the time difference between the first audio data block and the playback write cursor;

[0245] Based on the time difference, the system will either discard late arrivals, reset the timeline, process short intervals, or play normally.

[0246] Detect boundary events and reset playback state; and

[0247] When the sampling rate changes, the audio playback state corresponding to the new sampling rate is re-established.

[0248] The above-mentioned processing procedures can be completed by the same processor 210, or by multiple processors, digital signal processors, or other circuits with data processing capabilities working together.

[0249] Example 7

[0250] This application also provides a computer-readable storage medium storing a computer program thereon, the instructions of which are adapted to be loaded by a processor and executed by the method steps of Embodiment 1 shown above. The specific execution process can be found in the detailed description shown in the embodiments, and will not be repeated here. The device containing the storage medium can be an electronic device such as a personal computer, laptop computer, smartphone, or tablet computer.

[0251] For the device embodiments, since they basically correspond to the method embodiments, the relevant parts can be referred to in the description of the method embodiments. The device embodiments described above are merely illustrative. The components described as separate parts may or may not be physically separate, and 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 modules can be selected to achieve the purpose of this application according to actual needs. Those skilled in the art can understand and implement this without creative effort.

[0252] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0253] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1One or more processes and / or boxes Figure 1 The computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function selected in one or more boxes.

[0254] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function selected in one or more boxes.

[0255] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0256] Memory may include non-persistent memory in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0257] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0258] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0259] The above are merely embodiments of this application and are not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. An audio clock rendering method, characterized in that, include: Receive pulse code modulated audio data blocks carrying timestamps, and add the audio data blocks to a priority queue according to the timestamps; When the playback anchor timestamp has not yet been established and there are audio data blocks to be processed in the priority queue, the playback anchor timestamp is established based on the timestamp of the audio data block at the head of the priority queue. The playback write cursor is determined based on the playback anchor timestamp and the number of written frames, wherein the playback write cursor is the sum of the playback anchor timestamp and the time offset calculated from the number of written frames; Determine the time difference between the timestamp of the first audio data block and the playback write cursor; The audio data block at the head of the queue is processed according to the time difference, wherein: When the time difference meets the late arrival condition, the first audio data block in the queue is discarded; When the time difference meets the time axis breakage condition, the playback anchor timestamp is reset to the timestamp of the first audio data block, and the number of written frames is reset to zero. When the time difference meets the short interval condition, either wait or write a mute frame to the audio output interface according to the output buffer level of the audio output interface. When the time difference meets the normal playback conditions, the pulse code modulation data of the first audio data block is written to the audio output interface, and the number of written frames is updated according to the number of written frames.

2. The audio clock rendering method according to claim 1, characterized in that, The time difference is the difference between the timestamp of the first audio data block and the value obtained by writing the playback cursor. The late arrival condition includes the time difference being less than a negative late arrival threshold; When the time difference is less than a negative late arrival threshold, the first audio data block is discarded from the priority queue and the priority queue is updated.

3. The audio clock rendering method according to claim 2, characterized in that, The late arrival threshold is a configurable parameter, and its value ranges from 50 milliseconds to 150 milliseconds.

4. The audio clock rendering method according to claim 1, characterized in that, The time axis breakage condition includes the time difference being greater than the interval reset threshold; The interval reset threshold is a configurable parameter, and its value ranges from 200 milliseconds to 1000 milliseconds.

5. The audio clock rendering method according to claim 1, characterized in that, The short interval condition includes a time difference greater than zero and less than the interval reset threshold; When the time difference satisfies the short interval condition: When the output buffer level of the audio output interface is higher than the preset low water level threshold, wait for the next scheduling cycle; When the output buffer level of the audio output interface is not higher than the preset low water level threshold, a mute frame is written to the audio output interface to maintain the continuity of audio rendering.

6. The audio clock rendering method according to claim 1, characterized in that, Also includes: Detect boundary events and trigger a boundary recovery process when the boundary events are detected; The boundary events include at least one of the following: The timestamp of the first audio data block in the queue is rolled back beyond a preset rollback tolerance relative to the playback anchor timestamp; The time interval between the arrival time of the current audio data block and the arrival time of the most recent audio data block exceeds a preset interval threshold; Received a recovery boundary event signal from the sender; or The duration of consecutive audio decoding failures exceeds the preset failure threshold.

7. The audio clock rendering method according to claim 6, characterized in that, The boundary restoration process includes: Release underlying audio output resources; Clear the priority queue; Reset the playback anchor timestamp to an invalid value; Reset the number of written frames to zero; and After subsequent audio data blocks arrive, the playback anchor timestamp is re-established based on the timestamp of the subsequent audio data blocks.

8. The audio clock rendering method according to any one of claims 1 to 7, characterized in that, Also includes: Detect the sampling rate of the currently received audio data block; When the sampling rate is inconsistent with the sampling rate of the current audio renderer, the current audio renderer is closed, a new audio renderer is created with the sampling rate of the currently received audio data block, and the playback state is reset. The playback status reset includes at least clearing the priority queue, resetting the playback anchor timestamp to an invalid value, and resetting the number of written frames to zero. Furthermore, after a new audio data block arrives, the playback anchor timestamp is re-established based on the timestamp of the new audio data block.

9. An audio clock rendering device, comprising an audio receiving interface and an audio output interface, characterized in that, Also includes: The enqueue module is used to receive pulse code modulation audio data blocks carrying timestamps through the audio receiving interface, and add the audio data blocks to a priority queue according to the timestamps. The playback clock module is used to establish the playback anchor timestamp based on the timestamp of the audio data block at the head of the queue when the playback anchor timestamp has not yet been established and there are audio data blocks to be processed in the priority queue, and to determine the playback write cursor based on the playback anchor timestamp and the number of written frames. An exception handling module is used to determine the time difference between the timestamp of the first audio data block and the playback write cursor, and to determine the processing method corresponding to the first audio data block based on the time difference. The processing methods include late-arrival discard processing, timeline break processing, short interval processing, and normal playback processing. When performing the timeline break processing, the playback anchor timestamp is reset to the timestamp of the first audio data block and the number of written frames is reset to zero. as well as The output module is used to write the pulse code modulation data or silence frame of the head audio data block to the audio output interface according to the processing method determined by the exception handling module, and update the number of written frames according to the number of written frames when writing the pulse code modulation data.

10. The audio clock rendering apparatus according to claim 9, characterized in that, It also includes a boundary recovery module. The boundary recovery module is used to detect boundary events and execute the boundary recovery process when the boundary event is detected; The boundary recovery process includes releasing the underlying audio output resources, clearing the priority queue, resetting the playback anchor timestamp to an invalid value, and resetting the number of written frames to zero. After the subsequent audio data block arrives, the playback anchor timestamp is re-established based on the timestamp of the subsequent audio data block. The boundary events include at least one of the following: timestamp rollback event, data arrival interval exceeding a preset interval threshold, sender recovery boundary event, and decoding failure duration exceeding a preset failure threshold.

11. The audio clock rendering apparatus according to claim 10, characterized in that, It also includes a sampling rate monitoring unit. The sampling rate monitoring unit is used to detect the sampling rate of the currently received audio data block, and when the sampling rate is inconsistent with the sampling rate of the current audio renderer, it triggers the current audio renderer to close, creates a new audio renderer with the sampling rate of the currently received audio data block, and the boundary recovery module to perform a playback state reset.

12. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, the processor performs the audio clock rendering method according to any one of claims 1 to 8.

13. An audio receiving terminal, characterized in that, Including the processor and audio output interface, The processor is used to execute an audio clock rendering program, so that the audio receiving terminal executes the audio clock rendering method according to any one of claims 1 to 8, and outputs the audio data processed by the audio clock rendering method through the audio output interface.