Non-blocking audio file duration calculation method and device based on dynamic time slice scheduling, electronic equipment and storage medium

By using dynamic time-slice scheduling and buffer mechanisms, the main thread blocking and inaccuracy issues in audio file duration calculation are resolved, achieving accurate calculation of audio file duration and smooth system responsiveness, and is applicable to various audio file formats.

CN121662077APending Publication Date: 2026-03-13GUANGZHOU BAOLUN ELECTRONICS CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-18
Publication Date
2026-03-13

AI Technical Summary

Technical Problem

Existing technologies suffer from main thread blocking and inaccurate results when calculating audio file duration, especially with significant errors in variable bitrate files, and resource utilization is inflexible.

Method used

A dynamic time-slice scheduling method is adopted. By obtaining the sampling rate of the audio file and the number of sampling points per frame, the audio parsing task is decomposed into multiple interruptible short tasks. Combined with buffer and time-slice mechanisms, the system responsiveness and calculation accuracy are ensured.

Benefits of technology

It achieves accurate calculation of audio file duration, avoids main thread blocking, has good system responsiveness, is suitable for high-load and low-load scenarios, and reduces implementation complexity and maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121662077A_ABST
    Figure CN121662077A_ABST
Patent Text Reader

Abstract

The invention relates to a non-blocking audio file duration calculation method and device based on dynamic time slice scheduling, electronic equipment and a storage medium, and the method comprises the steps: decomposing a lengthy audio analysis task into a plurality of interruptible short tasks through a time slice scheduling mechanism, and guaranteeing the responsiveness of a system main thread or a key task; the frame rate and the sampling rate are strictly distinguished, the frame rate is converted into the sampling point rate, frame structures of different coding formats are correctly analyzed, and it is ensured that the calculation result is accurate. According to the method, the overall new performance of the system is optimized under the condition that the accuracy and precision of audio file duration calculation are ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of audio file processing technology, and in particular to a method, apparatus, electronic device, and storage medium for calculating the duration of non-blocking audio files based on dynamic time-slice scheduling. Background Technology

[0002] Audio file duration is fundamental metadata for digital media processing. In audio playback, users can intuitively grasp the total audio duration and current playback position; in audio editing, users can precisely trim and splice audio segments, ensuring timeline alignment; in data analysis, average audio length can be calculated to optimize recommendation algorithms or content strategies; in speech recognition, processing time can be estimated, computing resources allocated, and recognition result timestamps aligned; in streaming media transmission, correct segmentation information (such as HLS) can be generated to avoid playback interruptions or buffering. Clearly, audio file duration plays a crucial role in multiple digital media application scenarios.

[0003] Existing methods for obtaining the duration of audio files mainly fall into two categories: The first method is the overall parsing method, which reads the entire audio file into memory at once, parses the metadata in the file header or accumulates sample points frame by frame to obtain the total duration. However, it will continuously occupy CPU and I / O resources before the entire parsing is completed, and can only wait for the final result and cannot be canceled midway, causing the application to be unable to respond to other tasks in a timely manner. This method has a large peak memory consumption and blocks the main thread, and is suitable for small files and scenarios with sufficient memory. The second method is block reading, which divides the file into data blocks of a fixed size (e.g., 64 kB), reads and parses the audio frames in each block in turn, and has a fixed processing granularity, which makes resource utilization inflexible. At the same time, it uses the cumulative frame count or sampling points to convert into duration, which exacerbates system lag under high load and insufficient resource utilization under low load. This method can reduce the memory peak in large file scenarios, but the main thread is still blocked.

[0004] On the other hand, when the above method uses the "total number of bytes ÷ average bitrate" estimation model to calculate the duration of an audio file, it introduces significant errors in variable bitrate (VBR) files, where the bitrate varies with the frame rate, leading to inaccurate audio file duration calculations. Furthermore, when the above method uses "duration = total number of frames ÷ sampling rate" to calculate the audio file duration, it confuses "frame rate" with "sampling rate," ignoring the basic encoding rule that each frame of formats such as MP3 and AAC actually contains 1024 / 1152 sampling points, causing the calculated duration to deviate completely from the actual playback duration. Summary of the Invention

[0005] Therefore, the purpose of this invention is to provide a non-blocking audio file duration calculation method based on dynamic time slice scheduling, which solves the problems of main thread blocking and inaccurate results in the existing technology for calculating audio file duration.

[0006] A non-blocking audio file duration calculation method based on dynamic time-slice scheduling includes the following steps: S10: Obtain the sampling rate R and the number of sampling points per frame S of the target audio file; S20: Start the current time slice, and within the current time slice, start from the current position of the target audio file, read the complete audio frame and store it in the buffer until the stop reading condition is met; S30: Parse all audio frames read in the current time slice stored in the buffer, identify complete audio frames, and count the number of audio frames successfully parsed in the current time slice, ni. S40: Based on the number of successfully parsed audio frames ni in the current time slice, the sampling rate R of the target audio file, and the number of sampling points per frame S, calculate the parsed audio segment duration ti in the current time slice, where ti satisfies: ; Update the file read pointer and repeat steps S20~S40 until the target audio file is completely parsed or the end marker of the target audio file is encountered. S50: Sum the durations ti of each audio segment to obtain the total global duration of the target audio file. , satisfy:

[0007] Where N is the total number of time slices.

[0008] Compared with the prior art, the present invention has the following beneficial effects: 1) By introducing the key parameter of "number of sampling points per frame", the audio coding standard is strictly followed, which fundamentally solves the problems of existing technologies confusing "frame rate" and "sampling rate" and using incorrect formulas to cause inaccurate duration calculation. This achieves accurate duration calculation for VBR audio files with significant effect. 2) By adopting a time-slice mechanism, it is ensured that no single operation will monopolize CPU or I / O resources for a long time, thus guaranteeing system responsiveness. The system can "breathe" according to the current load, which can quickly complete scanning when the system is idle and actively "yield" when under high load, smoothing the system performance curve and achieving true non-blocking performance. It is suitable for application scenarios with high real-time requirements. 3) The core algorithm logic is clear, and there is no need to introduce complex multi-threaded synchronization mechanisms or large third-party libraries, which reduces the implementation complexity and maintenance cost.

[0009] Further, step S10 includes: S11: Read the header information of the target audio file and identify the format of the target audio file; S12: Based on the format of the target audio file, extract the sampling rate R and the number of sampling points per frame S of the target audio file.

[0010] Furthermore, FFmpeg, or libav* series libraries, or a self-compiled parser are used to identify the format of the target audio file and extract the sampling rate R and the number of sampling points per frame S.

[0011] Furthermore, the condition for stopping reading is any of the following: 1) The buffer is full; 2) The data read is insufficient to form a complete audio frame; 3) Current time slice quota exhausted.

[0012] Furthermore, the current time slice is determined according to the following method: SA0: Sets the initial value of the time slice; SA1: Obtain CPU feedback and I / O mode from the previous moment: If it is non-blocking I / O, proceed to step SA2A; If it is asynchronous I / O, execute step SA2B; SA2A: Obtain the number of EAGAIN operations for non-blocking I / O in the previous time step, and determine the I / O impact factor based on the number of EAGAIN operations; SA2B: Obtain the number of asynchronous I / O tasks in the previous time step, and determine the I / O impact factor based on the number of tasks; SA3: Correct the initial value of the time slice based on CPU feedback and I / O impact factor to obtain the current time slice: Current time slice = initial time slice value * (1 - CPU feedback) * I / O impact factor.

[0013] Furthermore, for non-blocking I / O: The number of EAGAIN events is greater than 2, and the I / O impact factor is 1.5; The number of EAGAIN events is 2, and the I / O impact factor is 1.3. The number of EAGAIN events is equal to 1, and the I / O impact factor is 1.1. The number of EAGAIN events is 0, and the I / O impact factor is 0.7. For asynchronous I / O: When the number of tasks is greater than 16, the I / O impact factor is 0.6. The number of tasks is between 13 and 16, and the I / O impact factor is 0.75. The number of tasks is between 9 and 12, and the I / O impact factor is 0.9; The number of tasks is between 4 and 8, and the I / O impact factor is 1.1. With fewer than 4 tasks, the I / O impact factor is 1.4.

[0014] Furthermore, the buffer is set as needed, with the buffer size ranging from 4KB to 64KB.

[0015] Meanwhile, the present invention also provides a non-blocking audio file duration calculation device based on dynamic time-slice scheduling, including: a parameter acquisition module, a dynamic time-slice scheduler, an audio parser, a segmented audio duration calculator, a target audio duration calculator, and a buffer; The parameter acquisition module is used to acquire the sampling rate R and the number of sampling points per frame S of the target audio file; The dynamic time slice scheduler is used to start the current time slice. Within the current time slice, it reads complete audio frames from the current position of the target audio file and stores them in the buffer until the stop reading condition is met. The audio parser is used to parse all audio frames read in the current time slice stored in the buffer, identify complete audio frames, and count the number of audio frames successfully parsed in the current time slice, ni. The audio segment duration calculator is used to calculate the duration ti of the parsed audio segments within the current time slice based on the number of successfully parsed audio frames ni, the sampling rate R of the target audio file, and the number of sampling points per frame S. ti satisfies the following: ; Update the file read pointer and repeatedly enter the dynamic time slice scheduler, audio parser, and segmented audio duration calculator until the target audio file is parsed or the end marker of the target audio file is encountered. The target audio duration calculator is used to sum the durations ti of each audio segment to obtain the total global duration of the target audio file. , satisfy:

[0016] Where N is the total number of time slices; A buffer is used to store the raw data read from the target audio file, including complete audio frames.

[0017] Compared with the prior art, the beneficial effects of the non-blocking audio file duration calculation device based on dynamic time slice scheduling provided by the present invention are the same as those of the non-blocking audio file duration calculation method based on dynamic time slice scheduling, and will not be repeated here. Attached Figure Description

[0018] To better understand and implement this invention, the following detailed description is provided in conjunction with the accompanying drawings.

[0019] Figure 1 This is a flowchart of the non-blocking audio file duration calculation method based on dynamic time slice scheduling according to the present invention; Figure 2 This is a pseudocode diagram of an embodiment of the present invention. Detailed Implementation

[0020] The technical solutions of the present invention will now be clearly and completely described with reference to the accompanying drawings of the embodiments of the present invention. The described embodiments are merely some embodiments of the present invention, and not all embodiments. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the protection scope of the present invention.

[0021] To address the problems of main thread blocking and inaccurate results in existing audio file duration calculation techniques, this invention proposes a non-blocking audio file duration calculation device based on dynamic time-slice scheduling. This device includes a non-blocking audio file duration calculation method based on dynamic time-slice scheduling. This method decomposes lengthy audio parsing tasks into multiple interruptible short tasks through a time-slice scheduling mechanism, ensuring the responsiveness of the system's main thread or critical tasks. By strictly distinguishing between frame rate and sampling rate, and converting the frame rate to sampling rate, it correctly parses the frame structure of different encoding formats, ensuring accurate calculation results. This method optimizes the overall system performance while maintaining the accuracy and precision of audio file duration calculation.

[0022] For specific implementation details, please refer to [link / reference]. Figure 1 The non-blocking audio file duration calculation device based on dynamic time-slice scheduling includes: a parameter acquisition module, a buffer, a dynamic time-slice scheduler, an audio parser, a segmented audio duration calculator, and a target audio duration calculator, used to execute the non-blocking audio file duration calculation method based on dynamic time-slice scheduling.

[0023] The parameter acquisition module is used to perform step S10: acquire the sampling rate R and the number of sampling points per frame S of the target audio file.

[0024] The parameter acquisition module includes a file format acquisition unit and a parameter extraction unit.

[0025] The file format acquisition unit is used to perform step S11: read the header information of the target audio file and identify the format of the target audio file.

[0026] The parameter extraction unit is used to perform step S12: extract the sampling rate R and the number of sampling points per frame of the target audio file based on the format of the target audio file.

[0027] Specifically, FFmpeg, libav* series libraries, or a self-compiled parser are used to identify the format of the target audio file and extract the sampling rate R and the number of sampling points per frame S.

[0028] For example, if the target audio file is identified as WAV, its header structure is "RIFF" + file size + "WAVE" + "fmt" + 24 / 26 byte fmt chunk + "data" + data length. Based on this header structure, the sampling rate R, bit depth, number of channels, and data length are extracted. The number of samples per frame S is then obtained based on the number of channels and bytes. Similarly, if the target audio file is identified as MP3, its header structure is ID3v2 tag (optional) + frame header (4 bytes per frame). Based on this header structure, the sampling rate index, bit rate index, and version / layer index are extracted. The sampling rate R is obtained by looking up the table using the sampling rate index, and the number of samples per frame S is obtained based on the version / layer index according to fixed encoding rules. MP3 typically has 1152 samples per frame. The same method is used to extract or derive the sampling rate R and the number of samples per frame S from the header structure for AAC and FLAC audio files.

[0029] The buffer is used to store the raw data read from the target audio file, including complete audio frames.

[0030] The buffer can be set as needed, such as a buffer of 4KB-64KB.

[0031] The dynamic time-slice scheduler is used to execute step S20: start the current time slice, and within the current time slice, read complete audio frames from the current position of the target audio file and store them in the buffer until reading stops when any of the following conditions are met: 4) The buffer is full; 5) The data read is insufficient to form a complete audio frame; 6) Current time slice quota exhausted.

[0032] In practice, the current time slice is determined as follows: SA0: Sets the initial value of the time slice.

[0033] In this embodiment, the initial value of the time slice is set to 50ms.

[0034] SA1: Obtain CPU feedback and I / O mode from the previous moment: If it is non-blocking I / O, proceed to step SA2A; If it is asynchronous I / O, execute step SA2B; If it is a pure I / O load, proceed to step SA2C.

[0035] SA2A: Obtain the number of EAGAIN operations for non-blocking I / O at the previous time step, and determine the I / O impact factor based on the number of EAGAIN operations.

[0036] SA2B: Obtain the number of asynchronous I / O tasks in the previous time step, and determine the I / O impact factor based on the number of tasks.

[0037] SA2C: Obtain the average latency of pure I / O load at the previous moment, and calculate the I / O impact factor based on the average latency.

[0038] In this embodiment, for non-blocking I / O: The number of EAGAIN events is greater than 2, and the I / O impact factor is 1.5; The number of EAGAIN events is 2, and the I / O impact factor is 1.3. The number of EAGAIN events is equal to 1, and the I / O impact factor is 1.1. The number of EAGAIN events is 0, and the I / O impact factor is 0.7.

[0039] The number of EAGAIN calls reflects the system's workload; a higher number of calls indicates greater I / O pressure, requiring a longer processing time.

[0040] For asynchronous I / O: When the number of tasks is greater than 16, the I / O impact factor is 0.6. The number of tasks is between 13 and 16, and the I / O impact factor is 0.75. The number of tasks is between 9 and 12, and the I / O impact factor is 0.9; The number of tasks is between 4 and 8, and the I / O impact factor is 1.1. With fewer than 4 tasks, the I / O impact factor is 1.4.

[0041] The more tasks there are, the heavier the system load becomes, and the shorter the individual time slices should be to ensure fair scheduling.

[0042] For a pure I / O load, the I / O impact factor is calculated using the following formula: I / O impact factor = 1 / (1 + average latency / 20).

[0043] SA3: The initial value of the time slice is corrected based on CPU feedback and I / O impact factor to obtain the current time slice. The current time slice = initial value of time slice * (1 - CPU feedback) * I / O impact factor. The CPU feedback is (0.2, 1.0).

[0044] In practice, non-blocking I / O or asynchronous I / O operations are preferred to calculate the current time slice, and the time slice is dynamically adjusted according to the system load to ensure that the scheduling thread is not blocked while waiting for disk data.

[0045] The audio parser is used to perform step S30: parsing all audio frames read in the current time slice stored in the buffer, identifying complete audio frames, and counting the number of audio frames successfully parsed in the current time slice, ni.

[0046] In practice, a frame synchronization mode is used to parse and identify all audio frames read from the current time slice stored in the buffer.

[0047] The segmented audio duration calculator is used to execute step S40: Based on the number of successfully parsed audio frames ni in the current time slice, the sampling rate R of the target audio file, and the number of sampling points per frame S, the segmented audio duration ti is calculated, where ti satisfies: .

[0048] Update the file read pointer and repeat steps S20 to S40 until the target audio file is parsed or the end marker of the target audio file is encountered.

[0049] The target audio duration calculator is used to perform step S50: summing the durations ti of each audio segment to obtain the total global duration of the target audio file. , satisfy:

[0050] Where N represents the target audio file that is read using N time slices.

[0051] First, calculate the duration *ti* of each segment of the target audio file, then sum them to obtain the total global duration of the target audio file. This effectively improves system responsiveness and reduces resource consumption. This setting allows other tasks to respond after each time slice is completed without blocking the main thread, thus improving system responsiveness; at the same time, a fixed small buffer (4KB-64KB) keeps memory usage stable and reduces resource consumption; additionally, the parsing progress can be displayed in real time, and mid-process cancellation is supported.

[0052] For an example, please see Figure 2 This invention calculates the duration of a target audio file in MP3 format. Based on the header structure, the sampling rate of the target audio file is 44100Hz, and the number of sampling points per frame is 1152. Non-blocking I / O is used to determine the current time slice, and a frame synchronization mode with a 0xFFF synchronization word is used to calculate the total global duration of the target audio frame.

[0053] Compared with the prior art, the present invention has the following beneficial effects: 1) By introducing the key parameter of "number of sampling points per frame", the audio coding standard is strictly followed, which fundamentally solves the problems of existing technologies confusing "frame rate" and "sampling rate" and using incorrect formulas to cause inaccurate duration calculation. This achieves accurate duration calculation for VBR audio files with significant results.

[0054] 2) By adopting a time-slice mechanism, it is ensured that no single operation will monopolize CPU or I / O resources for a long time, thus guaranteeing system responsiveness. The system can "breathe" according to the current load, and can quickly complete scanning when the system is idle, and actively "yield" when under high load, smoothing the system performance curve and achieving true non-blocking performance. It is suitable for application scenarios with high real-time requirements.

[0055] 3) The core algorithm logic is clear, and there is no need to introduce complex multi-threaded synchronization mechanisms or large third-party libraries, which reduces the implementation complexity and maintenance cost.

[0056] The aforementioned non-blocking audio file duration calculation devices based on dynamic time slice scheduling are all stored in an electronic device and executed by the electronic device to calculate the duration of non-blocking audio files.

[0057] The electronic devices include, but are not limited to, memory, processor, and network interface that can communicate with each other via a system bus.

[0058] The electronic device can be a rack server, blade server, tower server, or cabinet server, or other computing device. The electronic device can be a standalone server or a server cluster composed of multiple servers. The memory includes at least one type of readable storage medium, including flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. The memory can be an internal storage unit of the electronic device, such as the hard disk or RAM of the electronic device. The memory can also be an external storage device of the electronic device, such as a plug-in hard disk, smart media card (SMC), secure digital card (SD), flash card, etc. The memory may also include both internal storage units and external storage devices of the electronic device.

[0059] The processor can be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. This processor is typically used to control the overall operation of the electronic device, such as performing control and processing related to data interaction or communication with the electronic device. The processor is used to run program code stored in the memory or process data, such as running the duration calculation method for non-blocking audio files based on the modal decomposition method.

[0060] The network interface may include a wireless network interface or a wired network interface, which is typically used to establish communication connections between the electronic device and other electronic devices. For example, the network interface is used to connect the electronic device to an external data platform via a network, establishing a data transmission channel and communication connection between the electronic device and the external data platform. The network may be an intranet, the Internet, Global System for Mobile communication (GSM), Wideband Code Division Multiple Access (WCDMA), 4G network, 5G network, Bluetooth, Wi-Fi, or other wireless or wired networks. It should be noted that all directional indications (such as up, down, left, right, front, back, etc.) in the embodiments of the present invention are only used to explain the relative positional relationship and movement of each component in a certain specific posture (as shown in the figure). If the specific posture changes, the directional indication will also change accordingly.

[0061] Furthermore, the use of terms such as "first" and "second" in this invention is for descriptive purposes only and should not be construed as indicating or implying their relative importance or implicitly specifying the number of technical features indicated. Therefore, features defined with "first" and "second" may explicitly or implicitly include at least one of those features. Additionally, the technical solutions of the various embodiments can be combined with each other, but only on the basis of being achievable by those skilled in the art. When the combination of technical solutions is contradictory or impossible to implement, such a combination of technical solutions should be considered non-existent and not within the scope of protection claimed by this invention.

[0062] The embodiments described above are merely examples of several implementations of the present invention, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the invention. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of the present invention, and the present invention also intends to include these modifications and variations.

Claims

1. A method for calculating the duration of a non-blocking audio file based on dynamic time-slice scheduling, characterized in that, Includes the following steps: S10: Obtain the sampling rate R and the number of sampling points per frame S of the target audio file; S20: Start the current time slice, and within the current time slice, start from the current position of the target audio file, read the complete audio frame and store it in the buffer until the stop reading condition is met; S30: Parse all audio frames read in the current time slice stored in the buffer, identify complete audio frames, and count the number of audio frames successfully parsed in the current time slice, ni. S40: Based on the number of successfully parsed audio frames ni in the current time slice, the sampling rate R of the target audio file, and the number of sampling points per frame S, calculate the parsed audio segment duration ti in the current time slice, where ti satisfies: ; Update the file read pointer and repeat steps S20~S40 until the target audio file is completely parsed or the end marker of the target audio file is encountered. S50: Sum the durations ti of each audio segment to obtain the total global duration of the target audio file. , satisfy: Where N is the total number of time slices.

2. The method for calculating the duration of a non-blocking audio file based on dynamic time-slice scheduling according to claim 1, characterized in that, Step S10 includes: S11: Read the header information of the target audio file and identify the format of the target audio file; S12: Based on the format of the target audio file, extract the sampling rate R and the number of sampling points per frame S of the target audio file.

3. The method for calculating the duration of a non-blocking audio file based on dynamic time-slice scheduling according to claim 2, characterized in that, The target audio file format is identified using FFmpeg, libav* series libraries, or a self-compiled parser, and the sampling rate R and the number of samples per frame S are extracted.

4. The method for calculating the duration of a non-blocking audio file based on dynamic time-slice scheduling according to claim 1, characterized in that, The condition for stopping reading is any of the following: 1) The buffer is full; 2) The data read is insufficient to form a complete audio frame; 3) Current time slice quota exhausted.

5. The method for calculating the duration of a non-blocking audio file based on dynamic time-slice scheduling according to claim 1, characterized in that, The current time slice is determined in the following manner: SA0: Sets the initial value of the time slice; SA1: Obtain CPU feedback and I / O mode from the previous moment: If it is non-blocking I / O, proceed to step SA2A; If it is asynchronous I / O, proceed to step SA2B; SA2A: Obtain the number of EAGAIN operations for non-blocking I / O in the previous time step, and determine the I / O impact factor based on the number of EAGAIN operations; SA2B: Obtain the number of asynchronous I / O tasks in the previous time step, and determine the I / O impact factor based on the number of tasks; SA3: Correct the initial value of the time slice based on CPU feedback and I / O impact factor to obtain the current time slice: Current time slice = initial time slice value * (1 - CPU feedback) * I / O impact factor.

6. The method for calculating the duration of a non-blocking audio file based on dynamic time-slice scheduling according to claim 5, characterized in that: For non-blocking I / O: The number of EAGAIN events is greater than 2, and the I / O impact factor is 1.5; The number of EAGAIN events is 2, and the I / O impact factor is 1.

3. The number of EAGAIN events is equal to 1, and the I / O impact factor is 1.

1. The number of EAGAIN events is 0, and the I / O impact factor is 0.

7. For asynchronous I / O: When the number of tasks is greater than 16, the I / O impact factor is 0.

6. The number of tasks is between 13 and 16, and the I / O impact factor is 0.

75. The number of tasks is between 9 and 12, and the I / O impact factor is 0.9; The number of tasks is between 4 and 8, and the I / O impact factor is 1.

1. With fewer than 4 tasks, the I / O impact factor is 1.

4.

7. The method for calculating the duration of a non-blocking audio file based on dynamic time-slice scheduling according to claim 1, characterized in that, The buffer is set as needed, with a buffer size of 4KB-64KB.

8. A non-blocking audio file duration calculation device based on dynamic time-slice scheduling, characterized in that, It includes a parameter acquisition module, a dynamic time slice scheduler, an audio parser, a segmented audio duration calculator, a target audio duration calculator, and a buffer; The parameter acquisition module is used to acquire the sampling rate R and the number of sampling points per frame S of the target audio file; The dynamic time slice scheduler is used to start the current time slice. Within the current time slice, it reads complete audio frames from the current position of the target audio file and stores them in the buffer until the stop reading condition is met. The audio parser is used to parse all audio frames read in the current time slice stored in the buffer, identify complete audio frames, and count the number of audio frames successfully parsed in the current time slice, ni. The audio segment duration calculator is used to calculate the duration ti of the parsed audio segments within the current time slice based on the number of successfully parsed audio frames ni, the sampling rate R of the target audio file, and the number of sampling points per frame S. ti satisfies the following: ; Update the file read pointer and repeatedly enter the dynamic time slice scheduler, audio parser, and segmented audio duration calculator until the target audio file is parsed or the end marker of the target audio file is encountered. The target audio duration calculator is used to sum the durations ti of each audio segment to obtain the total global duration of the target audio file. , satisfy: Where N is the total number of time slices; A buffer is used to store the raw data read from the target audio file, including complete audio frames.

9. An electronic device, characterized in that, include: The electronic device comprises a chip, a processor, and a memory, the memory being used to store computer program code, the computer program code including computer instructions, wherein, when the chip executes the computer instructions, the electronic device performs the non-blocking audio file duration calculation method based on dynamic time-slice scheduling as described in any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, which includes program instructions that, when executed by a processor of an electronic device, cause the processor to perform the non-blocking audio file duration calculation method based on dynamic time-slice scheduling as described in any one of claims 1 to 7.