WO2023193632A1 - Audio thread processing method and apparatus, computer device and storage medium - Google Patents

Audio thread processing method and apparatus, computer device and storage medium Download PDF

Info

Publication number
WO2023193632A1
WO2023193632A1 PCT/CN2023/084321 CN2023084321W WO2023193632A1 WO 2023193632 A1 WO2023193632 A1 WO 2023193632A1 CN 2023084321 W CN2023084321 W CN 2023084321W WO 2023193632 A1 WO2023193632 A1 WO 2023193632A1
Authority
WO
WIPO (PCT)
Prior art keywords
audio
thread
status notification
instance
address
Prior art date
Application number
PCT/CN2023/084321
Other languages
French (fr)
Chinese (zh)
Inventor
袁章敬
潘风
周暄承
史岩峰
曾镇城
张冬
孙念
Original Assignee
北京字节跳动网络技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 北京字节跳动网络技术有限公司 filed Critical 北京字节跳动网络技术有限公司
Publication of WO2023193632A1 publication Critical patent/WO2023193632A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues

Definitions

  • the present disclosure relates to the field of computer technology, and specifically, to an audio thread processing method, device, computer equipment and storage medium.
  • the IOS system When an application in the IOS system plays audio, it needs to create an audio instance for playing audio. When the audio stops playing, the thread running the audio instance will call the destruction function to destroy the audio instance. But at the same time, the IOS system also runs an audio status notification thread for notifying the status information of each audio played in the system. When the audio stops playing, the audio status notification thread also needs to be run to generate notification information for notifying the audio to stop playing and feed it back to the application.
  • the audio status notification thread and the audio instance destruction thread will run at the same time, which will cause the system to freeze or even crash.
  • Embodiments of the present disclosure provide at least an audio thread processing method, device, computer equipment, and storage medium.
  • embodiments of the present disclosure provide an audio thread processing method, including:
  • the first thread is used to execute the audio instance destruction function to destroy the audio instance.
  • the running status of the audio status notification thread is detected according to the following steps:
  • the running status is determined based on the call stack information.
  • the method further includes:
  • determining the running status based on the call stack information includes:
  • determining the running status includes: the audio status notification thread has fed back the audio status notification information for the audio.
  • the method further includes:
  • the step of pointing to the instruction address is until it is determined that the target call library address does not exist among the plurality of call library addresses.
  • the method further includes:
  • the instruction address includes a program counter PC address and a return address
  • Determining whether the audio status notification thread is in an idle state according to the instruction address includes:
  • the audio status notification thread's running status before detecting the audio status notification thread's running status, it also includes:
  • Using the first thread to execute the audio instance destruction function to destroy the audio instance includes:
  • the storage location of the audio instance is determined, and the first thread is used to execute the audio instance destruction function to destroy the audio instance at the storage location.
  • embodiments of the present disclosure also provide an audio thread processing device, including:
  • the first processing module is used to point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback;
  • a calling module configured to use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function when the audio stops playing;
  • An acquisition module used to acquire the running status of the audio status notification thread detected by executing the audio processing function
  • Execution module configured to use the first thread to execute the audio instance destruction function to destroy the audio instance destruction function when the running status indicates that the audio status notification thread has fed back the audio status notification information for the audio. Audio example.
  • the device further includes:
  • Detection module used to detect the running status of the audio status notification thread according to the following steps
  • the running status is determined based on the call stack information.
  • the detection module is also configured to wait for a first preset period of time before returning to execute the acquisition of the audio when it is determined that the audio status notification thread is not in an idle state. The step of determining the instruction address pointed by the status notification thread at the current moment until it is determined that the audio status notification thread is in an idle state.
  • the detection module is configured to determine whether there is a target call library address corresponding to the target logical library from the multiple call library addresses included in the call stack information; Audio interruption processing logic information is stored, and the audio interruption processing logic information is used to generate audio status notification information;
  • determining the running status includes: the audio status notification thread has fed back the audio status notification information for the audio.
  • the detection module is further configured to resume execution of the audio status notification thread when the target call library address exists among multiple call library addresses, and wait for the third call library address. After a preset period of time, return to the step of obtaining the instruction address pointed by the audio status notification thread at the current moment until it is determined that the target call library address does not exist among the multiple call library addresses.
  • the device further includes:
  • a second processing module configured to, after using the first thread to execute the audio instance destruction function to destroy the audio instance, resume execution of the audio status notification thread to utilize the executed audio status notification Thread, generates audio status notification information for other audios and feeds it back to the application.
  • the instruction address includes a program counter PC address and a return address
  • the detection module is configured to determine that the audio status notification thread is in an idle state when it is determined that the PC address and the return address both match the address corresponding to the target function body.
  • the device further includes a storage module:
  • the storage module is used to determine the reference information corresponding to the audio instance and store the reference information before detecting the running status of the audio status notification thread;
  • the execution module is configured to determine the storage location of the audio instance according to the stored reference information, and use the first thread to execute the audio instance destruction function to destroy the audio at the storage location. Example.
  • an optional implementation manner of the present disclosure also provides a computer device, a processor, and a memory.
  • the memory stores machine-readable instructions executable by the processor, and the processor is configured to execute the instructions stored in the memory. machine-readable instructions. When the machine-readable instructions are executed by the processor, the When the machine-readable instructions are executed by the processor, the steps in the above-mentioned first aspect or any possible implementation manner of the first aspect are performed.
  • an optional implementation manner of the present disclosure also provides a computer-readable storage medium.
  • the computer-readable storage medium stores a computer program. When the computer program is run, it executes the above-mentioned first aspect, or any of the first aspects. steps in a possible implementation.
  • the audio thread processing method, device, computer equipment and storage medium provided by the embodiments of the present disclosure use the first thread to call the audio processing function pointed to by the audio instance destruction function when the audio stops playing, and then detect the audio thread by executing the audio processing function.
  • the running status of the audio status notification thread can accurately determine whether the audio status notification thread has fed back the audio status notification information for the audio that has stopped playing before using the first thread to execute the audio instance destruction function to destroy the audio instance. . Then, when it is determined that the audio status notification information has been fed back, the first thread is used to execute the audio instance destruction function to destroy the audio instance.
  • Figure 1 shows a flow chart of an audio thread processing method provided by an embodiment of the present disclosure
  • Figure 2 shows a specific implementation flow chart of an audio thread processing method provided by an embodiment of the present disclosure
  • Figure 3 shows a schematic diagram of an audio thread processing device provided by an embodiment of the present disclosure
  • FIG. 4 shows a schematic structural diagram of a computer device provided by an embodiment of the present disclosure.
  • the present disclosure provides an audio thread processing method, device, computer equipment and storage medium, which uses a preset audio processing function to limit the execution order of the audio status notification thread and the first thread that destroys the audio instance, that is, It will not affect the operation of the first thread that destroys the audio instance and the audio status notification thread in the system. It also avoids the concurrent execution of the audio status notification thread and the first thread that destroys the audio instance. Furthermore, it avoids the two threads competing for system resources. , causing the system to freeze or crash.
  • PC Program Counter
  • the execution subject of the method of using online course resources provided by this embodiment of the disclosure generally has certain computing capabilities.
  • Terminal equipment or other processing equipment where the terminal equipment can be user equipment (User Equipment, UE), mobile equipment, user terminals, terminals, personal digital processing equipment (Personal Digital Assistant, PDA), handheld devices, computer equipment, etc.; in In some possible implementations, the method of using the online course resources can be implemented by the processor calling computer-readable instructions stored in the memory.
  • the audio thread processing method provided by the embodiment of the present disclosure will be described below by taking the execution subject as a computer device as an example.
  • a flow chart of an audio thread processing method may include the following steps:
  • S101 Point the calling entry point of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback.
  • the above-mentioned application can be any application running in the IOS system and capable of audio playback.
  • the audio instance destruction function is used in the IOS system to destroy the created audio instance (audio unit).
  • the audio unit is created during audio playback and is used for audio playback. It can be destroyed when the audio stops playing, thereby releasing system resources. Stopping audio playback may include, but is not limited to, two situations: audio content completion and ongoing playback being interrupted.
  • the audio processing function (My_dispose function) is a preset processing function, which corresponds to a piece of audio processing logic and is used to detect the audio status notification thread in the system to see whether the audio status notification information for the currently stopped audio has been fed back.
  • the GOTHook method can be used to add the audio files corresponding to the applications in the IOS system.
  • the call entry point of the frequency instance destruction function points to the preset audio processing function.
  • GOT is a storage table for function address information, which can store various functions corresponding to the IOS system, such as execution functions, destruction functions, replacement functions, etc.
  • GOTHOOK is a way to replace the function address stored in the GOT table with the address corresponding to other functions.
  • the calling entry points of the audio instance destruction functions corresponding to each application can be directed to the preset audio processing function.
  • the call entry point of the unique audio instance destruction function can be directed to the preset audio processing function.
  • the first thread can be any thread running in the application, and specifically it can be the thread of the audio instance corresponding to the audio that is currently stopped playing.
  • the first thread when the audio stops playing, the first thread can be used to call the audio instance destruction function. Since the entry address corresponding to the first audio instance destruction function has been replaced with the address corresponding to the preset audio processing function, therefore, in After calling the audio instance destruction function, the audio processing function pointed to by the replaced entry address will be automatically called. In this way, the first thread running the audio instance is used to call the audio processing function pointed by the call entry point of the audio instance destruction function.
  • the audio status notification thread is a default notification thread in the IOS system, that is, AVAudioSession Notify Thread, which is used to send the audio status in the IOS system to the audio corresponding application. For example, generate a notification that the audio is currently playing, generate a notification that the audio has stopped playing, Generate a notification that audio playback is abnormal.
  • the audio status notification thread can be created when audio playback appears for the first time in the IOS system. It can always exist after creation and is used to notify the status of each audio in the IOS system.
  • the running status is used to indicate whether the audio status notification thread has generated and fed back audio status notification information for the audio that is currently stopped playing.
  • the audio processing function can be executed, and the running status of the audio status notification thread is detected according to the detection logic indicated by the audio processing function. Furthermore, by executing the audio processing function, the running status of the detected audio status notification thread can be obtained.
  • the running status of the audio status notification thread can be measured according to the following steps:
  • Step 1 Determine the audio status notification thread from the multiple threads running in the application.
  • an application can run multiple threads, such as audio thread, system default thread, screen display thread, etc.
  • the audio status notification thread can be determined from multiple threads running in the application.
  • Step 2 Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address.
  • the instruction address is used to indicate the pointer address corresponding to the audio status notification thread.
  • mach_msg function body the target function body
  • the mach_msg function is a function used to indicate whether the thread is running in the processor.
  • the audio status notification thread is in an idle state; otherwise, it can be determined that the audio status notification thread is not in an idle state, that is, it is running.
  • the audio status notification thread when it is determined that the audio status notification thread is not in an idle state, it means that the current audio status notification thread is still executing, and a timer timer can be created, and the timer will count to the first preset duration.
  • a timer timer can be created, and the timer will count to the first preset duration.
  • the first preset time length may be a waiting time preset by the developer.
  • the first preset time length may be 10 seconds (S), 8S and so on.
  • the instruction address may include at least one of a PC address and a return address corresponding to the audio status notification thread.
  • the instruction address only includes the PC address or the return address, and it is determined that this address is located in the mach_msg function body, it can be determined that the audio status notification thread is in an idle state.
  • the instruction address includes both the PC address and the return address
  • it is necessary to determine that both the PC address and the return address match the address corresponding to the target function body that is, it is necessary to determine that both the PC address and the return address are located in the mach_msg function. Only when the audio status notification thread is idle can the body be determined. Otherwise, it is determined that the audio status notification thread is not idle. In this way, using the PC address and the return address to check the idle state can improve the accuracy of the idle state of the determined audio state notification thread.
  • Step 3 If yes, pause the execution of the audio status notification thread, and perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread.
  • the call stack information includes the addresses of various call libraries called by the audio status notification thread during execution.
  • the audio status notification thread in the idle state may be suspended.
  • a stack backtracing operation for the audio status notification thread can be performed to determine the address of each call library called by the audio status notification thread during execution, that is, the call stack information is obtained.
  • Step 4 Determine the running status based on the call stack information.
  • step 4 can be implemented according to the following steps: determine whether there is a target call library address corresponding to the target logic library from the multiple call library addresses included in the call stack information, wherein the target logic library can specifically It is libEmbeddedSystemAUs.dylib, which stores audio interruption processing logic information.
  • the audio interruption processing logic information is used to generate audio status notification information.
  • libEmbeddedSystemAUs.dylib is a system library created in the IOS system to store audio interruption processing logic information.
  • the audio status notification thread can perform audio interruption processing operations based on the audio interruption processing logic information to generate audio status notification information.
  • the audio status notification thread has currently finished executing the audio that is currently stopped playing. Audio interrupt processing operation.
  • the running status of the audio status notification thread includes: the audio status notification thread has generated audio status notification information for the audio that is currently stopped playing, and has fed back to the application corresponding to the audio.
  • the target call library address exists among the multiple call library addresses included in the call stack information, it means that the audio status notification thread has not completed the audio interruption processing operation for the audio that is currently stopped playing, and needs to continue execution. Therefore, it is necessary to resume execution of the idle audio status notification thread that was suspended when executing step three above, and create a timer. When it is determined that the timer counts to the second preset duration, return to step two and step three above. , until it is determined that the target call library address does not exist among the multiple call library addresses included in the call stack information.
  • step 2 above the reason why we need to return to step 2 above is because during the execution process of the audio status notification thread, the corresponding instruction address it points to will change in real time. Then, the result of whether the audio status notification thread is in an idle state will also follow. Variety. Therefore, by returning to step 2 above, the idle state of the audio status notification thread can be re-determined, and then the accurate running status corresponding to the audio status notification thread can be determined.
  • the above-mentioned second preset time length is also the waiting time preset by the developer, which may be equal to the first preset time length, or may not be equal to the first preset time length, and is not limited here.
  • the audio status notification information is used to notify the application that the audio has stopped playing.
  • the first thread can be used to execute the audio instance destruction function corresponding to the audio that is currently stopped playing, so as to realize the destruction of the audio instance.
  • the detection logic indicated by the audio processing function can be specifically: First, check whether the audio status notification thread is idle. If not, wait for the first preset time period and recheck whether the audio status notification thread is idle until it is determined that the audio status notification thread is idle. If so, detect whether the target call library address corresponding to the target logic library exists among the multiple call library addresses corresponding to the audio status notification thread. If it does not exist, determine that the running status is that audio status notification information for the currently stopped playing audio has been generated. and give feedback. If it exists, wait for the second preset time period, return to execution and detect whether the audio status notification thread is idle, until it is determined that the target call library address is not included in the multiple call library addresses. Furthermore, the audio instance destruction function can be executed to destroy the audio instance.
  • the audio status notification thread at this time is still in a suspended state. Therefore, the execution of the audio status notification thread can also be resumed to use the executed audio status notification thread to generate audio status notification information for other audios and feed it back to the application.
  • the audio status notification thread can be used to generate audio status notification information for subsequent audio played in the system, for example, generate a notification to start playing the audio currently, and generate a notification to stop the audio playing. Therefore, the audio status notification information corresponding to each audio played in the system can be obtained in time.
  • reference information corresponding to the audio instance may also be determined and the reference information may be stored.
  • the reference information is used to indicate the storage location of the audio instance.
  • the reference information may be the pointer address, reference relationship, storage address and other information corresponding to the audio instance.
  • the storage location of the audio instance can be determined according to the reference information corresponding to the stored audio instance. Afterwards, the first thread can be used to execute the audio instance destruction function to destroy the audio instance stored at the storage location.
  • the preset audio processing function is used to limit the execution order of the audio status notification thread and the first thread that destroys the audio instance, which will not affect the first thread that destroys the audio instance and the audio status in the system.
  • the running of the notification thread also avoids the concurrent execution of the audio status notification thread and the first thread that destroys the audio instance; furthermore, it effectively avoids the problem of system lag or crash caused by two threads competing for system resources.
  • a process diagram can include the following steps:
  • S203 Determine the audio status notification thread from multiple threads running in the application.
  • S204 Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address.
  • the instruction address may include a PC address and a return address.
  • execute S205 If yes, execute S205; if not, start a timer, and after the timer count reaches the first preset duration, return to execute S204 until it is determined that the audio status notification thread is in an idle state.
  • S205 Perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread.
  • S206 Determine whether there is a target call library address corresponding to the target logical library from the multiple call library addresses included in the call stack information.
  • determine that the running status corresponding to the audio status notification thread includes: the audio status notification thread has fed back audio status notification information for audio, and execute S207; if yes, resume execution of the audio status notification thread, and start the timer. After the timer count reaches the second preset duration, execution returns to S204 until it is determined that the target call library address does not exist among the multiple call library addresses.
  • S207 Use the first thread to execute the audio instance destruction function to destroy the audio instance.
  • the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process.
  • the specific execution order of each step should be based on its function and possible The internal logic is determined.
  • the embodiment of the present disclosure also provides an audio thread processing device corresponding to the audio thread processing method. Since the principle of solving the problem of the device in the embodiment of the present disclosure is similar to the above-mentioned audio thread processing method of the embodiment of the present disclosure, therefore For the implementation of the device, please refer to the implementation of the method, and repeated details will not be repeated.
  • a schematic diagram of an audio thread processing device provided by an embodiment of the present disclosure includes:
  • the first processing module 301 is used to point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback ;
  • the calling module 302 is configured to use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function when the audio stops playing;
  • the acquisition module 303 is used to obtain the running status of the audio status notification thread detected by executing the audio processing function
  • Execution module 304 configured to use the first thread to execute the audio instance destruction function to destroy all audio instances when the running status indicates that the audio status notification thread has fed back the audio status notification information for the audio. Describe audio examples.
  • the device further includes:
  • Detection module 305 used to detect the running status of the audio status notification thread according to the following steps
  • the running status is determined based on the call stack information.
  • the detection module 305 is also configured to wait for a first preset period of time before returning to execute the acquisition of the audio status notification thread when it is determined that the audio status notification thread is not in an idle state.
  • the detection module 305 is configured to determine whether there is a target call library address corresponding to the target logic library from the multiple call library addresses included in the call stack information; the target logic library Audio interruption processing logic information is stored in, and the audio interruption processing logic information is used to generate audio status notification information;
  • determining the running status includes: the audio status notification thread has fed back the audio status notification information for the audio.
  • the detection module 305 is also configured to resume execution of the audio status notification thread when the target call library address exists among multiple call library addresses, and wait for After the second preset period of time, the step of obtaining the instruction address pointed by the audio status notification thread at the current moment is returned to execution until it is determined that the target call library address does not exist among the plurality of call library addresses.
  • the device further includes:
  • the second processing module 306 is configured to, after using the first thread to execute the audio instance destruction function to destroy the audio instance, resume execution of the audio status notification thread to utilize the executed audio status
  • the notification thread generates audio status notification information for other audios and feeds it back to the application.
  • the instruction address includes a program counter PC address and a return address
  • the detection module 305 is configured to determine that the audio status notification thread is in an idle state when it is determined that both the PC address and the return address match the address corresponding to the target function body.
  • the device further includes a storage module 307:
  • the storage module 307 is configured to determine the reference information corresponding to the audio instance and store the reference information before detecting the running status of the audio status notification thread;
  • the execution module 304 is configured to determine the storage location of the audio instance according to the stored reference information, and use the first thread to execute the audio instance destruction function to destroy the audio instance at the storage location. Audio example.
  • a schematic structural diagram of a computer device provided by an embodiment of the present application includes:
  • Processor 41 memory 42 and bus 43.
  • the memory 42 stores machine-readable instructions executable by the processor 41
  • the processor 41 is used to execute the machine-readable instructions stored in the memory 42 .
  • the processor 41 executes The following steps: S101: Point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback; S102: when the audio stops In the case of playback, use the first thread running the audio instance to call the audio instance destruction function pointed to Audio processing function; S103: Obtain the running status of the audio status notification thread detected by executing the audio processing function and S104: In the case where the running status indicates that the audio status notification thread has fed back audio status notification information for audio, use The first thread executes the audio instance destruction function to destroy the audio instance.
  • the above-mentioned memory 42 includes a memory 421 and an external memory 422; the memory 421 here is also called an internal memory, and is used to temporarily store the operation data in the processor 41, as well as the data exchanged with external memory 422 such as a hard disk.
  • the processor 41 communicates with the processor 42 through the memory 421.
  • the external memory 422 performs data exchange.
  • the processor 41 and the memory 42 communicate through the bus 43, so that the processor 41 executes the execution instructions mentioned in the above method embodiment.
  • Embodiments of the present disclosure also provide a computer-readable storage medium.
  • a computer program is stored on the computer-readable storage medium.
  • the storage medium may be a volatile or non-volatile computer-readable storage medium.
  • the computer program product of the audio thread processing method provided by the embodiment of the present disclosure includes a computer-readable storage medium storing program code.
  • the instructions included in the program code can be used to execute the audio thread processing method described in the above method embodiment. For details of the steps, please refer to the above method embodiments and will not be described again here.
  • the computer program product can be implemented specifically through hardware, software or a combination thereof.
  • the computer program product is embodied as a computer storage medium.
  • the computer program product is embodied as a software product, such as a Software Development Kit (SDK), etc. wait.
  • SDK Software Development Kit
  • the disclosed devices and methods can be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division.
  • multiple units or components may be combined.
  • some features can be ignored, or not implemented.
  • the coupling or direct coupling or communication connection between each other shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separate, as The components shown in a unit may or may not be a physical unit, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
  • each functional unit in various embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
  • the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor.
  • the technical solution of the present disclosure is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product.
  • the computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code. .
  • the products applying the technical solution of this application will clearly inform the personal information processing rules and obtain the individual's independent consent before processing personal information.
  • the product applying the technical solution in this application must obtain the individual's separate consent before processing sensitive personal information, and meet the requirement of "express consent" at the same time. For example, setting up clear and conspicuous signs on personal information collection devices such as cameras to inform them that they have entered the scope of personal information collection, and that personal information will be collected.
  • personal information processing rules may include personal information processing rules.
  • Information processors purposes of personal information processing, processing methods, types of personal information processed, etc.

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The present disclosure provides an audio thread processing method and apparatus, a computer device and a storage medium. The method comprises: pointing, to a preset audio processing function, a call entry of an audio instance destruction function corresponding to an application, wherein the audio instance destruction function is used for destructing a created audio instance, and the audio instance is used for audio playback; in the case of stopping audio playback, calling, by using a first thread running the audio instance, the audio processing function to which the audio instance destruction function points; acquiring a running state of an audio state notification thread detected by executing the audio processing function; and in the case that the running state indicates that the audio state notification thread feeds back audio state notification information for the audio, executing, by using the first thread, the audio instance destruction function to destruct the audio instance.

Description

一种音频线程处理方法、装置、计算机设备和存储介质Audio thread processing method, device, computer equipment and storage medium
本申请要求于2022年4月6日提交中国国家知识产权局、申请号为202210365555.0、申请名称为“一种音频线程处理方法、装置、计算机设备和存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the State Intellectual Property Office of China on April 6, 2022, with application number 202210365555.0 and the application title "An audio thread processing method, device, computer equipment and storage medium", which The entire contents are incorporated herein by reference.
技术领域Technical field
本公开涉及计算机技术领域,具体而言,涉及一种音频线程处理方法、装置、计算机设备和存储介质。The present disclosure relates to the field of computer technology, and specifically, to an audio thread processing method, device, computer equipment and storage medium.
背景技术Background technique
IOS系统中的应用在播放音频时,需要创建用于播放音频的音频实例,在音频停止播放情况下,运行音频实例的线程将调用销毁函数进行音频实例的销毁。但同时,IOS系统还运行有用于通知系统中播放的各个音频的状态信息的音频状态通知线程。在音频停止播放的情况下,也需要运行音频状态通知线程,以生成用于通知音频停止播放的通知信息并反馈给应用。When an application in the IOS system plays audio, it needs to create an audio instance for playing audio. When the audio stops playing, the thread running the audio instance will call the destruction function to destroy the audio instance. But at the same time, the IOS system also runs an audio status notification thread for notifying the status information of each audio played in the system. When the audio stops playing, the audio status notification thread also needs to be run to generate notification information for notifying the audio to stop playing and feed it back to the application.
如此,在某一音频停止播放时,将会出现音频状态通知线程和进行音频实例销毁的线程同时运行的情况,进而将引发系统出现卡顿甚至死机的问题。In this way, when a certain audio stops playing, the audio status notification thread and the audio instance destruction thread will run at the same time, which will cause the system to freeze or even crash.
发明内容Contents of the invention
本公开实施例至少提供一种音频线程处理方法、装置、计算机设备和存储介质。Embodiments of the present disclosure provide at least an audio thread processing method, device, computer equipment, and storage medium.
第一方面,本公开实施例提供了一种音频线程处理方法,包括:In a first aspect, embodiments of the present disclosure provide an audio thread processing method, including:
将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数;所述音频实例销毁函数用于销毁创建的音频实例;所述音频实例用于进行音频播放;Point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback;
在音频停止播放的情况下,利用运行所述音频实例的第一线程调用所述音频实例销毁函数指向的所述音频处理函数;When the audio stops playing, use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function;
获取通过执行所述音频处理函数,检测到的音频状态通知线程的运行状态;Obtain the running status of the audio status notification thread detected by executing the audio processing function;
在所述运行状态指示所述音频状态通知线程已反馈针对所述音频的音频状态通知信息的情况下,利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例。When the running status indicates that the audio status notification thread has fed back the audio status notification information for the audio, the first thread is used to execute the audio instance destruction function to destroy the audio instance.
在一种可能的实施方式中,根据以下步骤检测音频状态通知线程的运行状态: In a possible implementation, the running status of the audio status notification thread is detected according to the following steps:
从所述应用中运行的多个线程中,确定出所述音频状态通知线程;Determine the audio status notification thread from a plurality of threads running in the application;
获取所述音频状态通知线程在当前时刻指向的指令地址,并根据所述指令地址,确定所述音频状态通知线程是否处于空闲状态;Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address;
若是,则暂停执行所述音频状态通知线程,并执行对所述音频状态通知线程的栈回溯操作,确定所述音频状态通知线程对应的调用栈信息;If so, suspend the execution of the audio status notification thread, and perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread;
根据所述调用栈信息,确定所述运行状态。The running status is determined based on the call stack information.
在一种可能的实施方式中,所述方法还包括:In a possible implementation, the method further includes:
在确定所述音频状态通知线程未处于空闲状态的情况下,等待第一预设时长后返回执行获取所述音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定所述音频状态通知线程处于空闲状态。When it is determined that the audio status notification thread is not in an idle state, wait for the first preset time and then return to the step of obtaining the instruction address pointed by the audio status notification thread at the current moment until the audio status notification thread is determined. In idle state.
在一种可能的实施方式中,所述根据所述调用栈信息,确定所述运行状态,包括:In a possible implementation, determining the running status based on the call stack information includes:
从所述调用栈信息包括的多个调用库地址中,确定是否存在目标逻辑库对应的目标调用库地址;所述目标逻辑库中存储有音频打断处理逻辑信息,所述音频打断处理逻辑信息用于生成音频状态通知信息;From the multiple call library addresses included in the call stack information, determine whether there is a target call library address corresponding to the target logic library; audio interruption processing logic information is stored in the target logic library, and the audio interruption processing logic Information is used to generate audio status notification information;
若不存在所述目标调用库地址,则确定所述运行状态包括:所述音频状态通知线程已反馈针对所述音频的音频状态通知信息。If the target call library address does not exist, determining the running status includes: the audio status notification thread has fed back the audio status notification information for the audio.
在一种可能的实施方式中,所述方法还包括:In a possible implementation, the method further includes:
在多个所述调用库地址中存在所述目标调用库地址的情况下,恢复执行所述音频状态通知线程,并在等待第二预设时长后返回执行获取所述音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定多个所述调用库地址中不存在所述目标调用库地址。When the target call library address exists in multiple call library addresses, resume execution of the audio status notification thread, and return to execution after waiting for the second preset time period to obtain the audio status notification thread at the current moment. The step of pointing to the instruction address is until it is determined that the target call library address does not exist among the plurality of call library addresses.
在一种可能的实施方式中,在所述利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例之后,还包括:In a possible implementation, after using the first thread to execute the audio instance destruction function to destroy the audio instance, the method further includes:
恢复执行所述音频状态通知线程,以利用执行的所述音频状态通知线程,生成针对其他音频的音频状态通知信息并反馈给所述应用。Resume execution of the audio status notification thread to use the executed audio status notification thread to generate audio status notification information for other audios and feed it back to the application.
在一种可能的实施方式中,所述指令地址包括程序计数器PC地址和返回地址;In a possible implementation, the instruction address includes a program counter PC address and a return address;
所述根据所述指令地址,确定所述音频状态通知线程是否处于空闲状态,包括: Determining whether the audio status notification thread is in an idle state according to the instruction address includes:
在确定所述PC地址和返回地址均与目标函数体对应的地址相匹配的情况下,确定所述音频状态通知线程处于空闲状态。When it is determined that both the PC address and the return address match the address corresponding to the target function body, it is determined that the audio status notification thread is in an idle state.
在一种可能的实施方式中,在检测音频状态通知线程的运行状态之前,还包括:In a possible implementation, before detecting the audio status notification thread's running status, it also includes:
确定所述音频实例对应的引用信息,并存储所述引用信息;Determine the reference information corresponding to the audio instance, and store the reference information;
所述利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例,包括:Using the first thread to execute the audio instance destruction function to destroy the audio instance includes:
根据存储的所述引用信息,确定所述音频实例的存储位置,并利用所述第一线程执行所述音频实例销毁函数,销毁在所述存储位置处的所述音频实例。According to the stored reference information, the storage location of the audio instance is determined, and the first thread is used to execute the audio instance destruction function to destroy the audio instance at the storage location.
第二方面,本公开实施例还提供一种音频线程处理装置,包括:In a second aspect, embodiments of the present disclosure also provide an audio thread processing device, including:
第一处理模块,用于将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数;所述音频实例销毁函数用于销毁创建的音频实例;所述音频实例用于进行音频播放;The first processing module is used to point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback;
调用模块,用于在音频停止播放的情况下,利用运行所述音频实例的第一线程调用所述音频实例销毁函数指向的所述音频处理函数;A calling module, configured to use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function when the audio stops playing;
获取模块,用于获取通过执行所述音频处理函数,检测到的音频状态通知线程的运行状态;An acquisition module, used to acquire the running status of the audio status notification thread detected by executing the audio processing function;
执行模块,用于在所述运行状态指示所述音频状态通知线程已反馈针对所述音频的音频状态通知信息的情况下,利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例。Execution module, configured to use the first thread to execute the audio instance destruction function to destroy the audio instance destruction function when the running status indicates that the audio status notification thread has fed back the audio status notification information for the audio. Audio example.
在一种可能的实施方式中,所述装置还包括:In a possible implementation, the device further includes:
检测模块,用于根据以下步骤检测音频状态通知线程的运行状态Detection module, used to detect the running status of the audio status notification thread according to the following steps
从所述应用中运行的多个线程中,确定出所述音频状态通知线程;Determine the audio status notification thread from a plurality of threads running in the application;
获取所述音频状态通知线程在当前时刻指向的指令地址,并根据所述指令地址,确定所述音频状态通知线程是否处于空闲状态;Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address;
若是,则暂停执行所述音频状态通知线程,并执行对所述音频状态通知线程的栈回溯操作,确定所述音频状态通知线程对应的调用栈信息;If so, suspend the execution of the audio status notification thread, and perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread;
根据所述调用栈信息,确定所述运行状态。The running status is determined based on the call stack information.
在一种可能的实施方式中,所述检测模块,还用于在确定所述音频状态通知线程未处于空闲状态的情况下,等待第一预设时长后返回执行获取所述音频 状态通知线程在当前时刻指向的指令地址的步骤,直至确定所述音频状态通知线程处于空闲状态。In a possible implementation, the detection module is also configured to wait for a first preset period of time before returning to execute the acquisition of the audio when it is determined that the audio status notification thread is not in an idle state. The step of determining the instruction address pointed by the status notification thread at the current moment until it is determined that the audio status notification thread is in an idle state.
在一种可能的实施方式中,所述检测模块,用于从所述调用栈信息包括的多个调用库地址中,确定是否存在目标逻辑库对应的目标调用库地址;所述目标逻辑库中存储有音频打断处理逻辑信息,所述音频打断处理逻辑信息用于生成音频状态通知信息;In a possible implementation, the detection module is configured to determine whether there is a target call library address corresponding to the target logical library from the multiple call library addresses included in the call stack information; Audio interruption processing logic information is stored, and the audio interruption processing logic information is used to generate audio status notification information;
若不存在所述目标调用库地址,则确定所述运行状态包括:所述音频状态通知线程已反馈针对所述音频的音频状态通知信息。If the target call library address does not exist, determining the running status includes: the audio status notification thread has fed back the audio status notification information for the audio.
在一种可能的实施方式中,所述检测模块,还用于在多个所述调用库地址中存在所述目标调用库地址的情况下,恢复执行所述音频状态通知线程,并在等待第二预设时长后返回执行获取所述音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定多个所述调用库地址中不存在所述目标调用库地址。In a possible implementation, the detection module is further configured to resume execution of the audio status notification thread when the target call library address exists among multiple call library addresses, and wait for the third call library address. After a preset period of time, return to the step of obtaining the instruction address pointed by the audio status notification thread at the current moment until it is determined that the target call library address does not exist among the multiple call library addresses.
在一种可能的实施方式中,所述装置还包括:In a possible implementation, the device further includes:
第二处理模块,用于在所述利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例之后,恢复执行所述音频状态通知线程,以利用执行的所述音频状态通知线程,生成针对其他音频的音频状态通知信息并反馈给所述应用。A second processing module configured to, after using the first thread to execute the audio instance destruction function to destroy the audio instance, resume execution of the audio status notification thread to utilize the executed audio status notification Thread, generates audio status notification information for other audios and feeds it back to the application.
在一种可能的实施方式中,所述指令地址包括程序计数器PC地址和返回地址;In a possible implementation, the instruction address includes a program counter PC address and a return address;
所述检测模块,用于在确定所述PC地址和返回地址均与目标函数体对应的地址相匹配的情况下,确定所述音频状态通知线程处于空闲状态。The detection module is configured to determine that the audio status notification thread is in an idle state when it is determined that the PC address and the return address both match the address corresponding to the target function body.
在一种可能的实施方式中,所述装置还包括存储模块:In a possible implementation, the device further includes a storage module:
所述存储模块,用于在检测音频状态通知线程的运行状态之前,确定所述音频实例对应的引用信息,并存储所述引用信息;The storage module is used to determine the reference information corresponding to the audio instance and store the reference information before detecting the running status of the audio status notification thread;
所述执行模块,用于根据存储的所述引用信息,确定所述音频实例的存储位置,并利用所述第一线程执行所述音频实例销毁函数,销毁在所述存储位置处的所述音频实例。The execution module is configured to determine the storage location of the audio instance according to the stored reference information, and use the first thread to execute the audio instance destruction function to destroy the audio at the storage location. Example.
第三方面,本公开可选实现方式还提供一种计算机设备,处理器、存储器,所述存储器存储有所述处理器可执行的机器可读指令,所述处理器用于执行所述存储器中存储的机器可读指令,所述机器可读指令被所述处理器执行时,所 述机器可读指令被所述处理器执行时执行上述第一方面,或第一方面中任一种可能的实施方式中的步骤。In a third aspect, an optional implementation manner of the present disclosure also provides a computer device, a processor, and a memory. The memory stores machine-readable instructions executable by the processor, and the processor is configured to execute the instructions stored in the memory. machine-readable instructions. When the machine-readable instructions are executed by the processor, the When the machine-readable instructions are executed by the processor, the steps in the above-mentioned first aspect or any possible implementation manner of the first aspect are performed.
第四方面,本公开可选实现方式还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被运行时执行上述第一方面,或第一方面中任一种可能的实施方式中的步骤。In a fourth aspect, an optional implementation manner of the present disclosure also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program. When the computer program is run, it executes the above-mentioned first aspect, or any of the first aspects. steps in a possible implementation.
关于上述音频线程处理装置、计算机设备、及计算机可读存储介质的效果描述参见上述音频线程处理方法的说明,这里不再赘述。For a description of the effects of the above-mentioned audio thread processing device, computer equipment, and computer-readable storage medium, please refer to the description of the above-mentioned audio thread processing method, and will not be described again here.
本公开实施例提供的音频线程处理方法、装置、计算机设备和存储介质,通过在音频停止播放的情况下,利用第一线程调用音频实例销毁函数指向的音频处理函数,再通过执行音频处理函数检测音频状态通知线程的运行状态,可以实现在利用第一线程执行所述音频实例销毁函数,以销毁音频实之前,准确确定出音频状态通知线程,是否已反馈针对停止播放的音频的音频状态通知信息。继而,在确定已反馈音频状态通知信息的情况下,再利用第一线程执行音频实例销毁函数,以销毁音频实例。如此,利用预设的音频处理函数,限定音频状态通知线程和销毁音频实例的第一线程的先后执行顺序,既不会影响系统中销毁音频实例的第一线程和音频状态通知线程的运行,还避免了音频状态通知线程和销毁音频实例的第一线程的并发执行;进而,避免了因两个线程竞争系统资源,造成系统卡顿或死机的问题。The audio thread processing method, device, computer equipment and storage medium provided by the embodiments of the present disclosure use the first thread to call the audio processing function pointed to by the audio instance destruction function when the audio stops playing, and then detect the audio thread by executing the audio processing function. The running status of the audio status notification thread can accurately determine whether the audio status notification thread has fed back the audio status notification information for the audio that has stopped playing before using the first thread to execute the audio instance destruction function to destroy the audio instance. . Then, when it is determined that the audio status notification information has been fed back, the first thread is used to execute the audio instance destruction function to destroy the audio instance. In this way, using the preset audio processing function to limit the execution order of the audio status notification thread and the first thread that destroys the audio instance will not affect the operation of the first thread that destroys the audio instance and the audio status notification thread in the system, but also This avoids the concurrent execution of the audio status notification thread and the first thread that destroys the audio instance; furthermore, it avoids the problem of system lag or crash caused by two threads competing for system resources.
为使本公开的上述目的、特征和优点能更明显易懂,下文特举较佳实施例,并配合所附附图,作详细说明如下。In order to make the above-mentioned objects, features and advantages of the present disclosure more obvious and understandable, preferred embodiments are given below and described in detail with reference to the accompanying drawings.
附图说明Description of the drawings
为了更清楚地说明本公开实施例的技术方案,下面将对实施例中所需要使用的附图作简单地介绍,此处的附图被并入说明书中并构成本说明书中的一部分,这些附图示出了符合本公开的实施例,并与说明书一起用于说明本公开的技术方案。应当理解,以下附图仅示出了本公开的某些实施例,因此不应被看作是对范围的限定,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图获得其他相关的附图。In order to explain the technical solutions of the embodiments of the present disclosure more clearly, the drawings required to be used in the embodiments will be briefly introduced below. The drawings here are incorporated into the specification and constitute a part of this specification. These drawings are The drawings illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, without exerting creative efforts, they can also Other relevant drawings are obtained based on these drawings.
图1示出了本公开实施例所提供的一种音频线程处理方法的流程图;Figure 1 shows a flow chart of an audio thread processing method provided by an embodiment of the present disclosure;
图2示出了本公开实施例所提供的一种音频线程处理方法的具体实施流程图; Figure 2 shows a specific implementation flow chart of an audio thread processing method provided by an embodiment of the present disclosure;
图3示出了本公开实施例所提供的一种音频线程处理装置的示意图;Figure 3 shows a schematic diagram of an audio thread processing device provided by an embodiment of the present disclosure;
图4示出了本公开实施例所提供的一种计算机设备的结构示意图。FIG. 4 shows a schematic structural diagram of a computer device provided by an embodiment of the present disclosure.
具体实施方式Detailed ways
为使本公开实施例的目的、技术方案和优点更加清楚,下面将结合本公开实施例中附图,对本公开实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本公开一部分实施例,而不是全部的实施例。通常在此处描述和示出的本公开实施例的组件可以以各种不同的配置来布置和设计。因此,以下对本公开的实施例的详细描述并非旨在限制要求保护的本公开的范围,而是仅仅表示本公开的选定实施例。基于本公开的实施例,本领域技术人员在没有做出创造性劳动的前提下所获得的所有其他实施例,都属于本公开保护的范围。In order to make the purpose, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only These are some embodiments of the present disclosure, but not all embodiments. The components of the disclosed embodiments generally described and illustrated herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the disclosure is not intended to limit the scope of the claimed disclosure, but rather to represent selected embodiments of the disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without any creative efforts shall fall within the scope of protection of the present disclosure.
另外,本公开实施例中的说明书和权利要求书及上述附图中的术语“第一”、“第二”等是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的实施例能够以除了在这里图示或描述的内容以外的顺序实施。In addition, the terms "first", "second", etc. in the description and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances so that the embodiments described herein can be practiced in sequences other than those illustrated or described herein.
在本文中提及的“多个或者若干个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。字符“/”一般表示前后关联对象是一种“或”的关系。The "multiple or several" mentioned in this article means two or more. "And/or" describes the relationship between related objects, indicating that there can be three relationships. For example, A and/or B can mean: A exists alone, A and B exist simultaneously, and B exists alone. The character "/" generally indicates that the related objects are in an "or" relationship.
经研究发现,IOS系统中的音频,在停止播放的情况下,通常会出现音频状态通知线程,与销毁音频实例的线程竞争系统资源,引起音频应用和系统出现卡顿甚至死机的问题。Research has found that when audio in the iOS system stops playing, an audio status notification thread usually appears, competing with the thread that destroys the audio instance for system resources, causing audio applications and systems to freeze or even freeze.
基于上述研究,本公开提供了一种音频线程处理方法、装置、计算机设备和存储介质,利用预设的音频处理函数,限定音频状态通知线程和销毁音频实例的第一线程的先后执行顺序,既不会影响系统中销毁音频实例的第一线程和音频状态通知线程的运行,还避免了音频状态通知线程和销毁音频实例的第一线程的并发执行;进而,避免了因两个线程竞争系统资源,造成系统卡顿或死机的问题。Based on the above research, the present disclosure provides an audio thread processing method, device, computer equipment and storage medium, which uses a preset audio processing function to limit the execution order of the audio status notification thread and the first thread that destroys the audio instance, that is, It will not affect the operation of the first thread that destroys the audio instance and the audio status notification thread in the system. It also avoids the concurrent execution of the audio status notification thread and the first thread that destroys the audio instance. Furthermore, it avoids the two threads competing for system resources. , causing the system to freeze or crash.
针对以上方案所存在的缺陷,均是发明人在经过实践并仔细研究后得出的结果,因此,上述问题的发现过程以及下文中本公开针对上述问题所提出的解 决方案,都应该是发明人在本公开过程中对本公开做出的贡献。The defects in the above solutions are all the results obtained by the inventor after practice and careful study. Therefore, the discovery process of the above problems and the solutions proposed by the present disclosure to the above problems below are Solutions should be the inventor's contribution to this disclosure during the process of this disclosure.
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步定义和解释。It should be noted that similar reference numerals and letters represent similar items in the following figures, therefore, once an item is defined in one figure, it does not need further definition and explanation in subsequent figures.
需要说明的是,本公开实施例中所提到的特定名词包括:It should be noted that the specific nouns mentioned in the embodiments of this disclosure include:
程序计数器(Program Counter,PC):是计算机处理器中的寄存器,它包含当前正在执行的指令的地址。当每个指令被获取,程序计数器的存储地址加一,在每个指令被获取之后,程序计数器指向顺序中的下一个指令。Program Counter (PC): is a register in a computer processor that contains the address of the instruction currently being executed. As each instruction is fetched, the memory address of the program counter is incremented by one. After each instruction is fetched, the program counter points to the next instruction in the sequence.
为便于对本实施例进行理解,首先对本公开实施例所公开的一种在线课程资源的使用方法进行详细介绍,本公开实施例所提供的在线课程资源的使用方法的执行主体一般为具有一定计算能力的终端设备或其他处理设备,其中终端设备可以为用户设备(User Equipment,UE)、移动设备、用户终端、终端、个人数字处理设备(Personal Digital Assistant,PDA)、手持设备、计算机设备等;在一些可能的实现方式中,该在线课程资源的使用方法可以通过处理器调用存储器中存储的计算机可读指令的方式来实现。In order to facilitate understanding of this embodiment, a method for using online course resources disclosed in this embodiment of the disclosure is first introduced in detail. The execution subject of the method of using online course resources provided by this embodiment of the disclosure generally has certain computing capabilities. Terminal equipment or other processing equipment, where the terminal equipment can be user equipment (User Equipment, UE), mobile equipment, user terminals, terminals, personal digital processing equipment (Personal Digital Assistant, PDA), handheld devices, computer equipment, etc.; in In some possible implementations, the method of using the online course resources can be implemented by the processor calling computer-readable instructions stored in the memory.
下面以执行主体为计算机设备为例对本公开实施例提供的音频线程处理方法加以说明。The audio thread processing method provided by the embodiment of the present disclosure will be described below by taking the execution subject as a computer device as an example.
如图1所示,为本公开实施例提供的一种音频线程处理方法的流程图,可以包括以下步骤:As shown in Figure 1, a flow chart of an audio thread processing method provided by an embodiment of the present disclosure may include the following steps:
S101:将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数;音频实例销毁函数用于销毁创建的音频实例;音频实例用于进行音频播放。S101: Point the calling entry point of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback.
这里,上述应用可以为任一运行在IOS系统中的、能够进行音频播放的应用。音频实例销毁函数为IOS系中的、用于销毁创建的音频实例(audio unit)。audio unit在音频播放时创建,用于进行音频播放,可以在音频停止播放时销毁,从而实现系统资源的释放。音频停止播放可以包括但不限于音频内容播放完毕和正在播放的被打断两种情况。Here, the above-mentioned application can be any application running in the IOS system and capable of audio playback. The audio instance destruction function is used in the IOS system to destroy the created audio instance (audio unit). The audio unit is created during audio playback and is used for audio playback. It can be destroyed when the audio stops playing, thereby releasing system resources. Stopping audio playback may include, but is not limited to, two situations: audio content completion and ongoing playback being interrupted.
音频处理函数(My_dispose函数)为预设的处理函数,对应于一段音频处理逻辑,用于检测系统中的音频状态通知线程,是否已反馈针对当前停止播放的音频的音频状态通知信息。The audio processing function (My_dispose function) is a preset processing function, which corresponds to a piece of audio processing logic and is used to detect the audio status notification thread in the system to see whether the audio status notification information for the currently stopped audio has been fed back.
具体实施时,可以利用GOTHook的方式,将IOS系统中的应用对应的音 频实例销毁函数的调用入口指向预设的音频处理函数。其中,GOT作为一种函数地址信息的存放表格,其中可以存储有IOS系统对应的各个函数,例如,执行函数、销毁函数、替换函数等。GOTHOOK是一种将GOT表中存储的函数地址替换为其他函数对应的地址的方式。During specific implementation, the GOTHook method can be used to add the audio files corresponding to the applications in the IOS system. The call entry point of the frequency instance destruction function points to the preset audio processing function. Among them, GOT is a storage table for function address information, which can store various functions corresponding to the IOS system, such as execution functions, destruction functions, replacement functions, etc. GOTHOOK is a way to replace the function address stored in the GOT table with the address corresponding to other functions.
将IOS系统中的应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数,也即将音频实例销毁函数对应的入口地址替换为预设的音频处理函数对应的地址。Point the calling entry point of the audio instance destruction function corresponding to the application in the IOS system to the preset audio processing function, that is, replace the entry address corresponding to the audio instance destruction function with the address corresponding to the preset audio processing function.
可选地,若IOS系统中的各个应用对应的音频实例销毁函数不同,则可以将各个应用对应的音频实例销毁函数的调用入口均指向预设的音频处理函数。同理,若IOS系统中的各个应用均对应一个音频实例销毁函数,则可以将该唯一的音频实例销毁函数的调用入口均指向预设的音频处理函数。Optionally, if the audio instance destruction functions corresponding to each application in the IOS system are different, the calling entry points of the audio instance destruction functions corresponding to each application can be directed to the preset audio processing function. Similarly, if each application in the IOS system corresponds to an audio instance destruction function, the call entry point of the unique audio instance destruction function can be directed to the preset audio processing function.
S102:在音频停止播放的情况下,利用运行音频实例的第一线程调用音频实例销毁函数指向的音频处理函数。S102: When the audio stops playing, use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function.
第一线程可以为应用中运行的任一线程,具体可以为当前停止播放的音频对应的音频实例的线程。The first thread can be any thread running in the application, and specifically it can be the thread of the audio instance corresponding to the audio that is currently stopped playing.
具体实施时,在音频停止播放的情况下,可以利用第一线程调用音频实例销毁函数,由于第一音频实例销毁函数对应的入口地址已经替换为预设的音频处理函数对应的地址,因此,在调用音频实例销毁函数之后,将实现自动调用替换后的入口地址指向的音频处理函数。如此,实现了利用运行音频实例的第一线程调用音频实例销毁函数的调用入口指向的音频处理函数。During specific implementation, when the audio stops playing, the first thread can be used to call the audio instance destruction function. Since the entry address corresponding to the first audio instance destruction function has been replaced with the address corresponding to the preset audio processing function, therefore, in After calling the audio instance destruction function, the audio processing function pointed to by the replaced entry address will be automatically called. In this way, the first thread running the audio instance is used to call the audio processing function pointed by the call entry point of the audio instance destruction function.
需要说明的是,上述S101和S102之间并不存在严格的执行顺序。具体实施时,可以利用GOTHook的方式,预先将音频实例销毁函数的调用入口指向预设的音频处理函数,也可以在确定当前存在停止播放的音频时,将播放该音频的应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数,本公开实施例不进行具体限定。It should be noted that there is no strict execution sequence between the above S101 and S102. During specific implementation, you can use GOTHook to point the call entry of the audio instance destruction function to the preset audio processing function in advance. You can also destroy the audio instance corresponding to the application that plays the audio when it is determined that there is audio that has stopped playing. The calling entry point of the function points to a preset audio processing function, which is not specifically limited in the embodiment of the present disclosure.
S103:获取通过执行音频处理函数,检测到的音频状态通知线程的运行状态。S103: Obtain the running status of the audio status notification thread detected by executing the audio processing function.
这里,音频状态通知线程为IOS系统中的一个默认的通知线程,即AVAudioSession Notify Thread,用于对IOS系统中的音频的状态发送至音频对应的应用。例如,生成当前开始播放音频的通知,生成音频停止播放的通知、 生成音频播放出现异常的通知。音频状态通知线程可以在IOS系统首次出现音频播放时创建,创建之后可以一直存在,用于对IOS系统中的各个音频的状态进行通知。Here, the audio status notification thread is a default notification thread in the IOS system, that is, AVAudioSession Notify Thread, which is used to send the audio status in the IOS system to the audio corresponding application. For example, generate a notification that the audio is currently playing, generate a notification that the audio has stopped playing, Generate a notification that audio playback is abnormal. The audio status notification thread can be created when audio playback appears for the first time in the IOS system. It can always exist after creation and is used to notify the status of each audio in the IOS system.
运行状态用于指示音频状态通知线程是否已生成针对当前停止播放的音频的音频状态通知信息并反馈。The running status is used to indicate whether the audio status notification thread has generated and fed back audio status notification information for the audio that is currently stopped playing.
具体实施时,在调用音频处理函数后,可以执行该音频处理函数,按照该音频处理函数指示的检测逻辑,对音频状态通知线程的运行状态进行检测。进而,通过执行音频处理函数,可以获取检测到的音频状态通知线程的运行状态。During specific implementation, after calling the audio processing function, the audio processing function can be executed, and the running status of the audio status notification thread is detected according to the detection logic indicated by the audio processing function. Furthermore, by executing the audio processing function, the running status of the detected audio status notification thread can be obtained.
在一种实施例中,可以按照以下步骤测音频状态通知线程的运行状态:In one embodiment, the running status of the audio status notification thread can be measured according to the following steps:
步骤一、从应用中运行的多个线程中,确定出音频状态通知线程。Step 1: Determine the audio status notification thread from the multiple threads running in the application.
这里,一个应用可以运行多个线程,例如,音频线程、系统默认线程、画面显示线程等等。Here, an application can run multiple threads, such as audio thread, system default thread, screen display thread, etc.
具体实施时,在执行音频处理函数的过程中,可以从应用中运行的多个线程中,确定出音频状态通知线程。During specific implementation, during the execution of the audio processing function, the audio status notification thread can be determined from multiple threads running in the application.
步骤二、获取音频状态通知线程在当前时刻指向的指令地址,并根据指令地址,确定音频状态通知线程是否处于空闲状态。Step 2: Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address.
这里,指令地址用于指示音频状态通知线程对应的指针地址。Here, the instruction address is used to indicate the pointer address corresponding to the audio status notification thread.
具体实施时,在确定音频状态通知线程后,可以获取音频状态通知线程在当前时刻指向的指令地址,并判断该指令地址是否位于目标函数体(mach_msg函数体)内,也即判断指令地址是否与mach_msg函数体对应的地址相匹配。其中,mach_msg函数是一种用于指示线程是否在处理器中运行的函数。During specific implementation, after determining the audio status notification thread, you can obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the instruction address is located in the target function body (mach_msg function body), that is, determine whether the instruction address is consistent with the The address corresponding to the mach_msg function body matches. Among them, the mach_msg function is a function used to indicate whether the thread is running in the processor.
如果确定指令地址位于mach_msg函数体内,则可以确定音频状态通知线程处于空闲状态;反之,则可以确定音频状态通知线程未处于空闲状态,也即正在运行。If it is determined that the instruction address is located in the mach_msg function body, it can be determined that the audio status notification thread is in an idle state; otherwise, it can be determined that the audio status notification thread is not in an idle state, that is, it is running.
在一种实施例中,在确定音频状态通知线程未处于空闲状态的情况下,则说明当前音频状态通知线程仍在执行,则可以创建计时器timer,并在计时器计数到第一预设时长时,返回执行上述步骤二,直至确定音频状态通知线程处于空闲状态。In one embodiment, when it is determined that the audio status notification thread is not in an idle state, it means that the current audio status notification thread is still executing, and a timer timer can be created, and the timer will count to the first preset duration. When, return to step 2 above until it is determined that the audio status notification thread is in an idle state.
其中,计时器计数到第一预设时长后也即等待了第一预设时长。第一预设时长可以为开发人员预设的等待时长,例如,第一预设时长可以为10秒(S)、 8S等等。Wherein, after the timer counts to the first preset time period, the timer waits for the first preset time period. The first preset time length may be a waiting time preset by the developer. For example, the first preset time length may be 10 seconds (S), 8S and so on.
在一种实施例中,指令地址可以包括音频状态通知线程对应的PC地址和返回地址中的至少一种。在指令地址仅包括PC地址或返回地址的情况下,在确定这一个地址位于mach_msg函数体内的情况下,就可以确定音频状态通知线程处于空闲状态。In one embodiment, the instruction address may include at least one of a PC address and a return address corresponding to the audio status notification thread. In the case where the instruction address only includes the PC address or the return address, and it is determined that this address is located in the mach_msg function body, it can be determined that the audio status notification thread is in an idle state.
在指令地址同时包括PC地址和返回地址的情况下,则需要在确定PC地址和返回地址均与目标函数体对应的地址相匹配的情况下,也即在确定PC地址和返回地址均位于mach_msg函数体内的情况下,才可以确定音频状态通知线程处于空闲状态。否则,则确定音频状态通知线程未处于空闲状态。这样,利用PC地址和返回地址这两个地址进行空闲状态的检验,能够提高确定的音频状态通知线程的空闲状态的准确性。When the instruction address includes both the PC address and the return address, it is necessary to determine that both the PC address and the return address match the address corresponding to the target function body, that is, it is necessary to determine that both the PC address and the return address are located in the mach_msg function. Only when the audio status notification thread is idle can the body be determined. Otherwise, it is determined that the audio status notification thread is not idle. In this way, using the PC address and the return address to check the idle state can improve the accuracy of the idle state of the determined audio state notification thread.
步骤三、若是,则暂停执行音频状态通知线程,并执行对音频状态通知线程的栈回溯操作,确定音频状态通知线程对应的调用栈信息。Step 3: If yes, pause the execution of the audio status notification thread, and perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread.
这里,调用栈信息包括音频状态通知线程在执行过程中所调用的各个调用库地址。Here, the call stack information includes the addresses of various call libraries called by the audio status notification thread during execution.
本步骤在具体实施时,在确定音频状态通知线程处于空闲状态的情况下,则可以挂起(suspend)处于空闲状态的音频状态通知线程。同时,可以执行针对音频状态通知线程的栈回溯操作,确定音频状态通知线程在执行过程中所调用的各个调用库地址,也即得到了调用栈信息。During specific implementation of this step, if it is determined that the audio status notification thread is in an idle state, the audio status notification thread in the idle state may be suspended. At the same time, a stack backtracing operation for the audio status notification thread can be performed to determine the address of each call library called by the audio status notification thread during execution, that is, the call stack information is obtained.
步骤四、根据调用栈信息,确定运行状态。Step 4: Determine the running status based on the call stack information.
具体实施时,可以根据调用栈信息中包括的各个调用库地址,确定音频状态通知线程是否已反馈了针对当前停止播放的音频的音频状态通知信息。During specific implementation, it can be determined according to each call library address included in the call stack information whether the audio status notification thread has fed back the audio status notification information for the audio that is currently stopped playing.
在一种实施例中,针对步骤4,可以按照以下步骤实施:从调用栈信息包括的多个调用库地址中,确定是否存在目标逻辑库对应的目标调用库地址,其中,目标逻辑库具体可以为libEmbeddedSystemAUs.dylib,其中存储有音频打断处理逻辑信息,音频打断处理逻辑信息用于生成音频状态通知信息。其中,libEmbeddedSystemAUs.dylib是IOS系统中创建的一个,用于存储音频打断处理逻辑信息的系统库。In one embodiment, step 4 can be implemented according to the following steps: determine whether there is a target call library address corresponding to the target logic library from the multiple call library addresses included in the call stack information, wherein the target logic library can specifically It is libEmbeddedSystemAUs.dylib, which stores audio interruption processing logic information. The audio interruption processing logic information is used to generate audio status notification information. Among them, libEmbeddedSystemAUs.dylib is a system library created in the IOS system to store audio interruption processing logic information.
音频状态通知线程可以根据音频打断处理逻辑信息,执行音频打断处理操作,以生成音频状态通知信息。 The audio status notification thread can perform audio interruption processing operations based on the audio interruption processing logic information to generate audio status notification information.
具体实施时,在确定调用栈信息包括的多个调用库地址中,不存在目标逻辑库对应的目标调用库地址的情况下,则可以说明音频状态通知线程当前已经执行完了针对当前停止播放的音频的音频打断处理操作。这样,可以确定音频状态通知线程的运行状态包括:音频状态通知线程已生成了针对当前停止播放的音频的音频状态通知信息,并且已经反馈给该音频对应的应用。During specific implementation, when it is determined that among the multiple call library addresses included in the call stack information, there is no target call library address corresponding to the target logic library, it can be explained that the audio status notification thread has currently finished executing the audio that is currently stopped playing. Audio interrupt processing operation. In this way, it can be determined that the running status of the audio status notification thread includes: the audio status notification thread has generated audio status notification information for the audio that is currently stopped playing, and has fed back to the application corresponding to the audio.
在另一种实施例中,在多个调用库地址中存在目标调用库地址的情况下,恢复执行音频状态通知线程,并在等待第二预设时长后返回执行获取音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定多个调用库地址中不存在目标调用库地址。In another embodiment, when the target call library address exists among multiple call library addresses, resume execution of the audio status notification thread, and return to execution to obtain the audio status notification thread at the current moment after waiting for the second preset time period. The steps of pointing to the instruction address until it is determined that the target call library address does not exist among the multiple call library addresses.
这里,如果确定调用栈信息包括的多个调用库地址中存在目标调用库地址,则说明音频状态通知线程并未执行完成针对当前停止播放的音频的音频打断处理操作,还需要继续执行。因此,需要恢复执行在执行上述步骤三时挂起的处于空闲状态的音频状态通知线程,并创建计时器timer,在确定计时器计数到第二预设时长时,返回执行上述步骤二、步骤三,直至确定调用栈信息包括的多个调用库地址中不存在目标调用库地址。Here, if it is determined that the target call library address exists among the multiple call library addresses included in the call stack information, it means that the audio status notification thread has not completed the audio interruption processing operation for the audio that is currently stopped playing, and needs to continue execution. Therefore, it is necessary to resume execution of the idle audio status notification thread that was suspended when executing step three above, and create a timer. When it is determined that the timer counts to the second preset duration, return to step two and step three above. , until it is determined that the target call library address does not exist among the multiple call library addresses included in the call stack information.
此处,之所以需要返回执行上述步骤二,是因为音频状态通知线程在执行的过程中,其对应指向的指令地址将实时变化,继而,音频状态通知线程是否处于空闲状态的结果也将随之变化。因此,通过重新返回执行上述步骤二,可以实现重新确定音频状态通知线程的空闲状态,继而,确定出音频状态通知线程对应的准确运行状态。Here, the reason why we need to return to step 2 above is because during the execution process of the audio status notification thread, the corresponding instruction address it points to will change in real time. Then, the result of whether the audio status notification thread is in an idle state will also follow. Variety. Therefore, by returning to step 2 above, the idle state of the audio status notification thread can be re-determined, and then the accurate running status corresponding to the audio status notification thread can be determined.
其中,上述第二预设时长也为开发人员预设的等待时长,其可以等于第一预设时长,也可以不等于第一预设时长,此处不进行限定。Wherein, the above-mentioned second preset time length is also the waiting time preset by the developer, which may be equal to the first preset time length, or may not be equal to the first preset time length, and is not limited here.
S104:在运行状态指示所述音频状态通知线程已反馈针对音频的音频状态通知信息的情况下,利用第一线程执行音频实例销毁函数,以销毁音频实例。S104: When the running status indicates that the audio status notification thread has fed back audio status notification information for audio, use the first thread to execute the audio instance destruction function to destroy the audio instance.
这里,音频状态通知信息用于通知应用音频已经停止播放。Here, the audio status notification information is used to notify the application that the audio has stopped playing.
具体的,在运行状态指示音频状态通知线程已向应用反馈针对音频的音频状态通知信息的情况下,根据上述步骤三可知,此时的音频状态通知线程已被挂起。因此可以利用第一线程执行当前停止播放的音频对应的音频实例销毁函数,以实现对音频实例的销毁。Specifically, when the running status indicates that the audio status notification thread has fed back the audio status notification information for audio to the application, according to the above step three, it can be known that the audio status notification thread at this time has been suspended. Therefore, the first thread can be used to execute the audio instance destruction function corresponding to the audio that is currently stopped playing, so as to realize the destruction of the audio instance.
如此,基于上述各实施例可知,音频处理函数指示的检测逻辑具体可以为 先检测音频状态通知线程是否空闲,若否,则等待第一预设时长,重新检测是否空闲,直至确定音频状态通知线程处于空闲状态。若是,则检测音频状态通知线程对应的多个调用库地址中是否存在目标逻辑库对应的目标调用库地址,如果不存在,则确定运行状态为已生成针对当前停止播放的音频的音频状态通知信息并反馈。如果存在,则等待第二预设时长,返回执行检测音频状态通知线程是否空闲,直至确定多个调用库地址中不包括目标调用库地址。进而,可以执行音频实例销毁函数,以销毁音频实例。In this way, based on the above embodiments, it can be known that the detection logic indicated by the audio processing function can be specifically: First, check whether the audio status notification thread is idle. If not, wait for the first preset time period and recheck whether the audio status notification thread is idle until it is determined that the audio status notification thread is idle. If so, detect whether the target call library address corresponding to the target logic library exists among the multiple call library addresses corresponding to the audio status notification thread. If it does not exist, determine that the running status is that audio status notification information for the currently stopped playing audio has been generated. and give feedback. If it exists, wait for the second preset time period, return to execution and detect whether the audio status notification thread is idle, until it is determined that the target call library address is not included in the multiple call library addresses. Furthermore, the audio instance destruction function can be executed to destroy the audio instance.
在一种实施例中,在利用第一线程执行音频实例销毁函数,以销毁音频实例之后,此时的音频状态通知线程还处于被挂起的状态。因此,还可以恢复执行音频状态通知线程,以利用执行的音频状态通知线程,生成针对其他音频的音频状态通知信息并反馈给应用。In one embodiment, after the first thread is used to execute the audio instance destruction function to destroy the audio instance, the audio status notification thread at this time is still in a suspended state. Therefore, the execution of the audio status notification thread can also be resumed to use the executed audio status notification thread to generate audio status notification information for other audios and feed it back to the application.
这样,通过恢复执行音频状态通知线程,可以实现利用音频状态通知线程,生成针对后续在系统中播放的音频的音频状态通知信息,例如,生成当前开始播放音频的通知,生成音频停止播放的通。从而,可以实现对在系统中播放的各个音频对应的音频状态通知信息的及时获取。In this way, by resuming the execution of the audio status notification thread, the audio status notification thread can be used to generate audio status notification information for subsequent audio played in the system, for example, generate a notification to start playing the audio currently, and generate a notification to stop the audio playing. Therefore, the audio status notification information corresponding to each audio played in the system can be obtained in time.
在一种实施例中,在检测音频状态通知线程的运行状态之前,还可以确定音频实例对应的引用信息,并存储该引用信息。其中,引用信息用于指示音频实例的存储位置。示例性的,引用信息可以为音频实例对应的指针地址、引用关系、存储地址等信息。这样,通过存储音频实例对应的引用信息,可以实现对音频实例的暂存,便于后续在执行销毁操作时找到音频实例。In one embodiment, before detecting the running status of the audio status notification thread, reference information corresponding to the audio instance may also be determined and the reference information may be stored. Among them, the reference information is used to indicate the storage location of the audio instance. For example, the reference information may be the pointer address, reference relationship, storage address and other information corresponding to the audio instance. In this way, by storing the reference information corresponding to the audio instance, the audio instance can be temporarily stored, so that the audio instance can be found later when the destruction operation is performed.
进一步的,在执行利用第一线程执行音频实例销毁函数,以销毁所述音频实例的步骤时,可以根据存储的音频实例对应的引用信息,确定音频实例的存储位置。之后,可以利用第一线程执行音频实例销毁函数,销毁在存储位置处存储的音频实例。Further, when performing the step of using the first thread to execute the audio instance destruction function to destroy the audio instance, the storage location of the audio instance can be determined according to the reference information corresponding to the stored audio instance. Afterwards, the first thread can be used to execute the audio instance destruction function to destroy the audio instance stored at the storage location.
这样,基于上述各实施例,利用预设的音频处理函数,限定音频状态通知线程和销毁音频实例的第一线程的先后执行顺序,既不会影响系统中销毁音频实例的第一线程和音频状态通知线程的运行,还避免了音频状态通知线程和销毁音频实例的第一线程的并发执行;进而,有效避免了因两个线程竞争系统资源,造成系统卡顿或死机的问题。In this way, based on the above embodiments, the preset audio processing function is used to limit the execution order of the audio status notification thread and the first thread that destroys the audio instance, which will not affect the first thread that destroys the audio instance and the audio status in the system. The running of the notification thread also avoids the concurrent execution of the audio status notification thread and the first thread that destroys the audio instance; furthermore, it effectively avoids the problem of system lag or crash caused by two threads competing for system resources.
如图2所示,为本公开实施例提供的一种音频线程处理方法的具体实施流 程图,可以包括以下步骤:As shown in Figure 2, the specific implementation flow of an audio thread processing method provided by an embodiment of the present disclosure is A process diagram can include the following steps:
S201:将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数。S201: Point the calling entry point of the audio instance destruction function corresponding to the application to the preset audio processing function.
S202:在音频停止播放的情况下,利用第一线程调用音频实例销毁函数指向的音频处理函数。S202: When the audio stops playing, use the first thread to call the audio processing function pointed to by the audio instance destruction function.
S203:从应用中运行的多个线程中,确定出音频状态通知线程。S203: Determine the audio status notification thread from multiple threads running in the application.
S204:获取音频状态通知线程在当前时刻指向的指令地址,并根据指令地址,确定音频状态通知线程是否处于空闲状态。S204: Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address.
这里,指令地址可以包括PC地址和返回地址。Here, the instruction address may include a PC address and a return address.
如果是,执行S205;如果否,则可以开始计时器,在计时器计数达到第一预设时长后,返回执行S204,直至确定音频状态通知线程处于空闲状态。If yes, execute S205; if not, start a timer, and after the timer count reaches the first preset duration, return to execute S204 until it is determined that the audio status notification thread is in an idle state.
S205:执行对音频状态通知线程的栈回溯操作,确定音频状态通知线程对应的调用栈信息。S205: Perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread.
S206:从调用栈信息包括的多个调用库地址中,确定是否存在目标逻辑库对应的目标调用库地址。S206: Determine whether there is a target call library address corresponding to the target logical library from the multiple call library addresses included in the call stack information.
如果否,则确定音频状态通知线程对应的运行状态包括:音频状态通知线程已反馈针对音频的音频状态通知信息,并执行S207;如果是,则恢复执行音频状态通知线程,并开始计时器,在计时器计数达到第二预设时长后,返回执行S204,直至确定多个调用库地址中不存在目标调用库地址。If not, determine that the running status corresponding to the audio status notification thread includes: the audio status notification thread has fed back audio status notification information for audio, and execute S207; if yes, resume execution of the audio status notification thread, and start the timer. After the timer count reaches the second preset duration, execution returns to S204 until it is determined that the target call library address does not exist among the multiple call library addresses.
S207:利用第一线程执行音频实例销毁函数,以销毁音频实例。S207: Use the first thread to execute the audio instance destruction function to destroy the audio instance.
S208:恢复执行音频状态通知线程。S208: Resume execution of the audio status notification thread.
上述S201~S208的具体实施步骤,可以参照上述各实施例,此处不再赘述。For the specific implementation steps of S201 to S208, reference may be made to the above embodiments and will not be described again here.
本领域技术人员可以理解,在具体实施方式的上述方法中,各步骤的撰写顺序并不意味着严格的执行顺序而对实施过程构成任何限定,各步骤的具体执行顺序应当以其功能和可能的内在逻辑确定。Those skilled in the art can understand that in the above-mentioned methods of specific embodiments, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be based on its function and possible The internal logic is determined.
基于同一发明构思,本公开实施例中还提供了与音频线程处理方法对应的音频线程处理装置,由于本公开实施例中的装置解决问题的原理与本公开实施例上述音频线程处理方法相似,因此装置的实施可以参见方法的实施,重复之处不再赘述。 Based on the same inventive concept, the embodiment of the present disclosure also provides an audio thread processing device corresponding to the audio thread processing method. Since the principle of solving the problem of the device in the embodiment of the present disclosure is similar to the above-mentioned audio thread processing method of the embodiment of the present disclosure, therefore For the implementation of the device, please refer to the implementation of the method, and repeated details will not be repeated.
如图3所示,为本公开实施例提供的一种音频线程处理装置的示意图,包括:As shown in Figure 3, a schematic diagram of an audio thread processing device provided by an embodiment of the present disclosure includes:
第一处理模块301,用于将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数;所述音频实例销毁函数用于销毁创建的音频实例;所述音频实例用于进行音频播放;The first processing module 301 is used to point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback ;
调用模块302,用于在音频停止播放的情况下,利用运行所述音频实例的第一线程调用所述音频实例销毁函数指向的所述音频处理函数;The calling module 302 is configured to use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function when the audio stops playing;
获取模块303,用于获取通过执行所述音频处理函数,检测到的音频状态通知线程的运行状态;The acquisition module 303 is used to obtain the running status of the audio status notification thread detected by executing the audio processing function;
执行模块304,用于在所述运行状态指示所述音频状态通知线程已反馈针对所述音频的音频状态通知信息的情况下,利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例。Execution module 304, configured to use the first thread to execute the audio instance destruction function to destroy all audio instances when the running status indicates that the audio status notification thread has fed back the audio status notification information for the audio. Describe audio examples.
在一种可能的实施方式中,所述装置还包括:In a possible implementation, the device further includes:
检测模块305,用于根据以下步骤检测音频状态通知线程的运行状态Detection module 305, used to detect the running status of the audio status notification thread according to the following steps
从所述应用中运行的多个线程中,确定出所述音频状态通知线程;Determine the audio status notification thread from a plurality of threads running in the application;
获取所述音频状态通知线程在当前时刻指向的指令地址,并根据所述指令地址,确定所述音频状态通知线程是否处于空闲状态;Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address;
若是,则暂停执行所述音频状态通知线程,并执行对所述音频状态通知线程的栈回溯操作,确定所述音频状态通知线程对应的调用栈信息;If so, suspend the execution of the audio status notification thread, and perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread;
根据所述调用栈信息,确定所述运行状态。The running status is determined based on the call stack information.
在一种可能的实施方式中,所述检测模块305,还用于在确定所述音频状态通知线程未处于空闲状态的情况下,等待第一预设时长后返回执行获取所述音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定所述音频状态通知线程处于空闲状态。In a possible implementation, the detection module 305 is also configured to wait for a first preset period of time before returning to execute the acquisition of the audio status notification thread when it is determined that the audio status notification thread is not in an idle state. The instruction address pointed to at the current moment steps until the audio status notification thread is determined to be in an idle state.
在一种可能的实施方式中,所述检测模块305,用于从所述调用栈信息包括的多个调用库地址中,确定是否存在目标逻辑库对应的目标调用库地址;所述目标逻辑库中存储有音频打断处理逻辑信息,所述音频打断处理逻辑信息用于生成音频状态通知信息;In a possible implementation, the detection module 305 is configured to determine whether there is a target call library address corresponding to the target logic library from the multiple call library addresses included in the call stack information; the target logic library Audio interruption processing logic information is stored in, and the audio interruption processing logic information is used to generate audio status notification information;
若不存在所述目标调用库地址,则确定所述运行状态包括:所述音频状态通知线程已反馈针对所述音频的音频状态通知信息。 If the target call library address does not exist, determining the running status includes: the audio status notification thread has fed back the audio status notification information for the audio.
在一种可能的实施方式中,所述检测模块305,还用于在多个所述调用库地址中存在所述目标调用库地址的情况下,恢复执行所述音频状态通知线程,并在等待第二预设时长后返回执行获取所述音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定多个所述调用库地址中不存在所述目标调用库地址。In a possible implementation, the detection module 305 is also configured to resume execution of the audio status notification thread when the target call library address exists among multiple call library addresses, and wait for After the second preset period of time, the step of obtaining the instruction address pointed by the audio status notification thread at the current moment is returned to execution until it is determined that the target call library address does not exist among the plurality of call library addresses.
在一种可能的实施方式中,所述装置还包括:In a possible implementation, the device further includes:
第二处理模块306,用于在所述利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例之后,恢复执行所述音频状态通知线程,以利用执行的所述音频状态通知线程,生成针对其他音频的音频状态通知信息并反馈给所述应用。The second processing module 306 is configured to, after using the first thread to execute the audio instance destruction function to destroy the audio instance, resume execution of the audio status notification thread to utilize the executed audio status The notification thread generates audio status notification information for other audios and feeds it back to the application.
在一种可能的实施方式中,所述指令地址包括程序计数器PC地址和返回地址;In a possible implementation, the instruction address includes a program counter PC address and a return address;
所述检测模块305,用于在确定所述PC地址和返回地址均与目标函数体对应的地址相匹配的情况下,确定所述音频状态通知线程处于空闲状态。The detection module 305 is configured to determine that the audio status notification thread is in an idle state when it is determined that both the PC address and the return address match the address corresponding to the target function body.
在一种可能的实施方式中,所述装置还包括存储模块307:In a possible implementation, the device further includes a storage module 307:
所述存储模块307,用于在检测音频状态通知线程的运行状态之前,确定所述音频实例对应的引用信息,并存储所述引用信息;The storage module 307 is configured to determine the reference information corresponding to the audio instance and store the reference information before detecting the running status of the audio status notification thread;
所述执行模块304,用于根据存储的所述引用信息,确定所述音频实例的存储位置,并利用所述第一线程执行所述音频实例销毁函数,销毁在所述存储位置处的所述音频实例。The execution module 304 is configured to determine the storage location of the audio instance according to the stored reference information, and use the first thread to execute the audio instance destruction function to destroy the audio instance at the storage location. Audio example.
关于装置中的各模块的处理流程、以及各模块之间的交互流程的描述可以参照上述方法实施例中的相关说明,这里不再详述。For a description of the processing flow of each module in the device and the interaction flow between the modules, please refer to the relevant descriptions in the above method embodiments, and will not be described in detail here.
基于同一技术构思,本申请实施例还提供了一种计算机设备。参照图4所示,为本申请实施例提供的计算机设备的结构示意图,包括:Based on the same technical concept, embodiments of the present application also provide a computer device. Referring to Figure 4, a schematic structural diagram of a computer device provided by an embodiment of the present application includes:
处理器41、存储器42和总线43。其中,存储器42存储有处理器41可执行的机器可读指令,处理器41用于执行存储器42中存储的机器可读指令,所述机器可读指令被处理器41执行时,处理器41执行下述步骤:S101:将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数;音频实例销毁函数用于销毁创建的音频实例;音频实例用于进行音频播放;S102:在音频停止播放的情况下,利用运行音频实例的第一线程调用音频实例销毁函数指向的 音频处理函数;S103:获取通过执行音频处理函数,检测到的音频状态通知线程的运行状态以及S104:在运行状态指示所述音频状态通知线程已反馈针对音频的音频状态通知信息的情况下,利用第一线程执行音频实例销毁函数,以销毁音频实例。Processor 41, memory 42 and bus 43. The memory 42 stores machine-readable instructions executable by the processor 41 , and the processor 41 is used to execute the machine-readable instructions stored in the memory 42 . When the machine-readable instructions are executed by the processor 41 , the processor 41 executes The following steps: S101: Point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback; S102: when the audio stops In the case of playback, use the first thread running the audio instance to call the audio instance destruction function pointed to Audio processing function; S103: Obtain the running status of the audio status notification thread detected by executing the audio processing function and S104: In the case where the running status indicates that the audio status notification thread has fed back audio status notification information for audio, use The first thread executes the audio instance destruction function to destroy the audio instance.
上述存储器42包括内存421和外部存储器422;这里的内存421也称内存储器,用于暂时存放处理器41中的运算数据,以及与硬盘等外部存储器422交换的数据,处理器41通过内存421与外部存储器422进行数据交换,当计算机设备运行时,处理器41与存储器42之间通过总线43通信,使得处理器41在执行上述方法实施例中所提及的执行指令。The above-mentioned memory 42 includes a memory 421 and an external memory 422; the memory 421 here is also called an internal memory, and is used to temporarily store the operation data in the processor 41, as well as the data exchanged with external memory 422 such as a hard disk. The processor 41 communicates with the processor 42 through the memory 421. The external memory 422 performs data exchange. When the computer device is running, the processor 41 and the memory 42 communicate through the bus 43, so that the processor 41 executes the execution instructions mentioned in the above method embodiment.
本公开实施例还提供一种计算机可读存储介质,该计算机可读存储介质上存储有计算机程序,该计算机程序被处理器运行时执行上述方法实施例中所述的音频线程处理方法的步骤。其中,该存储介质可以是易失性或非易失的计算机可读取存储介质。Embodiments of the present disclosure also provide a computer-readable storage medium. A computer program is stored on the computer-readable storage medium. When the computer program is run by a processor, the steps of the audio thread processing method described in the above method embodiment are executed. Wherein, the storage medium may be a volatile or non-volatile computer-readable storage medium.
本公开实施例所提供的音频线程处理方法的计算机程序产品,包括存储了程序代码的计算机可读存储介质,所述程序代码包括的指令可用于执行上述方法实施例中所述的音频线程处理方法的步骤,具体可参见上述方法实施例,在此不再赘述。The computer program product of the audio thread processing method provided by the embodiment of the present disclosure includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the audio thread processing method described in the above method embodiment. For details of the steps, please refer to the above method embodiments and will not be described again here.
该计算机程序产品可以具体通过硬件、软件或其结合的方式实现。在一个可选实施例中,所述计算机程序产品具体体现为计算机存储介质,在另一个可选实施例中,计算机程序产品具体体现为软件产品,例如软件开发包(Software Development Kit,SDK)等等。The computer program product can be implemented specifically through hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium. In another optional embodiment, the computer program product is embodied as a software product, such as a Software Development Kit (SDK), etc. wait.
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的装置的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。在本公开所提供的几个实施例中,应该理解到,所揭露的装置和方法,可以通过其它的方式实现。以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,又例如,多个单元或组件可以结合,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些通信接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the device described above can be referred to the corresponding process in the foregoing method embodiment, and will not be described again here. In the several embodiments provided in this disclosure, it should be understood that the disclosed devices and methods can be implemented in other ways. The device embodiments described above are only illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components may be combined. Or some features can be ignored, or not implemented. On the other hand, the coupling or direct coupling or communication connection between each other shown or discussed may be through some communication interfaces, and the indirect coupling or communication connection of the devices or units may be in electrical, mechanical or other forms.
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为 单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。The units described as separate components may or may not be physically separate, as The components shown in a unit may or may not be a physical unit, that is, they may be located in one place, or they may be distributed over multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
另外,在本公开各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。In addition, each functional unit in various embodiments of the present disclosure may be integrated into one processing unit, or each unit may exist physically alone, or two or more units may be integrated into one unit.
所述功能如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个处理器可执行的非易失的计算机可读取存储介质中。基于这样的理解,本公开的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本公开各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(Read-Only Memory,ROM)、随机存取存储器(Random Access Memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the existing technology or the part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium, including Several instructions are used to cause a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM), random access memory (Random Access Memory, RAM), magnetic disk or optical disk and other media that can store program code. .
若本申请技术方案涉及个人信息,应用本申请技术方案的产品在处理个人信息前,已明确告知个人信息处理规则,并取得个人自主同意。若本申请技术方案涉及敏感个人信息,应用本申请技术方案的产品在处理敏感个人信息前,已取得个人单独同意,并且同时满足“明示同意”的要求。例如,在摄像头等个人信息采集装置处,设置明确显著的标识告知已进入个人信息采集范围,将会对个人信息进行采集,若个人自愿进入采集范围即视为同意对其个人信息进行采集;或者在个人信息处理的装置上,利用明显的标识/信息告知个人信息处理规则的情况下,通过弹窗信息或请个人自行上传其个人信息等方式获得个人授权;其中,个人信息处理规则可包括个人信息处理者、个人信息处理目的、处理方式、处理的个人信息种类等信息。If the technical solution of this application involves personal information, the products applying the technical solution of this application will clearly inform the personal information processing rules and obtain the individual's independent consent before processing personal information. If the technical solution in this application involves sensitive personal information, the product applying the technical solution in this application must obtain the individual's separate consent before processing sensitive personal information, and meet the requirement of "express consent" at the same time. For example, setting up clear and conspicuous signs on personal information collection devices such as cameras to inform them that they have entered the scope of personal information collection, and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed to have agreed to the collection of his or her personal information; or On personal information processing devices, when using obvious logos/information to inform personal information processing rules, obtain personal authorization through pop-up messages or asking individuals to upload their personal information; among them, personal information processing rules may include personal information processing rules. Information processors, purposes of personal information processing, processing methods, types of personal information processed, etc.
最后应说明的是:以上所述实施例,仅为本公开的具体实施方式,用以说明本公开的技术方案,而非对其限制,本公开的保护范围并不局限于此,尽管参照前述实施例对本公开进行了详细的说明,本领域的普通技术人员应当理解:任何熟悉本技术领域的技术人员在本公开揭露的技术范围内,其依然可以对前述实施例所记载的技术方案进行修改或可轻易想到变化,或者对其中部分技术 特征进行等同替换;而这些修改、变化或者替换,并不使相应技术方案的本质脱离本公开实施例技术方案的精神和范围,都应涵盖在本公开的保护范围之内。因此,本公开的保护范围应所述以权利要求的保护范围为准。 Finally, it should be noted that the above-mentioned embodiments are only specific implementations of the present disclosure and are used to illustrate the technical solutions of the present disclosure rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although refer to the foregoing The embodiments describe the present disclosure in detail. Those of ordinary skill in the art should understand that any person familiar with the technical field can still modify the technical solutions recorded in the foregoing embodiments within the technical scope disclosed in the present disclosure. changes may be easily imagined, or some of the technologies Features are equivalently substituted; and these modifications, changes or substitutions do not deviate from the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and shall be covered by the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be determined by the protection scope of the claims.

Claims (12)

  1. 一种音频线程处理方法,其特征在于,包括:An audio thread processing method, characterized by including:
    将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数;所述音频实例销毁函数用于销毁创建的音频实例;所述音频实例用于进行音频播放;Point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback;
    在音频停止播放的情况下,利用运行所述音频实例的第一线程调用所述音频实例销毁函数指向的所述音频处理函数;When the audio stops playing, use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function;
    获取通过执行所述音频处理函数,检测到的音频状态通知线程的运行状态;Obtain the running status of the audio status notification thread detected by executing the audio processing function;
    在所述运行状态指示所述音频状态通知线程已反馈针对所述音频的音频状态通知信息的情况下,利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例。When the running status indicates that the audio status notification thread has fed back the audio status notification information for the audio, the first thread is used to execute the audio instance destruction function to destroy the audio instance.
  2. 根据权利要求1所述的方法,其特征在于,根据以下步骤检测音频状态通知线程的运行状态:The method according to claim 1, characterized in that the running status of the audio status notification thread is detected according to the following steps:
    从所述应用中运行的多个线程中,确定出所述音频状态通知线程;Determine the audio status notification thread from a plurality of threads running in the application;
    获取所述音频状态通知线程在当前时刻指向的指令地址,并根据所述指令地址,确定所述音频状态通知线程是否处于空闲状态;Obtain the instruction address pointed by the audio status notification thread at the current moment, and determine whether the audio status notification thread is in an idle state based on the instruction address;
    若是,则暂停执行所述音频状态通知线程,并执行对所述音频状态通知线程的栈回溯操作,确定所述音频状态通知线程对应的调用栈信息;If so, suspend the execution of the audio status notification thread, and perform a stack traceback operation on the audio status notification thread to determine the call stack information corresponding to the audio status notification thread;
    根据所述调用栈信息,确定所述运行状态。The running status is determined based on the call stack information.
  3. 根据权利要求2所述的方法,其特征在于,所述方法还包括:The method of claim 2, further comprising:
    在确定所述音频状态通知线程未处于空闲状态的情况下,等待第一预设时长后返回执行获取所述音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定所述音频状态通知线程处于空闲状态。When it is determined that the audio status notification thread is not in an idle state, wait for the first preset time and then return to the step of obtaining the instruction address pointed by the audio status notification thread at the current moment until the audio status notification thread is determined. In idle state.
  4. 根据权利要求2所述的方法,其特征在于,所述根据所述调用栈信息,确定所述运行状态,包括:The method according to claim 2, wherein determining the running status according to the call stack information includes:
    从所述调用栈信息包括的多个调用库地址中,确定是否存在目标逻辑库对应的目标调用库地址;所述目标逻辑库中存储有音频打断处理逻辑信息,所述音频打断处理逻辑信息用于生成音频状态通知信息;From the multiple call library addresses included in the call stack information, determine whether there is a target call library address corresponding to the target logic library; audio interruption processing logic information is stored in the target logic library, and the audio interruption processing logic Information is used to generate audio status notification information;
    若不存在所述目标调用库地址,则确定所述运行状态包括:所述音频状态通知线程已反馈针对所述音频的音频状态通知信息。 If the target call library address does not exist, determining the running status includes: the audio status notification thread has fed back the audio status notification information for the audio.
  5. 根据权利要求4所述的方法,其特征在于,所述方法还包括:The method of claim 4, further comprising:
    在多个所述调用库地址中存在所述目标调用库地址的情况下,恢复执行所述音频状态通知线程,并在等待第二预设时长后返回执行获取所述音频状态通知线程在当前时刻指向的指令地址的步骤,直至确定多个所述调用库地址中不存在所述目标调用库地址。When the target call library address exists in multiple call library addresses, resume execution of the audio status notification thread, and return to execution after waiting for the second preset time period to obtain the audio status notification thread at the current moment. The step of pointing to the instruction address is until it is determined that the target call library address does not exist among the plurality of call library addresses.
  6. 根据权利要求5所述的方法,其特征在于,在所述利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例之后,还包括:The method according to claim 5, characterized in that, after using the first thread to execute the audio instance destruction function to destroy the audio instance, it further includes:
    恢复执行所述音频状态通知线程,以利用执行的所述音频状态通知线程,生成针对其他音频的音频状态通知信息并反馈给所述应用。Resume execution of the audio status notification thread to use the executed audio status notification thread to generate audio status notification information for other audios and feed it back to the application.
  7. 根据权利要求2所述的方法,其特征在于,所述指令地址包括程序计数器PC地址和返回地址;The method of claim 2, wherein the instruction address includes a program counter PC address and a return address;
    所述根据所述指令地址,确定所述音频状态通知线程是否处于空闲状态,包括:Determining whether the audio status notification thread is in an idle state according to the instruction address includes:
    在确定所述PC地址和返回地址均与目标函数体对应的地址相匹配的情况下,确定所述音频状态通知线程处于空闲状态。When it is determined that both the PC address and the return address match the address corresponding to the target function body, it is determined that the audio status notification thread is in an idle state.
  8. 根据权利要求1所述的方法,其特征在于,在检测音频状态通知线程的运行状态之前,还包括:The method according to claim 1, characterized in that before detecting the running status of the audio status notification thread, it further includes:
    确定所述音频实例对应的引用信息,并存储所述引用信息;Determine the reference information corresponding to the audio instance, and store the reference information;
    所述利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例,包括:Using the first thread to execute the audio instance destruction function to destroy the audio instance includes:
    根据存储的所述引用信息,确定所述音频实例的存储位置,并利用所述第一线程执行所述音频实例销毁函数,销毁在所述存储位置处的所述音频实例。According to the stored reference information, the storage location of the audio instance is determined, and the first thread is used to execute the audio instance destruction function to destroy the audio instance at the storage location.
  9. 一种音频线程处理装置,其特征在于,包括:An audio thread processing device, characterized by including:
    第一处理模块,用于将应用对应的音频实例销毁函数的调用入口指向预设的音频处理函数;所述音频实例销毁函数用于销毁创建的音频实例;所述音频实例用于进行音频播放;The first processing module is used to point the call entry of the audio instance destruction function corresponding to the application to the preset audio processing function; the audio instance destruction function is used to destroy the created audio instance; the audio instance is used for audio playback;
    调用模块,用于在音频停止播放的情况下,利用运行所述音频实例的第一线程调用所述音频实例销毁函数指向的所述音频处理函数;A calling module, configured to use the first thread running the audio instance to call the audio processing function pointed to by the audio instance destruction function when the audio stops playing;
    获取模块,用于获取通过执行所述音频处理函数,检测到的音频状态通知线程的运行状态; An acquisition module, used to acquire the running status of the audio status notification thread detected by executing the audio processing function;
    执行模块,用于在所述运行状态指示所述音频状态通知线程已反馈针对所述音频的音频状态通知信息的情况下,利用所述第一线程执行所述音频实例销毁函数,以销毁所述音频实例。Execution module, configured to use the first thread to execute the audio instance destruction function to destroy the audio instance destruction function when the running status indicates that the audio status notification thread has fed back the audio status notification information for the audio. Audio example.
  10. 一种计算机设备,其特征在于,包括:处理器、存储器,所述存储器存储有所述处理器可执行的机器可读指令,所述处理器用于执行所述存储器中存储的机器可读指令,所述机器可读指令被所述处理器执行时,所述处理器执行如权利要求1至8任意一项所述的音频线程处理方法的步骤。A computer device, characterized in that it includes: a processor and a memory, the memory stores machine-readable instructions executable by the processor, and the processor is used to execute the machine-readable instructions stored in the memory, When the machine-readable instructions are executed by the processor, the processor executes the steps of the audio thread processing method according to any one of claims 1 to 8.
  11. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被计算机设备运行时,所述计算机设备执行如权利要求1至8任意一项所述的音频线程处理方法的步骤。A computer-readable storage medium, characterized in that a computer program is stored on the computer-readable storage medium, and when the computer program is run by a computer device, the computer device executes the method according to any one of claims 1 to 8. The steps of the audio thread processing method described above.
  12. 一种计算机程序产品,其特征在于,当所述计算机程序产品在计算机上运行时,使得计算机执行如权利要求1-8中任一项所述的方法。 A computer program product, characterized in that, when the computer program product is run on a computer, it causes the computer to execute the method according to any one of claims 1-8.
PCT/CN2023/084321 2022-04-06 2023-03-28 Audio thread processing method and apparatus, computer device and storage medium WO2023193632A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210365555.0A CN114721800A (en) 2022-04-06 2022-04-06 Audio thread processing method and device, computer equipment and storage medium
CN202210365555.0 2022-04-06

Publications (1)

Publication Number Publication Date
WO2023193632A1 true WO2023193632A1 (en) 2023-10-12

Family

ID=82242574

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2023/084321 WO2023193632A1 (en) 2022-04-06 2023-03-28 Audio thread processing method and apparatus, computer device and storage medium

Country Status (2)

Country Link
CN (1) CN114721800A (en)
WO (1) WO2023193632A1 (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114721800A (en) * 2022-04-06 2022-07-08 北京字节跳动网络技术有限公司 Audio thread processing method and device, computer equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090083753A1 (en) * 2007-09-25 2009-03-26 Exent Technologies, Ltd. Dynamic thread generation and management for improved computer program performance
CN109634809A (en) * 2018-12-05 2019-04-16 腾讯音乐娱乐科技(深圳)有限公司 A kind of audio plays monitoring method and relevant device
CN113259744A (en) * 2021-05-13 2021-08-13 北京字跳网络技术有限公司 Video display method, device, equipment and medium
CN113365139A (en) * 2020-03-03 2021-09-07 腾讯科技(深圳)有限公司 Video recording method and device based on iOS system and storage medium
CN113810777A (en) * 2021-09-16 2021-12-17 上海哔哩哔哩科技有限公司 Playing method and device
CN114721800A (en) * 2022-04-06 2022-07-08 北京字节跳动网络技术有限公司 Audio thread processing method and device, computer equipment and storage medium

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20090083753A1 (en) * 2007-09-25 2009-03-26 Exent Technologies, Ltd. Dynamic thread generation and management for improved computer program performance
CN109634809A (en) * 2018-12-05 2019-04-16 腾讯音乐娱乐科技(深圳)有限公司 A kind of audio plays monitoring method and relevant device
CN113365139A (en) * 2020-03-03 2021-09-07 腾讯科技(深圳)有限公司 Video recording method and device based on iOS system and storage medium
CN113259744A (en) * 2021-05-13 2021-08-13 北京字跳网络技术有限公司 Video display method, device, equipment and medium
CN113810777A (en) * 2021-09-16 2021-12-17 上海哔哩哔哩科技有限公司 Playing method and device
CN114721800A (en) * 2022-04-06 2022-07-08 北京字节跳动网络技术有限公司 Audio thread processing method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN114721800A (en) 2022-07-08

Similar Documents

Publication Publication Date Title
WO2016127811A1 (en) Information processing method and terminal, and computer storage medium
WO2023193632A1 (en) Audio thread processing method and apparatus, computer device and storage medium
JP5756840B2 (en) Virtual time control device, virtual time control method, and non-transitory computer-readable storage medium
TWI612439B (en) Computing device, method and machine readable storage media for detecting unauthorized memory access
CN106155806B (en) Multitask scheduling method and server
JP7144642B2 (en) Behavior-based VM resource capture for forensics
JP6518649B2 (en) Method and system for collecting game data
WO2015103917A1 (en) Management method and apparatus of wireless routing device
JP2013073405A (en) Monitoring device, control method and control program
WO2018090506A1 (en) Method and device for exiting application
WO2016198027A1 (en) Multi-operation event execution method and device
TW201224921A (en) Decoding instructions from multiple instruction sets
WO2019127113A1 (en) Audio competition playing device and method therefor and mobile terminal
CN110298173A (en) The detection Malware hiding by the delay circulation of software program
JP2015534151A (en) System and method for generating event delivery information
CN110764965A (en) Process daemon method and device, electronic equipment and storage medium
CN106775620B (en) Timing method and device
EP2981894B1 (en) Method and apparatus for managing processes
WO2019007408A1 (en) Display method, device, wearable apparatus and computer-readable storage medium
EP3746901A1 (en) Protecting cryptographic keys stored in non-volatile memory
US9298502B2 (en) Pausing virtual machines using API signaling
JP6634083B2 (en) System error handling in data processing equipment
CN108132803B (en) Timing keep-alive and awakening method, system, terminal and medium based on mobile terminal
CN108009039B (en) Terminal information recording method, device, storage medium and electronic equipment
CN107003761A (en) System and method for intermodule communication

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 23784196

Country of ref document: EP

Kind code of ref document: A1