Audio task processing method and system based on first-in first-out strategy
By prioritizing audio tasks and optimizing resource allocation with the background management queue, the response lag and lag problems of the audio processing system when processing batch tasks are solved, significantly improving system performance and user experience.
Patent Information
- Application Number
- CN202411225879.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-03
- Publication Date
- 2024-12-20
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing audio processing systems are prone to response lag and system lag when processing batch tasks, resulting in poor user experience and degradation of performance.
Using the audio task processing method based on the first-in-first-out strategy, by obtaining new tasks and performing standardized format conversion, prioritizing tasks based on preset urgency, and dividing tasks into real-time, high-priority and low-priority , use the backend management queue to allocate and optimize computing resources, and promptly clear low-priority tasks to improve system response speed.
It significantly improves the overall performance and user experience of the audio processing system, improves computing efficiency and response speed, and avoids system lag and task backlog.
Smart Images

Figure CN119166343A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of audio processing, and in particular to an audio task processing method and system based on a first-in-first-out strategy. Background Art
[0002] In current audio processing system application scenarios, when performing operations such as multi-channel linkage, complex curve drawing, and large-scale data transmission, the system often needs to perform a series of high-intensity calculations. These calculations not only cover a variety of complex algorithms, such as audio signal spectrum analysis, filtering algorithms, etc., but may also require the call of external Python and C_DLL libraries to assist in completing specific mathematical operations or data processing. This process causes the overall amount of calculation of the system to grow exponentially, and the processing time will be greatly extended.
[0003] Especially when users perform interactive operations such as dragging, new tasks will continue to emerge and accumulate like a tide. If the traditional sequential execution mode is still followed, the audio processing system is prone to response lag, which will not only bring a very poor user experience, but also have a serious impact on the performance of the entire audio processing system.
[0004] For example, when processing large-scale multi-channel audio data linkage, assuming that the data volume of each channel is 100MB and 10 channels are processed simultaneously, the processing time of each channel is about 2 seconds according to the traditional method, and the total processing time will reach 20 seconds. Usually, due to the uneven distribution of computing resources, the system will be stuck for 10 to 20 seconds, making it impossible for users to respond to operations in time, and even causing the system to crash due to overflow of computing volume. Summary of the invention
[0005] In order to overcome the problems of response lag and system freeze in the existing audio processing system when processing batch tasks, the present invention provides an audio task processing method and system based on a first-in-first-out strategy.
[0006] The present invention provides an audio task processing method based on a first-in-first-out strategy, comprising the following steps:
[0007] Acquire a newly created audio task, and convert the data of the audio task into a standardized format to obtain task data;
[0008] According to the preset urgency of the audio task, the task data is prioritized and a priority parameter is added to the task data; wherein the priority classification includes real-time priority, high priority and low priority;
[0009] The remaining task data except the real-time priority are exported to the background management queue in the order of priority parameters from large to small.
[0010] Run the background processing function; the background processing function performs the following steps when running:
[0011] Perform feature analysis on the task data in the background management queue to obtain the task features corresponding to each task data;
[0012] Allocate computing resources for real-time priority task data for execution;
[0013] Calculate the resource requirements corresponding to the task characteristics, allocate computing resources to the task data in the background management queue in turn according to the remaining resources and resource requirements of the system, and remove the task data from the background management queue;
[0014] When the usage rate of the system resources is greater than the first threshold, the task data with the lowest priority parameter in the background management queue is removed.
[0015] Preferably, the step of acquiring a newly created audio task and converting the data of the audio task into a standardized format to obtain task data further includes the following steps:
[0016] Verifying the data format of the audio task to confirm whether the data format of the audio task complies with the standard;
[0017] When there is an error in the data format of the audio task, an error prompt is issued and a request is made to re-enter the audio task;
[0018] When the data format of the audio task is correct, the audio task is converted into task data in a unified standard format through semantic parsing, complex parameter decomposition, encoding conversion and data structure reorganization.
[0019] Preferably, the priority classification of the task data is performed according to the preset urgency of the audio task, and the priority parameter is added to the task data, which specifically includes the following steps:
[0020] Based on the neural network, the preset audio task urgency and the key features of the corresponding audio task are used as training data to create and train an adaptive priority evaluation model;
[0021] When new task data is detected, determining whether the task data has a corresponding preset audio task urgency;
[0022] If yes, the task data is prioritized and a priority parameter is added to the task data;
[0023] If not, obtain the key features of the audio task, and generate the priority classification and priority parameters of the audio task through an adaptive priority evaluation model.
[0024] Preferably, the background processing function is implemented in the following steps:
[0025] Use a separate background thread to run background processing functions in a multi-threaded system;
[0026] The background processing function creates multiple threads for processing multiple task data simultaneously.
[0027] Preferably, the task data is prioritized according to the preset urgency of the audio task, and a priority parameter is added to the task data, which also includes the following steps:
[0028] When a newly created audio task does not have a preset audio task urgency, a pop-up window is used to request the operator to set a priority category and priority parameters for the audio task.
[0029] The present invention also provides an audio task processing system based on a first-in-first-out strategy, comprising: a task receiving module, a task sorting module and a background management module;
[0030] The task receiving module is used to obtain the newly created audio task and convert the data of the audio task into a standardized format to obtain task data;
[0031] The task sorting module is used to prioritize the task data according to the preset urgency of the audio task, and add a priority parameter to the task data; wherein the priority classification includes real-time priority, high priority and low priority; and the remaining task data except the real-time priority are exported to the background management queue in the order of priority parameters from large to small at a regular time;
[0032] The background management module is used to run the background processing function; the background processing function performs the following steps when running:
[0033] Perform feature analysis on the task data in the background management queue to obtain the task features corresponding to each task data;
[0034] Allocate computing resources for real-time priority task data for execution;
[0035] Calculate the resource requirements corresponding to the task characteristics, allocate computing resources to the task data in the background management queue in turn according to the remaining resources and resource requirements of the system, and remove the task data from the background management queue;
[0036] When the usage rate of the system resources is greater than the first threshold, the task data with the lowest priority parameter in the background management queue is removed.
[0037] The beneficial effects of the present invention are:
[0038] (1) By prioritizing and sorting audio tasks, the audio processing tasks can be optimized, thereby significantly improving the overall performance of the audio processing system and user experience.
[0039] (2) By scheduling tasks in an orderly manner to background threads for calculation and promptly clearing low-priority audio tasks that have not yet started executing when new tasks continue to be added, efficient management is achieved, thereby significantly improving computing efficiency and system response speed. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] The present invention will be further described below in conjunction with the accompanying drawings, wherein:
[0041] Figure 1 This is a flow chart of a method according to Embodiment 1 of the present invention. DETAILED DESCRIPTION
[0042] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0043] See also Figure 1 As a first embodiment of the present invention, a method for processing an audio task based on a first-in-first-out strategy is disclosed, comprising the following steps:
[0044] S1. Task reception: obtaining a newly created audio task, and converting the data of the audio task into a standardized format to obtain task data;
[0045] S2, task sorting: according to the preset urgency of the audio task, the task data is prioritized and a priority parameter is added to the task data. The remaining task data except the real-time priority is exported to the background management queue in the order of priority parameters from large to small. The priority classification includes real-time priority, high priority, medium priority and low priority.
[0046] S3, background management: running the background processing function; the background processing function performs the following steps when running:
[0047] S31, performing characteristic analysis on the task data in the background management queue to obtain the task characteristics corresponding to each task data;
[0048] S32, allocating computing resources for execution of task data with real-time priority;
[0049] S33, calculating the resource requirements corresponding to the task characteristics, allocating computing resources to the task data in the background management queue in turn for execution according to the remaining resources and resource requirements of the system, and removing the task data from the background management queue;
[0050] S34: When the usage rate of system resources is greater than a first threshold, the task data with the lowest priority parameter in the background management queue is removed.
[0051] The priority classification includes real-time priority, high priority, medium priority and low priority. Real-time priority is the classification of audio tasks that must be executed when initiated and has the highest priority. The subsequent priorities are divided into high priority, medium priority and low priority from high to low. In particular, the low priority classification is an audio task that can be executed and can be directly abandoned when computing resources are insufficient without affecting the overall audio processing.
[0052] This embodiment also discloses an audio task processing system based on a first-in-first-out strategy, including: a task receiving module, a task sorting module and a background management module;
[0053] The task receiving module is used to obtain the newly created audio task and convert the data of the audio task into a standardized format to obtain task data;
[0054] The task sorting module is used to prioritize the task data according to the preset urgency of the audio task, and add a priority parameter to the task data; wherein the priority classification includes real-time priority, high priority and low priority; and the remaining task data except the real-time priority are exported to the background management queue in the order of priority parameters from large to small at a regular time;
[0055] The background management module is used to run the background processing function; the background processing function performs the following steps when running:
[0056] Perform feature analysis on the task data in the background management queue to obtain the task features corresponding to each task data;
[0057] Allocate computing resources to execute real-time priority task data;
[0058] Calculate the resource requirements corresponding to the task characteristics, allocate computing resources to the task data in the background management queue in turn according to the remaining resources and resource requirements of the system, and remove the task data from the background management queue;
[0059] When the usage rate of the system resources is greater than the first threshold, the task data with the lowest priority parameter in the background management queue is removed.
[0060] This embodiment optimizes the execution of audio processing tasks by classifying and sorting audio tasks by priority, thereby significantly improving the overall performance and user experience of the audio processing system. By orderly arranging tasks to background threads for calculation, and timely clearing low-priority audio tasks that have not yet started to be executed when new tasks continue to increase, efficient management is achieved, thereby significantly improving the calculation efficiency and system response speed.
[0061] The necessity of the standardized process of audio tasks in this embodiment is to ensure that the system can accurately and efficiently handle tasks of various types and sources. It makes the input tasks have a unified format and specification, which is convenient for subsequent processing and analysis, and reduces errors and processing difficulties caused by format differences.
[0062] Tasks generated by different users or within the system may differ in format, unit, and expression. If there is no standardized process, the system will need to spend extra time and resources to identify and convert them when processing, which is prone to errors and affects overall efficiency and accuracy. Standardized processes can provide consistency and predictability, which is the basis for the stable operation of the entire system.
[0063] On this basis, the audio task sequencing and system resource optimization of this embodiment can be implemented more conveniently and accurately.
[0064] The following is a second embodiment of the present invention, which is a more specific embodiment of the first embodiment. In step S1 of this embodiment, the following sub-steps are also included:
[0065] S11, verifying the data format of the audio task to confirm whether the data format of the audio task meets the standard;
[0066] S111, when there is an error in the data format of the audio task, issuing an error prompt and requesting to re-enter the audio task;
[0067] S1112. When the data format of the audio task is correct, the audio task is converted into task data with unified data units and unified encoding forms in a unified standard format through semantic analysis, complex parameter decomposition, encoding conversion and data structure reorganization.
[0068] In this embodiment, the data standardization process is an essential key step in implementing this embodiment. Converting the extracted and decomposed parameters into a unified standard format and unit within the system has multiple important meanings:
[0069] 1. First, it ensures the consistency and accuracy of system processing. In audio processing systems, task parameters from different sources may have a variety of formats and units. If they are not standardized, the system will need to frequently perform complex format and unit conversions during processing, which not only increases the complexity of processing, but also easily introduces errors, affecting the accuracy and stability of the system.
[0070] 2. Secondly, standardization helps improve the efficiency of the system. The unified standard format and unit allow the system to process directly without additional conversion steps, thereby significantly improving the processing speed, especially when faced with a large number of tasks and complex calculations. This advantage is more obvious.
[0071] 3. Furthermore, standardization is conducive to system maintenance and expansion. When the system needs to be integrated with other modules or external systems, unified standard formats and units can reduce the complexity of the interface, reduce the cost of communication and coordination, and make the system easier to maintain and expand.
[0072] 4. In other program environments, or in some simple, single-task and small-scale situations, similar functions may be temporarily realized without standardizing command data. However, for a complex audio processing system such as the one described in this embodiment, with diverse task types, extensive data sources and large computational complexity, it is difficult to ensure efficient and stable operation of the system without data standardization, and it is also difficult to achieve effective management and optimal allocation of resources.
[0073] In summary, data standardization is a crucial link in this embodiment, and plays an irreplaceable role in achieving efficient management of the audio processing system, optimizing execution, and improving overall performance and user experience.
[0074] In step S2 of this embodiment, the task data is prioritized according to the preset urgency of the audio task, and a priority parameter is added to the task data, which specifically includes the following steps:
[0075] S21. Based on a neural network, the preset audio task urgency and the key features of the corresponding audio task are used as training data to create and train an adaptive priority evaluation model;
[0076] S22, when new task data is detected, determining whether the task data has a corresponding preset audio task urgency;
[0077] S221: If yes, classify the task data by priority and add a priority parameter to the task data;
[0078] S222. If not, obtain key features of the audio task, such as the urgency of resource requirements, the degree of impact on the overall system performance, the relevance of the user's direct experience, etc., and generate the priority classification and priority parameters of the audio task through an adaptive priority evaluation model.
[0079] The above steps are to establish an adaptive priority evaluation model through a neural network, learn the existing audio task urgency classification method, and automatically generate the urgency of audio tasks that have not defined a preset urgency.
[0080] In other embodiments, the definition of the urgency of the audio task may also be completed directly by manually defining:
[0081] S23: When the newly created audio task does not have a preset audio task urgency, a pop-up window is provided to request the operator to set a priority category and priority parameters for the audio task according to specific circumstances.
[0082] Step S3 of this embodiment is implemented in the following steps:
[0083] S31. Use a separate background thread to run background processing functions in a multi-threaded system;
[0084] S32, the background processing function creates multiple threads for processing multiple task data simultaneously.
[0085] The detailed steps of task sorting in this embodiment are as follows:
[0086] C1. In task sorting, a "Task" class is defined, which has two attributes: "Priority" (priority, integer type) and "EntryTime" (entry time, DateTime type);
[0087] C2. In order to implement the task sorting logic, a comparator CompareTo is created. In the comparator, the priorities of the two tasks are compared first. If the priority of task A is higher than that of task B, then task A is ranked first. If the priority of task A is lower than that of task B, then task B is ranked first. For example, if the priority of task A is 90 and the priority of task B is 85, then task A takes precedence over task B.
[0088] C3. If the priorities of two tasks are the same, then compare their entry times; the task with an earlier entry time is ranked first; for example, the priorities of Task C and Task D are both 90, the entry time of Task C is 10:00 on July 25, 2024, and the entry time of Task D is 10:05 on July 25, 2024, then Task C is ranked before Task D.
[0089] For tasks of the same priority, for example, the priority of Task E and Task F are both 80, the entry time of Task E is 11:00 on July 25, 2024, and the entry time of Task F is 11:10 on July 25, 2024, Task E will be ranked ahead of Task F.
[0090] Regarding the case of inserting a new task midway, if task G is being processed, its priority is 80 and the entry time is 12:00 on July 25, 2024, and a new task H is inserted at this time, with a priority of 90 and an entry time of 12:05 on July 25, 2024. Since the priority of new task H is higher than that of task G, new task H will be placed before task G. If the new task I is inserted with a priority of 75 and an entry time of 12:02 on July 25, 2024, since its priority is lower than that of task G, new task I will be placed behind task G and wait for processing.
[0091] There are two main times for sorting: one is when a new task enters the system, it is immediately sorted and inserted according to the above comparison rules; the other is when the priority of an existing task changes due to certain conditions, such as the user adjusting the importance of the task, in which case its position in the queue will be readjusted according to the new priority after the current processing step is completed.
[0092] The specific example of setting the priority of the audio task in this embodiment is as follows:
[0093] First, define a series of constants and enumeration types to lay clear standards and boundaries for subsequent priority calculations. Specifically, three constants (i.e., pairs) EmergencyThreshold1, EmergencyThreshold2, and EmergencyThreshold3 are defined, with values of 3 seconds, 10 seconds, and 30 seconds, respectively, to accurately distinguish the time thresholds of tasks with different degrees of urgency. At the same time, the ImportanceLevel enumeration is created, covering the three levels of Critical (value 90, representing extremely important), Important (value 70, indicating important), and Moderate (value 40, meaning generally important). In addition, the UserExperienceImpactLevel enumeration is also defined, which includes the two levels of High (value 90, symbolizing high correlation) and Medium (value 70, indicating moderate correlation).
[0094] Next, we carefully constructed the AudioTask class, which includes key properties such as the task description (Description), estimated execution time (ExecutionTime), importance level (Importance), and impact level on user experience (UserExperienceImpact).
[0095] In the CalculatePriority method, follow these methodical steps to calculate the priority of a task:
[0096] In the initial stage, the priority variable priority is set to 0 to lay the foundation for subsequent calculations.
[0097] Next, the estimated execution time of the task is carefully compared with the previously defined time threshold. If the execution time is less than or equal to 3 seconds, the priority is increased by 95; if the execution time is between 3 seconds and 10 seconds (including 10 seconds), the priority is increased by 80; if the execution time is between 10 seconds and 30 seconds (including 30 seconds), the priority is increased by 50; and if the execution time is greater than 30 seconds, the priority is only increased by 1.
[0098] Then, the lower limit value corresponding to the importance level of the task is accumulated to the priority level. For example, when the importance level is Critical, 90 is accumulated to the priority level.
[0099] Then, the lower limit value corresponding to the impact level on user experience is also added to the priority. For example, if the impact level is High, 90 is added to the priority.
[0100] Finally, the accumulated priority sum is divided by 3, the final priority value is obtained by averaging, and it is returned.
[0101] The following is a third embodiment of the present invention, which is a more specific embodiment of the second embodiment.
[0102] Step S1 of this embodiment, task reception, is specifically implemented as follows:
[0103] After receiving the audio task, this embodiment uses a carefully designed specific parsing algorithm to perform in-depth and detailed preliminary disassembly and analysis of the task. The specific steps are as follows:
[0104] 1. Data extraction:
[0105] Assuming that a user instruction "increase the volume from 80% to 90%" is received, key elements are first extracted, including the initial volume "80%", the adjustment action "increase" and the target volume "90%".
[0106] For the timed audio parameter calibration tasks automatically generated within the system, such as "calibrate the high-frequency gain every 3 hours, with a range of -10dB to 10dB and an accuracy of 0.5dB", the calibration parameters "high-frequency gain", time setting "every 3 hours", calibration range "-10dB to 10dB" and accuracy requirement "0.5dB" are extracted.
[0107] 2. Format verification:
[0108] Check the format of the extracted data. In the User Volume Adjustment command, confirm that the format of "80%" and "90%" is correct and within the valid range of 0% to 100%. In the Calibration task, confirm that the time format "Every 3 hours" meets the standard and the numerical format of the range and precision is also correct.
[0109] If the data format is found to be incorrect, for example, the received user volume instruction is "increase the volume to 120%", which is beyond the valid range.
[0110] 3. Semantic analysis:
[0111] Understand the semantics of the instructions. For "Increase the volume from 80% to 90%", it is clear that it is a step-by-step increase. For the calibration task "Calibrate the high-frequency gain every 3 hours, with a range of -10dB to 10dB and an accuracy of 0.5dB", it is understood that the high-frequency gain is adjusted within the given range with an accuracy of 0.5dB every 3 hours.
[0112] 4. Parameter decomposition:
[0113] Decompose the composite parameters. For example, if you receive a command "adjust the left channel volume to 70% and the right channel volume to 80% at the same time", decompose it into the adjustment value "70%" for the left channel and the adjustment value "80%" for the right channel.
[0114] For instructions involving switching of multiple audio effects, such as "turn on the reverb effect and echo effect at the same time, with a reverb time of 2 seconds and an echo delay of 500 milliseconds", they are decomposed into the turning on state of the reverb effect and the reverb time parameters, as well as the turning on state of the echo effect and the echo delay parameters.
[0115] 5. Data standardization:
[0116] Convert the extracted and decomposed parameters into a standard format and unit that is unified within the system. For example, convert the volume percentage value into a specific value, and unify the time unit into milliseconds.
[0117] The next step is to convert the task into a format that the system can directly recognize and process, which includes the following specific operations:
[0118] Encoding conversion:
[0119] For example, the volume adjustment instruction input by the user may be in the form of text "increase the volume by 10%", and the system will convert it into a specific binary code, such as "01010110", so that the system can quickly identify and process it.
[0120] Parameter standardization:
[0121] For the volume parameter, no matter whether the user inputs "80%" or "0.8", it is uniformly converted into a numerical representation of the system's internal standard, such as an integer between 0 and 255, 80% corresponds to 204.
[0122] In terms of time parameters, if the user enters "every 5 minutes", the system will convert it into milliseconds, that is, 5*60*1000=300000 milliseconds.
[0123] Data structure adjustment:
[0124] The decomposed parameters are reorganized according to the data structure preset by the system. For example, the volume parameters of multiple audio channels are stored in an array of fixed length, and each element corresponds to the volume value of a channel.
[0125] Through the above operations such as encoding conversion, parameter standardization and data structure adjustment, the task can be presented in a format that the system can directly and efficiently process, making full and complete preparations for the subsequent processing flow.
[0126] Then, according to the pre-set classification rules, the tasks are divided into different types. For example, according to the urgency of the task, the user's real-time volume adjustment is classified as a high-urgency type, while the system's regular parameter calibration is classified as a medium-urgency type.
[0127] Finally, make full and complete preparations for the subsequent processing flow to ensure that the subsequent processing module can further process the task efficiently and accurately.
[0128] Step S2 of this embodiment, task sorting, is specifically implemented as follows:
[0129] 1. Factor Assessment:
[0130] Comprehensively consider multiple factors such as the urgency of the task and its importance to the system operation. For example, the task of adjusting the volume in real time during a live broadcast directly affects the user's real-time experience and is therefore extremely urgent.
[0131] Periodic background maintenance tasks, such as system data backup every 24 hours, are important but not immediate and are relatively less urgent.
[0132] 2. Priority assignment:
[0133] The task is assigned a corresponding priority parameter based on the evaluation results. For operational tasks with extremely high real-time requirements, such as users adjusting the volume in real time during a live broadcast, a higher priority parameter will be given, which may be set to 95.
[0134] For periodic background maintenance tasks, such as system data backup every 24 hours, the priority may be set to 20 because it is relatively less urgent.
[0135] 3. Queue:
[0136] After completing the priority setting, the task is accurately placed in the background calculation queue;
[0137] Ensure that the order of tasks is in strict accordance with the system's preset processing logic, and that high-priority tasks are placed at the front of the queue.
[0138] For example, when two tasks, "live broadcast volume adjustment" and "system data backup", are received at the same time, since the "live broadcast volume adjustment" task is more urgent and important, it will be placed at the front of the queue and processed first.
[0139] The existing priorities of this embodiment are preset in advance, and the types of tasks covered may have certain limitations, but this does not mean that there is no room for further expansion.
[0140] For the case where undefined operations are input into the system, the system has a certain degree of fault tolerance and adaptability, and will not directly refuse to execute when receiving undefined operations.
[0141] 1. First, an adaptive priority evaluation model can be built. When receiving new, undefined operations, the model can quickly and dynamically generate corresponding priorities based on some key features of the task, such as the urgency of resource requirements, the degree of impact on the overall system performance, and the relevance of the user's direct experience. This allows undefined operations to obtain appropriate priorities and have a chance to be executed.
[0142] 2. Secondly, use big data analysis and machine learning technology. By learning from a large amount of historical task data, the system can predict the priority of new tasks, even if these tasks have never appeared in the preset. For undefined operations, the system can try to assign priorities and resources to them based on the characteristics and processing methods of similar tasks to make execution possible.
[0143] 3. Third, establish a manual intervention mechanism. When encountering undefined operations, allow experienced administrators or professionals to assign priorities to them based on specific circumstances. Under manual judgment and intervention, decide whether to execute and how to execute the undefined operation.
[0144] In short, through these expansion methods, the system can be made more intelligent, flexible and comprehensive when processing tasks, so as to better cope with various complex and novel task types that may arise in the future, including undefined operations.
[0145] In this embodiment, in order to implement the sorting of task priorities, C# language can be used for programming:
[0146] First, define an AudioTask class to represent an audio processing task, which contains two properties: task name and priority. Next, create a class called PriorityComparer that implements IComparer. <audiotask>Interface used to define the rules for comparing task priorities.
[0147] In the Compare method of the PriorityComparer class, the comparison logic is clarified. If the priority of task x is higher than that of task y, -1 is returned, indicating that x should be ranked before y; if the priority of task x is lower than that of task y, 1 is returned, indicating that x should be ranked after y; if the priorities of the two are the same, 0 is returned.
[0148] In the Main method, an array tasks containing two AudioTask objects is created, namely the "live volume adjustment" task (priority 95) and the "system data backup" task (priority 20). First, print out the order of tasks before sorting, including the task name and the corresponding priority.
[0149] Then, call the Array.Sort method to sort the tasks array and pass in the custom PriorityComparer object as the comparator. After the sorting is completed, print out the sorted task order again.
[0150] This approach can ensure that high-priority tasks always take precedence over low-priority tasks in the processing order, thereby improving the efficiency and responsiveness of the audio processing system.
[0151] Specific sorting implementation algorithm:
[0152] Create an AudioTaskComparer class to implement IComparer <audiotask>The core purpose of this interface is to define comparison rules for audio tasks.
[0153] In the Compare method, follow the following rigorous process:
[0154] First, obtain the priority values of the two AudioTask objects x and y that need to be compared and calculate them through the CalculatePriority method.
[0155] Use the CompareTo method to compare the two priority values. If the comparison result is not 0, then the corresponding comparison result is returned according to the size of the priority values. In other words, the task with a larger priority value will be arranged first.
[0156] If the priority values are the same, then get the estimated execution time of x and y.
[0157] Use the CompareTo method again to compare the two execution times and return the corresponding comparison result. The task with the shorter execution time will be ranked higher.
[0158] When actually performing the sorting operation, the C# Array.Sort method is used skillfully, and the AudioTaskComparer object is passed in as a parameter. In this way, the Array.Sort method will strictly sort the audio task array in order according to the comparison logic defined in AudioTaskComparer.
[0159] Step S3 of this embodiment, background management, is specifically implemented as follows:
[0160] 1. Multi-threaded startup:
[0161] Enable multithreaded processing mode and create multiple threads to prepare for processing multiple tasks at the same time. For example, create independent threads for different types of tasks such as audio special effects processing and audio compression encoding. Set different priorities for each thread to ensure that threads with critical tasks are executed first.
[0162] 2. Task characteristics analysis:
[0163] Perform feature analysis on each task to be processed. Take the real-time audio mixing calculation task as an example. If the sampling rate is 48kHz, dual channels, and the duration is 10 minutes, and the algorithm involves complex spectrum synthesis and phase adjustment, it can be judged that the data volume is large and the algorithm is complex.
[0164] 3. Resource Demand Assessment:
[0165] Estimate resource requirements based on task characteristics. For the above real-time audio mixing task, it is calculated that 4 CPU cores and 2GB of memory may be required.
[0166] 4. Resource Allocation Decision:
[0167] Compare the current system resource status with the task requirements. Assuming that the current system has 8 available CPU cores and 6GB of available memory, the required resources can be allocated for the mixing task.
[0168] 5. Resource allocation execution:
[0169] Assign specific resources to the task. For example, assign 4 CPU cores and 2GB of memory to the above mixing task to ensure that it can be processed in a timely and accurate manner.
[0170] For example, for a complex real-time audio mixing calculation task, the sampling rate is 96kHz, 5.1 channels, the duration is 30 minutes, and the algorithm includes high-order filtering and dynamic range control. It is estimated that 6 CPU cores and 3GB of memory are required. The current system has 12 available CPU cores and 8GB of available memory, and the background calculation module will allocate corresponding resources to ensure the smooth progress of the task.
[0171] 6.Task management:
[0172] When new tasks are continuously pouring in, the module intelligently identifies and removes tasks that have not yet started to be executed based on the carefully pre-set rules. Especially at critical moments when system resources are tight, such as when the system memory usage reaches 85% and new tasks continue to be added, the module will comprehensively consider key factors such as task priority and estimated execution time for evaluation.
[0173] For example, for non-critical audio logging tasks, if their estimated execution time may exceed 15 seconds and their priority is only 10, they will be removed first to free up valuable system resources for ongoing and upcoming high-priority tasks; and for ongoing real-time audio special effects processing tasks, since their priority is as high as 90, even if system resources are tight, they will be fully guaranteed the resources they need to ensure that the tasks can be completed smoothly.
[0174] The algorithm implementation of calculating the resources required for the audio task in this embodiment is summarized as follows:
[0175] Create the ResourcePredictionModel class to implement the key functions of resource prediction.
[0176] In the PredictCpuCoreRequirement method, follow the following rigorous process:
[0177] First, get the AudioTask object task that needs to be predicted and the system's cpuCoreCount.
[0178] Then, depending on the specific characteristics of the task (such as sampling rate, number of channels, etc.) and the hardware characteristics of the system (such as the number of CPU cores), for example, the proportional relationship between sampling rate and CPU core requirements may be considered.
[0179] Specifically, we first conduct a detailed analysis of the large amount of historical data we have collected. These data include not only the characteristics of the task sampling rate, number of channels, audio duration, audio encoding format, but also performance indicators such as the number of CPU cores actually used to complete these tasks, memory usage, and processing time. By using data mining techniques such as association rule analysis and cluster analysis, we deeply explore the potential correlation and trends between different task characteristics and the number of CPU cores used.
[0180] Based on this, a multivariate nonlinear mathematical model is constructed. Assume that the model form is: the number of CPU cores required = a × sampling rate ^ b × number of channels ^ c × audio duration ^ d × e ^ (f × audio encoding format) + g. Among them, a, b, c, d, f and g are coefficients determined by methods such as multivariate regression analysis.
[0181] Next, the model is rigorously verified and optimized using a portion of data that is not involved in modeling. The accuracy of the model is evaluated by calculating indicators such as the mean square error (MSE) and mean absolute error (MAE) between the predicted value and the actual value. If the error is large, optimization algorithms such as stochastic gradient descent and Newton's method are used to adjust the coefficients to ensure the accuracy and reliability of the model.
[0182] When faced with a new audio task, we accurately obtain its characteristic values such as sampling rate, number of channels, audio duration, and audio encoding format. These characteristic values are substituted into the optimized mathematical model, and the estimated number of CPU cores required is obtained through rigorous calculation.
[0183] For example, for a task with a sampling rate of 48000 Hz, 2 channels, 60 seconds of audio, and MP3 audio encoding format, the model calculates: Assuming a = 0.01, b = 0.5, c = 0.3, d = 0.2, f = -0.1, g = 10, the number of CPU cores required = 0.01 × 48000^0.5 × 2^0.3 × 60^0.2 × e^(-0.1×1)+10≈8.5. Since the number of CPU cores is usually an integer, it is rounded up to 9 cores.
[0184] Finally, the predicted number of CPU cores required is returned, providing an important reference for efficient resource allocation.
[0185] In the characteristic analysis of audio tasks, the analysis criteria are mainly based on multiple key parameters and features of the task. For example, the sampling rate, the number of channels, the task duration, the complexity of the algorithms involved, etc. For audio mixing calculation tasks, the sampling rate of 48kHz is relatively high, the dual channels increase the amount of data, the duration of 10 minutes means a large data scale, and the complex spectrum synthesis and phase adjustment algorithms indicate high computational complexity.
[0186] The analysis results will be presented in a quantitative and classified form. For example, according to pre-set thresholds and standards, the data volume of the task will be divided into large, medium, and small levels, and the algorithm complexity will be divided into high, medium, and low levels.
[0187] Based on the analysis results, subsequent judgment execution will follow the following principles: for tasks with large data volumes and complex algorithms, more computing resources, such as more CPU cores and memory, will be allocated first; for simpler tasks, resources can be allocated relatively conservatively to achieve optimal utilization of resources.
[0188] The key points of this embodiment are:
[0189] First, we customized analysis parameters and standards that are more suitable for actual application scenarios based on the specific needs and characteristics of audio processing tasks. For example, we paid special attention to audio-specific parameters such as sampling rate and channels and set specific weights.
[0190] Secondly, it combines the overall architecture and resource management strategy of this system so that the feature analysis results can be more effectively integrated with subsequent resource allocation, task sequencing and execution strategies to form an organic whole, thereby achieving more efficient audio processing task management and optimization.
[0191] The task management of this embodiment can be implemented in code through the following key methods:
[0192] 1. "SendAsynMessage" method:
[0193] This method is used to implement the function of sending messages asynchronously. Inside the method, it first carefully checks whether there is a callback function. If it exists, it obtains the storage address of the message data through a specific function. Then, the relevant container mechanism is used to bind the callback method, so that after the task processing is completed, the corresponding notification or subsequent operation can be performed in time. Then, a carefully designed data sender object is created, which is designed to encapsulate the data to be sent and the detailed information of the network client related to it.
[0194] Then, different processing logic is executed according to the values of the passed parameters "Is it queued" and "Dictionary key". If the value of "Is it queued" is "Yes" and the "Dictionary key" is not "-1", the data sender object will be safely stored in the dictionary, and the "Dictionary key" will be used as the key index. However, if "Is it queued" is "Yes" and the "Dictionary key" is "-1", the lock mechanism will be enabled, and the data sender object will be queued in the sending queue in order according to the default low priority type.
[0195] Finally, by calling the relevant processing function, the message data is accurately sent to the target processing location, and a special waiting-for-processing flag is set to ensure the integrity and controllability of the entire process.
[0196] For example, when real-time audio adjustment information needs to be sent, this method can quickly and accurately transmit the relevant data.
[0197] 2. "SendCompressorParms" method:
[0198] This method mainly focuses on sending compressor parameters. When the method starts executing, it will strictly check whether the device information exists and is valid. Only when the device information is complete and valid will it proceed to the subsequent steps.
[0199] Next, the exact address of the output channel is obtained through a specific algorithm, and the compressor structure is cleverly converted into a byte array. Then, other related auxiliary methods are called to obtain the network client object, and the "SendAsynMessage" method is used to send it asynchronously. During the whole process, relevant debugging information and detailed operation logs are also output to facilitate subsequent troubleshooting and performance optimization.
[0200] For example, when adjusting audio compression effects, this method can ensure that the compressor parameters are accurately transferred and applied.
[0201] 3. "SendLinkageParms" method:
[0202] This method has the important responsibility of sending the linked channel parameters. First, it builds a complete list of linked channels through a series of logical operations. Then, by traversing this list, it calls the "SendCompressorParms" method one by one to send the compressor parameters, thus implementing the sending process of linked channel parameters in an orderly manner.
[0203] This method can ensure that the parameters of multiple linked channels can be sent and processed in a coordinated manner, ensuring the overall performance and stability of the system.
[0204] The task sorting mechanism based on the FIFO strategy in this embodiment: setting priorities for received tasks based on the first-in-first-out principle to ensure the rationality and efficiency of the task processing sequence. This strategy can accurately sort tasks according to their urgency and importance, effectively improving the system's response speed and processing efficiency.
[0205] Background thread computing tasks: Tasks are scheduled to independent background threads for computing, which realizes the parallelization of task processing and other system operations, avoids the interference of task processing on the foreground operations of the system, and improves the overall performance of the system.
[0206] Intelligent task management: When new tasks continue to be added, tasks that have not yet been started can be cleared in a timely manner, especially those with lower priority or less impact on the overall operation of the system. This intelligent screening and elimination mechanism can optimize system resource allocation and ensure the smooth execution of key tasks.
[0207] Collaborative work of multiple core modules: The system architecture is composed of a task receiving module, a task sorting module, a background computing module and a task management module. Each module works closely together and performs its own duties, forming an efficient and stable audio processing system.
[0208] Dynamic allocation of system resources: The background computing module can dynamically allocate computing resources according to the characteristics and requirements of the task, such as the number of CPU cores, memory usage, etc., to fully utilize the system hardware resources and improve the accuracy and timeliness of task processing.
[0209] The present invention also discloses a terminal device, including a processor and a storage device, the storage device is used to store one or more programs; when one or more programs are executed by the processor, the processor implements the above-mentioned audio task processing method based on the first-in first-out strategy. The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The processor is the control center of the test equipment, and various interfaces and lines are used to connect the various parts of the entire test equipment.
[0210] The storage device can be used to store computer programs and / or modules. The processor realizes various functions of the terminal device by running or executing the computer programs and / or modules stored in the storage device and calling the data stored in the storage device. The storage device can mainly include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required for a function, etc.; the data storage area can store data created according to the use of the terminal device, etc. In addition, the storage device can include a high-speed random access memory, and can also include a non-volatile memory, such as a hard disk, a memory, a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), at least one disk storage device, a flash memory device, or other volatile solid-state storage devices.
[0211] Wherein, if the module / unit integrated in the audio task processing system based on the first-in-first-out strategy is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the present invention implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in at least one computer-readable storage medium. When the computer program is executed by the processor, the steps of the above-mentioned various method embodiments can be implemented. Wherein, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file or some intermediate form. The computer-readable medium can include: any entity or device capable of carrying computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.
[0212] It should be noted that the embodiments of the devices and apparatuses described above are only illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place, or may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.< / audiotask> < / audiotask>
Claims
1. A method for processing audio tasks based on a first-in-first-out strategy, characterized in that: The steps include: Acquire a newly created audio task, and convert the data of the audio task into a standardized format to obtain task data; According to the preset urgency of the audio task, the task data is prioritized and a priority parameter is added to the task data. The remaining task data except the real-time priority is exported to the background management queue in the order of priority parameters from large to small. The priority classification includes real-time priority, high priority and low priority. Run the background processing function; the background processing function performs the following steps when running: Perform feature analysis on the task data in the background management queue to obtain the task features corresponding to each task data; Allocate computing resources to execute real-time priority task data; Calculate the resource requirements corresponding to the task characteristics, allocate computing resources to the task data in the background management queue in turn according to the remaining resources and resource requirements of the system, and remove the task data from the background management queue; When the usage rate of the system resources is greater than the first threshold, the task data with the lowest priority parameter in the background management queue is removed.
2. The audio task processing method based on the first-in-first-out strategy according to claim 1, characterized in that: The step of acquiring a newly created audio task and converting the data of the audio task into a standardized format to obtain task data also includes the following steps: Verifying the data format of the audio task to confirm whether the data format of the audio task complies with the standard; When there is an error in the data format of the audio task, an error prompt is issued and a request is made to re-enter the audio task; When the data format of the audio task is correct, the audio task is converted into task data in a unified standard format through semantic parsing, complex parameter decomposition, encoding conversion and data structure reorganization.
3. The audio task processing method based on the first-in-first-out strategy according to claim 1, characterized in that: The method of prioritizing the task data according to the preset urgency of the audio task and adding a priority parameter to the task data includes the following steps: Based on the neural network, the preset audio task urgency and the key features of the corresponding audio task are used as training data to create and train an adaptive priority evaluation model; When new task data is detected, determining whether the task data has a corresponding preset audio task urgency; If yes, the task data is prioritized and a priority parameter is added to the task data; If not, obtain the key features of the audio task, and generate the priority classification and priority parameters of the audio task through an adaptive priority evaluation model.
4. The audio task processing method based on the first-in-first-out strategy according to claim 1, characterized in that: The background processing function is implemented in the following steps: Use a separate background thread to run background processing functions in a multi-threaded system; The background processing function creates multiple threads for processing multiple task data simultaneously.
5. The audio task processing method based on the first-in-first-out strategy according to claim 1, characterized in that: The method of prioritizing the task data according to the preset urgency of the audio task and adding a priority parameter to the task data includes the following steps: When a newly created audio task does not have a preset audio task urgency, a pop-up window is used to request the operator to set a priority category and priority parameters for the audio task.
6. An audio task processing system based on a first-in-first-out strategy, characterized in that: include: Task receiving module, task sorting module and background management module; The task receiving module is used to obtain the newly created audio task and convert the data of the audio task into a standardized format to obtain task data; The task sorting module is used to prioritize the task data according to the preset urgency of the audio task, and add a priority parameter to the task data; wherein the priority classification includes real-time priority, high priority and low priority; and the remaining task data except the real-time priority are exported to the background management queue in the order of priority parameters from large to small at a regular time; The background management module is used to run the background processing function; the background processing function performs the following steps when running: Perform feature analysis on the task data in the background management queue to obtain the task features corresponding to each task data; Allocate computing resources to execute real-time priority task data; Calculate the resource requirements corresponding to the task characteristics, allocate computing resources to the task data in the background management queue in turn according to the remaining resources and resource requirements of the system, and remove the task data from the background management queue; When the usage rate of the system resources is greater than the first threshold, the task data with the lowest priority parameter in the background management queue is removed.
Citation Information
Patent Citations
Method and terminal for managing program memory footprint
CN105824702A
Multimedia data processing method and equipment
CN112000454A
Big data computing resource processing method, system and device, medium and program product
CN115543631A
Task processing method and electronic equipment
CN116737330A
Thread scheduling method and device, electronic equipment and storage medium
CN117271092A
