Buffer self-adaptive adjusting method, device, equipment and storage medium

文档序号:1904458 发布日期:2021-11-30 浏览:11次 中文

阅读说明:本技术 一种缓冲区自适应调整方法、装置、设备及存储介质 (Buffer self-adaptive adjusting method, device, equipment and storage medium ) 是由 谭人宽 张康 于 2021-08-04 设计创作,主要内容包括:本申请实施例公开了一种缓冲区自适应调整方法、装置、设备及存储介质。本申请实施例提供的技术方案通过缓冲区的读写周期确定缓冲区进行数据读写时的抖动是否在稳定状态,在缓冲区的抖动处于稳定状态时,根据缓冲区的存储空间大小和缓冲区在读写操作后的剩余数据大小,确定是否对缓冲区的存储空间大小进行调整,在确定对存储空间大小进行调整时,根据剩余数据大小和存储空间大小对缓冲区的存储空间大小进行调整,以对当前设备的缓冲区存储空间大小进行自适应调整,提高缓冲区的自适应调节能力。(The embodiment of the application discloses a buffer self-adaptive adjusting method, a device, equipment and a storage medium. The technical scheme provided by the embodiment of the application determines whether jitter of a buffer area during data reading and writing is in a stable state or not through a reading and writing period of the buffer area, determines whether to adjust the size of the storage space of the buffer area or not according to the size of the storage space of the buffer area and the size of the residual data of the buffer area after the reading and writing operation when the jitter of the buffer area is in the stable state, and adjusts the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the size of the storage space is determined to be adjusted so as to perform self-adaptive adjustment on the size of the storage space of the buffer area of the current equipment and improve the self-adaptive adjustment capability of the buffer area.)

1. A buffer adaptive adjustment method is characterized by comprising the following steps:

determining whether the jitter of the buffer area during data reading and writing is in a stable state according to the data reading and writing period of the buffer area;

when the jitter of the buffer area during data reading and writing is in a stable state, determining whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the residual data after the reading and writing operation;

and when the size of the storage space of the buffer area is determined to be adjusted, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space.

2. The buffer adaptive adjustment method according to claim 1, wherein the determining whether jitter of the buffer during data reading and writing is in a stable state according to a data reading and writing period of the buffer comprises:

determining an average writing period, a writing period variance, an average reading period and a reading period variance when the buffer area reads and writes data according to the data reading and writing period of the buffer area;

and determining whether the jitter of the buffer area during data reading and writing is in a stable state or not according to the average writing period, the writing period variance, the average reading period and the reading period variance.

3. The buffer adaptive adjustment method according to claim 2, wherein the determining whether jitter of the buffer during data reading and writing is in a stable state according to the average writing period, the writing period variance, the average reading period, and the reading period variance comprises:

determining a read-write jitter value of the buffer area according to the average writing period and the average reading period;

determining the variance fluctuation trend of the buffer area according to the writing period variance and the reading period variance;

and when the read-write jitter value is smaller than a set jitter threshold value and the variance fluctuation trend of the buffer area is a non-increasing trend, determining that the read-write cycle jitter of the buffer area is in a stable state.

4. The buffer adaptive adjustment method according to claim 1, wherein before determining whether to adjust the size of the storage space of the buffer, the method further comprises:

acquiring the size of the residual data of the buffer area after each read-write operation according to a set detection period, wherein the set detection period is greater than the data read-write period;

determining a maximum remaining data size and a minimum remaining data size among the remaining data sizes;

determining whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the remaining data after the read-write operation, wherein the determining comprises the following steps:

determining whether an ear return broadcast empty mode or a cache full load mode is met according to the size of the storage space of the buffer area, the size of the maximum residual data and the size of the minimum residual data;

and when the ear broadcast empty mode or the cache full load mode is met, adjusting the size of the storage space of the buffer area, otherwise, keeping the size of the storage space of the buffer area unchanged.

5. The buffer adaptive adjustment method according to claim 4, wherein the obtaining the size of the remaining data of the buffer after each read-write operation comprises:

taking the sum of the length of the cache residual data of the buffer area after each data writing operation and the length of the set reading and writing frame number as the size of the residual data after the data writing operation;

and taking the difference between the cache residual data length of the buffer after each data reading operation and the set reading and writing frame number length as the residual data size after the data writing operation.

6. The buffer adaptive adjustment method according to claim 4, wherein the determining whether the ear rebroadcasting empty mode or the buffer full mode is satisfied according to the size of the storage space of the buffer, the maximum remaining data size, and the minimum remaining data size comprises:

when the minimum residual data size is smaller than a set broadcast empty judgment threshold value, determining that an ear broadcast empty mode is met;

and when the maximum residual data size is larger than the storage space size of the buffer area, determining that a cache full load mode is met.

7. The buffer adaptive adjustment method according to claim 4, wherein the method further comprises:

and when the size of the residual data is larger than a set frame combination length threshold, carrying out frame combination processing on the audio data in the buffer area.

8. The buffer self-adaptive adjusting device is characterized by comprising a stability detection module, an adjustment judgment module and an adjustment execution module, wherein:

the stability detection module is used for determining whether the jitter of the buffer area during data reading and writing is in a stable state according to the data reading and writing period of the buffer area;

the adjustment judging module is used for determining whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the residual data after the read-write operation when the jitter of the buffer area during the data read-write operation is in a stable state;

and the adjustment execution module is used for adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the adjustment of the size of the storage space of the buffer area is determined.

9. A buffer adaptive adjustment device, comprising: a memory and one or more processors;

the memory for storing one or more programs;

when executed by the one or more processors, cause the one or more processors to implement the buffer adaptation adjustment method of any of claims 1-7.

10. A storage medium containing computer-executable instructions, which when executed by a computer processor, are configured to perform the buffer adaptive adjustment method of any of claims 1-7.

Technical Field

The embodiment of the application relates to the technical field of data processing, in particular to a buffer self-adaptive adjusting method, device, equipment and storage medium.

Background

With the enhancement of the audio processing function on the mobile terminal, people can record sound by using mobile terminals such as mobile phones and tablets, and more sound recording requirements of people are met, such as moving karaoke and the like. Meanwhile, when recording or collecting sound, it is common to monitor whether the sound is normal through the ear return technology.

In the existing ear return technology, the collected audio data can be stored in a buffer area with a fixed size, and a playing engine is waited to obtain the audio data for ear return playing. Generally, sound collection and ear return playing are performed according to a certain period, but with the use of a user, due to fluctuation of reading and writing in the sound collection and ear return playing processes, ear return playing is empty or a cache is full, ear return jamming or delay is caused easily, the ear return playing effect is affected, and meanwhile, if a larger buffer area is fixed to cover more use scenes, the real-time performance of ear return cannot be guaranteed.

Disclosure of Invention

The embodiment of the application provides a buffer area self-adaptive adjusting method, a buffer area self-adaptive adjusting device, buffer area self-adaptive adjusting equipment and a storage medium, so that the self-adaptive adjusting capability of the buffer area is improved.

In a first aspect, an embodiment of the present application provides a buffer adaptive adjustment method, including:

determining whether the jitter of the buffer area during data reading and writing is in a stable state or not according to the data reading and writing period of the buffer area;

when the jitter of the buffer area during data reading and writing is in a stable state, determining whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the residual data after the reading and writing operation;

and when the size of the storage space of the buffer area is determined to be adjusted, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space.

In a second aspect, an embodiment of the present application provides a buffer adaptive adjustment apparatus, including a stability detection module, an adjustment judgment module, and an adjustment execution module, where:

the stability detection module is used for determining whether the jitter of the buffer area is in a stable state when the data is read and written according to the data read and write period of the buffer area;

the adjustment judging module is used for determining whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the residual data after the read-write operation when the jitter of the buffer area during the data read-write operation is in a stable state;

and the adjustment execution module is used for adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the adjustment of the size of the storage space of the buffer area is determined.

In a third aspect, an embodiment of the present application provides a buffer adaptive adjustment device, including: a memory and one or more processors;

a memory for storing one or more programs;

when the one or more programs are executed by the one or more processors, the one or more processors are caused to implement the buffer adaptive adjustment method as in the first aspect.

In a fourth aspect, embodiments of the present application provide a storage medium containing computer-executable instructions for performing the buffer adaptive adjustment method as in the first aspect when executed by a computer processor.

The embodiment of the application determines whether jitter of a buffer area during data reading and writing is in a stable state or not through a reading and writing period of the buffer area, determines whether to adjust the size of the storage space of the buffer area or not according to the size of the storage space of the buffer area and the size of the residual data of the buffer area after reading and writing operations when the jitter of the buffer area is in the stable state, and adjusts the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when determining to adjust the size of the storage space so as to perform self-adaptive adjustment on the size of the storage space of the buffer area of the current equipment, thereby improving the self-adaptive capacity of the buffer area.

Drawings

Fig. 1 is a flowchart of a buffer adaptive adjustment method provided in an embodiment of the present application;

fig. 2 is a schematic diagram of data acquisition and playing of an ear return technology provided in an embodiment of the present application;

fig. 3 is a flowchart of another buffer adaptive adjustment method provided in an embodiment of the present application;

FIG. 4 is a schematic diagram of a data read/write cycle in an ideal state according to an embodiment of the present application;

FIG. 5 is a schematic diagram of a data read/write cycle in a jitter state according to an embodiment of the present disclosure;

fig. 6 is a flowchart of another buffer adaptive adjustment method provided in an embodiment of the present application;

fig. 7 is a flowchart of another buffer adaptive adjustment method provided in an embodiment of the present application;

fig. 8 is a state transition diagram of a buffer adaptive adjustment method according to an embodiment of the present application;

fig. 9 is a schematic structural diagram of a buffer adaptive adjustment apparatus according to an embodiment of the present application;

fig. 10 is a schematic structural diagram of a buffer adaptive adjustment device according to an embodiment of the present application.

Detailed Description

In order to make the objects, technical solutions and advantages of the present application more apparent, specific embodiments of the present application will be described in detail with reference to the accompanying drawings. It is to be understood that the specific embodiments described herein are merely illustrative of the application and are not limiting of the application. It should be further noted that, for the convenience of description, only some but not all of the relevant portions of the present application are shown in the drawings. Before discussing exemplary embodiments in more detail, it should be noted that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although a flowchart may describe the operations (or steps) as a sequential process, many of the operations can be performed in parallel, concurrently or simultaneously. In addition, the order of the operations may be re-arranged. The process may be terminated when its operations are completed, but may have additional steps not included in the figure. The processes may correspond to methods, functions, procedures, subroutines, and the like.

Fig. 1 is a flowchart of a buffer adaptive adjustment method provided in an embodiment of the present application, where the buffer adaptive adjustment method provided in the embodiment of the present application may be executed by a buffer adaptive adjustment apparatus, and the buffer adaptive adjustment apparatus may be implemented by hardware and/or software and integrated in a buffer adaptive adjustment device.

The following description will be given taking as an example a buffer adaptive adjustment method performed by the buffer adaptive adjustment apparatus.

Referring to fig. 1, the buffer adaptive adjustment method includes:

s101: and determining whether the jitter of the buffer area during data reading and writing is in a stable state or not according to the data reading and writing period of the buffer area.

The buffer provided in this embodiment is used to buffer audio data collected by a buffer adaptive adjustment device (hereinafter referred to as a device) or other audio collection devices, and wait for an audio playing engine to obtain the buffered audio data for playing, so as to implement aural return playing of sound collection.

Fig. 2 is a schematic diagram of data acquisition and playing of an ear return technology provided in an embodiment of the present application, for example, in a mobile K song, a user accesses an earphone (a wired earphone or a bluetooth earphone) on a device (a mobile phone or a tablet), acquires audio data recorded by the user through a microphone, writes the audio data into a buffer, obtains the audio data from the buffer by an audio playing engine, mixes the audio data with accompaniment music, and provides the mixture for other users or devices to play, and performs ear return playing through the earphone, so that the user can listen to sound acquired by the microphone from the earphone side to monitor whether a sound is missing or missing. The audio data may be encoded by Pulse Code Modulation (PCM), which is not limited in this application.

When the data reading and writing of the audio data are carried out in the buffer area, the data reading and writing period of the buffer area is counted, and whether the jitter of the buffer area during the data reading and writing is in a stable state or not is determined according to the data reading and writing period. When the jitter of the buffer area during data reading and writing is in a stable state, the method goes to step S102 to further determine whether the adjustment of the size of the storage space of the buffer area is needed, and when the jitter of the buffer area during data reading and writing is not in a stable state, it is determined that the adjustment of the size of the storage space of the buffer area is not needed.

The data read-write period includes a data write period and a data read period, that is, a time period for writing the audio data into the buffer and a time period for the audio playing engine to obtain the audio data from the buffer, and jitter of the buffer for data read-write can be understood as fluctuation between the data write period and the data read period. When the fluctuation between the data writing period and the data reading period is within the set fluctuation range, the jitter of the buffer area during data reading and writing is considered to be in a stable state, otherwise, the jitter of the buffer area during data reading and writing is considered not to be in the stable state. Generally, when the data writing period and the data reading period are close and stable, the jitter of the buffer area during data reading and writing is in a stable state.

S102: and when the jitter of the buffer area during data reading and writing is in a stable state, determining whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the residual data after the reading and writing operation.

It should be explained that, when the jitter of the buffer during data reading and writing is not in a stable state, because the fluctuation between the data writing period and the data reading period is unstable, if it is determined whether the size of the storage space of the buffer needs to be adjusted at this time, the size of the storage space obtained by adjustment is not suitable for the device, and the buffer is frequently adjusted, which is easily subject to the fluctuation caused by the non-audio playing engine system. The scheme determines the jitter during data reading and writing through the data reading and writing period, and the jitter is the fluctuation caused by the audio playing engine system and reflects the jitter caused by the audio, so that the fluctuation caused by the non-audio playing engine system is effectively eliminated.

Illustratively, when determining that jitter of the buffer during data reading and writing is in a stable state, obtaining a size of remaining data of the buffer after the data reading and writing operation, comparing the size of the storage space of the buffer with the size of the remaining data after the data reading and writing operation, and determining whether the size of the storage space of the buffer needs to be adjusted according to a comparison result.

It can be understood that, the data reading and writing of the buffer is performed according to the set reading and writing frame number length (including the writing frame number length and the reading frame number length, that is, the length of writing one frame of data into the buffer, and the length of reading one frame of data from the buffer by the audio playing engine), when the size of the remaining data after the reading and writing operation of the buffer is smaller than the size of the storage space, the size of the audio data acquired by the audio playing engine is smaller than the reading and writing frame number length, and at this time, the audio playing engine will fill the vacant part in the audio data, resulting in the occurrence of the empty condition of the ear back broadcasting; when the size of the remaining data after the read-write operation of the buffer area is larger than the size of the storage space, after the audio playing engine acquires the audio data, the audio data still remains in the buffer area, and at this time, the situation that the buffer is full occurs. It can be understood that when jitter during data reading and writing in the buffer is in a stable state, the ear playback empty and the buffer full load are alternately stored, and at this time, the size of the storage space of the buffer cannot cover the jitter during data reading and writing in the buffer, and the size of the storage space needs to be increased.

S103: and when the size of the storage space of the buffer area is determined to be adjusted, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space.

Illustratively, when determining to adjust the size of the storage space of the buffer, determining an adjustment range of the size of the storage space according to the size of the remaining data after the read-write operation and the current size of the storage space (for example, using the size of the remaining data as the adjustment range), and adjusting the size of the storage space of the buffer according to the adjustment range to increase the size of the storage space of the buffer to a degree of jitter when the coverable buffer performs the read-write of the data, thereby implementing the adaptive adjustment of the buffer.

In one possible embodiment, after the memory size of the buffer is adjusted, the adjusted memory size may be recorded, and the next time the earreturn function is turned on, the previously adjusted memory size will be used. In a possible embodiment, after the size of the storage space of the buffer is adjusted and the ear return function is turned off, the adjusted size of the storage space does not need to be recorded, and the default size of the storage space is used when the ear return function is turned on next time.

The method comprises the steps of determining whether jitter of a buffer area during data reading and writing is in a stable state or not through a reading and writing period of the buffer area, determining whether the size of the storage space of the buffer area is adjusted or not according to the size of the storage space of the buffer area and the size of the residual data of the buffer area after the reading and writing operation when the jitter of the buffer area is in the stable state, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the size of the storage space is determined to be adjusted, so that the size of the storage space of the buffer area of the current equipment is adaptively adjusted, the pause rate and the delay time of the ear return playing are reduced, the condition that the ear return playing is empty or the buffer is fully loaded is reduced, the adaptive energy saving capability of the buffer area is improved, the ear return real-time performance is guaranteed, and the ear return playing effect is optimized.

On the basis of the foregoing embodiment, fig. 3 is a flowchart of another buffer adaptive adjustment method provided in an embodiment of the present application, which is an embodiment of the foregoing buffer adaptive adjustment method. Referring to fig. 3, the buffer adaptive adjustment method includes:

s201: and determining the average writing period, the writing period variance, the average reading period and the reading period variance when the buffer area performs data reading and writing according to the data reading and writing period of the buffer area.

The buffer area provided in this embodiment reads and writes data according to a set data read-write period, where the data read-write period includes a data write period in which the buffer area writes data and a data read period in which the buffer area reads data (an audio playback engine reads data from the buffer area).

In the process of the ear return playing, the data reading and writing period of the buffer area in the time length is recorded, and the average writing period, the writing period variance, the average reading period and the reading period variance when the data reading and writing are carried out in the buffer area are determined according to the data reading and writing period in the time length. Specifically, the average write cycle and the write cycle variance when the buffer performs data writing are calculated according to the data write cycle when the buffer performs data writing within the set time length, and the average read cycle and the read cycle variance when the buffer performs data reading (the audio playback engine reads data from the buffer) are calculated according to the data read cycle when the buffer performs data reading within the set time length.

S202: and determining whether the jitter of the buffer area during data reading and writing is in a stable state or not according to the average writing period, the writing period variance, the average reading period and the reading period variance.

And determining whether the jitter of the buffer area during data reading and writing is in a stable state or not according to the determined average writing period, writing period variance, average reading period and reading period variance, and if so, jumping to the step S203 to determine whether the size of the storage space of the buffer area needs to be adjusted or not, otherwise, not adjusting the size of the storage space of the buffer area.

Specifically, when determining whether the jitter of the buffer during data reading and writing is in a stable state according to the average writing period, the writing period variance, the average reading period, and the reading period variance, the present embodiment includes steps S2021 to S2023:

s2021: and determining the read-write jitter value of the buffer area according to the average write period and the average read period.

Specifically, the average writing period and the average reading period are compared, and the comparison result is used as the read-write jitter value of the buffer. For example, the absolute value of the difference between the average write period and the average read period is used as the read-write jitter value of the buffer.

It will be appreciated that the read and write jitter values reflect the time delay between data acquisition and playback. In a possible embodiment, when the read-write jitter value is continuously increased, a performance exception prompt is sent out to prompt that the audio acquisition end or the audio playing end has performance problems, so that data processing is not timely.

S2022: and determining the variance fluctuation trend of the buffer area according to the writing period variance and the reading period variance.

Specifically, a variance fluctuation trend of the buffer is determined according to the writing period variance and the reading period variance, and the variance fluctuation trend reflects the variation trend of the writing period variance and the reading period variance. The variance fluctuation tendency provided by the present embodiment includes a writing variance fluctuation tendency determined from the writing period variance, and a reading variance fluctuation tendency determined from the reading period variance.

When the fluctuation trend of the write variance and the fluctuation trend of the read variance are both non-increasing trends (i.e. the variance of the write period and the variance of the read period do not increase all the time), the fluctuation trend of the variance of the buffer area is a non-increasing trend, otherwise, the fluctuation trend of the variance of the buffer area is considered to be an increasing trend (at least one of the fluctuation trend of the write variance and the fluctuation trend of the read variance is an increasing trend, and at this time, the data read and write of the buffer area are in an unbalanced or irregular state, which is not suitable for adjusting the buffer area).

S2023: and when the read-write jitter value is smaller than the set jitter threshold value and the variance fluctuation trend of the buffer area is a non-increasing trend, determining that the read-write cycle jitter of the buffer area is in a stable state.

Specifically, when the read-write jitter value is smaller than the set jitter threshold value and the variance fluctuation trend of the buffer area is a non-increasing trend, it can be considered that the data read-write of the buffer area is balanced, the fluctuation between the data write period and the data read period is in a stable state, and it is determined that the read-write period jitter of the buffer area is in a stable state. Wherein, the setting of the jitter threshold can be set according to the actual situation. For example, the set jitter threshold is set to 0, and when the read/write jitter value is 0 or approximately equal to 0, the read/write jitter value is considered to be smaller than the set jitter threshold, and the average write period and the average read period are close to each other.

Fig. 4 is a schematic diagram of a data read-write cycle in an ideal state according to an embodiment of the present application, and fig. 5 is a schematic diagram of a data read-write cycle in a jitter state according to an embodiment of the present application. As shown in fig. 4 and 5, in an ideal state, the audio acquisition and the audio playing are performed in the same period, at this time, the data writing period is the same as the data reading period, and at this time, the data reading and writing of the buffer area is not jittered, as can be seen from the callback timeline in fig. 4, the data acquisition and the ear return playing of the audio data are performed by calling back the read and write audio data in the buffer area according to the period T, and then the average data reading and writing period is T in a period of time. In an actual application scenario, as can be seen from the callback timeline in fig. 5, a callback period of data reading and writing is not fixed, for example, the data reading and writing periods of the two previous times and the two subsequent times are respectively T1 and T2, where T1 is smaller than T2, and T1+ T2 is 2T, although the average data reading and writing period in a period is also T, at this time, the buffer area reads and writes data at different time intervals, there is a case that the original buffer area with a fixed size cannot cover the jitter when the buffer area reads and writes data, and the jitter of reading and writing is different for different models, which needs to introduce jitter buffering, adaptively adjust the size of the storage space of the buffer area according to the jitter buffering, and improve the universality of mobile ear return.

S203: and when the jitter of the buffer area during data reading and writing is in a stable state, determining whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the residual data after the reading and writing operation.

S204: and when the size of the storage space of the buffer area is determined to be adjusted, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space.

The method comprises the steps of determining whether jitter of a buffer area during data reading and writing is in a stable state or not through a reading and writing period of the buffer area, determining whether the size of the storage space of the buffer area is adjusted or not according to the size of the storage space of the buffer area and the size of the residual data of the buffer area after the reading and writing operation when the jitter of the buffer area is in the stable state, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the size of the storage space is determined to be adjusted, so that the size of the storage space of the buffer area of the current equipment is adaptively adjusted, the pause rate and the delay time of the ear return playing are reduced, the condition that the ear return playing is empty or the buffer is fully loaded is reduced, the adaptive energy saving capability of the buffer area is improved, the ear return real-time performance is guaranteed, and the ear return playing effect is optimized. And determining whether jitter of the buffer area during data reading and writing is in a stable state or not through an average writing period, a writing period variance, an average reading period and a reading period variance during data reading and writing of the buffer area, performing dimensionality of data reading and writing (data is read from the buffer area by an audio playing engine) from the buffer area, calculating jitter of data acquisition and aural return playing, judging whether fluctuation between the data writing period and the data reading period is in a stable state or an irregular state, and effectively eliminating fluctuation caused by a non-audio playing engine system to the buffer area. And when the jitter of the reading and writing period of the buffer area is accurately judged to be in a stable state, the size of the storage space of the buffer area is adjusted, so that the condition that the size of the storage space of the buffer area is frequently adjusted is prevented, and the normal work of an audio playing engine system is ensured.

On the basis of the foregoing embodiment, fig. 6 is a flowchart of another buffer adaptive adjustment method provided in an embodiment of the present application, which is an embodiment of the foregoing buffer adaptive adjustment method. Referring to fig. 6, the buffer adaptive adjustment method includes:

s301: and determining whether the jitter of the buffer area during data reading and writing is in a stable state or not according to the data reading and writing period of the buffer area.

S302: and acquiring the size of the residual data of the buffer area after each read-write operation according to a set detection period, wherein the set detection period is greater than the data read-write period.

Specifically, the size of the remaining data of the buffer area after each read-write operation is obtained and recorded according to a set detection period, and the set detection period is greater than the data read-write period. The read-write operation includes a data write operation and a data write operation, and correspondingly, the remaining data provided by this embodiment includes a remaining data size after the data write operation and a remaining data size after the data write operation. Based on this, in this embodiment, acquiring the remaining data size of the buffer after each read-write operation specifically includes steps S3021 to S3022:

s3021: and taking the sum of the cache residual data length of the buffer after each data writing operation and the set reading and writing frame number length as the residual data size after the data writing operation.

Specifically, after the buffer performs data write operation each time, the cache remaining data length (the length of the actual remaining data in the buffer after the data write operation) in the buffer is determined, the sum of the cache remaining data length and the set read-write frame number length is calculated, and the sum result is used as the size of the remaining data after the data write operation.

S3022: and taking the difference between the cache residual data length of the buffer after each data reading operation and the set reading and writing frame number length as the residual data size after the data writing operation.

Specifically, after the buffer performs data reading operation each time, the cache residual data length (the length of the actual residual data in the buffer after the data reading operation) in the buffer is determined, the difference between the cache residual data length and the set read-write frame number length is calculated, and the difference result is used as the size of the residual data after the data reading operation.

For example, assuming that the data read/write period is 20ms and the detection period is set to 2s, that is, the buffer performs data read/write operations every 20ms, then 100 data write operations and 100 data read operations are performed in the set detection period, and correspondingly, the remaining data size after 100 data write operations and the remaining data size after 100 data write operations are recorded, that is, the remaining data size after 200 data read/write operations of the buffer is recorded in the set detection period.

S303: a maximum remaining data size and a minimum remaining data size among the remaining data sizes are determined.

Specifically, for each set detection period, the maximum value and the minimum value among all the remaining data sizes are determined, the minimum remaining data size is determined as the minimum remaining data size, and the maximum remaining data size is determined as the maximum remaining data size.

S304: and when the jitter of the buffer area during data reading and writing is in a stable state, determining whether the requirement of an ear replay broadcasting empty mode or a cache full-load mode is met according to the size of the storage space, the maximum residual data size and the minimum residual data size of the buffer area.

And when the jitter of the buffer area during data reading and writing is in a stable state, determining whether the requirement of an ear replay broadcasting empty mode or a cache full-load mode is met according to the size of the storage space, the maximum residual data size and the minimum residual data size of the buffer area. The ear return play null mode may be understood as a mode in which when the audio playing engine acquires audio data from the buffer, and the size of data provided by the buffer is smaller than the length of single-frame data during ear return play, the audio playing audio automatically performs filling play on the audio data. The buffer full mode may be understood as a mode in which the size of the audio data of the data acquisition is larger than the size of the storage space. It can be understood that, when the ear return broadcast empty mode and the buffer full mode are satisfied, the size of the storage space of the buffer cannot cover the jitter of data reading and writing.

Specifically, in this embodiment, determining whether the ear replay broadcast empty mode or the buffer full mode is satisfied according to the size of the storage space, the maximum remaining data size, and the minimum remaining data size of the buffer area specifically includes steps S3041-S3042:

s3041: and when the minimum residual data size is smaller than a set broadcast empty judgment threshold value, determining that the ear broadcast empty mode is met.

Specifically, the minimum remaining data size is compared with a set broadcast empty judgment threshold, and when the minimum remaining data size is smaller than the set broadcast empty judgment threshold, it is determined that the ear return broadcast empty mode is satisfied. In this embodiment, the set broadcast empty determination threshold is set to 0, that is, when the minimum remaining data size is smaller than 0, it is determined that the ear return broadcast empty mode is satisfied. And when the size of the residual data is larger than or equal to the set broadcast empty judgment threshold (namely the minimum residual data size is larger than or equal to 0), determining that the ear broadcast return empty mode is not satisfied, namely the ear broadcast return empty condition does not occur in the set detection period.

S3042: and when the maximum residual data size is larger than the storage space size of the buffer area, determining that the cache full-load mode is met.

Specifically, the maximum remaining data size is compared with the storage space size of the current buffer area, when the maximum remaining data size is larger than the storage space size of the buffer area, it is determined that the full-load mode of the cache is satisfied, and when the maximum remaining data size is smaller than or equal to the storage space size of the buffer area, it is determined that the full-load mode of the cache is not satisfied, that is, the full-load condition of the cache does not occur within the set detection period.

S305: and when the ear broadcast empty mode or the cache full load mode is met, adjusting the size of the storage space of the buffer area, otherwise, keeping the size of the storage space of the buffer area unchanged.

When the requirement of the ear broadcast empty mode or the buffer full mode is determined, the storage space size of the buffer area can not cover the jitter of data reading and writing at the moment, and then the storage space size of the buffer area is determined to be required to be adjusted. And when the ear return broadcast empty mode and the cache full load mode are not satisfied, the jitter of the data read-write can be determined to be covered by the buffer area at the moment, and the size of the storage space of the buffer area is kept unchanged.

S306: and when the size of the storage space of the buffer area is determined to be adjusted, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space.

The method comprises the steps of determining whether jitter of a buffer area during data reading and writing is in a stable state or not through a reading and writing period of the buffer area, determining whether the size of the storage space of the buffer area is adjusted or not according to the size of the storage space of the buffer area and the size of the residual data of the buffer area after the reading and writing operation when the jitter of the buffer area is in the stable state, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the size of the storage space is determined to be adjusted, so that the size of the storage space of the buffer area of the current equipment is adaptively adjusted, the pause rate and the delay time of the ear return playing are reduced, the condition that the ear return playing is empty or the buffer is fully loaded is reduced, the adaptive energy saving capability of the buffer area is improved, the ear return real-time performance is guaranteed, and the ear return playing effect is optimized. And determining the maximum residual data size and the minimum residual data size according to the residual data size of the buffer area after each read-write operation in the set detection period, judging whether the maximum residual data size and the minimum residual data size meet an ear-to-broadcast empty mode or a cache full-load mode, accurately judging the jitter of the buffer area during data read-write when the storage space size of the current buffer area can be covered, and more accurately adjusting the storage space size of the buffer area.

On the basis of the foregoing embodiment, fig. 7 is a flowchart of another buffer adaptive adjustment method provided in an embodiment of the present application, which is an embodiment of the foregoing buffer adaptive adjustment method. Referring to fig. 7, the buffer adaptive adjustment method includes:

s401: and determining whether the jitter of the buffer area during data reading and writing is in a stable state or not according to the data reading and writing period of the buffer area.

S402: and acquiring the size of the residual data of the buffer area after each read-write operation according to a set detection period, wherein the set detection period is greater than the data read-write period.

S403: a maximum remaining data size and a minimum remaining data size among the remaining data sizes are determined.

S404: and when the jitter of the buffer area during data reading and writing is in a stable state, determining whether the requirement of an ear replay broadcasting empty mode or a cache full-load mode is met according to the size of the storage space, the maximum residual data size and the minimum residual data size of the buffer area.

S405: and when the ear broadcast empty mode or the cache full load mode is met, adjusting the size of the storage space of the buffer area, otherwise, keeping the size of the storage space of the buffer area unchanged.

S406: and when the size of the storage space of the buffer area is determined to be adjusted, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space.

S407: and when the size of the residual data is larger than the set length threshold of the combined frame, carrying out combined frame processing on the audio data in the buffer area.

Specifically, when it is determined that jitter of the buffer area during data reading and writing is in a stable state, if the size of the remaining data of the buffer area is greater than a set threshold of the length of the resultant frame, more audio data is retained in a set detection period, and the playing speed of the audio data needs to be increased. In this embodiment, when the size of the remaining data is greater than the set threshold of the frame merging length, the frame merging processing is performed on the audio data in the buffer area, for example, two or more frames of audio data in the buffer area are overlapped and synthesized into one frame of audio data, and the audio playing engine acquires the audio data after frame merging, so that variable-speed playing of the audio data is realized, and an earreturn playing effect with low time delay is realized under the condition that the integrity of sound is ensured.

Based on this, when the size of the remaining data is greater than the set full frame length threshold, the embodiment performs a frame merging process on the audio data in the buffer region, including: and when the minimum residual data size is larger than the length of the reading and writing frame number of one frame, carrying out frame combination processing on the audio data in the buffer area.

Specifically, the minimum remaining data size is compared with the length of the reading/writing frame number, and when the minimum remaining data size is greater (or much greater) than the length of the reading/writing frame number, the audio data in the buffer is subjected to frame combination processing. The frame combining processing on the audio data in the buffer area may be performed based on a hamming window, or may be performed based on a time domain companding (variable speed and non-variable pitch) algorithm, which is not limited in this application.

The method comprises the steps of determining whether jitter of a buffer area during data reading and writing is in a stable state or not through a reading and writing period of the buffer area, determining whether the size of the storage space of the buffer area is adjusted or not according to the size of the storage space of the buffer area and the size of the residual data of the buffer area after the reading and writing operation when the jitter of the buffer area is in the stable state, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the size of the storage space is determined to be adjusted, so that the size of the storage space of the buffer area of the current equipment is adaptively adjusted, the pause rate and the delay time of the ear return playing are reduced, the condition that the ear return playing is empty or the buffer is fully loaded is reduced, the adaptive energy saving capability of the buffer area is improved, the ear return real-time performance is guaranteed, and the ear return playing effect is optimized. Meanwhile, when the size of the residual data is larger than the set length threshold of the combined frame, the audio data in the buffer area is combined, so that the retention of the audio data in the buffer area is reduced, and the effect of low-delay ear return playing is realized under the condition of ensuring the completeness of sound.

Fig. 8 is a state transition diagram of a buffer adaptive adjustment method according to an embodiment of the present application, and as shown in fig. 8, when jitter during reading and writing data in a buffer is not in a stable state (state a in fig. 8), a processing manner of the buffer is maintained, that is, a storage space size of the buffer is maintained.

When the jitter of the buffer during data reading and writing is in a stable state, if the ear broadcast empty mode or the buffer full load mode (state B in fig. 8) is satisfied, the buffer is processed in such a way that the size of the storage space of the buffer is adjusted, that is, the size of the remaining data and the size of the storage space are adjusted. If the ear return broadcast empty mode and the buffer full mode are not satisfied (state C in fig. 8), the buffer is processed in the current state.

When the size of the residual data is larger than the set combined frame length threshold (state D in the figure), the processing mode of the buffer area is combined frame acceleration, namely, the audio data in the buffer area is subjected to combined frame processing. When the size of the remaining data is not larger than the set combined frame length threshold (state E in the figure), the processing mode of the buffer area is kept as it is.

When the jitter of the buffer area during data reading and writing is not in a stable state, the jitter is in a stable state but does not satisfy the ear-return broadcast empty mode and the buffer full-load mode, or the jitter is in a stable state but the size of the residual data is not larger than the set full-frame length threshold, the size of the storage space of the buffer area is kept unchanged, when the jitter is in a stable state and meets the ear broadcast empty mode or the buffer full mode, the size of the storage space of the buffer area is increased, when the jitter is in a steady state and the remaining data size is larger than the set full frame length threshold, the audio data in the buffer area is processed by frame combination, the size of the storage space of the buffer area of the current equipment is adjusted in a self-adaptive way, the pause rate and the time delay of the ear return playing are reduced, and the detention of audio data in the buffer area is reduced, and the effect of low-delay earreturn playing is realized under the condition of ensuring the completeness of sound.

Fig. 9 is a schematic structural diagram of a buffer adaptive adjustment apparatus according to an embodiment of the present application. Referring to fig. 9, the buffer adaptive adjustment apparatus includes a stability detection module 31, an adjustment judgment module 32, and an adjustment execution module 33.

The stability detection module 31 is configured to determine whether jitter of the buffer area during data reading and writing is in a stable state according to a data reading and writing period of the buffer area; an adjustment judging module 32, configured to determine whether to adjust the size of the storage space of the buffer area according to the size of the storage space of the buffer area and the size of the remaining data after the read-write operation when the jitter during data read-write in the buffer area is in a stable state; and an adjusting execution module 33, configured to adjust the size of the storage space of the buffer area according to the size of the remaining data and the size of the storage space when determining to adjust the size of the storage space of the buffer area.

The method comprises the steps of determining whether jitter of a buffer area during data reading and writing is in a stable state or not through a reading and writing period of the buffer area, determining whether the size of the storage space of the buffer area is adjusted or not according to the size of the storage space of the buffer area and the size of the residual data of the buffer area after the reading and writing operation when the jitter of the buffer area is in the stable state, adjusting the size of the storage space of the buffer area according to the size of the residual data and the size of the storage space when the size of the storage space is determined to be adjusted, so that the size of the storage space of the buffer area of the current equipment is adaptively adjusted, the pause rate and the delay time of the ear return playing are reduced, the condition that the ear return playing is empty or the buffer is fully loaded is reduced, the adaptive energy saving capability of the buffer area is improved, the ear return real-time performance is guaranteed, and the ear return playing effect is optimized.

The embodiment of the application also provides buffer area self-adaptive adjusting equipment which can integrate the buffer area self-adaptive adjusting device provided by the embodiment of the application. Fig. 10 is a schematic structural diagram of a buffer adaptive adjustment device according to an embodiment of the present application. Referring to fig. 10, the buffer adaptive adjustment apparatus includes: an input device 43, an output device 44, a memory 42, and one or more processors 41; a memory 42 for storing one or more programs; when the one or more programs are executed by the one or more processors 41, the one or more processors 41 are caused to implement the buffer adaptive adjustment method as provided in the above embodiments. The buffer adaptive adjusting device, the device and the computer provided by the above can be used for executing the buffer adaptive adjusting method provided by any of the above embodiments, and have corresponding functions and beneficial effects.

Embodiments of the present application also provide a storage medium containing computer-executable instructions, which when executed by a computer processor, are used to perform the buffer adaptive adjustment method provided in the above embodiments. Of course, the storage medium provided in the embodiments of the present application contains computer-executable instructions, and the computer-executable instructions are not limited to the above buffer adaptive adjustment method, and may also perform related operations in the buffer adaptive adjustment method provided in any embodiments of the present application. The buffer adaptive adjustment device, the device and the storage medium provided in the above embodiments may execute the buffer adaptive adjustment method provided in any embodiment of the present application, and refer to the buffer adaptive adjustment method provided in any embodiment of the present application without detailed technical details described in the above embodiments.

The foregoing is considered as illustrative of the preferred embodiments of the invention and the technical principles employed. The present application is not limited to the particular embodiments described herein, and various obvious changes, adaptations and substitutions may be made by those skilled in the art without departing from the scope of the present application. Therefore, although the present application has been described in more detail with reference to the above embodiments, the present application is not limited to the above embodiments, and may include other equivalent embodiments without departing from the spirit of the present application, and the scope of the present application is determined by the scope of the claims.

19页详细技术资料下载
上一篇:一种医用注射器针头装配设备
下一篇:处理器中物理内存保护机制的实现方法及装置

网友询问留言

已有0条留言

还没有人留言评论。精彩留言会获得点赞!

精彩留言,会给你点赞!

技术分类