Scheduling method, electronic equipment and readable medium

By detecting the rotation angle information of electronic devices, the priority of the rotation thread is dynamically adjusted, and the thread blocking problem caused by the simultaneous scheduling of rotating threads and write threads is solved, and the timely transmission of audio data is realized and the user experience is improved.

CN119292554APending Publication Date: 2025-01-10HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310845214.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-07-10
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

In electronic devices, when rotating threads and write threads are scheduled at the same time, it may cause thread blockage, resulting in delayed audio data transmission, generating a burst sound, and reducing user experience.

Method used

By detecting the rotation angle information of the electronic device, the priority of the rotation thread is dynamically adjusted, so that it can obtain higher scheduling priority in the rotation scenario, ensuring timely scheduling and avoiding long waits for the write thread.

Benefits of technology

It effectively avoids thread blockage, ensures that audio data is transmitted to the speaker in time, improves user experience, and avoids the occurrence of sound explosion.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119292554A_ABST
    Figure CN119292554A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of intelligent terminals, and discloses a scheduling method, electronic equipment and a readable medium. According to the scheduling method, when it is detected that the electronic equipment rotates from the first posture to the second posture, the scheduling priority of the current rotating thread can be set based on the pre-configured high scheduling priority, so that the scheduling priority of the rotating thread is improved, the rotating thread is scheduled in time, and thread blocking is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of intelligent terminals, and in particular to a scheduling method, an electronic device and a readable medium. Background Art

[0002] When a user uses an electronic device to watch a video, in order to ensure the stereo playback effect of the electronic device, when the user rotates the electronic device, the electronic device can adjust the playback mode of the audio data according to the rotation angle of the electronic device, that is, the speaker on the left side of the electronic device always plays the audio data of the left channel, and the speaker on the right channel always plays the audio data of the right channel, thereby achieving a stereo effect.

[0003] In the process of adjusting the audio data playback mode, two threads are involved. One is the write thread, which is used to transmit the audio data to the speaker to play the audio data. The other is the rotation thread, which is used to switch the corresponding channels based on the rotation angle, that is, to adjust the audio data playback mode. In some cases, such as when both the write thread and the rotation thread need to be scheduled, the two threads may be blocked, which may cause the write thread to fail to be scheduled in time and fail to transmit the audio data to the speaker in time, resulting in popping sounds (POP sounds), which reduces the user experience. Summary of the invention

[0004] In order to prevent the writing thread from being unable to be scheduled in time and unable to transmit the audio data to the speaker in time, thereby causing popping sounds, the embodiments of the present application provide a scheduling method, an electronic device, and a readable medium.

[0005] In a first aspect, an embodiment of the present application provides a scheduling method, which is applied to an electronic device, including: the electronic device is in a first posture, and a first thread of the electronic device has a first priority, wherein the first thread is used to adjust the channel playback mode of the electronic device; detecting that the electronic device rotates from the first posture to the second posture, calling a first function to adjust the priority of the first thread from the first priority to the second priority, wherein the second priority is higher than the first priority; calling the first thread to adjust the channel playback mode of the electronic device to the channel playback mode corresponding to the second posture.

[0006] In the embodiment of the present application, the first posture may be a horizontal posture or a vertical posture, and the second posture may be a vertical posture or a horizontal posture. The rotation angles of the first posture and the second posture may be the rotation angle information in the embodiment of the present application. The first thread may be a rotating thread in the embodiment of the present application, the first priority may be a default scheduling priority of the rotating thread in the embodiment of the present application, and the second priority may be a higher scheduling priority of the rotating thread in the embodiment of the present application.

[0007] The embodiment of the present application enables the electronic device to set the scheduling priority of the rotation thread based on a pre-configured higher scheduling priority when detecting a change in the posture information of the electronic device, such as detecting rotation angle information, so as to increase the scheduling priority of the rotation thread, realize timely scheduling of the rotation thread, avoid thread blocking, and avoid the write thread being in a waiting state for a long time.

[0008] In one possible implementation, when it is detected that the electronic device is rotated from a first posture to a second posture, a first function is called to adjust the priority of the first thread from the first priority to the second priority, including: when it is detected that the electronic device is rotated from the first posture to the second posture, a flag of the first thread is set to a first identifier; when it is detected that the flag of the first thread is the first identifier, a first function is called to adjust the priority of the first thread from the first priority to the second priority.

[0009] It can be understood that the first flag may be true.

[0010] In one possible implementation, calling the first function to adjust the priority of the first thread from the first priority to the second priority includes: calling the first function to obtain the second priority of the first thread recorded in the priority mapping table, and adjusting the priority of the first thread from the first priority to the second priority.

[0011] It can be understood that the first function can be the setParameterPriority function in the embodiment of the present application. Through the preset function, the scheduling priority of the rotation thread can be set according to the detected rotation angle information and the priority mapping table.

[0012] In a possible implementation, calling the first function to obtain the second priority of the first thread recorded in the priority mapping table includes: calling the first function to obtain the second priority of the first thread recorded in the priority mapping table based on rotation angle information corresponding to the second posture.

[0013] In a possible implementation, when it is detected that the first thread has been executed, the first function is called to adjust the priority of the first thread from the second priority to the first priority.

[0014] In the embodiment of the present application, after the rotation angle is set, the priority of the first thread can be restored to the first priority through the first function to avoid interfering with the scheduling of other threads. The first function can be the setParameterPriority function in the embodiment of the present application.

[0015] In one possible implementation, when it is detected that the first thread has completed execution, a first function is called to adjust the priority of the first thread from the second priority to the first priority, including: when it is detected that the first thread has completed execution, a flag of the first thread is set to a second flag; when it is detected that the flag of the first thread is the second flag, the first function is called to adjust the priority of the first thread from the second priority to the first priority.

[0016] In the embodiment of the present application, the second identifier may be a false identifier.

[0017] In a possible implementation, when it is detected that the electronic device is started, the priority configuration file is parsed to obtain a priority mapping table.

[0018] In an embodiment of the present application, when it is detected that the electronic device is started, the thread priority processing module can parse the priority configuration file to obtain a priority mapping table.

[0019] In a possible implementation, when it is detected that the first thread has been executed, the first thread releases the resource mutex; when it is detected that the resource mutex is not occupied, the second thread occupies the resource mutex, wherein the second thread is used to transmit audio data.

[0020] In the embodiment of the present application, the second thread may be a write thread of the hardware abstraction layer (HAL) in the embodiment of the present application.

[0021] In a second aspect, an embodiment of the present application provides an electronic device, comprising: a memory for storing instructions executed by one or more processors of the electronic device, and a processor, which is one of the one or more processors of the electronic device, for implementing any scheduling method provided by the above-mentioned first aspect and various possible implementations of the above-mentioned first aspect.

[0022] In a third aspect, an embodiment of the present application provides a readable medium having instructions stored thereon, which, when executed on an electronic device, enables the electronic device to implement any scheduling method provided by the first aspect and various possible implementations of the first aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] Figure 1 According to an embodiment of the present application, a schematic diagram of a scenario in which the tablet computer 100 is rotated from a horizontal position to a vertical position is shown;

[0024] Figure 2 According to an embodiment of the present application, a schematic diagram of an electronic device system architecture is shown;

[0025] Figure 3According to an embodiment of the present application, a schematic diagram of threads involved in a rotation scenario in an electronic device system architecture is shown;

[0026] Figure 4 According to an embodiment of the present application, a flow chart of a scheduling method is shown;

[0027] Figure 5 According to an embodiment of the present application, an interactive schematic diagram of a scheduling method is shown;

[0028] Figure 6 According to some embodiments of the present application, a schematic structural diagram of an electronic device 10 is shown. DETAILED DESCRIPTION

[0029] The illustrative embodiments of the present application include, but are not limited to, a scheduling method, an electronic device, and a readable medium.

[0030] It can be understood that the technical solution of the present application is applicable to electronic devices, for example, including but not limited to mobile phones, smart watches, televisions, tablet computers, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptop computers, ultra-mobile personal computers (UMPC), netbooks, personal digital assistants (PDA), etc. The embodiments of the present invention do not impose any restrictions on the specific types of electronic devices.

[0031] Figure 1 FIG. 1 shows a schematic diagram of a user rotating a tablet computer 100 while watching a video. For example, when a user rotates the tablet computer 100 from the Figure 1 The horizontal placement shown in a is rotated as Figure 1 During the vertical placement process shown in b, the sensor of the tablet computer 100 can detect that the posture of the tablet computer 100 has changed, and can adjust the playing mode of the audio data according to the detected rotation angle of the tablet computer 100.

[0032] In some embodiments, Figure 1 As shown in FIG. 1 , the tablet computer 100 has multiple speakers. The speakers at different positions of the tablet computer 100 play audio data of different channels to achieve a rotating sound effect. Figure 1When placed horizontally as shown in a, the left channel audio data is played through the speakers corresponding to power amplifiers (PA) 1 and PA2, and the right channel audio data is played through the speakers corresponding to PA3 and PA4. Figure 1 b, the left channel audio data is played through the speakers corresponding to PA2 and PA4, and the right channel audio data is played through the speakers corresponding to PA1 and PA3. In this way, during the rotation of the tablet computer 100, the left speaker always plays the left channel audio data of the application (APP), and the right channel speaker plays the right channel audio data of the APP.

[0033] It can be understood that when the user uses the tablet computer 100 to play audio data, while rotating the tablet computer, two threads are involved in the operation, one is a writing thread, which is used to transmit the audio data to the speaker to play the audio data. The other is a rotation thread, which is used to switch the corresponding channel based on the rotation angle, that is, to adjust the playing mode of the audio data.

[0034] For example, when the sensor detects the rotation angle information, the rotation angle information is passed to the rotation thread. At the same time, the application that plays audio will also send audio data to the write thread in real time. The electronic device system defaults to setting the rotation thread and the write thread to share a resource mutex lock, where the resource mutex lock is used to enable the locked thread to obtain scheduling resources relative to the unlocked party, and can be scheduled, while the unlocked party cannot be scheduled. When the rotation thread receives the rotation angle, the resource mutex lock will be occupied. However, due to the lower priority of the rotation thread, such as the priority of the sound effect parameter thread or other threads, although the rotation thread occupies the resource mutex lock, the rotation thread cannot be scheduled in time, resulting in the inability to release the resource mutex lock in time, which in turn causes thread blocking, that is, the write thread cannot obtain the resource mutex lock, so that the write thread cannot be scheduled in time, and cannot send audio data to the speaker in time, thereby producing popping sound, which reduces the user experience.

[0035] In order to solve the problem that the write thread cannot obtain the resource mutex lock in time, causing the write thread to be in a waiting state for a long time and causing popping sound, an embodiment of the present application provides a scheduling method, which can pre-configure a higher scheduling priority of the rotating thread in a rotation scenario (for example, higher than the default scheduling priority of the rotating thread set by the electronic device system). In this way, when the electronic device detects the rotation angle information of the electronic device, it can set the scheduling priority of the current rotating thread based on the pre-configured higher scheduling priority, so as to improve the priority of the rotating thread, schedule the rotating thread in time, and avoid the write thread being in a waiting state for a long time.

[0036] In some embodiments, the correspondence between the rotation parameter and the scheduling priority, such as the correspondence between the rotation angle information and the scheduling priority, can be preset and recorded in a priority mapping table. When the rotation angle information is detected, a preset function, such as the setParameterPriority function, can be called to set the scheduling priority of the HAL rotation thread according to the detected rotation angle information and the priority mapping table through the preset function.

[0037] For example, the default priority value of the rotating thread is 120. When the user rotates the electronic device from horizontal to vertical placement, the flag of the rotating thread is updated to the first flag (for example, true). At this time, the preset function can be called to set the scheduling priority of the rotating thread to the preset higher scheduling priority of 100, thereby increasing the priority value of the rotating thread from 120 to 100, so that when the rotating thread occupies the resource mutex lock, it can be scheduled in time and the resource mutex lock can be released in time, avoiding the writing thread from being in a waiting state for a long time, avoiding the blocking of the writing thread, and avoiding popping sound.

[0038] It can be understood that the lower the value of the priority, the higher the priority level. For example, if the priority value of the write thread is 90 and the priority value of the spin thread is 120, the priority of the write thread is greater than the priority of the spin thread.

[0039] In an embodiment of the present application, after the rotation angle is set, the flag of the rotation thread is updated to a second flag (eg, false), and the priority of the rotation thread can be restored to a default priority through a preset function to avoid interfering with the scheduling of other threads.

[0040] The following describes the method of transmitting audio data during audio playback of electronic devices in combination with the structure of the electronic device. Figure 2 As shown, the electronic device includes an APP layer, a framework layer (framework, FWK), a HAL, a kernel layer (kernel), and a hardware layer.

[0041] The APP layer includes a music player application and an APP layer thread. The music player application is used to detect the user's operation and send the instruction corresponding to the operation to the APP layer thread. The APP layer thread is used to determine the corresponding audio data according to the instruction corresponding to the operation and write the audio data into the buffer 1 (or shared buffer) of the FWK layer.

[0042] The FWK layer includes buffer 1 and framework layer threads. Buffer 1 is used to temporarily store data sent by the APP layer thread, such as audio data. The framework layer thread is used to obtain the data stored in buffer 1 and send the data to the HAL thread of the HAL layer.

[0043] The HAL layer includes a HAL layer thread. The HAL layer thread is used to obtain data sent by the framework layer thread, such as audio data, and write the data into the buffer 2 of the kernel layer.

[0044] The kernel layer includes a buffer 2. The buffer 2 is used to temporarily store data sent by the HAL layer thread, such as audio data.

[0045] The hardware layer includes a digital signal processor (DSP) and a speaker. The DSP is used to obtain audio data from the buffer 2, process the audio data, and send it to the speaker. The speaker is used to obtain and play the audio data sent by the DSP.

[0046] In order to better understand the thread calling method during the rotation of the tablet, the following Figure 3 The structure of the electronic device shown in the figure introduces in detail the thread calling method during the rotation of the tablet computer.

[0047] like Figure 3 As shown, the framework layer threads of the FWK layer include a write thread and a parameter setting thread, and the FWK layer also includes a system service, a sensor service, and a thread priority processing module.

[0048] The write thread is used to obtain and transfer the audio data stored in buffer 1, and write the audio data to the HAL write thread and sound effect thread of the HAL layer.

[0049] When the sensor detects that the electronic device is rotating, the posture data of the electronic device, such as the rotation angle information obtained, can be sent to the system service as the detected data. The system service is used to start the rotation process when the rotation angle information is obtained, and send the rotation angle information to the parameter setting thread. The parameter setting thread is used to input the rotation angle information into the HAL rotation thread of the HAL layer.

[0050] The HAL threads of the HAL layer include the HAL write thread, the sound effect thread, the HAL rotation thread, and the parameter setting function (adevset parameters).

[0051] The HAL write thread (or write thread) is used to write the audio data passed in by the FWK layer's write thread into the kernel layer's buffer 2. The sound effect thread (or effect thread) is used to call the parameter setting function and set the sound effect parameters according to the audio data passed in by the FWK layer's write thread, such as setting the digital theater system (DTS) sound effect. The HAL rotation thread is used to receive the rotation angle information passed in by the FWK layer's parameter setting thread, call the parameter setting function to process the rotation angle information, pass the rotation angle information to the kernel layer, and finally set it in the DSP to achieve channel switching. For example, on a tablet computer such as Figure 1 When placed horizontally as shown in a, the left channel audio data is played through the speakers corresponding to PA1 and PA2, and the right channel audio data is played through the speakers corresponding to PA3 and PA4. Figure 1 When placed vertically as shown in b, the audio data of the left channel is played through the speakers corresponding to PA2 and PA4, and the audio data of the right channel is played through the speakers corresponding to PA1 and PA3.

[0052] The thread priority processing module is used to parse the priority mapping table and store the information recorded in the priority mapping table in the memory. When the parameter setting thread obtains the rotation angle information, the priority of the HAL rotation thread is determined and increased based on the priority mapping table parsed by the thread priority processing module, so that the HAL rotation thread can be scheduled in time when it occupies the resource mutex.

[0053] The kernel layer also includes a thread priority configuration module. The thread priority configuration module is used to configure a priority mapping table of different parameters and corresponding thread scheduling priorities. For example, the thread priority configuration module configures the corresponding relationship between the rotation angle information and the HAL rotation thread scheduling priority, and records it in the priority mapping table. Among them, the higher scheduling priority of the thread recorded in the priority mapping table is higher than the default scheduling priority.

[0054] The scheduling method provided in the embodiment of the present application is described in detail below. The scheduling method in the embodiment of the present application is applied to electronic equipment. Figure 4 A schematic diagram of a scheduling method according to an embodiment of the present application is shown, and the scheduling method includes:

[0055] 401: Configure a priority mapping table.

[0056] In an embodiment of the present application, a priority mapping table of different parameters and corresponding thread scheduling priorities can be configured through a thread priority configuration module of the kernel layer of an electronic device. The correspondence between the parameters and the scheduling priorities recorded in the priority mapping table can be combined with specific application scenarios. It can be understood that the higher scheduling priority of the HAL rotating thread recorded in the priority mapping table is greater than the default scheduling priority of the HAL rotating thread, that is, the higher scheduling priority value of the HAL rotating thread recorded in the priority mapping table is less than the default scheduling priority of the HAL rotating thread.

[0057] For example, if the default scheduling priority value of the HAL rotation angle is 120, then set the higher scheduling priority value of the HAL rotation thread to 100.

[0058] It can be understood that when the electronic device is started, mParameterPriority is enabled and the scheduling priority of the HAL rotation thread is set to the default scheduling priority; the thread priority processing module of the electronic device can parse the priority mapping table and store the information recorded in the priority mapping table in the memory.

[0059] 402: Detecting the rotation angle information of the electronic device.

[0060] In the embodiment of the present application, when the posture of the electronic device changes, the sensor of the electronic device can detect the posture change information of the electronic device, such as rotation angle information.

[0061] For example, when the user turns the tablet computer 100 from Figure 1 Place it horizontally as shown in a and rotate it to Figure 1 When placed vertically as shown in b, the sensor of the tablet computer 100 can detect that the rotation angle of the electronic device is 90°.

[0062] In an embodiment of the present application, the sensor can transmit the rotation angle information to the system service, start the rotation process, and the system service sends the rotation angle information to the parameter setting thread. The parameter setting thread can send the rotation angle information to the HAL rotation thread.

[0063] It can be understood that when the HAL rotation thread obtains the rotation angle information, the resource mutex lock is occupied.

[0064] It can be understood that a thread is the smallest unit that the operating system can schedule operations on. It is contained in a process and is the actual operating unit in the process. A thread refers to a single sequential control flow in a process. Multiple threads can run concurrently in a process, and each thread executes different tasks in parallel. In a multi-threaded system, each thread is assigned an execution priority. The priority determines the order in which the thread is executed by the central processing unit (CPU). Threads with higher priorities can obtain more execution time than threads with lower priorities in a period of time. Scheduling is the allocation of CPU resources among threads. The concurrent execution of multiple threads is actually carried out through a schedule.

[0065] Resource mutex locks are used to protect threads from completely executing operations on shared resources without being intervened by other threads during the access process.

[0066] 403: Call a preset function to set the HAL rotation angle thread to a higher scheduling priority recorded in the priority mapping table.

[0067] In an embodiment of the present application, when the parameter setting thread obtains the rotation angle information, the flag of the HAL rotation thread is set to the first flag, and a preset function, such as setParameterPriority, GetParameterPriority, and androidSetThreadPriority function, is called to determine the higher scheduling priority of the HAL rotation thread based on the obtained rotation angle information and the priority mapping table parsed by the thread priority processing module, and set the HAL rotation thread to the higher scheduling priority recorded in the priority mapping table.

[0068] For example, corresponding to the scene where the rotation angle information is detected, the flag of the HAL rotation thread is true, that is, the input parameter of the setParameterPriority function is true, so that the higher priority of the HAL rotation thread is obtained through the setParameterPriority function based on GetParameterPriority. The higher priority value of the HAL rotation thread obtained through GetParameterPriority is 100, and androidSetThreadPriority is called to set the priority of the HAL rotation thread to a higher priority value of 100.

[0069] In the embodiment of the present application, the parameter setting thread can set the HAL rotation thread according to the value of the higher scheduling priority recorded in the priority mapping table, so that after the HAL rotation thread obtains the resource mutex, it can be scheduled in time, and then release the resource mutex in time. Avoid occupying the resource mutex for a long time, resulting in the HAL write thread being unable to obtain the resource mutex, causing thread blocking, and avoiding popping sound.

[0070] 404: The HAL spinning thread is detected to have finished executing, and a preset function is called to set the HAL spinning thread to the default scheduling priority.

[0071] It can be understood that when it is detected that the execution of the HAL rotating thread has ended, the parameter setting function can call preset functions, such as the setParameterPriority and androidSetThreadPriority functions, to set the flag of the HAL rotating thread to the second flag, release the resource mutex lock, and set the HAL rotating thread to the default scheduling priority, such as setting the scheduling priority value of the HAL rotating thread to 120, to avoid the HAL rotating thread occupying the resource mutex lock and causing thread blocking.

[0072] For example, when it is detected that the HAL spinning thread has finished executing, the flag of the HAL spinning thread and the input parameter of the setParameterPriority function are updated to false, and the androidSetThreadPriority function is called to set the priority of the HAL spinning thread to the default priority.

[0073] In an embodiment of the present application, by pre-configuring a higher scheduling priority of the HAL rotation thread in different scenarios, when the electronic device detects the rotation angle information of the electronic device, it can set the scheduling priority of the current HAL rotation thread based on the pre-configured higher scheduling priority to increase the priority of the HAL rotation thread, realize timely scheduling of the HAL rotation thread, avoid the HAL write thread being in a waiting state for a long time, and avoid the generation of popping sounds.

[0074] The following example takes the scenario of a user rotating a tablet computer while using it as an example. Figure 5 The interactive schematic diagram shown in the figure illustrates the scheduling method provided in the embodiment of the present application. The scheduling method includes:

[0075] 501: FWK reads and parses the priority configuration file from the kernel layer.

[0076] In an embodiment of the present application, when the tablet computer starts (or when the FWK starts), the thread priority processing module of the FWK reads and parses the priority configuration file recorded by the thread priority configuration module in the kernel layer, that is, the priority mapping table between parameters and scheduling priorities, and the thread priority processing module supports the parameter setting thread to query the correspondence between parameters and scheduling priorities in real time, so that the parameter setting thread adjusts the priority of the thread according to the priority mapping table.

[0077] The correspondence between the parameters recorded in the priority mapping table and the scheduling priority can also be combined with specific application scenarios. For example, the default scheduling priority value of the HAL rotation angle is 120, and the scheduling priority of the HAL write thread is 90. Corresponding to the scenario where the rotation angle information is detected, the higher scheduling priority of the HAL rotation thread is 100.

[0078] In some embodiments, the thread priority processing module may write the parsed priority mapping table into the memory.

[0079] It can be understood that when the electronic device is started, mParameterPriority is enabled and the scheduling priority of the HAL rotation thread is set to the default scheduling priority.

[0080] 502: APP plays audio.

[0081] In an embodiment of the present application, when the APP detects that the user clicks on an audio playback control or a video playback control, the audio data corresponding to the user's click operation is sent to the FWK to play the audio or video.

[0082] 503: FWK calls HAL write operation from the HAL layer.

[0083] In an embodiment of the present application, when the FWK obtains the audio data, the write thread of the FWK may call the HAL write thread from the HAL layer to implement the HAL write operation.

[0084] In some embodiments, the write thread (or playback thread) of the FWK may call the HAL write function through the first (binder) communication mechanism.

[0085] 504: The HAL layer writes the APP audio data to the kernel buffer of the kernel layer.

[0086] In an embodiment of the present application, the HAL layer can write the audio data sent by the FWK layer into the buffer 2 of the kernel layer through the HAL write thread.

[0087] 505: The kernel layer sends direct memory access (DMA) audio data to the ADSP of the hardware layer.

[0088] In an embodiment of the present application, when the buffer 2 of the kernel layer obtains audio data, DMA is triggered to send the audio data to the ADSP of the hardware, so that the audio data is processed by the algorithm on the ADSP side, and the processed audio data is sent to the speaker to realize audio playback.

[0089] 506: The hardware layer reports the rotation trigger angle information to FWK.

[0090] In an embodiment of the present application, when the user rotates the tablet computer, the sensor at the hardware layer detects the rotation angle information of the electronic device and reports the rotation angle information, the system service (system_server) starts the rotation processing, and sends the rotation angle information to the parameter setting thread of FWK.

[0091] In an embodiment of the present application, when the parameter setting thread obtains the rotation angle information, the flag of the HAL rotation thread is set to the first flag (true), and a preset function is called, such as the setParameterPriority function, which obtains the higher priority of the HAL rotation thread based on GetParameterPriority, and calls androidSetThreadPriority to set the priority of the HAL rotation thread to a higher priority.

[0092] 507: FWK queries the mapping table to increase the priority of the HAL spinning thread of the HAL layer.

[0093] In an embodiment of the present application, the parameter setting thread of FWK can set a higher scheduling priority of the HAL rotation thread according to the acquired rotation angle information and the priority mapping table parsed by the thread priority processing module to improve the scheduling priority of the HAL rotation thread in real time.

[0094] For example, the default scheduling priority of the HAL rotation thread is 120, and the scheduling priority of the HAL rotation thread recorded in the priority mapping table parsed by the thread priority processing module is 100, then the parameter setting thread increases the priority of the HAL rotation thread to 100.

[0095] Among them, the parameter setting thread can improve the scheduling priority of the HAL spinning thread in the following ways:

[0096] First, it is determined whether the parameter setting thread is enabled or effective, that is, whether the parameter setting thread can set the priority. The determination method may be to determine whether the flag of the HAL rotation thread is true.

[0097] Among them, when the electronic device is detected to be rotating, the flag of the HAL rotation thread is true, that is, the input parameter of the setParameterPriority function is true, so as to obtain the higher priority of the HAL rotation thread based on GetParameterPriority through the setParameterPriority function. Get the higher priority of the HAL rotation thread through GetParameterPriority, and call androidSetThreadPriority to set the priority of the HAL rotation thread to a higher priority. When it is detected that the HAL rotation thread has been executed, the input parameter of the setParameterPriority function is changed to false, and the androidSetThreadPriority function is called to set the priority of the HAL rotation thread to the default priority.

[0098] Among them, enable refers to the input and output of the control signal, that is, an "allow" signal.

[0099] 508: The HAL layer sets the rotation angle information to the kernel layer.

[0100] In the embodiment of the present application, the HAL rotation thread may call a parameter setting function (adev_set_parameters) to transfer the rotation angle information to the buffer 2 of the kernel layer.

[0101] 509: The kernel layer sets the rotation angle information to the ADSP of the hardware layer.

[0102] In an embodiment of the present application, the buffer 2 of the kernel layer obtains the rotation angle information and can transmit the rotation angle information to the ADSP in the DSP of the hardware layer through remote processing multi-core communication (audio packet routing, APR) to switch the left and right channels through the algorithm on the ADSP side.

[0103] It can be understood that when the HAL rotation thread completes setting the rotation angle information, the resource mutex lock is released.

[0104] 510: FWK sets the sound effect parameters to the HAL layer.

[0105] In an embodiment of the present application, the write thread (or playback thread) of FWK can simultaneously set the sound effect parameters to the sound effect thread, and then the sound effect thread (or first thread) corresponding to the HAL layer waits for the HAL rotation thread to release the resource mutex lock in the parameter setting function.

[0106] In some embodiments, corresponding to a scenario where the sound effect parameters do not need to be modified, step 510 may not be included.

[0107] 511: The parameter setting thread of the FWK layer restores the priority of the HAL spinning thread to the default priority.

[0108] In an embodiment of the present application, when the HAL rotation thread is executed, the parameter setting thread of the FWK can update the flag bit of the HAL rotation thread to the second flag, and call the setParameterPriority function to restore the scheduling priority of the HAL rotation thread to the default scheduling priority.

[0109] For example, the default priority of the HAL spinning thread is 120, and the parameter setting thread reduces the priority of the HAL spinning thread to 120.

[0110] For example, when it is detected that the HAL spinning thread has finished executing, the input parameter of the setParameterPriority function is changed to false, and the androidSetThreadPriority function is called to set the priority of the HAL spinning thread to the default priority of 120.

[0111] 512: The HAL layer sends the sound effect parameter setting to FWK.

[0112] In the embodiment of the present application, due to the real-time improvement of the scheduling priority of the HAL rotating thread, the HAL write thread can be scheduled in time, ensuring the quick release of the mutex lock in the parameter setting function (less than 20ms), avoiding the situation where the HAL write thread and the sound effect thread corresponding to the HAL layer cannot obtain the mutex lock for a long time and block the FWKHAL write thread, and realizing the execution of the sound effect configuration after the HAL write thread obtains the resource mutex lock.

[0113] 513: FWK calls HAL write operation to the HAL layer.

[0114] In the embodiment of the present application, since the write thread (or playback thread) of FWK does not need to wait for a long time for the sound effect setting operation, the audio data writing operation can be performed in time, avoiding the generation of popping sounds.

[0115] 514: The HAL layer writes APP audio data to the kernel buffer.

[0116] In the embodiment of the present application, the HAL write thread of the HAL layer can write the audio data into the buffer 2 of the kernel layer.

[0117] 515: The kernel layer sends DMA audio data to the hardware ADSP.

[0118] In an embodiment of the present application, when the buffer 2 of the kernel layer obtains audio data, DMA is triggered to send the audio data to the ADSP of the hardware DSP, so as to switch the left and right channels through the algorithm on the ADSPSP side to realize audio playback.

[0119] In an embodiment of the present application, the scheduling priority of the current HAL rotation thread can be set based on a pre-configured higher scheduling priority to increase the priority of the HAL rotation thread, implement timely scheduling of the HAL rotation thread, avoid the HAL write thread being in a waiting state for a long time, and avoid popping sound.

[0120] The hardware structure of each electronic device mentioned in this application is described below by taking the electronic device 10 as an example. Figure 6 As shown, the electronic device 10 may include a processor 110, a power module 140, a memory 180, a mobile communication module 130, a wireless communication module 120, a sensor module 190, an audio module 150, a camera 170, an interface module 160, a button 101 and a display screen 102, etc.

[0121] It is to be understood that the structure illustrated in the embodiment of the present invention does not constitute a specific limitation on the electronic device 10. In other embodiments of the present application, the electronic device 10 may include more or fewer components than shown in the figure, or combine some components, or separate some components, or arrange the components differently. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.

[0122] The processor 110 may include one or more processing units, for example, a processing module or processing circuit including a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processing (DSP), a microprocessor (MCU), an artificial intelligence (AI) processor, or a programmable logic device (field programmable gate array, FPGA). Different processing units may be independent devices or integrated into one or more processors. A storage unit may be provided in the processor 110 for storing instructions and data. In some embodiments, the storage unit in the processor 110 is a cache memory 180.

[0123] It can be understood that the scheduling method in the embodiment of the present application can be executed by the processor 110 of the corresponding electronic device. The power module 140 may include a power supply, a power management component, etc. The power supply may be a battery. The power management component is used to manage the charging of the power supply and the power supply of the power supply to other modules. In some embodiments, the power management component includes a charging management module and a power management module. The charging management module is used to receive charging input from the charger; the power management module is used to connect the power supply, the charging management module and the processor 110. The power management module receives input from the power supply and / or the charging management module to power the processor 110, the display screen 102, the camera 170, and the wireless communication module 120.

[0124] The mobile communication module 130 may include, but is not limited to, an antenna, a power amplifier, a filter, a low noise amplifier (LNA), etc. The mobile communication module 130 may provide a solution for wireless communications including 2G / 3G / 4G / 5G, etc., applied to the electronic device 10. The mobile communication module 130 may receive electromagnetic waves by an antenna, and perform filtering, amplification, and other processing on the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 130 may also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna. In some embodiments, at least some of the functional modules of the mobile communication module 130 may be arranged in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 130 may be arranged in the same device as at least some of the modules of the processor 110.

[0125] The wireless communication module 120 may include an antenna, and transmit and receive electromagnetic waves via the antenna. The wireless communication module 120 may provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc., which are applied to the electronic device 10. The electronic device 10 may communicate with the network and other devices through wireless communication technology.

[0126] It can be understood that in the embodiment of the present application, when the electronic device is a receiving device, the video data and audio data from other electronic devices in the recording group, as well as the recording content label and time stamp information corresponding to each data, can be received through the wireless communication module. And when the electronic device is a sending device, the video data and audio data, as well as the recording content label and time stamp information corresponding to each data, can be sent to other electronic devices in the recording group through the wireless communication module.

[0127] In some embodiments, the mobile communication module 130 and the wireless communication module 120 of the electronic device 10 may also be located in the same module.

[0128] The display screen 102 is used to display a human-computer interaction interface, images, videos, etc. The display screen 102 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light emitting diode or an active-matrix organic light emitting diode (AMOLED), a flexible light-emitting diode (FLED), a quantum dot light emitting diode (QLED), etc.

[0129] The sensor module 190 may include a proximity light sensor, a pressure sensor, a gyro sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and the like.

[0130] The audio module 150 is used to convert digital audio information into an analog audio signal output, or to convert an analog audio input into a digital audio signal. The audio module 150 can also be used to encode and decode audio signals. In some embodiments, the audio module 150 can be arranged in the processor 110, or some functional modules of the audio module 150 can be arranged in the processor 110. In some embodiments, the audio module 150 may include a speaker, an earpiece, a microphone, and an earphone interface. The camera 170 is used to capture static images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element converts the optical signal into an electrical signal, and then passes the electrical signal to the image signal processing (image signal processing, ISP) to convert it into a digital image signal. The electronic device 10 can realize the shooting function through the ISP, the camera 170, the video codec, the graphic processing unit (graphic processing unit, GPU), the display screen 102 and the application processor.

[0131] The interface module 160 includes an external memory interface, a USB interface, and a subscriber identification module (SIM) card interface. The external memory interface can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 10. The external memory card communicates with the processor 110 via the external memory interface to implement a data storage function. The universal serial bus interface is used for the electronic device 10 to communicate with other electronic devices. The subscriber identification module card interface is used to communicate with a SIM card installed in the electronic device 10, for example, to read a phone number stored in the SIM card, or to write a phone number into the SIM card.

[0132] In some embodiments, the electronic device 10 further includes a button 101, a motor, an indicator, etc. Among them, the button 101 may include a volume button, an on / off button, etc. The motor is used to make the electronic device 10 vibrate, for example, vibrate when the user's electronic device 10 is called, so as to prompt the user to answer the call of the electronic device 10. The indicator may include a laser indicator, a radio frequency indicator, an LED indicator, etc.

[0133] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.

[0134] Program code may be applied to input instructions to perform the functions described herein and to generate output information. The output information may be applied to one or more output devices in a known manner. For purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.

[0135] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.

[0136] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including but not limited to floppy disks, optical disks, optical disks, read-only memories (compact disc-read only memories, CD-ROMs), magneto-optical disks, read-only memories (read only memory, ROM), random access memories (random access memory, RAM), erasable programmable read-only memories (erasable programmable read-only memories, EPROM), electrically erasable programmable read-only memories (electrically erasable programmable read-only memories, EEPROM), magnetic or optical cards, flash memory, or a tangible machine-readable memory for transmitting information (e.g., carrier waves, infrared signals, digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Accordingly, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).

[0137] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.

[0138] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.

[0139] It should be noted that in the examples and description of this patent, the terms "include", "comprises" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also includes other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, an element defined by the sentence "includes one" does not exclude the presence of other identical elements in the process, method, article or device including the element. Although the present application has been illustrated and described with reference to certain preferred embodiments of the present application, it should be understood by those skilled in the art that various changes may be made to it in form and detail without departing from the spirit and scope of the present application.

Claims

1. A scheduling method, applied to electronic equipment, characterized in that: include: The electronic device is in a first posture, and a first thread of the electronic device has a first priority, wherein the first thread is used to adjust a channel playing mode of the electronic device; detecting that the electronic device rotates from the first posture to a second posture, calling a first function to adjust the priority of the first thread from the first priority to a second priority, wherein the second priority is higher than the first priority; The first thread is called to adjust the channel playing mode of the electronic device to the channel playing mode corresponding to the second posture.

2. The scheduling method according to claim 1, characterized in that: The detecting that the electronic device rotates from the first posture to the second posture, and calling a first function to adjust the priority of the first thread from the first priority to the second priority, includes: Detecting that the electronic device rotates from the first posture to the second posture, setting the flag bit of the first thread to a first identifier; It is detected that the flag bit of the first thread is the first identifier, and the first function is called to adjust the priority of the first thread from the first priority to a second priority.

3. The scheduling method according to claim 1, characterized in that: The calling the first function to adjust the priority of the first thread from the first priority to the second priority includes: The first function is called to obtain the second priority of the first thread recorded in the priority mapping table, and the priority of the first thread is adjusted from the first priority to the second priority.

4. The scheduling method according to claim 3, characterized in that: The calling the first function to obtain the second priority of the first thread recorded in the priority mapping table includes: The first function is called to obtain the second priority of the first thread recorded in the priority mapping table based on the rotation angle information corresponding to the second posture.

5. The scheduling method according to claim 1, characterized in that: include: It is detected that the first thread has been executed, and a first function is called to adjust the priority of the first thread from the second priority to the first priority.

6. The scheduling method according to claim 5, characterized in that: The detecting that the first thread has been executed and calling a first function to adjust the priority of the first thread from the second priority to the first priority includes: Upon detecting that the first thread has been executed, setting a flag of the first thread to a second flag; It is detected that the flag bit of the first thread is the second flag, and the first function is called to adjust the priority of the first thread from the second priority to the first priority.

7. The scheduling method according to claim 4, characterized in that: include: When it is detected that the electronic device is started, the priority configuration file is parsed to obtain the priority mapping table.

8. The scheduling method according to claim 1, characterized in that: include: Upon detecting that the first thread has completed execution, the first thread releases the resource mutex lock; It is detected that the resource mutex lock is not occupied, and a second thread occupies the resource mutex lock, wherein the second thread is used to transmit audio data.

9. An electronic device, characterized in that: It comprises: a memory for storing instructions executed by one or more processors of the electronic device, and the processor, which is one of the one or more processors of the electronic device, for executing the scheduling method according to any one of claims 1 to 8.

10. A readable medium, characterized in that: The readable medium stores instructions, which, when executed on an electronic device, enable the electronic device to execute the scheduling method according to any one of claims 1 to 8.