Display device and audio stream read-write method
By creating a sub-thread in the display device to wait for the audio peripherals to be configured before executing the audio stream read/write task, the problem of mismatch between audio stream format and playback parameters is solved, thus improving audio playback quality.
Patent Information
- Application Number
- CN202111563267.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-20
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2041-12-20
AI Technical Summary
During the audio stream reading and writing process, improper main thread task order can lead to a mismatch between the audio stream format and playback parameters, affecting playback quality.
Create a separate sub-thread in the display device to wait for the audio peripheral to complete its playback parameters and format configuration before performing audio stream read/write tasks, ensuring that the audio stream is adapted to the playback parameters and format.
By executing the main thread and child threads in parallel, the audio stream is guaranteed to have the appropriate format and playback parameters when written to the audio peripheral, thus improving the audio playback quality.
Smart Images

Figure CN116320588B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent display device technology, and in particular to a display device and an audio stream reading and writing method. Background Technology
[0002] Display devices refer to terminal devices capable of outputting specific display images, such as smart TVs, mobile terminals, smart advertising screens, and projectors. Taking smart TVs as an example, smart TVs are television products based on Internet application technologies, possessing open operating systems and chips, and having open application platforms. They enable two-way human-computer interaction and integrate multiple functions such as audio-visual, entertainment, and data to meet diverse and personalized user needs.
[0003] Display devices can use external devices (peripherals) to increase storage space, play audio and video streams, and acquire data. Specifically, display devices play audio streams via audio peripherals. The display device executes tasks related to playing audio streams through audio peripherals in different threads, for example... Figure 1 As shown, the display device performs tasks such as configuring playback parameters for audio peripherals and reading / writing audio streams in the main thread, and performs audio stream format configuration tasks in a child thread. The main thread and the child thread execute in parallel.
[0004] Each thread needs to execute tasks in a preset order. If the main thread executes tasks in the order of reading and writing audio streams and writing audio streams to audio peripherals first, followed by configuring playback parameters for the audio peripherals, then when the audio peripherals receive and play the audio stream, they can only use the current playback parameters because the corresponding playback parameters have not yet been configured. This results in a mismatch between the current playback parameters and the audio stream, leading to low playback quality. If the main thread executes tasks in the order of configuring playback parameters for audio peripherals first, followed by reading and writing audio streams and writing audio streams to the audio peripherals, then it is easy for sub-threads to not finish executing, i.e., the audio stream format configuration task is not completed. This causes problems with the format of the read audio stream, which in turn causes problems with the format of the audio stream subsequently written to the audio peripherals, reducing the playback quality of the audio peripherals. Summary of the Invention
[0005] This application provides a display device and an audio stream reading / writing method to improve the playback quality of audio streams.
[0006] In a first aspect, this application provides a display device, comprising: a display and a controller, wherein,
[0007] The display is configured to display a user interface;
[0008] The controller is configured as follows:
[0009] Obtain connection status change information of external devices;
[0010] Based on the connection status change information of the external device, it is determined whether there is a newly connected target audio peripheral device on the display device, and the target audio peripheral device is used to play audio streams;
[0011] When the target audio peripheral exists, a first child thread is created;
[0012] In the first sub-thread, a judgment task, a waiting task, and a read / write task are executed sequentially. The judgment task is used to determine whether the target audio peripheral has completed the configuration of playback parameters. The waiting task is used to wait for the completion of the configuration of the playback parameters of the target audio peripheral and / or the completion of the configuration of the audio stream format within a specified time. The read / write task is used to read the audio stream and write the read audio stream to the target audio peripheral.
[0013] Secondly, this application provides an audio stream reading and writing method applied to a display device, the method comprising:
[0014] Obtain connection status change information of external devices;
[0015] Based on the connection status change information of the external device, it is determined whether there is a newly connected target audio peripheral device on the display device, and the target audio peripheral device is used to play audio streams;
[0016] When the target audio peripheral exists, a first child thread is created;
[0017] In the first sub-thread, a judgment task, a waiting task, and a read / write task are executed sequentially. The judgment task is used to determine whether the target audio peripheral has completed the configuration of playback parameters. The waiting task is used to wait for the completion of the configuration of the playback parameters of the target audio peripheral and / or the completion of the configuration of the audio stream format within a specified time. The read / write task is used to read the audio stream and write the read audio stream to the target audio peripheral.
[0018] As can be seen from the above technical solution, when the display device detects a newly connected target audio peripheral, a separate first sub-thread is created to execute the task of writing the audio stream to the target audio peripheral. In this first sub-thread, waiting tasks can be executed first to wait for the playback parameter configuration task of the target audio peripheral to complete, and waiting for the audio stream format configuration task to complete, before executing the audio stream read / write task. This ensures that the audio stream written to the target audio peripheral has a compatible format and that the target audio peripheral has compatible playback parameters, thereby guaranteeing the quality of the audio stream played by the target audio peripheral. Attached Figure Description
[0019] To more clearly illustrate the technical solution of this application, the drawings used in the embodiments will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This diagram illustrates how tasks related to writing audio streams to audio peripherals are executed sequentially in the main thread.
[0021] Figure 2 This application illustrates the usage scenario of the display device.
[0022] Figure 3 This is a hardware configuration block diagram of the control device in the embodiments of this application;
[0023] Figure 4 This is a hardware configuration block diagram of the control device in the embodiments of this application;
[0024] Figure 5 This is a hardware configuration diagram of the display device in the embodiments of this application;
[0025] Figure 6 This is a software configuration diagram of the display device in the embodiments of this application;
[0026] Figure 7 This is a flowchart illustrating the process of writing an audio stream to a target audio peripheral in an embodiment of this application.
[0027] Figure 8 This is a flowchart illustrating the determination of the target audio peripheral in the embodiments of this application;
[0028] Figure 9(1) is a schematic diagram of the tasks executed by each thread in the embodiments of this application;
[0029] Figure 9(2) is a schematic diagram of the tasks executed by each thread in the embodiments of this application;
[0030] Figure 10 This is a flowchart illustrating the determination of the playback path and playback strategy in this application embodiment;
[0031] Figure 11 This is a framework diagram for creating the first child thread in an embodiment of this application;
[0032] Figure 12 This is a framework diagram illustrating the configuration of playback parameters in an embodiment of this application.
[0033] Figure 13 This is a logic block diagram of the judgment task and the waiting task in the embodiments of this application;
[0034] Figure 14 This is a logic block diagram of the waiting task executed in an embodiment of this application;
[0035] Figure 15 This is a logic block diagram of the waiting task executed in an embodiment of this application;
[0036] Figure 16 This is a logic block diagram of the read / write tasks performed in the embodiments of this application;
[0037] Figure 17 This is a logic block diagram for performing read / write tasks in an embodiment of this application. Detailed Implementation
[0038] The embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described below do not represent all embodiments consistent with this application. They are merely examples of systems and methods consistent with some aspects of this application as detailed in the claims.
[0039] It should be noted that the brief descriptions of terms in this application are only for the convenience of understanding the embodiments described below, and are not intended to limit the embodiments of this application. Unless otherwise stated, these terms should be understood in their ordinary and common meaning.
[0040] The terms "first," "second," "third," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar or related objects or entities, and do not necessarily imply a specific order or sequence, unless otherwise specified. It should be understood that such terms are interchangeable where appropriate.
[0041] The terms “comprising” and “having”, and any variations thereof, are intended to cover but not exclude inclusion, for example, a product or device that includes a range of components is not necessarily limited to all of the components that are clearly listed, but may include other components that are not clearly listed or that are inherent to such product or device.
[0042] The term "module" refers to any known or subsequently developed hardware, software, firmware, artificial intelligence, fuzzy logic, or combination of hardware and / or software code that is capable of performing the functions associated with that element.
[0043] Figure 2 This is a schematic diagram illustrating a usage scenario of the display device according to an embodiment. For example... Figure 2 As shown, the display device 200 can communicate with the server 300 via the Internet, the user can operate the display device 200 through the control device 100, and the display device 200 can play audio streams through the audio peripheral 400.
[0044] In some embodiments, the control device 100 may be a remote control. Communication between the remote control and the display device includes at least one of infrared protocol communication, Bluetooth protocol communication, and other short-range communication methods, controlling the display device 200 wirelessly or via a wired connection. Users can control the display device 200 by inputting control commands through at least one method, such as buttons on the remote control, voice input, or control panel input.
[0045] In some embodiments, the control device 100 may also be a mobile terminal, such as a mobile phone. Communication between the mobile terminal and the display device 200 includes Internet Protocol (IP) communication or Bluetooth protocol communication, as well as at least one of other short-range and long-range communication methods. Users can control the display device 200 by inputting user commands through at least one method such as buttons, voice input, or control panel input on the mobile terminal. Figure 3 An exemplary configuration block diagram of a control device 100, exemplified by a remote control, is shown. Figure 3 As shown, the control device 100 includes a controller, a communication interface, a user input / output interface, a memory, and a power supply.
[0046] Figure 4 An exemplary hardware configuration block diagram of a control device 100, taking a mobile terminal as an example, is shown. Figure 4 As shown, the control device 100 includes at least one of the following components: radio frequency (RF) circuit, memory, display unit, camera, sensor, audio circuit, wireless Fidelity (Wi-Fi) circuit, processor, Bluetooth circuit, and power supply.
[0047] Figure 5 A hardware configuration block diagram of a display device 200 according to an exemplary embodiment is shown.
[0048] In some embodiments, the display device 200 includes at least one of a tuner 210, a communicator 220, a detector 230, an external device interface 240, a controller 250, a display 260, an audio output interface 270, a memory, a power supply, and a user interface.
[0049] In some embodiments, the communicator 220 is a component used to communicate with external devices or servers according to various communication protocol types. For example, the communicator may include at least one of a Wi-Fi module, a Bluetooth module, a wired Ethernet module, other network communication protocol chips or near-field communication protocol chips, and an infrared receiver. The display device 200 can establish the transmission and reception of control signals and data signals with the control device 100 or the server 300 through the communicator 220.
[0050] In some embodiments, the external device interface 240 may include, but is not limited to, one or more interfaces such as: High Definition Multimedia Interface (HDMI), analog or data high-definition component input interface (component), composite video input interface (CVBS), USB input interface (USB), RGB port, etc. It may also be a composite input / output interface formed by multiple interfaces mentioned above.
[0051] In some embodiments, the controller 250 and the tuner 210 may be located in different separate devices, that is, the tuner 210 may also be located in an external device of the main device where the controller 250 is located, such as an external set-top box.
[0052] In some embodiments, the controller 250 controls the operation of the display device and responds to user operations via various software control programs stored in memory. The controller 250 controls the overall operation of the display device 200. For example, in response to receiving a user command to select a UI object to display on the display 260, the controller 250 can perform operations related to the object selected by the user command.
[0053] In some embodiments, the user can input user commands through a graphical user interface (GUI) displayed on the display 260, and the user input interface receives the user input commands through the GUI. Alternatively, the user can input user commands by inputting specific sounds or gestures, and the user input interface receives the user input commands by recognizing the sounds or gestures through sensors.
[0054] In some embodiments, a "user interface" is the medium through which an application or operating system interacts and exchanges information with a user, enabling the conversion between the internal form of information and a form acceptable to the user. A common form of user interface is the graphical user interface (GUI), which refers to a user interface related to computer operation displayed graphically. It can be an icon, window, control, or other interface element displayed on the screen of an electronic device. Controls can include at least one of the visual interface elements such as icons, buttons, menus, tabs, text boxes, dialog boxes, status bars, navigation bars, and widgets.
[0055] See Figure 6 In some embodiments, the system is divided into four layers, from top to bottom: the Applications layer (referred to as the "Application Layer"), the Application Framework layer (referred to as the "Framework Layer"), the Android runtime and system library layer (referred to as the "System Runtime Layer"), and the kernel layer.
[0056] In some embodiments, at least one application runs in the application layer. These applications may be Windows programs, system settings programs, or clock programs that come with the operating system; they may also be applications developed by third-party developers. In specific implementations, the application packages in the application layer are not limited to the examples above.
[0057] The framework layer provides application programming interfaces (APIs) and programming frameworks for applications in the application layer. The application framework layer includes predefined functions. It acts as a central processing unit, determining the actions taken by applications in the application layer. Applications can access system resources and obtain system services during execution through the API interface.
[0058] like Figure 6 As shown, the application framework layer in this embodiment includes managers, content providers, etc., wherein the managers include at least one of the following modules: ActivityManager, which interacts with all activities running in the system; LocationManager, which provides access to system location services for system services or applications; PackageManager, which retrieves various information related to application packages currently installed on the device; NotificationManager, which controls the display and clearing of notification messages; and WindowManager, which manages icons, windows, toolbars, wallpapers, and desktop widgets on the user interface.
[0059] In some embodiments, the audio peripheral 400 can be wired to the display device 200, for example, the audio peripheral 400 can be a Universal Serial Bus (USB) audio peripheral, an Audio Return Channel (ARC) device, etc., or it can be wirelessly connected to the display device 200, for example, the audio peripheral 400 can be a Bluetooth audio device, a wireless network audio device, etc. Accordingly, the audio peripheral 400 can transmit audio streams with the display device 200 according to an interface protocol, or it can transmit audio streams with the display device 200 according to an Internet protocol.
[0060] Display device 200 can be configured as follows Figure 7 The process shown writes the audio stream to the audio peripheral to improve its playback quality, as detailed below:
[0061] S701, Obtain connection status change information of external devices.
[0062] In this embodiment, the change in the connection status between the external device and the display device 200 is referred to as the connection status change information of the external device. The connection status change information includes: the display device 200 newly connects to the external device, and the display device disconnects the currently connected external device. The external device and the display device 200 can be connected by wired or wireless connection. The external device can be a device that has never been connected to the display device 200, or a device that has been connected to the display device 200 before.
[0063] The display device 200 is configured with a host service to monitor the access and disconnection events of external devices. Correspondingly, the access event of an external device corresponds to the connection status change information of a newly connected external device to the display device 200, and the disconnection event of an external device corresponds to the connection status change information of a currently disconnected external device to the display device 200.
[0064] In one implementation, the external device and the display device 200 are connected via a wired connection, that is, the external device and the display device 200 are connected by inserting a connecting cable into the corresponding interface. The display device 200 monitors the connection status of each interface to identify whether a newly connected external device has appeared or whether a disconnected external device has appeared. For example, if an interface that was originally idle is detected to be occupied, it indicates that a newly connected external device has appeared. If an interface that was originally occupied is detected to be idle, it indicates that a disconnected external device has appeared. When the display device 200 detects a change in the connection status of an interface, it locates the interface and obtains the connection status change information of the external device generated on that interface, such as the event type (connection or disconnection), the time when the connection and disconnection events occurred, interface information (interface number, interface address, interface type, interface usage permissions, interface-related protocols, etc.), and device information of the external device (device name, device type, device function, memory, internally stored data, usage permissions, etc.).
[0065] In one implementation, the external device and the display device 200 are wirelessly connected, i.e., they connect via Bluetooth, wireless network protocols, or similar protocols. The display device 200 identifies newly connected external devices by monitoring received connection requests, or identifies disconnected external devices by monitoring received disconnection indications. When the display device 200 detects a change in the connection status of an external device, it locates the corresponding external device and obtains its connection status change information, such as request type (access request, disconnection indication), request reception time, communication channel information (establishment time, communication address, etc.), and device information (device name, device type, device function, memory, internally stored data, and usage permissions).
[0066] S702. Based on the connection status change information of the external device, determine whether there is a newly connected target audio peripheral device on the display device, the target audio peripheral device being used to play an audio stream.
[0067] In this embodiment, the newly connected audio peripheral to the display device 200 is referred to as the target audio peripheral. That is, only audio peripherals that undergo a connection status change and are connected to the display device 200 are considered target audio peripherals. Based on the aforementioned information on the connection status change of external devices, it can be further determined whether a target audio peripheral exists. (See also...) Figure 8 The details are as follows:
[0068] S801. Identify the connection status and device type in the connection status change information of the external device.
[0069] S802. Based on the connection status and the device type, determine whether the external device is a target audio peripheral, wherein the connection status of the target audio peripheral is connected to a display device, and the device type of the target audio peripheral is an audio device.
[0070] In this embodiment, the device type of the external device, i.e., a storage device or an audio peripheral, can be identified from the connection status change information of the external device. The corresponding connection status, i.e., connected to display device 200 or disconnected from display device 200, is also identified. For example, display device 200 monitors an insertion event at interface A and identifies external device a as connected; monitors an unplugging event at interface B and identifies external device b as unplugged; and monitors a Bluetooth connection request and identifies external device c as sending the connection request. Simultaneously, external devices a and b are identified as audio devices, i.e., external devices a and b are audio peripherals, and external device c is identified as a storage device. Based on this, external device a is the target audio peripheral.
[0071] S703. When the target audio peripheral exists, create a first child thread.
[0072] When the display device 200 detects the presence of a target audio peripheral, it uses multiple threads in parallel to play an audio stream on the target audio peripheral. The display device 200 executes the playback parameter configuration task for the target audio peripheral in the main thread, ensuring that the target audio peripheral has playback parameters suitable for the audio stream to be played, thus guaranteeing the playback quality of the audio stream. The display device 200 executes the audio stream format configuration task in the second sub-thread, ensuring that the audio stream has a data stream format suitable for playback by the target audio peripheral, thereby guaranteeing that the audio stream can be played normally by the target audio peripheral and ensuring the playback quality of the audio stream. In this embodiment, the display device 200 creates a separate sub-thread, namely the first sub-thread, to execute the relevant tasks of writing the audio stream to the target audio peripheral independently. The first sub-thread, the main thread, and the second sub-thread can be located in the same process or in different processes. As shown in Figure 9(1), the first sub-thread, the main thread, and the second sub-thread are located in the same process, for example, all in process A. In this case, the first sub-thread, the main thread, and the second sub-thread communicate with each other via inter-thread communication. As shown in Figure 9(2), the first sub-thread, the main thread, and the second sub-thread can be located in different processes. For example, the first sub-thread and the main thread are located in the same process, such as process A, while the second sub-thread is located in another process, such as process B. In this case, the first sub-thread and the main thread communicate with each other, and the first sub-thread, the main thread, and the second sub-thread communicate with each other.
[0073] S704. In the first sub-thread, a judgment task, a waiting task, and a read / write task are executed sequentially. The judgment task is used to determine whether the target audio peripheral has completed the configuration of playback parameters. The waiting task is used to wait for the completion of the configuration of the playback parameters of the target audio peripheral and / or the completion of the configuration of the audio stream format within a specified time. The read / write task is used to read the audio stream and write the read audio stream to the target audio peripheral.
[0074] Based on the parallel execution of the main thread, the first sub-thread, and the second sub-thread, the first sub-thread first performs a judgment task, namely, determining whether the playback parameters are configured correctly. Before executing the audio stream read / write tasks, a waiting task can be executed first to wait for the playback parameter configuration task of the target audio peripheral in the main thread to complete (if the judgment result is that the configuration is not complete), and to wait for the audio stream format configuration task in the second sub-thread to complete. Then, the audio stream read / write tasks are executed. In this way, it can be ensured that the audio stream written to the target audio peripheral has a suitable format and that the target audio peripheral has suitable playback parameters, thereby ensuring the quality of the audio stream played by the target audio peripheral.
[0075] Before creating the first child thread, display device 200 follows the procedure as follows: Figure 10 The process shown determines the playback path of the audio stream and the playback strategy applicable to the target audio peripheral, as follows:
[0076] S1001. Obtain the device information of the target audio peripheral.
[0077] S1002. Based on the device information of the target audio peripheral, determine the playback path of the audio stream and the playback strategy applicable to the target audio peripheral.
[0078] Taking a monitoring USB interface as an example, the external device connected to this USB interface is a USB device, which can be referred to as... Figure 11 The logic block diagram shown.
[0079] A USB driver is configured in the display device 200 to identify insertion and removal events of external devices. In this embodiment, if an insertion event is detected, it means that a new external device has been inserted into the USB interface; if a removal event is detected, it means that the external device in the USB interface has been removed.
[0080] The USB host service monitors insertion and removal events and obtains connection status change information of the corresponding external devices from these events. In this embodiment, the connection status change information of the external device includes at least the event type (connection to display device 200 or disconnection from display device 200) and the device type of the external device (audio peripheral or storage device). The USB host service transmits the insertion event to the USB service agent in the form of a message.
[0081] This embodiment addresses the scenario where an audio peripheral is connected to a display device 200. The USB service proxy determines the device type of the external device based on the connection status change information of the external device. When the external device is identified as an audio peripheral, the message is passed to the audio service proxy, which then passes the message to the audio service.
[0082] The audio server forwards the message to the audio policy server. Upon receiving the message, the audio policy server extracts the connection status change information of the audio peripheral and records it. The audio policy server can then compare the stored record with the received connection status change information to identify the USB interface whose connection status has changed, as well as the audio peripheral whose USB interface has changed. It then generates a corresponding change notification and sends this notification to the player client.
[0083] Based on the received change notification, the player client re-determines the audio device for playing the audio stream. In one scenario, if the change notification indicates disconnecting the audio peripheral already inserted in the USB interface from the display device 200, the player client will use the display device 200's speaker as the audio device for the audio stream, or, based on further playback instructions, will use another connected and available audio peripheral as the audio device for the audio stream (this scenario is not the focus of this application). In another scenario, if the change notification indicates inserting an audio peripheral into the USB interface, that audio peripheral will be used as the audio device for playing the audio stream; in this embodiment, this audio peripheral is referred to as the target audio peripheral. Further, the player client will determine the audio playback path based on the target audio peripheral. For example, the player client will use the identifier (address, name, etc.) of the target audio peripheral as the destination identifier to instruct the audio stream to be played on the target audio peripheral corresponding to the destination identifier. The player client generates a target audio peripheral notification based on the destination identifier and the device information of the target audio peripheral, and sends the target audio peripheral notification to the audio hardware interface layer of the display device 200.
[0084] After receiving the notification from the target audio peripheral, the audio hardware interface layer of the display device 200 obtains the device information of the target audio peripheral and determines the appropriate playback strategy for the target audio peripheral based on the device information, such as data packet transmission mode and playback parameters. For example, in this embodiment, the target audio peripheral is a USB device suitable for playing audio streams in tunnel mode. After determining the playback path and playback strategy corresponding to the target audio peripheral, the player client will establish a first sub-thread to separately execute the task of writing the audio stream to the target audio peripheral.
[0085] As discussed above, the foundation for display device 200 to play high-quality audio streams on the target audio peripheral includes configuring the target audio peripheral with appropriate playback parameters and configuring the audio stream with the appropriate format. Based on this, display device 200 executes the playback parameter configuration task for the target audio peripheral in its main thread, which can be found by referring to... Figure 12 The details are as follows:
[0086] and Figure 11The process of receiving messages about changes in the connection status of audio peripherals is consistent with the publicly disclosed audio server. After receiving the message, the audio server sends a specific broadcast based on the connection status change information of the audio device to notify the application that processes the corresponding connection status change information. For example, if the connection status change information of the audio peripheral is "connected to display device 200", then the specific playback includes the connection status change information of the display device; if the connection status change information of the audio peripheral is "disconnected from display device 200", then the specific playback includes the disconnection status change information of the display device.
[0087] After receiving a broadcast, the application invokes the device control service based on the broadcast type. Specifically, if the broadcast includes information about changes in the status of the connected display device, the application configures the corresponding playback parameters for the target audio peripheral. Once configuration is complete, the application is notified via a callback. The application then transmits the configuration status information (including "configuration complete" and "awaiting configuration") to the audio hardware interface layer of the display device 200 to inform the target audio peripheral that the playback parameters have been configured. If the broadcast includes information about a disconnection from the display device, the application clears the relevant information of the USB device previously plugged into the USB port. The next time an external device is plugged into the USB port, the application performs the identification and monitoring of the insertion event as described above. When the newly plugged-in external device is used as the new target audio peripheral, the application performs related tasks such as configuring playback parameters and creating the first child thread.
[0088] The process by which the display device 200 performs the audio stream format configuration task in the second sub-thread is as follows:
[0089] In this embodiment, as described above, the display device 200 determines the playback strategy (such as data packet transmission mode) applicable to the target audio peripheral at the audio hardware interface layer. When executing the second sub-thread, the display device 200 first executes the task of obtaining the determined playback strategy from the audio hardware interface layer of the display device 200, and further determines the data packet transmission mode based on the obtained playback strategy, and determines the recognizable data packet format, i.e., the audio stream format, based on the data packet transmission mode. Then, it executes the audio stream format configuration task, that is, first converts the format of the audio stream to be played into the format indicated in the data packet transmission mode, thereby ensuring that the audio stream after the format configuration can be recognized and played by the target audio peripheral, so as to ensure the playback quality of the audio stream.
[0090] In some embodiments, the second sub-thread can be a separate thread that executes in parallel with the main thread. That is, while the second sub-thread is executing, it retrieves the execution result (the determined playback strategy) from the main thread and uses this result as a basis to execute the audio stream format configuration task. In this case, the audio stream format configuration task in the second sub-thread executes in parallel with the target audio peripheral playback parameter configuration task in the main thread. Thus, by executing multiple tasks in parallel, the total execution time of multiple tasks can be effectively saved, and the overall execution efficiency of multiple tasks can be improved.
[0091] In some embodiments, the second sub-thread can be a task in the main thread, executed according to the preset execution order of tasks in the main thread. That is, first, the playback parameter configuration task of the target audio peripheral is executed in the main thread, and after the playback parameter configuration task is completed, the second sub-thread is executed in the main thread, that is, the audio stream format configuration task is executed. Figure 11 The illustrated process allows configuration status information to be obtained from the audio hardware interface layer of the display device 200 before the second sub-thread is executed. Once the configuration status information obtained from the audio hardware interface layer of the display device 200 indicates that the configuration is complete, it means that the playback parameter configuration task has been completed, and the second sub-thread can then begin execution. This method of executing multiple tasks in a single thread effectively reduces message interaction between threads and ensures the orderly execution of each task.
[0092] In this embodiment, the first sub-thread executes in parallel with the main thread and the second sub-thread. The process of executing the judgment task in the first sub-thread can be referred to... Figure 13 The logic block diagram shown is as follows:
[0093] S1301. Determine whether the target audio peripheral is connected to the display device.
[0094] S1302. If the target audio peripheral is connected to the display device, determine whether the playback parameters of the target audio peripheral are configured, and determine the waiting task to be executed based on the determination result.
[0095] S1303. If the target audio peripheral is not connected to the display device, then the first sub-thread is terminated.
[0096] First, it checks whether the target audio peripheral is connected to ensure that the display device 200 has a connected and usable external audio device, thereby ensuring the validity of the subsequent audio stream playback process. If the target audio peripheral is not connected to the display device 200, the first sub-thread is terminated to prevent the display device 200 from executing invalid tasks.
[0097] Next, it is determined whether the playback parameter configuration task has been completed. Configuration status information is obtained from the audio hardware interface layer of the display device 200 to determine whether the playback parameter configuration task has been completed. If the obtained configuration status information indicates that configuration is complete, the playback parameter configuration task is considered complete; otherwise, if the obtained configuration status information indicates that configuration is pending, the playback parameter configuration task is considered incomplete.
[0098] Furthermore, based on different judgment results, the waiting task to be executed next is selected.
[0099] If the judgment result is that the execution is complete, then a continuous waiting task is executed. This waiting task corresponds to a first specified time. If the first specified time is met, the completion time of the audio stream format configuration task falls within this first specified time. After the waiting time reaches the first specified time, the audio stream read and write tasks are executed. At this time, all read audio stream data will have the specified data format.
[0100] If the judgment result is that the task has not been completed, and while executing continuous waiting tasks, the system continues to judge whether the playback parameter configuration task has been completed. This waiting task corresponds to a second specified time. If the second specified time is met, the target audio peripheral is given a certain amount of time to configure the playback parameters, while limiting the time the target audio peripheral spends on configuration to prevent the target audio peripheral from remaining silent for an extended period. In some embodiments, the audio stream format configuration task can also be completed during the repeated waiting process of judging whether the playback parameter configuration task has been completed. Thus, while waiting for the target audio peripheral to configure the playback parameters, the system can also simultaneously wait for the audio stream format configuration to be completed.
[0101] In some embodiments, the specified waiting time can be controlled by controlling the number of waits, where each wait corresponds to a preset waiting duration, and the specified time is the product of the preset waiting duration and the total number of waits. Figure 13 As shown, the first specified time can be set to wait 20 times, the second specified time can be set to wait 100 times, and the waiting time for each wait can be specified as 10ms.
[0102] In some embodiments, the process of executing the waiting task described above can be controlled by adding flag information to the waiting configuration flag bit in the configuration status information. Specifically:
[0103] Based on the judgment result, mark the waiting configuration flag in the configuration status information.
[0104] A waiting configuration flag is set in the configuration status information. This waiting configuration flag indicates the current configuration status of the target audio peripheral. If the target audio peripheral has completed the configuration of playback parameters, a first identifier, such as false, is added to the waiting configuration flag; if the target audio peripheral has not completed the configuration of playback parameters, a second identifier, such as true, is added to the waiting configuration flag. First, the configuration status information is obtained from the audio hardware interface layer of the display device 200. When the configuration status information is identified as waiting for configuration, the waiting configuration flag is marked as true; when the configuration status information is identified as configuration complete, the waiting configuration flag is marked as false.
[0105] Determine if the current number of waits is greater than or equal to the preset number of waits. If it is, terminate the waiting task and execute the audio stream read / write task. If it is less than the preset number of waits, continue executing the waiting task.
[0106] In this embodiment, if the waiting configuration flag is set to true, the display device 200 waits to execute / perform the playback parameter configuration task of the target audio peripheral. This process of waiting to execute / perform the playback parameter configuration task of the target audio peripheral is called "waiting once." That is, if the waiting configuration flag is detected as false once, a wait is required. In this embodiment, each wait corresponds to a preset waiting duration. After the waiting duration is reached, the next waiting configuration flag identification process is executed, and this cycle repeats.
[0107] In this embodiment, different preset waiting times can be set for different judgment results. For example, the preset waiting time corresponding to the judgment result of completion is called the first preset waiting time, and the preset waiting time corresponding to the judgment result of incomplete execution is called the second preset waiting time. Furthermore, the first preset waiting time can be set to be less than the second preset waiting time to appropriately shorten the waiting time required for the target audio peripheral after configuration, so as to execute the subsequent audio stream read / write tasks as quickly as possible in this scenario.
[0108] For an explanation of scenarios where the judgment result is "execution completed," please refer to [reference needed]. Figure 14 The logic block diagram shown below illustrates the specific process as follows:
[0109] S1401. If the judgment result is that the configuration is complete, then add first marker information, which indicates that the target audio peripheral does not need to wait for the configuration of playback parameters.
[0110] S1402. Determine whether the current total number of waits is greater than or equal to the first preset number of waits, wherein each wait corresponds to a specified waiting duration, and the total waiting duration corresponding to the first preset number of waits is equal to the specified duration.
[0111] S1403. If the current total number of waits is less than the first preset number of waits, then determine whether the target audio peripheral is connected to the display device. If the target audio peripheral is connected to the display device, then when the first marker information is detected, wait for the specified waiting time and then repeat the above waiting process until the current number of waits is greater than or equal to the first preset number of waits. If the target audio peripheral is not connected to the display device, then terminate the first sub-thread.
[0112] S1404. If the current total number of waiting times is greater than or equal to the first preset number of waiting times, then the waiting task is terminated.
[0113] First, determine whether the current waiting count is greater than or equal to the first preset waiting count. If the current waiting count is less than the first preset waiting count, it means that the total waiting time has not yet reached the first specified time, and it cannot be guaranteed that the audio stream has been fully configured. Therefore, the waiting task needs to continue. If the current waiting count is greater than or equal to the first preset waiting count, it means that the total waiting time has reached the first specified time, and it can be guaranteed that the audio stream has been fully configured. Therefore, the waiting task can be terminated, and the audio stream read and write tasks can be executed.
[0114] When the current waiting count is less than the first preset waiting count, it is determined whether the target audio peripheral is connected to the display device. If the target audio peripheral is connected to the display device, it means that the target audio peripheral is currently available, and the waiting task can continue to be executed. Otherwise, it means that the target audio peripheral is currently unavailable. At this time, the first sub-thread is terminated, that is, the target audio peripheral is no longer used to play the audio stream.
[0115] When determining if a target audio peripheral is connected to a display device, the current waiting configuration flag is identified. In this scenario, the target audio peripheral has already completed the playback parameter configuration at the beginning, meaning the waiting configuration flag is false. Therefore, in this scenario, there is no need to check again whether the target audio peripheral has completed the playback parameter configuration; the current waiting process can be executed directly. After the set waiting time for each waiting period is reached, the above process continues to be executed repeatedly until the current waiting count is greater than or equal to the first preset waiting count.
[0116] For example, when the initial judgment of whether the playback parameter configuration task has been completed is successful, the waiting configuration flag is set to false, and a first preset waiting count N = 20 is set based on this waiting configuration flag (false), with each waiting duration t = 10ms. It is then determined whether the current waiting count is greater than or equal to 20. If it is, the waiting task is terminated, and the audio stream read / write task is executed. If it is less than 20, it is determined whether the target audio peripheral is connected to the display device 200. If not connected, the first sub-thread is terminated; if connected, the current waiting flag is checked. If the check result is false, 10ms is waited, and after 10ms, the waiting count is accumulated once, and the above process continues until the current waiting count is greater than or equal to 20, at which point the waiting task is terminated, and the audio stream read / write task is executed.
[0117] For explanations regarding scenarios where the judgment result indicates incomplete execution, please refer to [link / reference]. Figure 15 The logic block diagram shown below illustrates the specific process as follows:
[0118] S1501. If the judgment result is "waiting for configuration", then add second marker information, which indicates that the target audio peripheral needs to wait for the configuration of playback parameters.
[0119] S1502. Determine whether the current total number of waits is greater than or equal to the second preset number of waits, wherein each wait corresponds to a specified waiting duration, and the total waiting duration corresponding to the second preset number of waits is equal to the specified duration.
[0120] S1503. If the current total number of waits is less than the first preset number of waits, then determine whether the target audio peripheral is connected to the display device. If the target audio peripheral is connected to the display device, then when the second marker information is detected, determine whether the target audio peripheral has completed the configuration of playback parameters. When the configuration is completed, terminate the waiting task. While waiting for the configuration, wait for the specified waiting time and then repeat the above waiting process until the current number of waits is greater than or equal to the second preset number of waits. If the target audio peripheral is not connected to the display device, then terminate the first sub-thread.
[0121] S1504. If the current total number of waiting times is greater than or equal to the second preset number of waiting times, then the waiting task is terminated.
[0122] First, determine if the current waiting count is greater than or equal to the second preset waiting count. If the current waiting count is less than the second preset waiting count, it means the total waiting time has not yet reached the second specified duration, and the audio stream cannot be guaranteed to be fully configured. Therefore, the waiting task needs to continue. Simultaneously, the target audio peripheral's playback parameter configuration task in the main thread can continue to be executed in parallel while the waiting task is being executed. However, if the current waiting count is greater than or equal to the second preset waiting count, it means the total waiting time has reached the second specified duration, guaranteeing the audio stream is fully configured and meeting the minimum standard for audio stream playback. To avoid spending too much time waiting for the target audio peripheral to configure playback parameters, and to prevent users from waiting too long without any audio playback after connecting the target audio peripheral, the waiting task can be terminated, and the audio stream read / write task can be executed to ensure the audio stream plays as quickly as possible.
[0123] When the current waiting count is less than the second preset waiting count, it is determined whether the target audio peripheral is connected to the display device. If the target audio peripheral is connected to the display device, it means that the target audio peripheral is currently available, and the waiting task can continue to be executed. Otherwise, it means that the target audio peripheral is currently unavailable. At this time, the first sub-thread is terminated, that is, the target audio peripheral is no longer used to play the audio stream.
[0124] When determining if a target audio peripheral is connected to the display device, the current configuration waiting flag is identified. In this scenario, the configuration waiting flag is false, meaning the target audio peripheral has not completed playback parameter configuration during the initial determination. The system then continues to check if the target audio peripheral has completed configuration, obtaining configuration status information. If the configuration status information indicates configuration completion, the target audio peripheral is ready to play the audio stream normally. During the process of waiting for the target audio peripheral to configure playback parameters, it is assumed that the entire audio stream has completed its format configuration task. At this point, the waiting task can be terminated, and audio stream read / write tasks can be executed. If the configuration status information indicates configuration waiting, one waiting count is accumulated, and the above process continues to loop until the current waiting count is greater than or equal to a second preset waiting count.
[0125] For example, when the initial determination of whether the playback parameter configuration task has been completed is not found to be completed, the waiting configuration flag is set to true, and a second preset waiting count N = 100 is set based on this waiting configuration flag (true), with each waiting period t = 10ms. It is then determined whether the current waiting count is greater than or equal to 100. If it is, the waiting task is terminated, and the audio stream read / write task is executed. If it is less than 100, it is determined whether the target audio peripheral is connected to the display device 200. If not, the first sub-thread is terminated; if connected, the current waiting flag is identified. If the identification result is true, it is determined whether the target audio peripheral has completed the playback parameter configuration. If it has, the waiting task is terminated, and the audio stream read / write task is executed; if not, it waits for 10ms, and after 10ms, the waiting count is accumulated once, and the above process continues until the current waiting count is greater than or equal to 100, at which point the waiting task is terminated, and the audio stream read / write task is executed.
[0126] After executing the waiting task, the audio stream read / write task is executed. The process of executing the audio stream read / write task in the first child thread can be found in [reference needed]. Figure 16 The logic block diagram shown is as follows:
[0127] S1601. Determine whether the target audio peripheral is connected to the display device.
[0128] S1602. If the target audio peripheral is not connected to the display device, then the first sub-thread is terminated.
[0129] S1603. If the target audio peripheral is connected to the display device, the decoded audio stream is obtained from the second sub-thread in the display device. The second sub-thread is used to perform the format configuration task of the audio stream, wherein the second sub-thread is executed in parallel with the first sub-thread.
[0130] S1604. Determine whether the audio stream has been successfully read.
[0131] S1605. If the reading is successful, the read audio stream is written to the target audio peripheral.
[0132] S1606. If the read fails, wait for a preset time and then repeat the above read process.
[0133] In some embodiments, due to factors such as network or the internal execution logic of the display device 200, problems such as audio stream reading failure or decoding failure may occur. In this case, the display device 200 repeats the above process after waiting for a preset time (such as a third specified time) until the audio stream is successfully read.
[0134] After the audio stream is successfully read, the read audio stream is written to the driver of the target audio peripheral.
[0135] After receiving the written audio stream, the target audio peripheral plays the audio stream using the configured playback parameters.
[0136] In some embodiments, reference may be made to, such as Figure 17 The logic block diagram shown writes the read audio stream to the driver of the target audio peripheral, as detailed below:
[0137] S1701. Identify the current configuration status of the audio driver output format of the target audio peripheral.
[0138] S1702. If the configuration status is "switching complete", then the read audio stream is written to the target audio peripheral.
[0139] S1703. If the configuration status is switching, the read audio stream is set to 0, and 0 data is written to the target audio peripheral until the configuration status is monitored as completed switching.
[0140] The stability of the target audio peripheral's audio driver output format affects the output quality of the audio stream. For example, if the target audio peripheral is switching its audio driver output format, its stability is low. If the read audio stream is directly written to the driver, the target audio peripheral will play the written audio stream while switching output formats, resulting in distorted sound and reduced playback quality. To solve this problem, when the target audio peripheral is switching its audio driver output format, the corresponding read audio stream can be set to 0, and 0 data can be written to the driver. This way, the target audio peripheral will not play 0 data while switching output formats, thus avoiding the distorted sound problem. Once the audio driver output format switching is complete, the read audio stream can be written to the driver normally for playback.
[0141] As can be seen from the above technical solutions, the display device and audio stream read / write method provided in the above embodiments, when the display device recognizes a newly connected audio peripheral, creates a separate first sub-thread to execute the task of writing the audio stream to the audio peripheral. In the first sub-thread, a waiting task can be executed first to wait for the playback parameter configuration task of the audio peripheral to complete, and to wait for the audio stream format configuration task to complete, before executing the audio stream read / write task. This ensures that the audio stream written to the audio peripheral has a suitable format and that the audio peripheral has suitable playback parameters, thereby ensuring the quality of the audio stream played by the audio peripheral.
[0142] Similar parts between the embodiments provided in this application can be referred to mutually. The specific implementation methods provided above are only a few examples under the overall concept of this application and do not constitute a limitation on the scope of protection of this application. For those skilled in the art, any other implementation methods extended from the solution of this application without creative effort shall fall within the scope of protection of this application.
Claims
1. A display device, characterized in that, include: The monitor is configured to display the user interface; The controller is configured as follows: Obtain connection status change information of external devices; Based on the connection status change information of the external device, it is determined whether there is a newly connected target audio peripheral device on the display device, and the target audio peripheral device is used to play audio streams; When the target audio peripheral exists, a first child thread is created; In the first sub-thread, a judgment task, a waiting task, and a read / write task are executed sequentially. The judgment task is used to determine whether the target audio peripheral has completed the configuration of playback parameters. The waiting task is used to wait for the completion of the configuration of the playback parameters of the target audio peripheral and / or the completion of the configuration of the audio stream format within a specified time. The read / write task is used to read the audio stream and write the read audio stream to the target audio peripheral. The controller is configured to perform the judgment task in the first sub-thread as follows: Determine whether the target audio peripheral is connected to the display device; If the target audio peripheral is connected to the display device, it is determined whether the playback parameters of the target audio peripheral have been configured, and the waiting task to be executed is determined based on the determination result.
2. The display device according to claim 1, characterized in that, Based on the connection status change information of the external device, the controller determines whether a newly connected target audio peripheral has been configured to access the display device. Identify the connection status and device type in the connection status change information of the external device; Based on the connection status and the device type, it is determined whether the external device is a target audio peripheral, wherein the connection status of the target audio peripheral is connected to a display device, and the device type of the target audio peripheral is an audio device.
3. The display device according to claim 1, characterized in that, The controller is also configured to: before creating the first child thread. Obtain the device information of the target audio peripheral; Based on the device information of the target audio peripheral, the playback path of the audio stream and the playback strategy applicable to the target audio peripheral are determined.
4. The display device according to claim 1, characterized in that, The controller is configured to perform the judgment task in the first sub-thread as follows: If the target audio peripheral is not connected to the display device, the first sub-thread is terminated.
5. The display device according to claim 4, characterized in that, The controller obtains the configuration status information of the target audio peripheral from the main thread of the display device. The configuration status information indicates whether the playback parameters have been configured. The main thread and the first sub-thread are executed in parallel.
6. The display device according to claim 4, characterized in that, The controller is configured to perform a waiting task in the first sub-thread as follows: If the determination result is that the configuration is complete, then add the first marker information, which indicates that the target audio peripheral does not need to wait for the configuration of playback parameters; Determine whether the current total number of waits is greater than or equal to a first preset number of waits, wherein each wait corresponds to a specified waiting duration, and the total waiting duration corresponding to the first preset number of waits is equal to the specified duration; If the current total number of waits is less than the first preset number of waits, then it is determined whether the target audio peripheral is connected to the display device. If the target audio peripheral is connected to the display device, then when the first marker information is detected, the above waiting process is repeated after waiting for the specified waiting time until the current number of waits is greater than or equal to the first preset number of waits. If the target audio peripheral is not connected to the display device, then the first sub-thread is terminated. If the current total number of waits is greater than or equal to the first preset number of waits, then the waiting task is terminated.
7. The display device according to claim 4, characterized in that, The controller is configured to perform a waiting task in the first sub-thread as follows: If the determination result is "waiting for configuration", then add a second marker, which indicates that the target audio peripheral needs to wait for the configuration of playback parameters. Determine whether the current total number of waits is greater than or equal to the second preset number of waits, wherein each wait corresponds to a specified waiting duration, and the total waiting duration corresponding to the second preset number of waits is equal to the specified duration; If the current total number of waits is less than the first preset number of waits, it is determined whether the target audio peripheral is connected to the display device. If the target audio peripheral is connected to the display device, when the second marker information is detected, it is determined whether the target audio peripheral has completed the configuration of playback parameters. When the configuration is completed, the waiting task is terminated. While waiting for the configuration, the above waiting process is repeated after the specified waiting time until the current number of waits is greater than or equal to the second preset number of waits. If the target audio peripheral is not connected to the display device, the first sub-thread is terminated. If the current total number of waits is greater than or equal to the second preset number of waits, then the waiting task is terminated.
8. The display device according to claim 1, characterized in that, The controller is configured to perform read / write tasks in the first sub-thread as follows: Determine whether the target audio peripheral is connected to the display device; If the target audio peripheral is not connected to the display device, then the first sub-thread is terminated; If the target audio peripheral is connected to the display device, the decoded audio stream is obtained from the second sub-thread in the display device. The second sub-thread is used to perform the format configuration task of the audio stream, wherein the second sub-thread is executed in parallel with the first sub-thread. Determine whether the audio stream was read successfully; If the read is successful, the read audio stream will be written to the target audio peripheral. If the read fails, the above read process will be repeated after a preset time.
9. The display device according to claim 8, characterized in that, The controller is configured to write the read audio stream to the target audio peripheral as follows: Identify the current configuration status of the audio driver output format of the target audio peripheral; If the configuration status is "switching complete", the read audio stream will be written to the target audio peripheral. If the configuration status is switching, the read audio stream will be set to 0, and 0 data will be written to the target audio peripheral until the configuration status is monitored as completed switching.
10. An audio stream reading and writing method, characterized in that, Applied to a display device, the method includes: Obtain connection status change information of external devices; Based on the connection status change information of the external device, it is determined whether there is a newly connected target audio peripheral device on the display device, and the target audio peripheral device is used to play audio streams; When the target audio peripheral exists, a first child thread is created; In the first sub-thread, a judgment task, a waiting task, and a read / write task are executed sequentially. The judgment task is used to determine whether the target audio peripheral has completed the configuration of playback parameters. The waiting task is used to wait for the completion of the configuration of the playback parameters of the target audio peripheral and / or the completion of the configuration of the audio stream format within a specified time. The read / write task is used to read the audio stream and write the read audio stream to the target audio peripheral. The step of performing the judgment task in the first sub-thread includes: Determine whether the target audio peripheral is connected to the display device; If the target audio peripheral is connected to the display device, it is determined whether the playback parameters of the target audio peripheral have been configured, and the waiting task to be executed is determined based on the determination result.
Citation Information
Patent Citations
Reverse screen projection audio control method and device and computer readable storage medium
CN112512133A
Display device and audio data writing method
CN113138745A
Sound effect configuration method and device, intelligent sound box, computer equipment and storage medium
CN113641329A
