Audio data distribution method, electronic device and storage medium
By determining the encoding instance of Bluetooth device and the data location of the ring buffer in the electronic device, the problem of inconsistent audio data reading rhythm of Bluetooth device is solved, and the audio playback effect of Bluetooth device is improved.
Patent Information
- Application Number
- CN202210360227.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-06
- Publication Date
- 2025-08-19
- Estimated Expiration
- 2042-04-06
AI Technical Summary
In the prior art, Bluetooth devices cannot share all audio data with Bluetooth devices due to limited Bluetooth channels, resulting in different codecs reading audio data from electronic devices with different encoding algorithms, which affects the normal playback effect of audio data.
By determining the encoded instance of each Bluetooth device in the electronic device, recording the head and tail position of the data segment of the ring buffer, and reading and downloading data from the ring buffer according to the reading status and device capability information of the encoded instance, ensuring that the encoded instances of different Bluetooth devices can obtain audio data at an appropriate rhythm.
It realizes the distribution of appropriate audio data based on the capability information of the Bluetooth device, improves the audio playback effect of the Bluetooth device, and meets the needs of different reading rhythms.
Smart Images

Figure CN116935869B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Bluetooth communications, and in particular to an audio data distribution method, electronic device, and storage medium. Background Art
[0002] When existing electronic devices such as mobile phones share Bluetooth audio data with Bluetooth devices (such as Bluetooth headphones or speakers), due to the limited Bluetooth channels, not all Bluetooth audio data can be shared with the Bluetooth device. Instead, the Bluetooth audio data is encoded and compressed through an audio encoder (Codec) and then sent to the Bluetooth device. However, due to the limitations of the Android native architecture, electronic devices only use one set of Codecs to obtain audio data and encode the obtained audio data. In order to improve the audio playback effect of Bluetooth devices, Codecs with different encoding algorithms can be used to encode the corresponding Bluetooth devices according to the music playback capabilities of the Bluetooth devices. However, Codecs with different encoding algorithms read audio data from electronic devices at different rhythms, which will affect the normal playback of audio data. Summary of the Invention
[0003] In view of the above, it is necessary to provide an audio data distribution method, electronic device and storage medium.
[0004] In a first aspect, an embodiment of the present application provides an audio data distribution method, which is applied in an electronic device, the method comprising: interacting with each Bluetooth device, comprising: determining a coding instance of each Bluetooth device, wherein the coding instance is used to encode audio data according to a coding algorithm through an encoder; recording a data segment header position and a data segment tail position of a circular buffer of the electronic device, and recording the amount of data read from the circular buffer by the coding instance of each Bluetooth device and the position of the amount of data read, wherein the amount of data between the data segment header position and the data segment tail position is the amount of data that can be read from the circular buffer; receiving a play instruction and obtaining a read data request of the coding instance of each Bluetooth device in response to the play instruction, and judging whether the coding instance of each Bluetooth device has read audio data from the circular buffer within a current timing cycle according to the read status of the coding instance of each Bluetooth device, wherein the read data request includes the amount of data to be read; when each of the coding instances of the Bluetooth device is within the current timing cycle The reading status of the coding instance of the Bluetooth device is in the read state, and the data segment header position of the circular buffer is updated according to the position of the data amount read by the coding instance of each Bluetooth device. When the reading status of at least one coding instance of the Bluetooth device is in the unread state within the current timing cycle, the data segment header position of the circular buffer is not updated; the amount of data to be read of the coding instance of each Bluetooth device is determined from the read data request of the coding instance of each Bluetooth device; according to the amount of data to be read of the coding instance of each Bluetooth device and the position of the data amount already read by the coding instance of each Bluetooth device, the coding instance of each Bluetooth device reads the data amount to be read from the circular buffer starting from the position of the data amount already read by the coding instance of each Bluetooth device, records and updates the position of the data amount already read from the circular buffer by the coding instance of each Bluetooth device, and sets the reading status of the coding instance of each Bluetooth device to the read state. In the above technical solution, the electronic device obtains the device capability information of each Bluetooth device, and determines the encoding instance of each Bluetooth device based on the device capability information of each Bluetooth device. According to the read data request of the encoding instance of each Bluetooth device 200, the electronic device reads the corresponding amount of data from the circular buffer and sends it to the encoding instance of each Bluetooth device 200, thereby enabling the electronic device to distribute data to different encoders and meet the needs of obtaining audio data from encoding instances with different reading rhythms.
[0005] In one embodiment of the present application, each Bluetooth device encoding instance reading the amount of data to be read from the position of the data volume of the circular buffer as the starting point includes: determining whether to download data from the hardware abstraction layer of the electronic device to the circular buffer based on the amount of data to be read of each Bluetooth device encoding instance and the position of the amount of data already read by each Bluetooth device encoding instance; when it is determined that the data is to be downloaded from the hardware abstraction layer of the electronic device to the circular buffer, downloading a preset amount of data from the hardware abstraction layer to the circular buffer for storage and updating the data segment tail position of the circular buffer based on the stored data, and each Bluetooth device encoding instance reading the amount of data to be read from the circular buffer; or when it is determined that the data is not to be downloaded from the hardware abstraction layer of the electronic device to the circular buffer, each Bluetooth device encoding instance reading the amount of data to be read from the data volume of the circular buffer as the starting point. In the above technical solution, when it is determined that the data in the circular buffer is insufficient for the encoding instance of the Bluetooth device to obtain, data can be downloaded from the hardware abstraction layer of the electronic device to the circular buffer for the encoding instance to read, and the data segment tail position of the circular buffer can be updated.
[0006] In one embodiment of the present application, the method of determining whether to download data from the hardware abstraction layer of the electronic device to the circular buffer based on the amount of data to be read of the coding instance of each Bluetooth device and the position of the amount of data already read by the coding instance of each Bluetooth device includes: determining the target data amount between the position of the amount of data already read in the circular buffer by the coding instance of each Bluetooth device and the end position of the data segment; when the target data amount is greater than the amount of data to be read by the Bluetooth device, determining not to download data from the hardware abstraction layer to the circular buffer; when the target data amount is less than or equal to the amount of data to be read by the Bluetooth device, determining to download data from the hardware abstraction layer to the circular buffer. The above technical solution determines whether to download data from the hardware abstraction layer to the circular buffer by comparing the target data amount between the position of the amount of data already read by the coding instance of each Bluetooth device and the end position of the data segment and the amount of data to be read by the Bluetooth device.
[0007] In one embodiment of the present application, downloading a preset amount of data from the hardware abstraction layer to the circular buffer for storage and updating the tail position of a data segment in the circular buffer based on the stored data includes: downloading a preset amount of data from the hardware abstraction layer to the circular buffer, storing the downloaded data at the tail position of a data segment in the circular buffer, and updating the tail position of a data segment in the circular buffer based on the stored data. In the above technical solution, the tail position of a data segment in the circular buffer is updated when data is downloaded to the circular buffer for storage, so that data can be read in the next encoding instance.
[0008] In one embodiment of the present application, the preset data volume is not less than the difference between the target data volume and the data volume to be read from each Bluetooth device. The above technical solution can ensure that the circular buffer has enough data for the coding instance to read.
[0009] In one embodiment of the present application, the interaction with each Bluetooth device includes: the Bluetooth protocol stack of the electronic device responds to the connection request sent by the Bluetooth device and establishes a communication connection with the Bluetooth device; the Bluetooth protocol stack sends a device capability acquisition instruction to the Bluetooth device; the Bluetooth protocol stack receives the device capability information sent by the Bluetooth device, wherein the device capability information includes the audio coding format supported by the Bluetooth device; the Bluetooth protocol stack determines the audio coding format supported by the Bluetooth device based on the device capability information, and determines the coding instance of the Bluetooth device based on the audio coding format; the agent of the Bluetooth protocol stack obtains the coding instance of the Bluetooth device, and maps the Bluetooth device and the coding instance of the Bluetooth device into a corresponding relationship. With the above technical solution, when the electronic device connects and interacts with the Bluetooth device, the Bluetooth protocol stack can determine the coding instance corresponding to the audio coding format supported by the Bluetooth device, thereby achieving the purpose of the Bluetooth device receiving the coded data sent by the encoder of the audio coding format corresponding to the Bluetooth device, thereby improving the audio playback effect of the Bluetooth device.
[0010] In one embodiment of the present application, the Bluetooth protocol stack determines the audio coding formats supported by the Bluetooth device based on the device capability information, including: when the Bluetooth protocol stack determines that the device capability information of the Bluetooth device includes multiple audio coding formats, the Bluetooth protocol stack selects the audio coding format with the best sound quality from the multiple audio coding formats as the audio coding format of the Bluetooth device. In the above technical solution, the Bluetooth protocol stack can select the audio coding format with the best sound quality from the multiple audio coding formats as the audio coding format of the Bluetooth device, further improving the audio playback effect of the Bluetooth device.
[0011] In one embodiment of the present application, determining the encoding instance of the Bluetooth device based on the audio encoding format includes: the Bluetooth protocol stack determining a coding scheme corresponding to the audio coding format based on the audio encoding format of the Bluetooth device; determining the encoding instance corresponding to the Bluetooth device based on the coding scheme, wherein the coding instance is encoded according to the coding scheme.
[0012] In one embodiment of the present application, the receiving of a play instruction and responding to the play instruction to obtain a read data request for each encoding instance of the Bluetooth device, and determining whether each encoding instance of the Bluetooth device has read audio data from the circular buffer within the current timing cycle based on the read status of the encoding instance of each Bluetooth device, wherein the read data request includes the amount of data to be read, including: the application of the electronic device responding to the play instruction input by the user and sending the play instruction to the Bluetooth protocol stack; the Bluetooth protocol stack responding to the play instruction and starting a timer to cycle according to the timing cycle; the agent of the Bluetooth protocol stack obtaining a read data request for an encoding instance within the current timing cycle of the timer, and determining whether all encoding instances have read audio data from the circular buffer within the current timing cycle based on the read status of the encoding instance. In the above technical solution, when the Bluetooth protocol stack receives a play instruction from an application at the application layer, it starts a timer to cycle according to the timing cycle, and determines whether all encoding instances have read audio data from the circular buffer within the current timing cycle based on the timing cycle.
[0013] In one embodiment of the present application, updating the data segment header position of the circular buffer based on the position of the data volume read by each encoding instance of the Bluetooth device includes: the agent updating the data segment header position of the circular buffer based on the position of the data volume read by each encoding instance of the Bluetooth device, wherein the position of the data volume read by each encoding instance of the Bluetooth device refers to the position of the data volume marked in the circular buffer when each encoding instance of the Bluetooth device reads the data volume from the circular buffer. In the above technical solution, the agent updates the data segment header position of the circular buffer to facilitate data reading by the next encoding instance.
[0014] In one embodiment of the present application, the agent updates the data segment header position of the circular buffer based on the position of the data volume read by each encoding instance of the Bluetooth device, including: determining the minimum data volume from the data volume read by each encoding instance of the Bluetooth device; and updating the data segment header position corresponding to the minimum data volume as the data segment header position of the circular buffer. The above technical solution can update the data segment header position of the circular buffer based on the position of the data volume corresponding to the minimum data volume.
[0015] In one embodiment of the present application, determining the amount of data to be read from the encoding instance of each Bluetooth device from the read data request of the encoding instance of each Bluetooth device includes: the agent determining the amount of data to be read from the read data request of the encoding instance of each Bluetooth device. In the above technical solution, the agent determines the amount of data to be read from the read data request of the encoding instance of each Bluetooth device.
[0016] In one embodiment of the present application, the coding instance of each of the Bluetooth devices reads the data of the amount of data to be read from the position of the data amount of the circular buffer as the starting point, including: the agent determines whether to download data from the electronic device hardware abstraction layer to the circular buffer according to the amount of data to be read of the coding instance of each of the Bluetooth devices and the position of the amount of data already read by the coding instance of each of the Bluetooth devices; when it is determined that the data is to be downloaded from the hardware abstraction layer of the electronic device to the circular buffer, the agent downloads a preset amount of data from the hardware abstraction layer to the circular buffer for storage and updates the data segment tail position of the circular buffer according to the stored data; the agent determines whether to download data from the hardware abstraction layer to the circular buffer according to the amount of data to be read of the coding instance of each of the Bluetooth devices The agent then reads the data amount to be read from the circular buffer based on the data amount and the position of the data amount already read by the coding instance of each Bluetooth device, starting from the position of the data amount already read by the coding instance of each Bluetooth device, and sends the read data to the coding instance of each Bluetooth device; or when it is determined that there is no need to download data from the hardware abstraction layer of the electronic device to the circular buffer, the agent reads the data amount to be read from the circular buffer based on the data amount to be read by the coding instance of each Bluetooth device and the position of the data amount already read by the coding instance of each Bluetooth device, starting from the position of the data amount already read by the coding instance of each Bluetooth device, and sends the read data to the coding instance of each Bluetooth device. The above technical solution downloads a preset amount of data from the hardware abstraction layer to the circular buffer for storage by the agent, and sends the data in the circular buffer to the coding instance by the agent, thereby realizing the agent's function of managing the circular buffer and the coding instance.
[0017] In a second aspect, an embodiment of the present application provides an electronic device comprising a processor and a memory; wherein the processor is coupled to the memory; the memory is used to store program instructions; and the processor is used to read the program instructions stored in the memory to implement the above-mentioned audio data distribution method.
[0018] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which stores program instructions. When the program instructions are executed by a processor, the above-mentioned audio data distribution method is executed.
[0019] In addition, the technical effects brought about by the second to third aspects can be found in the descriptions of the methods of each design in the above method section, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.
[0021] Figure 1 This is a software structure block diagram of an electronic device in one embodiment of the present application.
[0022] Figure 2 This is a diagram of the application environment of the audio data distribution method in one embodiment of the present application.
[0023] Figure 3 This is a flowchart of an audio data distribution method in one embodiment of the present application.
[0024] Figure 4 Schematic diagram of a flow chart of a method for an electronic device to interact with each Bluetooth device in one embodiment of the present application.
[0025] Figure 5 Schematic diagram of an operating interface of an electronic device in one embodiment of the present application.
[0026] Figure 6 Schematic diagram of a connection interface of an electronic device in one embodiment of the present application.
[0027] Figure 7 This is a flowchart of an audio data distribution method in another embodiment of the present application.
[0028] Figure 8 This is a schematic diagram of a music playback interface of an electronic device in one embodiment of the present application.
[0029] Figure 9A-9B This is a schematic diagram of updating a data segment header in a ring buffer according to an embodiment of the present application.
[0030] Figures 10A-10B This is a schematic diagram of a ring buffer downloading data from the HAL layer in one embodiment of the present application.
[0031] Figure 11Schematic diagram of the structure of an electronic device in an embodiment of the present application. DETAILED DESCRIPTION
[0032] In the following, the terms "first" and "second" are used for descriptive purposes only and are not to be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Thus, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present application, words such as "exemplary" or "for example" are used to indicate examples, illustrations or explanations. Any embodiment or design described as "exemplary" or "for example" in the embodiments of the present application should not be interpreted as being more preferred or more advantageous than other embodiments or design schemes. Specifically, the use of words such as "exemplary" or "for example" is intended to present related concepts in a concrete way.
[0033] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which this application belongs. The terms used in the specification of this application are for the purpose of describing specific embodiments only and are not intended to limit this application. It should be understood that, unless otherwise specified in this application, " / " means or. For example, A / B can mean A or B. "And / or" in this application is merely a way to describe the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. "At least one" means one or more. "Multiple" means two or more than two. For example, at least one of a, b or c can mean: a, b, c, a and b, a and c, b and c, a, b and c.
[0034] To facilitate the description of each embodiment below, a brief description of the user interface (UI) involved in the embodiments of the present application is first given. UI is a medium interface for interaction and information exchange between an application or operating system and a user, which can realize the conversion between the internal form of information and the form acceptable to the user. The user interface of an application is a source code written in a specific computer language such as JAVA and extensible markup language (XML). The interface source code is parsed and rendered on an electronic device, and finally presented as content that the user can recognize, such as pictures, text, buttons and other controls. Controls are the basic elements of the user interface. Typical controls include buttons, widgets, toolbars, menu bars, text boxes, scroll bars, images and text. The properties and contents of controls in the interface are defined by tags or nodes, such as XML through <textview> 、 <imgview> 、 <videoview>The controls contained in the interface are specified by nodes such as <head> and <body>. A node corresponds to a control or attribute in the interface, and the node is presented as user-visible content after parsing and rendering. In addition, many applications, such as hybrid applications, usually also contain web pages in their interfaces. A web page, also known as a page, can be understood as a special control embedded in the application interface. A web page is a source code written in a specific computer language, such as hypertext markup language (HTML), cascading style sheets (CSS), JAVA scripts (JavaScript, JS), etc. The web page source code can be loaded and displayed as user-recognizable content by a browser or a web page display component with similar functions to a browser. The specific content contained in a web page is also defined by tags or nodes in the web page source code, such as HTML through <body>. 、 、 <video> 、 <canvas>To define the elements and attributes of a web page.
[0035] A common form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operations that uses graphics to display. It can be an icon, window, control, or other interface element displayed on the display of an electronic device.
[0036] The present application provides an audio data distribution method, which is applied in an electronic device 100. Figure 1 FIG2 is a block diagram of the software structure of the electronic device 100 in an embodiment of the present application. The layered architecture divides the software into the application layer, application framework layer, hardware abstraction layer (HAL) and kernel layer from top to bottom.
[0037] The application layer can include a series of application packages. Figure 1 As shown, the application package may include an audio application or a video application.
[0038] The application framework layer provides an application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions. Figure 1 As shown, the application framework layer may include a Bluetooth framework layer and an audio framework layer. The audio framework layer includes a ring buffer.
[0039] The Hardware Abstraction Layer (HAL) provides a unified access interface for different hardware devices. Figure 1 As shown, the HAL layer may include a Bluetooth protocol stack and a ring buffer. The Bluetooth protocol stack includes an agent, which is used to manage the ring buffer.
[0040] The kernel layer is the layer between hardware and software. The kernel layer includes at least various drivers, e.g. Figure 1 The Bluetooth driver shown.
[0041] refer to Figure 2 , which is an application environment diagram of an audio data distribution method in an embodiment of the present application. The audio data distribution method is applied in an electronic device 100. The electronic device 100 is communicatively connected to at least two Bluetooth devices 200 via a Bluetooth communication module. In one embodiment, the electronic device 100 includes, but is not limited to, a smartphone, a laptop, a desktop, a handheld PC, a personal digital assistant, an embedded processor, a digital signal processor (DSP), a graphics device, a video game device, a set-top box, a microcontroller, a cellular phone, a portable media player, a handheld device, a wearable device (e.g., display glasses or goggles, a head-mounted display (HMD), a watch, a head-mounted device, an armband, jewelry, etc.), a virtual reality (VR) and / or augmented reality (AR) device, an Internet of Things (IoT) device, an intelligent audio system, an in-vehicle infotainment device, a streaming client device, an e-book reading device, a POS machine, a control system of an electric vehicle, and various other electronic devices. In one embodiment, the Bluetooth device 200 includes a Bluetooth device with Bluetooth audio playback capability, such as a Bluetooth headset and a Bluetooth speaker.
[0042] When existing electronic devices such as mobile phones share Bluetooth audio data with Bluetooth devices (such as Bluetooth headphones or speakers), due to limited Bluetooth channels, they cannot share all of the Bluetooth audio data with the Bluetooth device. Instead, the Bluetooth audio data is encoded and compressed using an audio codec (Codec) and then sent to the Bluetooth device. However, due to the limitations of the native Android architecture, electronic devices only use a single set of Codecs to acquire and encode audio data. For example, when an electronic device is connected to two different Bluetooth devices, it uses the same Codec to acquire, encode, and send the encoded audio data to each Bluetooth device. However, different Bluetooth devices support different encoding algorithms, and the sound quality of audio data compressed using different encoding algorithms varies when played back on a Bluetooth device. For example, audio data encoded using the Advanced Audio Codec (AAC) algorithm produces better sound quality than audio data encoded using the Sub-band Coding (SBC) algorithm. To improve the audio playback quality of Bluetooth devices, it is necessary to use Codecs with different encoding algorithms based on the capabilities of the Bluetooth device to encode the audio data played back by the device. However, codecs using different encoding algorithms read audio data from electronic devices at different rhythms. As a result, when codecs using different encoding algorithms encode audio data played by Bluetooth devices, different codecs cannot obtain the required audio data from the electronic device according to the requirements of the encoding algorithm.
[0043] Based on the above situation, the embodiment of the present application provides an audio data distribution method, which can send audio data to the corresponding Codec according to the Codec read data request using different encoding algorithms. Figure 3 FIG. 1 is a flow chart of an audio data distribution method according to an embodiment of the present invention. The method comprises the following steps.
[0044] In step S301, the electronic device 100 interacts with each Bluetooth device 200, including: obtaining device capability information of each Bluetooth device 200, and determining a coding instance of each Bluetooth device 200 based on the device capability information of each Bluetooth device 200, wherein the coding instance is a functional module for encoding audio data according to a coding algorithm through an encoder (Codec).
[0045] In this embodiment, the method for electronic device 100 to interact with Bluetooth device 200 is as follows: Figure 4 The flowchart shown is explained in detail.
[0046] In step S302, the electronic device 100 records the data segment header and data segment tail positions in the ring buffer, and records the amount of data read from the ring buffer by each encoding instance of the Bluetooth device 200 and the position of the data read. The amount of data between the data segment header and the data segment tail represents the amount of data that can be read from the ring buffer. It should be noted that a ring buffer is a data structure used to represent a fixed-size, end-to-end connected buffer, and a ring buffer can store audio data.
[0047] In step S303, the electronic device 100 obtains a read data request from each coding instance of the Bluetooth device 200 in response to the play instruction, and determines whether each coding instance of the Bluetooth device 200 has read audio data from the circular buffer within the current timing cycle based on the read status of the coding instance of each Bluetooth device 200, wherein the read data request includes the amount of data to be read. If each coding instance of the Bluetooth device 200 has read audio data from the circular buffer within the current timing cycle, step S304 is executed. Otherwise, if at least one coding instance of the Bluetooth device 200 has not read audio data from the circular buffer within the current timing cycle, step S305 is executed.
[0048] It should be noted that the read status of the coding instance of each Bluetooth device 200 includes a read state and a second state. The read state indicates that the coding instance of each Bluetooth device 200 has read data from the circular buffer in the current timing cycle, and the unread state indicates that the coding instance of each Bluetooth device 200 has not read data from the circular buffer in the current timing cycle. Determining whether the coding instance of each Bluetooth device 200 has read audio data from the circular buffer in the current timing cycle based on the read status of the coding instance of each Bluetooth device 200 includes: if the read status of the coding instance of each Bluetooth device 200 is the read state, determining that the coding instance of each Bluetooth device 200 has read audio data from the circular buffer in the current timing cycle; if the read status of the coding instance of each Bluetooth device 200 is the unread state, determining that the coding instance of each Bluetooth device 200 has not read audio data from the circular buffer in the current timing cycle.
[0049] It should be noted that the total amount of data received by the coding instances of different Bluetooth devices 200 from the electronic device within the preset time period is the same, but the rhythm of the data reading of the coding instances of different Bluetooth devices 200 within the preset time period is different. The total amount of data and the preset time period can be determined by the electronic device 100 and the Bluetooth device 200 when they interact. For example, the total amount of data is set to 1000 bytes of data, and the preset time period is set to 1S. For example, coding instance A reads 1000 bytes of audio data in the first 800ms of the preset time period (1S) and rests in the last 200ms of the preset time period (1S); coding instance B reads 200 bytes of audio data every 200ms within the preset time period (1S) and reads it at a uniform speed; coding instance C reads 100 bytes of audio data every 100ms within the preset time period (1S) and reads it at a uniform speed. Since different coding instances read Bluetooth audio data at different rates, the existing Android architecture cannot simultaneously have multiple coding instances obtain data from the electronic device.
[0050] In step S304, the electronic device 100 updates the data segment header position in the circular buffer based on the position of the data volume read by each coding instance of the Bluetooth device 200. The position of the data volume read by each coding instance of the Bluetooth device 200 refers to the position of the data volume marked in the circular buffer when each coding instance of the Bluetooth device 200 reads the data volume from the circular buffer. After step S304 is executed, step S305 is executed.
[0051] In step S305, the electronic device 100 determines the amount of data to be read of the coding instance of each Bluetooth device 200 from the read data request of the coding instance of each Bluetooth device 200, and determines whether to download data from the HAL layer to the ring buffer based on the amount of data to be read of the coding instance of each Bluetooth device 200 and the position of the amount of data already read of the coding instance of each Bluetooth device 200.
[0052] In one embodiment of the present application, based on the amount of data to be read of the coding instance of each Bluetooth device 200 and the position of the amount of data already read by the coding instance of each Bluetooth device 200, determining whether to download data from the HAL layer to the circular buffer includes: determining the target data amount between the position of the amount of data already read by the coding instance of each Bluetooth device 200 in the circular buffer and the end position of the data segment; if the target data amount is greater than the amount of data to be read by the Bluetooth device 200, determining not to download data from the HAL layer to the circular buffer; if the target data amount is less than or equal to the amount of data to be read by the Bluetooth device 200, determining to download data from the HAL layer to the circular buffer. It should be noted that the HAL layer can obtain audio data from the circular buffer of the audio framework layer and download the obtained audio data to the circular buffer of the HAL layer.
[0053] In one embodiment of the present application, if it is determined that the electronic device 100 downloads data from the HAL layer to the ring buffer, step S306 is executed; otherwise, if it is determined that the electronic device 100 does not need to download data from the HAL layer to the ring buffer, step S307 is executed.
[0054] In step S306, the electronic device 100 downloads a preset amount of data from the HAL layer to the ring buffer for storage, and updates the tail position of the data segment of the ring buffer according to the stored data. After step S306 is completed, step S307 is executed.
[0055] In one embodiment of the present application, the electronic device 100 downloads a preset amount of data from the HAL layer to the circular buffer for storage and updates the tail position of the data segment of the circular buffer according to the stored data, including: the electronic device 100 downloads a preset amount of data from the HAL layer to the circular buffer, stores the downloaded data from the tail position of the data segment of the circular buffer, and updates the tail position of the data segment of the circular buffer according to the stored data. It should be noted that the preset amount of data downloaded from the HAL layer to the circular buffer by the electronic device 100 is determined according to the target data amount of each Bluetooth device 200 and the amount of data to be read from each Bluetooth device 200. In one embodiment of the present application, the preset amount of data downloaded from the HAL layer to the circular buffer by the electronic device 100 is not less than the difference between the target data amount of each Bluetooth device 200 and the amount of data to be read from each Bluetooth device 200.
[0056] In step S307, the coding instance of each Bluetooth device 200 reads the data to be read from the circular buffer starting from the position of the data amount already read by the coding instance of each Bluetooth device, records and updates the position of the data amount already read from the circular buffer by the coding instance of each Bluetooth device 200, and sets the reading status of the coding instance of each Bluetooth device 200 to the read status.
[0057] It should be noted that, in the next timing cycle, the electronic device 100 continues to execute steps S303 to S307 until receiving a pause playback instruction.
[0058] In this application, the electronic device 100 obtains the device capability information of each Bluetooth device 200, and determines the encoding instance of each Bluetooth device 200 based on the device capability information of each Bluetooth device 200. According to the read data request of the encoding instance of each Bluetooth device 200, the corresponding amount of data is read from the circular buffer and sent to the encoding instance of each Bluetooth device 200, thereby achieving the purpose of the electronic device distributing data to different encoders. It should be noted that the encoding instance of each Bluetooth device 200 obtains data from the circular buffer and encodes it. The electronic device 100 sends the encoded data to the Bluetooth device 200 corresponding to the encoding instance of each Bluetooth device 200 for playback, thereby achieving the purpose of the Bluetooth device 200 receiving the encoded data sent by the encoder with the device capability corresponding to the Bluetooth device 200, thereby improving the audio playback effect of the Bluetooth device 200.
[0059] refer to Figure 4 FIG. 1 is a flow chart of a method for interaction between an electronic device 100 and a Bluetooth device 200 in an embodiment of the present application, which specifically includes the following steps.
[0060] In step S401 , the Bluetooth protocol stack of the electronic device 100 responds to the connection request sent by the Bluetooth device 200 , establishes a communication connection with the Bluetooth device 200 , and records the physical device address of the Bluetooth device 200 .
[0061] For ease of explanation, the following describes a method for the electronic device 100 to interact with each Bluetooth device 200 provided in an embodiment of the present application, taking a mobile phone as an example and a Bluetooth headset as an example as an example.
[0062] refer to Figure 5 As shown, the user performs the operation of turning on the Bluetooth function by selecting the "Turn on Bluetooth" option 601 on the operation interface 60 of the mobile phone. In response to the user's selection of the "Turn on Bluetooth" option 601, the mobile phone searches for the broadcast signal sent by the Bluetooth headset near the mobile phone. In this embodiment, the broadcast signal sent by the Bluetooth headset includes two states. The first state is that the broadcast signal sent by the Bluetooth headset is a broadcast signal with continuous cached data. The second state is that the broadcast signal sent by the Bluetooth headset is a broadcast signal without continuous cached data. In this embodiment, the continuous cached data refers to the data for which there is a connection record between the mobile phone and the Bluetooth headset. If the mobile phone searches that the broadcast signal sent by the Bluetooth headset is a broadcast signal with continuous cached data, that is, there is a connection record between the mobile phone and the Bluetooth headset, the mobile phone is connected to the Bluetooth headset. If the mobile phone searches that the broadcast signal sent by the Bluetooth headset is a broadcast signal without continuous cached data, for example, the Bluetooth headset is connected to the mobile phone for the first time, the mobile phone displays the connection interface 70.
[0063] refer to Figure 6 As shown, it is a schematic diagram of the connection interface 70 in one embodiment of the present application. The connection interface 70 displays the name of the Bluetooth headset searched by the mobile phone and the connection control 701 corresponding to the name of the Bluetooth headset. After the user clicks the connection control 701, the mobile phone responds to the user's operation of clicking the connection control 701 and establishes a Bluetooth connection with the Bluetooth headset corresponding to the connection control 701. For example, the names of all nearby Bluetooth headsets searched by the mobile phone are displayed on the connection interface 70. If the user clicks the connection control 701 corresponding to the name of one of the Bluetooth headsets, the mobile phone establishes a Bluetooth connection with the Bluetooth headset corresponding to the connection control 701 and records the access path address of the Bluetooth headset. In this embodiment, the access path address of the Bluetooth headset includes at least the physical device address of the Bluetooth headset.
[0064] In step S402 , the Bluetooth protocol stack sends a device capability acquisition instruction to the Bluetooth device 200 .
[0065] In step S403 , the Bluetooth device 200 responds to the device capability acquisition instruction and sends the device capability information of the Bluetooth device 200 to the Bluetooth protocol stack of the electronic device 100 , wherein the device capability information includes the audio coding formats supported by the Bluetooth device 200 .
[0066] In this embodiment, the audio coding formats supported by the Bluetooth device 200 include sub-band coding (SBC), advanced audio codec (AAC), APTX, and low-latency high-definition audio codec (LDAC).
[0067] In step S404, the Bluetooth protocol stack determines the audio coding format supported by the Bluetooth device 200 according to the device capability information, and determines the encoding instance of the Bluetooth device 200 according to the audio coding format supported by the Bluetooth device 200. The encoding instance of the Bluetooth device 200 is encoded according to the audio coding format of the Bluetooth device 200.
[0068] In one embodiment of the present application, the Bluetooth protocol stack determines the audio coding format of the Bluetooth device 200 based on the device capability information, including: when the Bluetooth protocol stack determines that the device capability information of the Bluetooth device 200 includes multiple audio coding formats, the Bluetooth protocol stack selects the audio coding format with the best sound quality from the multiple audio coding formats as the audio coding format of the Bluetooth device 200. For example, when the Bluetooth protocol stack determines that the device capability information of the Bluetooth device 200 includes the SBC coding format and the AAC coding format, the Bluetooth protocol stack selects the AAC coding format with the better sound quality as the audio coding format of the Bluetooth device 200.
[0069] In one embodiment of the present application, determining a coding instance for the Bluetooth device 200 based on the audio coding format of the Bluetooth device 200 includes: the Bluetooth protocol stack determining a coding scheme corresponding to the audio coding format based on the audio coding format of the Bluetooth device 200; and determining a coding instance corresponding to the Bluetooth device 200 based on the coding scheme, wherein the coding instance is encoded according to the determined coding scheme. For example, when the Bluetooth protocol stack determines that the audio coding format of the Bluetooth device 200 is the AAC coding format, the Bluetooth protocol stack determines that the coding scheme corresponding to the AAC coding format is the AAC coding algorithm, and provides a coding instance corresponding to the Bluetooth device 200, wherein the coding instance is encoded according to the AAC coding algorithm.
[0070] In step S405 , the agent of the Bluetooth protocol stack obtains the coding instance of the Bluetooth device 200 , and maps the Bluetooth device 200 and the coding instance of the Bluetooth device 200 into a corresponding relationship.
[0071] In one embodiment of the present application, if the Bluetooth protocol stack determines that the encoding instance of the first Bluetooth device is an encoding instance encoded based on the SBC encoding algorithm, and determines that the encoding instance of the second Bluetooth device is an encoding instance encoded based on the AAC encoding algorithm, the agent obtains the encoding instance of Bluetooth device A and the encoding instance of Bluetooth device B from the Bluetooth protocol stack, and maps the first Bluetooth device and the encoding instance encoded based on the SBC encoding algorithm into a corresponding relationship, and maps the second Bluetooth device and the encoding instance encoded based on the AAC encoding algorithm into a corresponding relationship. In this way, when the electronic device 100 interacts with each Bluetooth device 200, the electronic device 100 sets an encoding instance for the corresponding Bluetooth device 200, and provides encoding services for the corresponding Bluetooth device through the encoding instance of each Bluetooth device 200. It should be noted that the agent is a functional module or program code for managing the circular buffer and / or encoding instance.
[0072] In an embodiment of the present application, after the electronic device 100 determines the encoding instance corresponding to each Bluetooth device 200 according to the device capability information of the Bluetooth device 200, the audio data distribution method includes the following steps.
[0073] Step S701 : An application at the application layer responds to a play instruction input by a user and sends the play instruction to the Bluetooth protocol stack.
[0074] For ease of explanation, the following application uses a music player as an example to introduce the method of sending a play instruction to the Bluetooth protocol stack in the embodiment of the present application. Figure 8 As shown, when a user clicks the play button 91 on the music playback interface 90 of the music player of the electronic device 100 (such as a mobile phone), the music player responds to the user's operation of clicking the play button 91 on the music playback interface 90, generates a play instruction, and sends the play instruction to the application framework layer, and the application framework layer sends the play instruction to the Bluetooth protocol stack of the HAL layer.
[0075] Step S702: The Bluetooth protocol stack responds to the play instruction and starts a timer to perform cyclic timing according to a timing period.
[0076] In this embodiment, starting the timer to perform cyclic timing according to the timing cycle refers to the process in which the timer resets the time from zero to the end of the current timing cycle and enters the next timing cycle to start timing again. In this embodiment, the timing cycle can be set according to user needs.
[0077] In step S703, the Bluetooth protocol stack agent obtains a read data request for a coding instance within the current timing cycle of the timer, and determines, based on the read status of the coding instance, whether all coding instances have read audio data from the circular buffer within the current timing cycle, wherein the read data request includes the amount of data to be read. If all coding instances have read audio data from the circular buffer within the current timing cycle, step S704 is executed. Otherwise, if at least one coding instance has not read audio data from the circular buffer within the current timing cycle, step S705 is executed.
[0078] In step S704, the agent updates the data segment header position in the circular buffer based on the position of the data volume read by each encoding instance. The position of the data volume read by each encoding instance refers to the position of the data volume marked in the circular buffer when each encoding instance reads the data volume from the circular buffer. After step S704 is executed, step S705 is executed.
[0079] In one embodiment of the present application, the agent updates the data segment header position of the circular buffer according to the position of the data amount read by each encoding instance, including: determining the minimum value of the data amount from the data amount read by each encoding instance; and updating the position of the data amount corresponding to the minimum value as the data segment header position of the circular buffer. In this embodiment, the specific method flow of the audio data distribution method is described by taking the electronic device 100 including the first encoding instance and the second encoding instance as an example. Figure 9A As shown, in the current timing cycle, the position of the amount of data read from the circular buffer by the first encoding instance is marked as A, the position of the amount of data read from the circular buffer by the second encoding instance is marked as B, the data segment head position of the circular buffer is marked as M1, and the segment tail position is marked as M2. Figure 9B As shown, since the amount of data read by the first encoding instance is the minimum of the amount of data read by the two encoding instances, the agent updates the position A of the amount of data read by the first encoding instance to the data segment head position of the circular buffer.
[0080] In step S705, the agent determines the amount of data to be read of the coding instance from the read data request of the coding instance, and determines whether the electronic device downloads data from the HAL layer to the ring buffer based on the amount of data to be read of the coding instance and the position of the amount of data already read by the coding instance.
[0081] In one embodiment of the present application, judging whether the electronic device downloads data from the HAL layer to the circular buffer based on the amount of data to be read of the coding instance and the position of the amount of data already read by the coding instance includes: the agent determines the target data amount of the circular buffer between the position of the amount of data already read by the coding instance and the end position of the data segment; if the target data amount of the coding instance is greater than the amount of data to be read of the coding instance, the agent determines that the data does not need to be downloaded from the HAL layer to the circular buffer; if the target data amount of the coding instance is less than or equal to the amount of data to be read of the coding instance, the agent determines that the data is downloaded from the HAL layer to the circular buffer.
[0082] refer to Figure 10A As shown, the agent determines the target data amount (marked as D2) of the circular buffer between the position A of the amount of data read in the first encoding instance or the second encoding instance and the end position M2 of the data segment in the current timing cycle. If the target data amount is greater than the amount of data to be read (marked as D1) of the first encoding instance or the second encoding instance, the agent determines not to download data from the HAL layer to the circular buffer. Figure 10B If the target data amount is less than the to-be-read data amount D1 of the first encoding instance or the second encoding instance, the agent determines to download the data from the HAL layer to the ring buffer.
[0083] In one embodiment of the present application, if it is determined that the data is to be downloaded from the HAL layer to the ring buffer, step S706 is executed; otherwise, if it is determined that the data is not to be downloaded from the HAL layer to the ring buffer, step S707 is executed.
[0084] In step S706, the agent downloads a preset amount of data from the HAL layer into the ring buffer for storage, and updates the tail position of the data segment in the ring buffer. After step S706 is completed, step S707 is executed.
[0085] In one embodiment of the present application, the agent downloads a preset amount of data from the HAL layer into the circular buffer and stores the downloaded data at the end of the data segment in the circular buffer. It should be noted that the preset amount of data that the agent downloads from the HAL layer into the circular buffer is determined based on the target data amount of the encoding instance and the amount of data to be read from the encoding instance. In one embodiment of the present application, the preset amount of data that the agent downloads from the HAL layer into the circular buffer is not less than the difference between the target data amount and the amount of data to be read from the Bluetooth device 200.
[0086] In step S707, the agent reads data of the amount of data to be read for the encoding instance from the circular buffer, sends the read data to the encoding instance, records the position of the amount of data already read from the circular buffer for the encoding instance, and sets the read status of the encoding instance to the read state. In one embodiment of the present application, the agent reads data of the amount of data to be read for the encoding instance starting from the position of the amount of data already read in the circular buffer for the encoding instance, sends the read data to the encoding instance, records and updates the position of the amount of data already read from the circular buffer for the encoding instance, and sets the read status of the encoding instance to the read state.
[0087] The proxy receives a read data request from another encoding instance in the Bluetooth protocol stack and repeats steps S703 to S707 to complete the proxy's data distribution for each encoding instance until the timing cycle ends or a pause instruction is received. It should be noted that within a timing cycle, all encoding instances in the Bluetooth protocol stack complete at least one read data request and receive at least one data received from the proxy.
[0088] It should be noted that after the encoding instance receives the audio data sent by the proxy, it encodes and compresses the audio data according to the audio coding format supported by the Bluetooth device 100 corresponding to the encoding instance to generate encoded data, and then sends the encoded data to the Bluetooth protocol stack of the electronic device 100. The Bluetooth protocol stack sends the encoded data to the Bluetooth device 200 corresponding to the encoding instance according to the recorded path address of the Bluetooth device 200, thus enabling the proxy to distribute data to encoding instances with different data acquisition rhythms.
[0089] The electronic device 100 involved in the embodiment of the present application is introduced below. Figure 11 , which is a schematic diagram of the hardware structure of an electronic device 100 according to an embodiment of the present application. In this embodiment, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0090] It should be understood that the structures illustrated in the embodiments of the present application do not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.
[0091] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.
[0092] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0093] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.
[0094] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.
[0095] The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C bus lines. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, and the like via different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K via the I2C interface, enabling communication between the processor 110 and the touch sensor 180K via the I2C bus interface, thereby implementing the touch function of the electronic device 100.
[0096] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface, enabling the function of answering calls through a Bluetooth headset.
[0097] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface, enabling the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.
[0098] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface, enabling the function of playing music through Bluetooth headphones.
[0099] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display 194 and the camera 193. MIPI interfaces include the camera serial interface (CSI) and the display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the camera function of the electronic device 100. The processor 110 and the display 194 communicate via the DSI interface to implement the display function of the electronic device 100.
[0100] The GPIO interface can be configured via software. The GPIO interface can be configured as either a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to the camera 193, display 194, wireless communication module 160, audio module 170, sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.
[0101] The USB interface 130 is an interface that complies with USB standards and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, or to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio. This interface can also be used to connect other electronic devices 100, such as AR devices.
[0102] It is understood that the interface connection relationship between the modules illustrated in the embodiments of the present application is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.
[0103] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also provide power to the electronic device 100 via the power management module 141.
[0104] The power management module 141 is used to connect the battery 142, the charging management module 140, and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the display 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.
[0105] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.
[0106] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.
[0107] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.
[0108] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.) or displays an image or video through the display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.
[0109] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.
[0110] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).
[0111] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0112] Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.
[0113] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.
[0114] The ISP processes data fed back by camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and converted into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 193.
[0115] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.
[0116] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.
[0117] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. This allows electronic device 100 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.
[0118] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU can enable intelligent cognitive applications in electronic device 100, such as image recognition, face recognition, speech recognition, and text comprehension.
[0119] The internal memory 121 may include one or more random access memories (RAM) and one or more non-volatile memories (NVM).
[0120] Random access memory may include static random-access memory (SRAM), dynamic random access memory (DRAM), synchronous dynamic random access memory (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM, for example, the fifth generation of DDR SDRAM is generally referred to as DDR5 SDRAM), etc.
[0121] Non-volatile memory may include disk storage devices and flash memory.
[0122] Flash memory can be divided into NOR FLASH, NAND FLASH, 3D NAND FLASH, etc. according to the operating principle; single-level cell (SLC), multi-level cell (MLC), triple-level cell (TLC), quad-level cell (QLC), etc. according to the storage cell potential level; universal flash storage (UFS) and embedded multi media card (eMMC) can be divided into UFS and embedded multi media card according to the storage specification.
[0123] The random access memory can be directly read and written by the processor 110, and can be used to store executable programs (such as machine instructions) of the operating system or other running programs, and can also be used to store user and application data.
[0124] The non-volatile memory may also store executable programs and user and application data, etc., and may be loaded into the random access memory in advance for direct reading and writing by the processor 110 .
[0125] The external memory interface 120 can be used to connect to an external non-volatile memory to expand the storage capacity of the electronic device 100. The external non-volatile memory communicates with the processor 110 via the external memory interface 120 to implement data storage. For example, files such as music and videos can be stored in the external non-volatile memory.
[0126] The internal memory 121 or the external memory interface 120 is used to store one or more computer programs. The one or more computer programs are configured to be executed by the processor 110. The one or more computer programs include multiple instructions. When the multiple instructions are executed by the processor 110, the audio data distribution method described in the above embodiment can be executed on the electronic device 100 to implement the function of distributing audio data to the encoder.
[0127] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0128] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110.
[0129] The speaker 170A, also called a "speaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.
[0130] The receiver 170B, also called a "handset", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be heard by placing the receiver 170B close to the human ear.
[0131] Microphone 170C, also known as "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to realize sound signal collection, noise reduction, and identification of sound sources, and realize directional recording function, etc.
[0132] The headphone jack 170D is used to connect a wired headphone and can be a USB interface 130 or a 3.5mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0133] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A can be located on display screen 194. There are many types of pressure sensors 180A, such as resistive, inductive, and capacitive. A capacitive pressure sensor can include at least two parallel plates made of conductive material. When force acts on pressure sensor 180A, the capacitance between the electrodes changes. Electronic device 100 determines the intensity of the pressure based on this change in capacitance. When a touch operation is applied to display screen 194, electronic device 100 detects the touch intensity based on pressure sensor 180A. Electronic device 100 can also calculate the touch location based on the detection signal from pressure sensor 180A. In some embodiments, touch operations applied to the same touch location but with different touch intensities can correspond to different operation instructions. For example, when a touch operation with an intensity less than a first pressure threshold is applied to a short message application icon, a command to view short messages is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to a short message application icon, a command to create a new short message is executed.
[0134] The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyroscope sensor 180B. The gyroscope sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyroscope sensor 180B can also be used for navigation and somatosensory game scenes.
[0135] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude using the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.
[0136] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover based on the magnetic sensor 180D. Based on the detected opening and closing status of the case or flip cover, features such as automatic unlocking of the flip cover can be configured.
[0137] Accelerometer 180E can detect the magnitude of acceleration of electronic device 100 in all directions (generally three axes). When electronic device 100 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of electronic device 100, enabling applications such as switching between landscape and portrait modes and pedometers.
[0138] The distance sensor 180F is used to measure distance. The electronic device 100 can measure distance using infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure distance to achieve fast focusing.
[0139] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user is holding the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.
[0140] Ambient light sensor 180L is used to sense ambient light brightness. Electronic device 100 can adaptively adjust the brightness of display screen 194 based on the perceived ambient light. Ambient light sensor 180L can also be used to automatically adjust white balance when taking photos. Ambient light sensor 180L can also work with proximity light sensor 180G to detect whether electronic device 100 is in a pocket to prevent accidental touches.
[0141] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.
[0142] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to prevent the electronic device 100 from shutting down abnormally due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to prevent abnormal shutdown due to low temperature.
[0143] The touch sensor 180K is also referred to as a "touch device." The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also referred to as a "touch screen." The touch sensor 180K is used to detect touch operations applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operations to an application processor to determine the type of touch event. Visual output related to the touch operations can be provided via the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, at a location different from that of the display screen 194.
[0144] The bone conduction sensor 180M can obtain vibration signals. In some embodiments, the bone conduction sensor 180M can obtain vibration signals from the vibrating bones of the human body. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure pulse signals. In some embodiments, the bone conduction sensor 180M can also be set in headphones to form bone conduction headphones. The audio module 170 can parse out voice signals based on the vibration signals of the vibrating bones of the human body obtained by the bone conduction sensor 180M to implement voice functions. The application processor can parse heart rate information based on the blood pressure pulse signals obtained by the bone conduction sensor 180M to implement heart rate detection functions.
[0145] The buttons 190 include a power button, a volume button, and the like. The buttons 190 may be mechanical buttons or touch buttons. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.
[0146] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.
[0147] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power level changes, messages, missed calls, notifications, etc.
[0148] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting it into or removing it from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.
[0149] This embodiment also provides a computer storage medium, which stores computer instructions. When the computer instructions are executed on the electronic device 100, the electronic device 100 executes the above-mentioned related method steps to implement the audio data distribution method in the above-mentioned embodiment.
[0150] This embodiment also provides a computer program product. When the computer program product is run on a computer, it enables the computer to execute the above-mentioned related steps to implement the audio data distribution method in the above-mentioned embodiment.
[0151] In addition, an embodiment of the present application also provides a device, which can specifically be a chip, component or module, and the device may include a connected processor and memory; wherein the memory is used to store computer-executable instructions, and when the device is running, the processor can execute the computer-executable instructions stored in the memory to enable the chip to execute the audio data distribution method in the above-mentioned method embodiments.
[0152] Among them, the electronic device 100, computer storage medium, computer program product or chip provided in this embodiment are all used to execute the corresponding methods provided above. Therefore, the beneficial effects that can be achieved can refer to the beneficial effects in the corresponding methods provided above, and will not be repeated here.
[0153] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.
[0154] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0155] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the present embodiment.
[0156] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0157] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0158] The above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit the present application. Although the present application has been described in detail with reference to the above preferred embodiments, those skilled in the art should understand that modifications or equivalent replacements of the technical solutions of the present application should not depart from the spirit and scope of the technical solutions of the present application.< / canvas> < / video> < / videoview> < / imgview> < / textview>
Claims
1. A method for distributing audio data, applied in an electronic device, characterized in that: The method comprises: Interacting with each Bluetooth device includes: determining an encoding instance of each Bluetooth device, wherein the encoding instance is used to encode the audio data according to the encoding algorithm through an encoder; Recording the data segment header position and the data segment tail position of the circular buffer of the electronic device, and recording the amount of data read from the circular buffer and the position of the read data by each coding instance of the Bluetooth device, wherein the amount of data between the data segment header position and the data segment tail position is the amount of data that can be read from the circular buffer; receiving a play instruction and responding to the play instruction, obtaining a read data request of the encoding instance of each Bluetooth device, and determining whether the encoding instance of each Bluetooth device has read audio data from the circular buffer within a current timing cycle according to a read status of the encoding instance of each Bluetooth device, wherein the read data request includes an amount of data to be read; If the read status of the coding instance of each Bluetooth device is in the read state in the current timing cycle, updating the data segment header position of the circular buffer according to the position of the amount of data read by the coding instance of each Bluetooth device; and if the read status of at least one coding instance of the Bluetooth device is in the unread state in the current timing cycle, not updating the data segment header position of the circular buffer; Determining the amount of data to be read from the encoding instance of each Bluetooth device from the read data request of the encoding instance of each Bluetooth device; According to the amount of data to be read of the coding instance of each Bluetooth device and the position of the amount of data already read by the coding instance of each Bluetooth device, the coding instance of each Bluetooth device reads the data of the amount of data to be read from the circular buffer starting from the position of the amount of data already read by the coding instance of each Bluetooth device, records and updates the position of the amount of data already read from the circular buffer by the coding instance of each Bluetooth device, and sets the reading status of the coding instance of each Bluetooth device to the read status.
2. The audio data distribution method according to claim 1, wherein: The encoding instance of each of the Bluetooth devices reads the data to be read from the data position of the ring buffer as the starting position, including: Determining whether to download data from the electronic device hardware abstraction layer to the ring buffer according to the amount of data to be read from the coding instance of each Bluetooth device and the position of the amount of data already read from the coding instance of each Bluetooth device; If it is determined that data is to be downloaded from the hardware abstraction layer of the electronic device to the circular buffer, a preset amount of data is downloaded from the hardware abstraction layer to the circular buffer for storage and a tail position of a data segment of the circular buffer is updated according to the stored data, and each encoding instance of the Bluetooth device reads the amount of data to be read from the position of the amount of data in the circular buffer as a starting point; or If it is determined that the data does not need to be downloaded from the hardware abstraction layer of the electronic device to the circular buffer, each encoding instance of the Bluetooth device reads the amount of data to be read from the circular buffer.
3. The audio data distribution method according to claim 2, wherein: The determining whether to download data from the electronic device hardware abstraction layer to the ring buffer according to the amount of data to be read of the coding instance of each Bluetooth device and the position of the amount of data already read of the coding instance of each Bluetooth device comprises: Determine a target data amount of the circular buffer between a position of the amount of data read in the circular buffer by each encoding instance of the Bluetooth device and a position of the end of the data segment; When the target data amount is greater than the amount of data to be read from the Bluetooth device, determining not to download data from the hardware abstraction layer to the ring buffer; When the target data volume is less than or equal to the to-be-read data volume of the Bluetooth device, it is determined to download the data from the hardware abstraction layer to the ring buffer.
4. The audio data distribution method according to claim 2, wherein: The downloading of a preset amount of data from the hardware abstraction layer into the ring buffer for storage and updating the tail position of the data segment of the ring buffer according to the stored data includes: The preset amount of data is downloaded from the hardware abstraction layer to the circular buffer, the downloaded data is stored at the tail position of the data segment of the circular buffer, and the tail position of the data segment of the circular buffer is updated according to the stored data.
5. The audio data distribution method according to claim 3, wherein: The preset data volume is not less than the difference between the target data volume and the amount of data to be read from each of the Bluetooth devices.
6. The audio data distribution method according to claim 2, wherein: The interaction with each Bluetooth device includes: The Bluetooth protocol stack of the electronic device responds to the connection request sent by the Bluetooth device and establishes a communication connection with the Bluetooth device; The Bluetooth protocol stack sends a device capability acquisition instruction to the Bluetooth device; The Bluetooth protocol stack receives device capability information sent by the Bluetooth device, wherein the device capability information includes an audio coding format supported by the Bluetooth device; The Bluetooth protocol stack determines the audio coding format supported by the Bluetooth device according to the device capability information, and determines the coding instance of the Bluetooth device according to the audio coding format; The agent of the Bluetooth protocol stack obtains the coding instance of the Bluetooth device, and maps the Bluetooth device and the coding instance of the Bluetooth device into a corresponding relationship.
7. The audio data distribution method according to claim 2, wherein: The Bluetooth protocol stack determining, according to the device capability information, the audio coding format supported by the Bluetooth device includes: If the Bluetooth protocol stack determines that the device capability information of the Bluetooth device includes multiple audio coding formats, the Bluetooth protocol stack selects an audio coding format with the best sound quality from the multiple audio coding formats as the audio coding format of the Bluetooth device.
8. The audio data distribution method according to claim 7, wherein: The example of determining the encoding of the Bluetooth device according to the audio encoding format includes: The Bluetooth protocol stack determines a coding scheme corresponding to the audio coding format according to the audio coding format of the Bluetooth device; A coding instance corresponding to the Bluetooth device is determined according to the coding scheme, wherein the coding instance is encoded according to the coding scheme.
9. The audio data distribution method according to claim 6, wherein: The receiving of the play instruction and the responding to the play instruction, obtaining a read data request of the coding instance of each Bluetooth device, and determining whether the coding instance of each Bluetooth device has read audio data from the circular buffer within a current timing cycle according to a read status of the coding instance of each Bluetooth device, wherein the read data request includes an amount of data to be read, including: The application of the electronic device responds to the play instruction input by the user and sends the play instruction to the Bluetooth protocol stack; The Bluetooth protocol stack responds to the play instruction and starts a timer to perform cyclic timing according to a timing period; The agent of the Bluetooth protocol stack obtains a read data request of an encoding instance within a current timing cycle of the timer, and determines whether all encoding instances within the current timing cycle have read audio data from the circular buffer based on the read status of the obtained encoding instance.
10. The audio data distribution method according to claim 9, wherein: The updating of the data segment header position of the circular buffer according to the position of the amount of data read by the coding instance of each Bluetooth device comprises: The agent updates the data segment header position of the circular buffer according to the position of the data amount read by the encoding instance of each Bluetooth device, wherein the position of the data amount read by the encoding instance of each Bluetooth device refers to the position of the data amount marked in the circular buffer when the encoding instance of each Bluetooth device reads the data amount from the circular buffer.
11. The audio data distribution method according to claim 10, wherein: The agent updates the data segment header position of the ring buffer according to the position of the amount of data read by the coding instance of each Bluetooth device, including: determining a minimum value of the amount of data from the amount of data read from the encoding instance of each of the Bluetooth devices; The position of the data amount corresponding to the minimum value is used as the data segment head position of the ring buffer for updating.
12. The audio data distribution method according to claim 9, wherein: Determining the amount of data to be read from the encoding instance of each Bluetooth device from the read data request of the encoding instance of each Bluetooth device includes: The agent determines the amount of data to be read from the encoding instance of each Bluetooth device from the read data request of the encoding instance of each Bluetooth device.
13. The audio data distribution method according to claim 12, wherein: The encoding instance of each of the Bluetooth devices reads the data to be read from the data position of the ring buffer as the starting position, including: The agent determines whether to download data from the electronic device hardware abstraction layer to the ring buffer according to the amount of data to be read of the coding instance of each Bluetooth device and the position of the amount of data already read by the coding instance of each Bluetooth device; If it is determined that data is downloaded from the hardware abstraction layer of the electronic device to the circular buffer, the agent downloads a preset amount of data from the hardware abstraction layer to the circular buffer for storage and updates the tail position of the data segment of the circular buffer according to the stored data; the agent reads the amount of data to be read from the circular buffer starting from the position of the amount of data read by the coding instance of each Bluetooth device according to the amount of data to be read of the coding instance of each Bluetooth device and the position of the amount of data read by the coding instance of each Bluetooth device, and sends the read data to the coding instance of each Bluetooth device; or If it is determined that there is no need to download data from the hardware abstraction layer of the electronic device to the circular buffer, the agent reads the data to be read from the circular buffer based on the amount of data to be read of the coding instance of each Bluetooth device and the position of the amount of data already read by the coding instance of each Bluetooth device, taking the position of the amount of data already read by the coding instance of each Bluetooth device as the starting point, and sends the read data to the coding instance of each Bluetooth device.
14. An electronic device, characterized in that: comprising a processor and a memory; wherein the processor is coupled to the memory; The memory is used to store program instructions; The processor is configured to read the program instructions stored in the memory to implement the audio data distribution method according to any one of claims 1 to 13.
15. A computer-readable storage medium, characterized in that The computer-readable storage medium stores program instructions, and when the program instructions are executed by a processor, the audio data distribution method according to any one of claims 1 to 13 is implemented.
Citation Information
Patent Citations
Apparatus and method for remote display and content protection in virtualized graphics processing environment
CN108694034A
Data transmission method and apparatus, electronic apparatus, and computer readable medium
CN109274405A