Audio playing method and device and storage medium

By enabling the direct-through thread in the terminal to directly send audio with a code rate of more than or equal to 96kbps to the HAL layer, the sound quality loss problem caused by frequency down processing in the Android audio architecture is solved, and high-quality audio playback is achieved.

CN118939226APending Publication Date: 2024-11-12BEIJING XIAOMI MOBILE SOFTWARE CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310539284.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-05-12
Publication Date
2024-11-12

AI Technical Summary

Technical Problem

The existing Android audio architecture needs to downgrade the frequency when the input code rate is greater than or equal to 96kbps, resulting in damage to the audio quality and affecting the user experience.

Method used

By enabling the pass-through thread in the terminal, the target audio is sent directly to the hardware abstract HAL layer, avoiding downs and mixing processing, and directly output to the audio playback output port or external playback device.

Benefits of technology

Ensure the integrity of the audio code rate, improve user auditory experience, avoid sound quality loss, and improve the quality of audio playback.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118939226A_ABST
    Figure CN118939226A_ABST
Patent Text Reader

Abstract

The invention relates to an audio playing method and device and a storage medium. In the method, in response to the fact that an audio playing application in a terminal is triggered to play a target audio and the code rate of the target audio is greater than or equal to a code rate threshold value, a direct connection thread is started; sending the target audio to a hardware abstraction HAL layer of the terminal through the straight-through thread; and selecting an audio playing output port on the HAL layer, and outputting the target audio by using the audio playing output port so as to play the target audio. According to the invention, the processing of frequency reduction and / or sound mixing on the target audio in the audio playing process can be avoided, the code rate integrity of the target audio during playing is ensured, and the auditory experience of a user is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of information processing, and in particular to an audio playback method, device and storage medium. Background Art

[0002] With the development of terminal technology, users have higher and higher requirements on the audio playback quality of terminals.

[0003] In the related art, since the Android audio architecture theoretically supports a codec algorithm with a maximum bit rate of 96 kilobits per second (kbps), when the input bit rate of the terminal's audio architecture is greater than or equal to 96kbps, the audio needs to be down-converted. However, down-converting will cause the audio quality played by the terminal to be damaged, thus affecting the user experience. Summary of the invention

[0004] In order to overcome the problems existing in the related art, the present disclosure provides an audio playback method, device and storage medium.

[0005] According to a first aspect of an embodiment of the present disclosure, there is provided an audio playback method, which is applied to a terminal and includes:

[0006] In response to an audio playback application in the terminal being triggered to play a target audio, and a bit rate of the target audio being greater than or equal to a bit rate threshold, enabling a pass-through thread;

[0007] Sending the target audio to the hardware abstraction HAL layer of the terminal through the pass-through thread;

[0008] An audio playback output port is selected at the HAL layer, and the target audio is outputted using the audio playback output port to play the target audio.

[0009] In one implementation, sending the target audio to the HAL layer of the terminal through the direct thread includes:

[0010] Determine an audio category object corresponding to the target audio file played by the audio playback application, wherein the audio category object is used to indicate a buffer area for caching audio data corresponding to the target audio file;

[0011] The audio data cached in the buffer area indicated by the audio category object is sent to the HAL of the terminal through the direct thread.

[0012] In one embodiment, the method further comprises: monitoring, by a preset audio scheduler, the remaining playback time supported by the audio data currently cached in the cache area;

[0013] If the remaining playback time is less than the time threshold, the audio data to be cached is stored in the cache area.

[0014] In one implementation, the using the audio playback output port to output the target audio to play the target audio includes:

[0015] Play the target audio outputted by the audio playback output port; or

[0016] The target audio outputted from the audio playback output port is sent to an external playback device connected to the audio playback output port, and the target audio is played through the external playback device.

[0017] In one embodiment, the method further comprises: calling a pre-created HAL layer interface, wherein the interface is used to control functional parameters of the audio playback;

[0018] Based on the HAL layer interface, functional parameters of the audio playback output port for playing the target audio are adjusted.

[0019] According to a second aspect of an embodiment of the present disclosure, there is provided an audio playback device, applied to a terminal, the device comprising:

[0020] An execution unit, configured to enable a pass-through thread in response to an audio playback application in the terminal being triggered to play a target audio, wherein a bit rate of the target audio is greater than or equal to a bit rate threshold;

[0021] A transmission unit, configured to send the target audio to a hardware abstraction HAL layer of the terminal through the direct thread;

[0022] The playing unit is used to select an audio playing output port in the HAL layer, and use the audio playing output port to output the target audio so as to play the target audio.

[0023] In one implementation, the transmission unit implements sending the target audio to the HAL layer of the terminal in the following manner, including:

[0024] Determine an audio category object corresponding to the target audio file played by the audio playback application, wherein the audio category object is used to indicate a buffer area for caching audio data corresponding to the target audio file;

[0025] The audio data cached in the buffer area indicated by the audio category object is sent to the HAL of the terminal through the direct thread.

[0026] In one embodiment, the transmission unit is further used to: monitor the remaining playback time supported by the audio data currently cached in the cache area through a preset audio scheduler;

[0027] If the remaining playback time is less than the time threshold, the audio data to be cached is stored in the cache area.

[0028] In one implementation, the playing unit uses the audio playing output port to output the target audio to play the target audio, including:

[0029] Play the target audio outputted by the audio playback output port; or

[0030] The target audio outputted from the audio playback output port is sent to an external playback device connected to the audio playback output port, and the target audio is played through the external playback device.

[0031] In one embodiment, the device further comprises:

[0032] a processing unit, configured to call a pre-created HAL layer interface, wherein the interface is configured to control functional parameters of the audio playback; and

[0033] Based on the HAL layer interface, functional parameters of the audio playback output port for playing the target audio are adjusted.

[0034] According to a third aspect of an embodiment of the present disclosure, there is provided an audio playback device, comprising: a processor; and a memory for storing processor executable commands; wherein the processor is configured to: execute the audio playback method described in any one of the implementations of the first aspect.

[0035] According to a fourth aspect of an embodiment of the present disclosure, a storage medium is provided, in which instructions are stored. When the instructions in the storage medium are executed by a processor of a device, the device is enabled to execute the audio playback method described in any one of the implementations of the first aspect.

[0036] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: the target audio with a bit rate greater than or equal to a bit rate threshold is sent directly to the hardware abstraction layer through a direct thread, thereby avoiding down-conversion and / or mixing of the target audio during the process, thereby ensuring the bit rate integrity of the target audio during playback, and thereby improving the user's auditory experience.

[0037] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.

[0039] Figure 1 The figure is a flow chart of an audio playing method according to an exemplary embodiment.

[0040] Figure 2 is a flow chart of another audio playing method according to an exemplary embodiment.

[0041] Figure 3 is a flow chart of another audio playing method according to an exemplary embodiment.

[0042] Figure 4 The present invention is a block diagram of an audio playback device according to an exemplary embodiment.

[0043] Figure 5 The present invention is a block diagram of an audio playback device according to an exemplary embodiment. DETAILED DESCRIPTION

[0044] Here, exemplary embodiments will be described in detail, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present disclosure.

[0045] With the development of terminal technology, users have higher and higher requirements for the audio playback quality (that is, sound quality) of the terminal. Generally speaking, the bit rate when playing an audio file is a key factor in determining the sound quality. The higher the bit rate when playing an audio file, the higher the corresponding sound quality and the better the user experience.

[0046] The process of playing audio files in the Android system in the related art is roughly as follows:

[0047] a. The application creates an Audio Track or MediaPlayer object to play the audio file. AudioTrack is suitable for real-time streaming, while MediaPlayer is suitable for playing local files or network streaming media.

[0048] b. The application provides the path or streaming data of the audio file to the AudioTrack or MediaPlayer object.

[0049] c. The application calls the play method of the AudioTrack or MediaPlayer object to start playing the audio file.

[0050] d. The AudioTrack or MediaPlayer object sends the audio data to the audio dispatcher (AudioFlinger), which processes and mixes the audio data and sends the mixed audio data to the audio hardware.

[0051] e. Audio hardware converts audio data into analog signals and outputs audio signals through speakers or headphones.

[0052] f. The application can control the state of audio playback by calling the pause, resume, stop and other methods of the AudioTrack or MediaPlayer object.

[0053] g. When the audio file finishes playing or the application calls the stop method, the AudioTrack or MediaPlayer object releases the audio resources and stops audio playback.

[0054] During the whole process, AudioFlinger is responsible for managing the buffer and mixing of audio data, mixing multiple audio streams into the same audio output signal. The audio hardware is responsible for converting digital signals into analog signals and outputting audio signals. At the same time, the application controls the state and progress of audio playback by calling methods of the AudioTrack or MediaPlayer object to play and control audio files.

[0055] It is understandable that after the above-mentioned down-conversion and mixing processing, the final audio file to be played will have a larger bit rate loss compared to the original audio file. Therefore, the audio file played by the player will cause a large loss of sound quality due to the bit rate loss of the audio file, thereby reducing the user experience.

[0056] Figure 1 is a flow chart of an audio playing method according to an exemplary embodiment. Figure 1 As shown, the audio playing method is applied in a terminal and includes the following steps.

[0057] In step S11, in response to an audio playback application in a terminal being triggered to play a target audio, and the bit rate of the target audio being greater than or equal to a bit rate threshold, a pass-through thread is enabled.

[0058] In an embodiment of the present disclosure, the audio playback application is started based on a user request or preset information.

[0059] Exemplarily, the terminal starts an audio playback application, such as Q music player, in response to a user request.

[0060] In an embodiment of the present disclosure, the audio playback application in the terminal is triggered to play the target audio in the form of an Android application installation package (APK) that loads the audio file.

[0061] Exemplarily, Q music player is started and the target audio APK is loaded in the terminal.

[0062] Exemplarily, obtaining an audio file package may be implemented in the following code form.

[0063]

[0064] It can be understood that in the above code, first, the code obtains the UID (user ID) of the current application through the `IPCThreadState::self()->getCallingUid()` function. Then, it uses the `getPackagesForUid(uid,packages)` method of the PermissionController instance permissionController class to obtain all package names associated with the UID.

[0065] If the UID has associated package names, one of these package names will be selected as the clientName and stored in the clientName variable of type String16.

[0066] In an embodiment of the present disclosure, the target audio refers to an audio file with higher sound quality required by the user (ie, the target audio). When the bit rate of the target audio is greater than or equal to the bit rate threshold, the direct thread preset in the system is enabled to transmit the target audio.

[0067] Exemplarily, when the bit rate of the audio file is greater than or equal to 96 kilobits per second (kbps), a preset direct thread is enabled to transmit the target audio.

[0068] In the embodiment of the present disclosure, before enabling the through thread, a corresponding category file may also be created.

[0069] Exemplarily, before enabling the direct thread, an Audio Track category file may be created based on an audio application framework (AudioApplication Framework) in the Android system for acquisition.

[0070] It is understandable that Audio Track is a class (i.e., category file) responsible for audio data output in the Android system. Before audio data transmission, a corresponding Audio Track category file is created, and corresponding functional parameters are assigned when creating the corresponding AudioTrack category file, so that the audio file can be adjusted accordingly through the corresponding functional parameters in the subsequent processing process.

[0071] Among them, the functional parameters include: the sampling rate of the audio file, the number of channels, the data format, and the buffer size.

[0072] Exemplarily, the buffer area is used to store audio files to be played, and the buffer area can store at least one audio file to perform a multi-audio playback task.

[0073] In the embodiment of the present disclosure, for the selection of creating an Audio Track category file output identifier, a corresponding identifier for directly outputting an audio file to a hardware module for playing the audio file may be selected.

[0074] Exemplarily, taking the Android system as an example, the output flag of the Audio Track category file may be "AUDIO_OUTPUT_FLAG_DIRECT".

[0075] In the embodiment of the present disclosure, before enabling the pass-through thread, the process also includes creating the pass-through thread.

[0076] It is understandable that the music APK creates a direct thread by calling the AudioFlinger API to transfer the music data in the AudioTrack buffer to the HAL layer. By directly transmitting music data, redundant memory copying and data processing can be avoided, thereby improving transmission efficiency.

[0077] For example, in Android's audio system, Audio Flinger is one of the more important services. Audio Flinger has the functions of executing policies, managing audio streaming devices, and transmitting audio files. The threads that AudioFlinger can correspond to include: "Direct Output Thread". This thread is a direct output thread, derived from Playback Thread. The corresponding identifier is "AUDIO_OUTPUT_FLAG_DIRECT". This thread can output the audio file directly to the hardware module that plays the audio file without mixing. Therefore, for the creation of a direct thread, one example can be the creation of a "Direct Output Thread" thread.

[0078] It is understandable that in the Android system, the Direct Output Thread (DO thread) is an important part of the AudioTrack object, which is used to achieve real-time audio stream output and low-latency playback. The DO thread runs at a higher priority and is responsible for outputting audio data to the audio hardware. The DO thread implements audio output by polling the audio data in the audio buffer to achieve real-time performance and low latency.

[0079] The DO thread can read audio data from the audio buffer, convert it into a digital signal, and send it to the audio hardware.

[0080] Specifically, the DO thread is responsible for writing audio data to the audio buffer at fixed time intervals and sending it to the audio hardware for decoding and output. At the same time, the DO thread will also adjust its own operating state according to parameters such as the length and output rate of the audio data to ensure the stability and consistency of the audio output.

[0081] Therefore, through the efficient operation of DO threads, real-time output of audio data can be achieved, thus achieving a smooth, low-latency, and high-quality audio experience.

[0082] In step S12, the target audio is sent to the hardware abstraction HAL layer of the terminal through a direct thread.

[0083] In step S13, the target audio is output to play the target audio.

[0084] In the disclosed embodiment, after the audio file is sent to the HAL layer through the pass-through thread, the corresponding hardware module is selected to play the audio file based on the constructed interface correspondence.

[0085] For example, after the DO thread is created, the music APK (audio file) will start the thread and start transferring the music data (audio file) from the AudioTrack buffer to the HAL layer interface. While the thread is transferring the music data, AudioFlinger will monitor in real time whether the data in the buffer has been played, and write new music data to the buffer when the music data has been played to a certain extent in the buffer. AudioFlinger is also responsible for communicating with the HAL layer interface and transferring the music data in the buffer to the HAL layer interface, thereby achieving seamless transmission and playback of audio data.

[0086] Furthermore, after the audio file reaches the HAL layer, the HAL layer interface sends the music data to the audio hardware for playback.

[0087] The disclosed embodiment provides an audio playback method, which realizes the transmission of target audio through a hardware module in a terminal audio system architecture by selecting a direct thread in the system, thereby avoiding the down-conversion mixing process of the target audio and reducing the bit rate loss of the audio file.

[0088] In the embodiment of the present disclosure, before sending the target audio to the HAL layer of the terminal through the direct thread, it also includes creating a HAL layer interface.

[0089] It is understandable that the HAL layer is an abstract layer that hides the underlying implementation details of the hardware and provides a unified hardware access interface for the Android system. The HAL layer interface exists in the form of a .so library in the Android system. The HAL layer interface includes the driver of the hardware module that plays the audio file, and manages and controls the functions and parameters of the hardware module that plays the audio file.

[0090] Exemplarily, the creation of the HAL layer interface can be achieved by the following steps:

[0091] In step S121, determine the audio functions and parameters that need to be implemented.

[0092] For example, you may need to implement the functions and parameters of audio playback, recording, mute, volume, and other hardware modules that can be used to manage audio files.

[0093] In step S122, a driver for the HAL layer interface is written.

[0094] It is understandable that this driver should be closely related to the audio hardware and is used to manage and control various functions and parameters of the hardware. In the driver, it is necessary to implement the specific operations of audio functions and parameters and provide a unified interface layer so that the upper-level music APK can communicate with the driver through this interface.

[0095] In step S123, the hardware abstraction layer of the HAL layer interface is written.

[0096] It can be understood that this hardware abstraction layer is a set of interfaces and data structures that hide the differences between audio hardware and drivers and provide a unified HAL layer interface for the Android system. In the hardware abstraction layer, it is necessary to define various functions and data structures of the HAL layer interface and implement them as code that can correctly communicate with the underlying driver.

[0097] In step S124, the driver and the hardware abstraction layer are compiled into a .so dynamic link library and installed in the / lib / hw directory of the Android system.

[0098] In step S125, in the music APK, the corresponding functions are called through the .so library of the HAL layer interface to implement the control of audio functions and parameters.

[0099] Figure 2 FIG. 1 is a flowchart of another audio playing method according to an exemplary embodiment. Figure 2 In one embodiment shown, sending the target audio to the HAL layer of the terminal through a direct thread includes the following steps:

[0100] In step S21: determine the audio category object corresponding to the target audio played by the audio playback application, and the audio category object is used to indicate the cache area for caching audio data corresponding to the target audio file.

[0101] For example, the creation of an Audio Track class object in Android is taken as an example. When the Audio Track class object is created, the parameters related to the corresponding stored audio buffer area have been defined.

[0102] In an Audio Track, a buffer of size bufferSizeInBytes is created and allocated by the AudioTrack object. When writing audio data to an AudioTrack, the AudioTrack caches the data in the buffer for output.

[0103] After determining the size of the buffer, AudioTrack needs to indicate the buffer area corresponding to the audio data of the cached target audio file, which is usually achieved by setting the playback mode and track parameters. The following are the specifics:

[0104] (I) Regarding playback mode: AudioTrack provides multiple playback modes, such as MODE_STREAM or MODE_STATIC. MODE_STREAM indicates the streaming mode, which is suitable for real-time playback of digital audio streams; MODE_STATIC indicates the static mode, which is suitable for playing pre-allocated audio data.

[0105] (ii) Track parameters: When creating an AudioTrack object, you can specify track parameters for it, such as sampling rate, number of channels, sample bytes, etc. These parameters need to be set according to the characteristics of the target audio file to ensure that the audio data can be correctly decoded and output in the buffer.

[0106] Through the above settings, AudioTrack can effectively indicate the cache area of ​​the audio data corresponding to the cache target audio file and achieve high-quality, smooth, and low-latency audio playback effects. At the same time, the application can also adjust the cache area and parameters according to actual needs to achieve a better audio experience. Therefore, the audio category object is used to indicate the cache target audio file, and can also indicate the cache area of ​​the audio data corresponding to the cache target audio file for the relevant parameters of the audio cache area defined in the audio category object.

[0107] In the embodiment of the present disclosure, the buffer area is used to store audio files to be played, and the buffer area can store at least one audio file to perform a multi-audio playback task.

[0108] In step S22: the audio data buffered in the buffer area indicated by the audio category object is sent to the HAL layer of the terminal through the direct thread.

[0109] In the disclosed embodiment, a through thread is created by calling a preset Audio Flinger application programming interface (API) to transfer the audio file in the Audio Track category file buffer to the HAL layer interface.

[0110] It can be understood that the pass-through thread sends the audio data cached in the buffer area indicated by the audio category object to the HAL layer of the terminal through the following steps.

[0111] In step S23, the DO thread periodically polls the audio data in the buffer to check the availability and playing status of the audio data.

[0112] In step S24, when the DO thread reads the audio data in the buffer area, it converts it into a digital signal and outputs it to the audio hardware through the underlying audio output interface of the Audio Track object.

[0113] In step S25, the underlying audio output interface is provided by Audio Flinger, which converts the digital signal into an analog signal and sends it to the audio hardware through the audio driver.

[0114] In step S26, the audio hardware converts the analog signal into a sound waveform and outputs the audio signal through a speaker or headphones.

[0115] Based on this, the DO thread, as the core part of the Audio Track object, can effectively send audio data to the terminal's HAL layer through real-time data reading and audio output, and achieve high-quality, low-latency audio playback effects. At the same time, the DO thread can also achieve a more stable and coherent audio playback effect through its own state adjustment and data processing.

[0116] Illustratively, the following Table 1 shows the bit rate test results of audio files played by the audio playback method provided by the embodiment of the present disclosure and the audio playback method provided by the related art.

[0117] Table 13

[0118]

[0119] As described in the above related technical embodiments, the audio playback process includes frequency reduction and mixing. Therefore, when the audio is played using the related technology, the audio bit rate obtained by each test node is less than the input audio bit rate.

[0120] With the audio playback method provided by the embodiment of the present disclosure, since the audio file is sent directly to the HAL layer through the DO thread without down-conversion and mixing, lossless playback of audio bit rate can be achieved.

[0121] Figure 3 is a flowchart of another audio playing method according to an exemplary embodiment. Figure 3 In one embodiment shown, the audio playing method further includes the following steps.

[0122] In step S31, the remaining playback time supported by the audio data currently cached in the cache area is monitored by a preset audio scheduler.

[0123] In the disclosed embodiment, the audio data in the buffer area is detected in real time through Audio Flinger.

[0124] Exemplarily, AudioFlinger monitors in real time whether the data in the buffer has been played completely, which can be achieved through an interrupt mechanism provided by a timer or audio hardware.

[0125] In step S32, if the remaining playing time is less than the time threshold, the audio data to be cached is stored in the cache area.

[0126] Exemplarily, Audio Flinger stores a pointer or index in the audio buffer, pointing to the audio data currently being played. The audio hardware periodically sends an interrupt signal to Audio Flinger to notify Audio Flinger that a section of audio data has been played. When Audio Flinger receives an interrupt signal, it determines whether there is any remaining audio data in the audio buffer that can be played based on the pointer or index of the audio data currently being played. If so, Audio Flinger will continue to play the next section of audio data. If not, or the remaining playback time of the audio data is less than the preset time threshold, Audio Flinger will notify Audio Track, trigger the callback function, and notify the application that some more audio data needs to be written to the audio buffer. By using a timer or interrupt mechanism to monitor the data in the buffer in real time, Audio Flinger can ensure the continuous playback of the audio stream and improve the efficiency and stability of audio playback. At the same time, this real-time monitoring mechanism can also avoid problems such as incoherent or stuck audio data playback, and improve the user's listening experience.

[0127] In one implementation, the target audio is outputted using the audio playback output port to play the target audio, including the following methods:

[0128] (iii) Playing the target audio output from the audio playback output port.

[0129] Exemplarily, following the above embodiments, it can be known that the audio hardware corresponding to the HAL layer interface may be the hardware of the terminal, that is, the target audio is directly played at the output port of the terminal.

[0130] (iv) sending the target audio outputted by the audio playback output port to an external playback device connected to the audio playback output port, and playing the target audio through the external playback device.

[0131] In the disclosed embodiment, there is a data connection relationship between the external speaker and the output port.

[0132] Exemplarily, the external speaker device may be a Bluetooth headset. When the external speaker device is a Bluetooth headset, there is a Bluetooth connection relationship with the output port.

[0133] Exemplarily, the external speaker device may be a Bluetooth headset configured with a digital-to-analog converter (DAC) chip to enhance the transmission rate with the output port.

[0134] In the disclosed embodiment, when the external speaker is configured as a hardware device having a Bluetooth connection relationship with the output port, a low-latency high-definition audio codec (Low Latency and High-Definition Audio Codec, LHDC) can also be introduced into the Qualcomm audio processing framework (Audio Digital Signal Processor, ADSP) to achieve the output of high-bitrate audio.

[0135] It can be understood that the LHDC encoder can provide high-compression data encoding for digital audio signals and transmit them to headphones or other Bluetooth audio devices. At the receiving end, the LHDC decoder decodes the received data and converts the digital audio signal into an analog audio signal through a digital-to-analog converter for headphone output. Compared with other commonly used Bluetooth encoders, the LHDC encoder has lower transmission latency and can achieve faster audio response time.

[0136] In the disclosed embodiment, an algorithm processing library may be integrated into the Qualcomm ADSP framework to implement calculation of the amount of data to be processed based on corresponding parameters in the algorithm processing library.

[0137] Exemplarily, the corresponding parameters include at least one of the following: bit rate, sampling rate, number of channels and number of frames.

[0138] In the embodiment of the present disclosure, the number of packets to be transmitted to the external device is calculated based on the calculation result of the data link to be processed and the preset maximum transmission unit (MTU), thereby realizing the transmission of the data packets.

[0139] Based on the same concept, an embodiment of the present disclosure also provides an audio playback device.

[0140] It is understandable that, in order to realize the above functions, the audio playback device provided by the embodiment of the present disclosure includes hardware structures and / or software modules corresponding to the execution of each function. In combination with the units and algorithm steps of each example disclosed in the embodiment of the present disclosure, the embodiment of the present disclosure can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the technical solution of the embodiment of the present disclosure.

[0141] Figure 4 is a block diagram of an audio playback device according to an exemplary embodiment. Figure 4The device is applied to a terminal and includes: an execution unit 401, a transmission unit 402 and a playback unit 403.

[0142] Execution unit 401, for enabling a pass-through thread in response to an audio playback application in a terminal being triggered to play a target audio, and the bit rate of the target audio being greater than or equal to a bit rate threshold

[0143] The transmission unit 402 is used to send the target audio to the hardware abstraction HAL layer of the terminal through a direct thread;

[0144] The playing unit 403 is used to select an audio playing output port at the HAL layer, and use the audio playing output port to output the target audio so as to play the target audio.

[0145] In one implementation, the transmission unit 402 implements sending the target audio to the HAL layer of the terminal in the following manner, including:

[0146] Determine an audio category object corresponding to the target audio played by the audio playback application, where the audio category object is used to indicate a cache area for caching audio data corresponding to the target audio file;

[0147] The audio data cached in the buffer area indicated by the audio category object is sent to the HAL of the terminal through the pass-through thread.

[0148] In one implementation, the transmission unit 402 is further configured to: monitor the remaining playback time supported by the audio data currently cached in the cache area through a preset audio scheduler;

[0149] If the remaining playback time is less than the time threshold, the audio data to be cached is stored in the cache area.

[0150] In one implementation, the playing unit 403 uses the audio playing output port to output the target audio to play the target audio, including:

[0151] Play audio plays the target audio output from the output port; or

[0152] The target audio output from the audio playback output port is sent to an external playback device connected to the audio playback output port, and the target audio is played through the external playback device.

[0153] In one embodiment, the device further comprises:

[0154] The processing unit is used to call a pre-created HAL layer interface, where the interface is used to control the functional parameters of audio playback; and based on the HAL layer interface, adjust the functional parameters of the audio playback output port to play the target audio.

[0155] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0156] Figure 5 1 is a block diagram of an apparatus 500 for audio playback according to an exemplary embodiment. For example, the apparatus 500 may be a mobile phone, a computer, a digital broadcast terminal, a messaging device, a game console, a tablet device, a medical device, a fitness device, a personal digital assistant, etc.

[0157] Reference Figure 5 , the device 500 may include one or more of the following components: a processing component 502 , a memory 504 , a power component 506 , a multimedia component 508 , an audio component 510 , an input / output (I / O) interface 512 , a sensor component 514 , and a communication component 516 .

[0158] The processing component 502 generally controls the overall operation of the device 500, such as operations associated with display, phone calls, data communications, camera operations, and recording operations. The processing component 502 may include one or more processors 520 to execute instructions to complete all or part of the steps of the above-mentioned method. In addition, the processing component 502 may include one or more modules to facilitate the interaction between the processing component 502 and other components. For example, the processing component 502 may include a multimedia module to facilitate the interaction between the multimedia component 508 and the processing component 502.

[0159] The memory 504 is configured to store various types of data to support operations on the device 500. Examples of such data include instructions for any application or method operating on the device 500, contact data, phone book data, messages, pictures, videos, etc. The memory 504 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.

[0160] Power component 506 provides power to various components of device 500. Power component 506 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for device 500.

[0161] The multimedia component 508 includes a screen that provides an output interface between the device 500 and the user. In some embodiments, the screen may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor may not only sense the boundaries of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 508 includes a front camera and / or a rear camera. When the device 500 is in an operating mode, such as a shooting mode or a video mode, the front camera and / or the rear camera may receive external multimedia data. Each front camera and rear camera may be a fixed optical lens system or have a focal length and optical zoom capability.

[0162] The audio component 510 is configured to output and / or input audio signals. For example, the audio component 510 includes a microphone (MIC), and when the device 500 is in an operating mode, such as a call mode, a recording mode, and a speech recognition mode, the microphone is configured to receive an external audio signal. The received audio signal can be further stored in the memory 504 or sent via the communication component 516. In some embodiments, the audio component 510 also includes a speaker for outputting audio signals.

[0163] I / O interface 512 provides an interface between processing component 502 and peripheral interface modules, such as keyboards, click wheels, buttons, etc. These buttons may include but are not limited to: a home button, a volume button, a start button, and a lock button.

[0164] The sensor assembly 514 includes one or more sensors for providing various aspects of status assessment for the device 500. For example, the sensor assembly 514 can detect the open / closed state of the device 500, the relative positioning of components, such as the display and keypad of the device 500, the sensor assembly 514 can also detect the position change of the device 500 or a component of the device 500, the presence or absence of user contact with the device 500, the orientation or acceleration / deceleration of the device 500, and the temperature change of the device 500. The sensor assembly 514 may include a proximity sensor configured to detect the presence of a nearby object without any physical contact. The sensor assembly 514 may also include an optical sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 514 may also include an accelerometer, a gyroscope sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.

[0165] The communication component 516 is configured to facilitate wired or wireless communication between the device 500 and other devices. The device 500 can access a wireless network based on a communication standard, such as WiFi, 2G or 3G, or a combination thereof. In an exemplary embodiment, the communication component 516 receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component 516 also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.

[0166] In an exemplary embodiment, the apparatus 500 may be implemented by one or more application specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic components to perform the above methods.

[0167] In an exemplary embodiment, a non-transitory computer-readable storage medium including instructions is also provided, such as a memory 504 including instructions, and the instructions can be executed by the processor 520 of the device 500 to perform the above method. For example, the non-transitory computer-readable storage medium can be a ROM, a random access memory (RAM), a CD-ROM, a magnetic tape, a floppy disk, an optical data storage device, etc.

[0168] It is to be understood that in the present disclosure, "plurality" refers to two or more than two, and other quantifiers are similar. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship. The singular forms "a", "the" and "the" are also intended to include plural forms, unless the context clearly indicates other meanings.

[0169] It is further understood that the terms "first", "second", etc. are used to describe various information, but such information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other, and do not indicate a specific order or degree of importance. In fact, the expressions "first", "second", etc. can be used interchangeably. For example, without departing from the scope of the present disclosure, the first information can also be referred to as the second information, and similarly, the second information can also be referred to as the first information.

[0170] It will be further understood that the terms “center”, “longitudinal”, “lateral”, “front”, “back”, “up”, “down”, “left”, “right”, “vertical”, “horizontal”, “top”, “bottom”, “inside”, “outside”, etc., indicating orientations or positional relationships based on the orientations or positional relationships shown in the accompanying drawings, are only for the convenience of describing the present embodiment and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation.

[0171] It can be further understood that, unless otherwise specified, “connection” includes a direct connection without other components between the two, and also includes an indirect connection with other components between the two.

[0172] It is further understood that, although the operations are described in a specific order in the drawings in the embodiments of the present disclosure, it should not be understood as requiring the operations to be performed in the specific order shown or in a serial order, or requiring the execution of all the operations shown to obtain the desired results. In certain environments, multitasking and parallel processing may be advantageous.

[0173] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the invention disclosed herein. This application is intended to cover any modifications, uses or adaptations of the present disclosure, which follow the general principles of the present disclosure and include common knowledge or customary technical means in the art that are not disclosed in the present disclosure.

[0174] It should be understood that the present disclosure is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the scope of the appended claims.

Claims

1. An audio playback method, characterized in that: Applied to a terminal, the method comprises: In response to an audio playback application in the terminal being triggered to play a target audio, and a bit rate of the target audio being greater than or equal to a bit rate threshold, enabling a pass-through thread; Sending the target audio to the hardware abstraction HAL layer of the terminal through the pass-through thread; An audio playback output port is selected at the HAL layer, and the target audio is outputted using the audio playback output port to play the target audio.

2. The audio playback method according to claim 1, characterized in that: The step of sending the target audio to the HAL layer of the terminal through the direct thread includes: Determine an audio category object corresponding to the target audio file played by the audio playback application, wherein the audio category object is used to indicate a buffer area for caching audio data corresponding to the target audio file; The audio data cached in the buffer area indicated by the audio category object is sent to the HAL of the terminal through the direct thread.

3. The audio playback method according to claim 2, characterized in that: The method further comprises: Monitoring the remaining playback time supported by the audio data currently cached in the cache area through a preset audio scheduler; If the remaining playback time is less than the time threshold, the audio data to be cached is stored in the cache area.

4. The audio playback method according to any one of claims 1 to 3, characterized in that: The using the audio playback output port to output the target audio to play the target audio includes: Play the target audio outputted by the audio playback output port; or The target audio outputted from the audio playback output port is sent to an external playback device connected to the audio playback output port, and the target audio is played through the external playback device.

5. The audio playback method according to claim 1, characterized in that: The method further comprises: Calling a pre-created HAL layer interface, wherein the interface is used to control functional parameters of the audio playback; Based on the HAL layer interface, functional parameters of the audio playback output port for playing the target audio are adjusted.

6. An audio playback device, characterized in that: Applied to a terminal, the device comprises: An execution unit, configured to enable a pass-through thread in response to an audio playback application in the terminal being triggered to play a target audio, wherein a bit rate of the target audio is greater than or equal to a bit rate threshold; A transmission unit, configured to send the target audio to a hardware abstraction HAL layer of the terminal through the direct thread; The playing unit is used to select an audio playing output port in the HAL layer, and use the audio playing output port to output the target audio so as to play the target audio.

7. The audio playback device according to claim 6, characterized in that: The transmission unit implements sending the target audio to the HAL layer of the terminal in the following manner, including: Determine an audio category object corresponding to the target audio file played by the audio playback application, wherein the audio category object is used to indicate a buffer area for caching audio data corresponding to the target audio file; The audio data cached in the buffer area indicated by the audio category object is sent to the HAL of the terminal through the direct thread.

8. The audio playback device according to claim 7, characterized in that: The transmission unit is also used for: Monitoring the remaining playback time supported by the audio data currently cached in the cache area through a preset audio scheduler; If the remaining playback time is less than the time threshold, the audio data to be cached is stored in the cache area.

9. The audio playback device according to any one of claims 6 to 8, characterized in that: The playing unit uses the audio playing output port to output the target audio to play the target audio, including: Play the target audio outputted by the audio playback output port; or The target audio outputted from the audio playback output port is sent to an external playback device connected to the audio playback output port, and the target audio is played through the external playback device.

10. The audio playback device according to claim 6, characterized in that: The device also includes: a processing unit, configured to call a pre-created HAL layer interface, wherein the interface is configured to control functional parameters of the audio playback; and Based on the HAL layer interface, functional parameters of the audio playback output port for playing the target audio are adjusted.

11. An audio playback device, characterized in that: include: processor; a memory for storing processor executable instructions; Wherein, the processor is configured to: execute the audio playback method described in any one of claims 1 to 5.

12. A storage medium, characterized in that: The storage medium stores instructions, and when the instructions in the storage medium are executed by a processor of a device, the device is enabled to execute the audio playback method according to any one of claims 1 to 5.

Citation Information

Cited By

  • Android mobile terminal video cache optimization method and system

    CN119402704A