Independent channel output method for multiple types of audio sources, SOC chip and automobile
By using producer threads and consumer threads to process audio streams in the SOC chip, and realizing independent channel output of multiple types of audio streams through the preset DAI interface, the problems of hardware resource occupation and high cost in the existing technology are solved. Improved system scalability and efficiency.
Patent Information
- Application Number
- CN202111583136.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-22
- Publication Date
- 2024-09-10
- Estimated Expiration
- 2041-12-22
AI Technical Summary
When existing technology implements independent channel output of multiple types of audio sources, hardware resources occupy a large space, system power consumption is high, hardware costs are high, and software scalability is limited.
By introducing producer threads and consumer threads into the SOC chip, different types of audio streams are extracted and processed from audio data respectively, and put into the FIFO buffer pool, and then rearranged and combined into multi-channel audio data according to the DAI protocol. , transmitted to the audio codec through the preset DAI interface for channel separation and playback, realizing independent channel output of multiple types of audio streams.
It saves IC pin and DMA resources, reduces wiring layout space, reduces hardware costs, improves system scalability, and simplifies device selection.
Smart Images

Figure CN116389970B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of audio processing, and in particular to a method for outputting independent sound channels of multiple types of sound sources, a SOC chip and a car. Background Art
[0002] At present, with the rapid development of electronic technology and the new energy vehicle industry and the rise of new Internet car-making forces, car cockpits have gradually been replaced by smart cockpits. Since the multimedia system of the smart cockpit is extremely complex and diverse, there are many types of sound sources, which puts higher requirements on the audio system. For example, the current multimedia system sound source types include navigation sound, media sound, system prompt sound, VoIP (Voice over Internet Protocol: Internet phone), telephone, etc. At this time, assuming that there are two types of sound sources that need to be played, from the user experience perspective, the navigation sound is provided to the driver to finally reach the destination, while the media sound requires the same output throughout the car. Based on this, the navigation sound should be output only to the left front speaker on the car, while the media sound needs to be output to all the speakers in the car to achieve the best user experience.
[0003] In the prior art, in order to control the audio streams of different types of audio sources to be correctly transmitted to the desired audio device, an ADSP (Audio Digital Signal Processing) can be built into the SOC (System on Chip), and at the ADSP driver level, its built-in TDM (Time-Divisioned Multiplex) slots (i.e., channels) are abstracted into multiple independent DAIs (Digital Audio Interfaces) by group, and then multiple DMAs (Direct Memory Access) are used to achieve separate playback of two types of audio sources. In the prior art, there are also solutions that do not have ADSP built into the SOC. For example, two groups of DAIs corresponding to two audio hardware interfaces are set in the SOC, and then two DMA controllers are set to achieve separate playback of two types of audio sources. The shortcomings of the solutions in the prior art are that the above two solutions both achieve the separate playback of multiple types of audio sources by increasing hardware resources. In this way, the above solutions in the prior art will have the problem of occupying a large space for PCB (Printed Circuit Board) board space layout and wiring layout, and the system power consumption is large, the hardware cost is high, and the software scalability is also limited. Summary of the invention
[0004] Based on this, it is necessary to provide a method for independent channel output of multiple types of audio sources, a SOC chip and a car to address the above-mentioned technical problems, so as to optimize the hardware design of the SOC, reduce the required wiring layout space, save hardware costs and improve scalability.
[0005] A method for outputting independent channels of multiple types of audio sources, comprising:
[0006] When playing audio data, wake up producer threads corresponding to each stream type in the audio data; the audio data contains multiple audio streams of stream type; each producer thread corresponds to a different stream type;
[0007] The awakened producer thread extracts an audio stream from the audio data according to the stream type, and puts the extracted audio stream into a FIFO buffer pool corresponding to the producer thread; each producer thread corresponds to a FIFO buffer pool;
[0008] Taking out audio streams from all the FIFO buffer pools through the consumer process thread, rearranging and combining all the taken out audio streams into a multi-channel audio data according to the DAI protocol, and then writing the multi-channel audio data into the DMA buffer;
[0009] The multi-channel audio data in the DMA buffer is transmitted to the audio codec through a preset DAI for channel separation, and then the multi-channel audio data after channel separation is converted and played respectively through a preset number of conversion and playback modules; the preset number of the conversion and playback modules is equal to the number of the FIFO buffer pools and corresponds one to one.
[0010] A SOC chip comprises a DMA, a preset DAI, an audio codec connected to at least two conversion and playback modules, and a CPU for executing the method for outputting independent channels of multiple types of audio sources, wherein the DMA comprises a DMA buffer connected to the CPU and a DMA controller connected to the DMA buffer; the preset DAI comprises a first DAI interface and a second DAI interface; the first DAI interface is connected to the second DAI interface via a physical DAI bus.
[0011] A car comprises the SOC chip.
[0012] The above-mentioned multi-type sound source independent channel output method, SOC chip and automobile, in the multi-type sound source independent channel output method, when playing audio data, wake up the producer thread corresponding to each stream type in the audio data; the audio data contains multiple stream types of audio streams; the awakened producer thread takes out the audio stream from the audio data according to the stream type, and puts the taken out audio stream into the FIFO (First Input First Output) buffer pool corresponding to the producer thread; the consumer process thread takes out the audio stream from all the FIFO buffer pools, and rearranges and combines all the taken out audio streams into a multi-channel audio data according to the DAI protocol, and then writes the multi-channel audio data into a DMA buffer; the multi-channel audio data in the DMA buffer is transmitted to the audio codec through a preset DAI for channel separation, and then the multi-channel audio data after channel separation is converted and played respectively by a preset number of conversion and playback modules; the preset number of the conversion and playback modules is equal to the number of the FIFO buffer pools and corresponds one to one.
[0013] In the present invention, firstly, different producer threads are required to extract the audio streams of different stream types corresponding to them from the audio data, and then put the extracted audio streams into the corresponding FIFO buffer pools; on the other hand, it is also necessary to extract all audio streams from all FIFO buffer pools through consumer process threads, and rearrange and combine all the extracted audio streams into a multi-channel audio data according to the DAI protocol, write the multi-channel audio data into a DMA buffer, and transmit the multi-channel audio data to the audio codec 13 through a preset DAI for channel separation, and then perform data conversion and playback on the multi-channel audio data after channel separation through different conversion and playback modules 2. That is, the present invention does not need to have ADSP built into the SoC chip, and only needs to use a set of DAI interfaces (a first DAI interface and a second DAI interface connected by a physical DAI bus) to achieve the purpose of simultaneously outputting multiple stream types of audio streams through independent channels (and then transmitting and distributing them to different audio devices to achieve simultaneous independent channel playback of audio streams of different stream types), saving IC (Integrated Circuit) pin and DMA resources, optimizing the hardware design of the SOC, reducing the required wiring layout space, saving hardware costs, and improving scalability. In addition, the only set of DAI interfaces in the SOC in the present invention does not need to be limited to TDM, so the device selection is easy, which can further save hardware costs. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.
[0015] Figure 1 is a flow chart of a method for outputting independent channels of multiple types of audio sources in one embodiment of the present invention;
[0016] Figure 2 It is a schematic diagram of the transmission of audio stream in the SOC chip and the conversion and playback module in one embodiment of the present invention;
[0017] Figure 3 It is a schematic diagram of the transmission of audio stream in the SOC chip and the conversion and playback module in another embodiment of the present invention;.
[0018] The reference numerals in the specification are as follows:
[0019] 1. SOC chip; 11. CPU; 111. Producer thread; 112. FIFO buffer pool; 113. Consumer process thread; 1131. Data buffer area; 1132. BUFFER; 12. DMA; 121. DMA buffer; 122. DMA controller; 123. First DAI interface; 13. Audio codec; 131. Second DAI interface; 2. Conversion and playback module. DETAILED DESCRIPTION
[0020] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0021] In one embodiment, a method for outputting multiple types of audio sources with independent channels is provided, which is applied in Figure 2In the CPU (central processing unit) 11 of the SOC chip 1 shown, in a specific embodiment, the SOC chip 1 includes a DMA 12, a preset DAI, an audio codec 13 connected to at least two conversion and playback modules 2, and a CPU 11 for executing the multi-type audio source independent channel output method, and the DMA 12 includes a DMA buffer 121 connected to the CPU 11 and a DMA controller 122 connected to the DMA buffer 121. The preset DAI includes a first DAI interface 123 and a second DAI interface 131; the first DAI interface 123 is connected to the second DAI interface 131 via a physical DAI bus. Figure 1 As shown, the method for outputting multiple types of audio sources with independent channels includes the following steps:
[0022] S10, when playing audio data, wake up the producer threads 111 corresponding to each stream type in the audio data; the audio data contains multiple stream types of audio streams; each producer thread 111 corresponds to a different stream type; wherein the audio data contains at least one or more stream types of audio streams, each stream type of audio stream is output through an audio playback program, and will be transmitted to different conversion playback devices through the SOC chip 1 for playback. That is, the producer threads 111 are created through the preset audio service (such as AudioFlinger) after the system is turned on, and the total number of producer threads 111 is the preset number, which can be determined according to the specific number of stream types of the audio streams to be transmitted. In this step S10, when playing audio data, the producer threads 111 that need to be woken up are only the number of stream types corresponding to the audio streams contained in the audio data (this number should be less than or equal to the total number of producer threads 111, that is, less than or equal to the preset number).
[0023] S20, the awakened producer thread 111 extracts the audio stream from the audio data according to the stream type, and puts the extracted audio stream into the FIFO buffer pool 112 corresponding to the producer thread 111; each producer thread 111 corresponds to a FIFO buffer pool 112; that is, after the producer threads 111 corresponding to different audio streams contained in the audio data are awakened respectively, the audio playback program will write the audio data into different circular buffers (a circular buffer corresponds to a stream type and a producer thread 111) according to different stream types, and then, the corresponding awakened producer thread 111 will extract the audio stream from the circular buffer and write it into the FIFO buffer pool 112 corresponding to the producer thread 111.
[0024] S30, the consumer process thread 113 takes out audio streams from all the FIFO buffer pools 112, and after rearranging and combining all the taken out audio streams into a multi-channel audio data according to the DAI protocol, the multi-channel audio data is written into the DMA buffer 121. That is, the consumer process thread 113 needs to continuously take out audio streams from all the FIFO buffer pools 112. It can be understood that when there is an audio stream in the FIFO buffer pool 112, the consumer process thread 113 can directly take out the audio stream from the FIFO buffer pool 112. Since the current audio data may not contain an audio stream of the stream type corresponding to which the producer thread 111 has been created, that is, the audio playback program corresponding to the stream type may not play the audio stream, at this time, the corresponding producer thread 111 will not be awakened, and therefore, there will be no audio stream in the corresponding FIFO buffer pool 112, so the consumer process thread 113 cannot directly take out the audio stream from the FIFO buffer pool 112, so the audio stream taken out by the consumer process thread 113 from the empty FIFO buffer pool 112 can be recorded as 0 (since all the audio streams taken out need to be rearranged and combined into a multi-channel audio data in accordance with the DAI protocol later, the DAI protocol requires that the audio streams corresponding to all channels must exist). In this embodiment, after the consumer process thread 113 takes out the audio streams from all the FIFO buffer pools 112, it will rearrange and combine all the audio streams taken out (the actual audio streams taken out or 0 mentioned in the above description) into a multi-channel audio data in accordance with the DAI protocol, and then write the multi-channel audio data into the DMA buffer 121.
[0025] S40, the multi-channel audio data in the DMA buffer 121 is transmitted through a preset DAI (such as Figure 2 As shown, the preset DAI includes a first DAI interface 123 and a second DAI interface 131) transmitted to the audio codec 13 for channel separation, and then the multi-channel audio data after channel separation is converted and played by a preset number of conversion and playback modules 2; the preset number of conversion and playback modules 2 is equal to and corresponds to the number of the FIFO buffer pools 112. That is, in this embodiment, the multi-channel audio data can be output to a preset number of conversion and playback modules for separate playback through a preset DAI.
[0026] In the present invention, firstly, different producer threads 111 are required to extract the audio streams of different stream types corresponding to them from the audio data, and then put the extracted audio streams into the corresponding FIFO buffer pool 112; on the other hand, it is also necessary to extract all audio streams from all FIFO buffer pools 112 through consumer process thread 113, and rearrange and combine all the extracted audio streams into a multi-channel audio data according to the DAI protocol, and then write the multi-channel audio data into the DMA buffer 121, and transmit the multi-channel audio data to the audio codec 13 through a preset DAI for channel separation, and then perform data conversion and playback on the multi-channel audio data after channel separation through different conversion and playback modules 2. That is, the present invention does not need to have an ADSP built into the SOC chip 1. It only needs to use a set of DAI interfaces (for example, the first DAI interface 123 and the second DAI interface 131 connected by a physical DAI bus) to achieve the purpose of simultaneously outputting multiple stream types of audio streams through independent channels (and then transmitting and distributing them to different audio devices to achieve simultaneous independent channel playback of audio streams of different stream types), saving IC (Integrated Circuit) pin and DMA12 resources, optimizing the hardware design of the SOC, reducing the required wiring layout space, saving hardware costs, and improving scalability. In addition, the only set of DAI interfaces in the SOC in the present invention does not need to be limited to TDM, so the device selection is easy, which can further save hardware costs.
[0027] In an embodiment of the present invention, only one set of DAI interfaces is designed in the SOC chip 1, and the SOC does not contain a built-in ADSP. Assuming that the system has N (can be 4 groups or more) types of audio stream types, each audio stream type is dual-channel / 32 bits wide / 48KHz sampling rate, and the DAI interface is configured as 8slots / 32bits. Using the software of the present invention, N types of audio streams can be transmitted to the specified channel individually or simultaneously, thereby realizing the distribution of different channels to corresponding speakers. In the SOC chip 1 that does not contain ADSP, the present invention only needs to design a set of DAI interfaces in hardware to complete simultaneous output, and more flexible scalability is achieved through the above-mentioned multi-type sound source independent channel output method of the present invention. The present invention can be applied to real-time operating systems or non-real-time operating systems.
[0028] In one embodiment, in step S10, waking up producer threads 111 corresponding to the stream types in the audio data further includes:
[0029] Obtain all the tream types in the audio data; that is, since the producer thread 111 that needs to be awakened is only the number of tream types corresponding to the audio stream contained in the audio data, it is necessary to first determine all the tream types in the audio data.
[0030] The producer threads 111 corresponding to the acquired stream types are awakened, and the consumer process thread 113 is awakened by the producer thread 111 that is awakened first. That is, after all the stream types in the audio data are determined, the producer threads 111 corresponding to the stream types determined above can be awakened accordingly, and then the consumer process thread 113 is awakened by the producer thread 111 that is awakened first, so that the consumer process thread 113 can take out the audio stream written by the producer thread 111 from the FIFO buffer pool 112 in time when data transmission occurs.
[0031] In one embodiment, in the step S10, before waking up the producer thread 111 corresponding to each stream type in the audio data, the step further includes:
[0032] After the system is turned on, a preset number of producer threads 111 corresponding to different stream types are created, and a preset number of FIFO buffer pools 112 corresponding to each producer thread 111 are applied; that is, after the system is turned on, multiple producer threads 111 can be created through a preset audio service (such as AudioFlinger), and the preset number of producer threads 111 can be equal to the preset number of different stream types of audio streams that need to be transmitted. When the above-mentioned SOC chip 1 is used in a car, the producer thread 111 is used to receive and process the audio data transmitted to the CPU 11 by each audio playback program of the car (used to play audio streams of different stream types, and audio streams of different stream types may need to be played in speakers at different locations in the car), and write different audio streams in the audio data into different FIFO buffer pools 112 corresponding to the audio streams. And the producer thread 111 first enters a dormant state after the boot is completed and waits for the audio playback program to transmit the audio stream before being awakened. At the same time, after the system is started, it is necessary to apply (for example, through AudioHal) for a preset number of FIFO buffer pools 112 corresponding to each producer thread 111, so as to receive the audio stream written down after being processed by the producer thread 111, that is, one producer thread 111 corresponds to one FIFO buffer pool 112, so the number of FIFO buffer pools 112 is also a preset number.
[0033] Create the consumer process thread 113 for taking out the audio stream from each of the FIFO buffer pools 112. In this step, after the system is turned on, it is also necessary to synchronously create a consumer process thread 113 corresponding to all FIFO buffer pools 112. The consumer process thread 113 is used to obtain the audio stream written in the FIFO buffer pool 112 and rearrange and combine all the taken out audio streams into a multi-channel audio data according to the DAI protocol, and then write the multi-channel audio data into the DMA buffer 121. It can be understood that when the audio playback program starts to transmit audio data to the producer thread 111, if the first producer thread 111 is awakened, it can be considered that there is data transmission at this time, and the consumer process thread 113 will also be awakened by the first awakened producer thread 111. After the consumer process thread 113 is just created, since there is no data transmission, the consumer process thread 113 will enter a dormant state and wait to be awakened.
[0034] Furthermore, after creating a preset number of producer threads 111 corresponding to different stream types, and applying for a preset number of FIFO buffer pools 112 corresponding to each producer thread 111, the method further includes:
[0035] Apply for a preset number of data transmission identifiers corresponding to different stream types, encapsulate each data transmission identifier and the corresponding producer thread 111 and the FIFO buffer pool 112 into a data output module, and add the data output module to the global output linked list; that is, in this embodiment, the data transmission identifier is the basis identifier for the consumer process thread 113 to take out the audio stream from the FIFO buffer pool 112 corresponding to different producer threads 111. Only after the producer thread 111 and the FIFO buffer pool 112 corresponding to each stream type in the audio data are determined according to the data transmission identifier, the consumer process thread 113 can accurately take out the audio stream from the FIFO buffer pool 112. In this embodiment, the global output linked list is a linked list, and the data transmission identifier of each data output module in the global output linked list corresponds to a stream type and a data output module, and one data output module corresponds to one producer thread 111 and the FIFO buffer pool 112.
[0036] Apply for a preset number of data buffers 1131 and a BUFFER 1132 corresponding to each of the FIFO buffer pools 112. Figure 3 As shown in the figure, the consumer process thread 113 will correspond to a preset number of data buffer areas 1131 and a BUFFER 1132. In this embodiment, the applied data buffer areas 1131 will be used to write the audio stream taken out by the consumer process thread 113 from the corresponding FIFO buffer pool 112 (when the FIFO buffer pool 112 corresponding to the producer thread 111 is empty, the corresponding data buffer area 1131 will be written with 0), and then, the written audio stream (and the written 0) will all be rearranged and combined into multi-channel audio data according to the DAI protocol and written into the BUFFER 1132.
[0037] In one embodiment, in step S30, the process of taking out audio streams from all the FIFO buffer pools 112 through the consumer process thread 113, and rearranging and combining all the taken out audio streams into a multi-channel audio data according to the DAI protocol, and then writing the multi-channel audio data into the DMA buffer 121 includes:
[0038] The global output linked list is traversed through the consumer process thread 113, and all the data output modules in the global output linked list corresponding to each stream type in the audio data are marked; that is, the global output linked list is generated according to the data transmission identifiers corresponding to different stream types, and the global output linked list contains multiple data output modules corresponding to different data transmission identifiers, each data transmission identifier corresponds to a stream type and a data output module, and one data output module corresponds to one producer thread 111 and the FIFO buffer pool 112.
[0039] Determine whether the FIFO buffer pool 112 in the marked data output module is not empty, and take out the audio stream from the FIFO buffer pool 112 that is not empty, and write the taken out audio stream into the data buffer area 1131 corresponding to the FIFO buffer pool 112; that is, before rearranging and combining all the taken out audio streams into a multi-channel audio data according to the DAI protocol, first determine whether the FIFO buffer pool 112 is empty. Specifically, in all the data output modules corresponding to each stream type in the audio data, the FIFO buffer pool 112 is not empty, because the producer thread 111 in these data output modules will take out the audio stream and write it into the corresponding FIFO buffer pool 112, so there will be an audio stream (not empty) in the FIFO buffer pool 112 in the marked data output module in the global output linked list; and when the FIFO buffer pool 112 is not empty, the consumer process thread 113 The audio stream is taken out from the FIFO buffer pool 112 that is not empty, and the taken out audio stream is written into the data buffer area 1131 corresponding to the FIFO buffer pool 112 .
[0040] Determine that the FIFO buffer pool 112 in the unmarked data output module is empty, and write 0 into the data buffer area 1131 corresponding to the empty FIFO buffer pool 112; that is, the audio stream of the stream type corresponding to the unmarked data output module does not exist in the audio data to be played, so the producer thread 111 in these data output modules will not be awakened, and the FIFO buffer pool 112 will not be written into the audio stream, so the FIFO buffer pool 112 in the unmarked data output module is empty. When the FIFO buffer pool 112 is empty, write 0 into the data buffer area 1131 corresponding to the empty FIFO buffer pool 112 through the consumer process thread 113.
[0041] After all the data buffers 1131 are written with data, all the retrieved audio streams are rearranged and combined into the multi-channel audio data and written into the BUFFER 1132 by the consumer process thread 113 according to the DAI protocol; that is, the multi-channel audio data has been rearranged and combined into the BUFFER 1132 according to the DAI protocol.
[0042] The multi-channel audio data in the BUFFER 1132 is written into the DMA buffer 121. Furthermore, the DMA controller 122 in the DMA12 controls the multi-channel audio data in the DMA12 buffer to be distributed to different channels of the first DAI interface 123 according to the arranged order, and then the first DAI interface 123 transmits the multi-channel audio data to the second DAI interface 131 in the CODEC through the physical DAI bus.
[0043] In one embodiment, after step S20, after putting the retrieved audio stream into the FIFO buffer pool 112 corresponding to the producer thread 111, the process further includes:
[0044] When the FIFO buffer pool 112 is full, the producer thread 111 is switched to a dormant state, so that the producer thread 111 stops putting the extracted audio stream into the FIFO buffer pool 112. That is, since the FIFO buffer pool 112 has a certain capacity, when the FIFO buffer pool 112 is full, the producer thread 111 cannot continue to write the audio stream into the corresponding FIFO buffer pool 112. Therefore, when the FIFO buffer pool 112 is full, the producer thread 111 needs to be switched from the awakened data transmission state to the dormant state, so that the producer thread 111 stops putting the extracted audio stream into the FIFO buffer pool 112.
[0045] In one embodiment, in step S30, after the consumer process thread 113 retrieves the audio stream from all the FIFO buffer pools 112, the process further includes:
[0046] Determine the producer thread 111 corresponding to the FIFO buffer pool 112 of the taken-out audio stream, and when the determined producer thread 111 is in a sleep state, send a data taking notification to the producer thread 111, so that the producer thread 111 is awakened from the sleep state according to the data sending notification, and then continue to put the taken-out audio stream into the FIFO buffer pool 112. Corresponding to the previous embodiment, when the FIFO buffer pool 112 is full, it is necessary to switch the producer thread 111 from the awakened data transmission state to the sleep state, so that the producer thread 111 stops putting the taken-out audio stream into the FIFO buffer pool 112. Therefore, when the FIFO buffer pool 112 is full and the producer thread 111 has entered the sleep state, if the consumer process thread 113 takes out the audio stream from all the FIFO buffer pools 112, at this time, the consumer process thread 113 will send a data removal notification to the producer thread 111 after taking out the audio stream. The data removal notification is used to notify the producer thread 111 that a piece of the audio stream in the corresponding FIFO buffer pool 112 has been taken away. At this time, after receiving the data sending notification, the producer thread 111 will be awakened from the sleep state, and can continue to put the taken-out audio stream into the FIFO buffer pool 112. Understandably, no matter the producer thread 111 is in a dormant state or the producer thread 111 is awakened from the dormant state to continue data transmission, the action of the consumer process thread 113 taking out the audio stream from all the FIFO buffer pools 112 will continue without being affected.
[0047] In one embodiment, the SOC chip 1 further includes an audio codec 13, the DMA 12 includes a DMA buffer 121 connected to the CPU 11 and a DMA controller 122 connected to the DMA buffer 121; the preset DAI includes a first DAI interface 123 and a second DAI interface 131; the first DAI interface 123 is connected to the second DAI interface 131 via a physical DAI bus. In this embodiment, the step S40, that is, the multi-channel audio data in the DMA buffer is transmitted to the audio codec through a preset DAI for channel separation, and then the multi-channel audio data after channel separation is converted and played by each conversion and playback unit in the conversion and playback module, includes:
[0048] The multi-channel audio data in the DMA buffer 121 is written into the first DAI interface 123 through the DMA controller 122; that is, the DMA controller 122 will distribute the multi-channel audio data transmission rearranged and combined in the DMA buffer 121 according to the DAI protocol to different channels in the first DAI interface 123 according to the order just arranged.
[0049] The multi-channel audio data in the first DAI interface 123 is transmitted to the second DAI interface 131 of the audio codec 13 according to the DAI protocol through the physical DAI bus; that is, the first DAI FIFO of the first DAI interface 123 (applied for the first DAI interface 123 after power-on) will transmit the multi-channel audio data in different channels of the first DAI interface 123 to the second DAI FIFO (applied for the second DAI interface 131 after power-on) in the second DAI interface 131 of the audio codec 13 through the physical DAI bus in the order just arranged, one by one.
[0050] The multi-channel audio data is pulse-coded modulated and channel data is separated by the audio codec 13 to obtain channel separation data streams corresponding to each of the tream types in the audio data; that is, the audio codec 13 will pulse-code modulate the channel data of the data in the second DAI FIFO to obtain channel separation data streams corresponding to each of the tream types in the audio data, and separate each channel separation data stream into different channels in the second DAI interface 131, and each channel separation data stream corresponds to one of the tream types. It can be understood that since the audio codec 13 has separated and obtained the channel separation data streams corresponding to each of the tream types in the audio data, different channel separation data streams can be flexibly processed in the subsequent conversion and playback module 2, such as sound effect processing, volume processing, mixing, etc. on different channel separation data streams, and the above operations can be easily completed.
[0051] The audio codec 13 determines the corresponding conversion and playback module 2 according to the tream type of the channel separation data stream, and transmits each of the channel separation data to the corresponding conversion and playback module 2, so that the conversion and playback module 2 converts the channel separation data into an analog signal and plays it. That is, each channel separation data stream corresponds to a tream type, and each tream type corresponds to a conversion and playback module 2 (the conversion and playback modules 2 are two or more, and the preset number of the conversion and playback modules 2 is equal to and one-to-one corresponding to the number of the FIFO buffer pool 112 and the producer thread 111), and the conversion and playback module 2 includes a preset number of DAC converters (digital-to-analog converters) corresponding to different channels in the second DAI interface 131, and a power amplifier and a speaker connected to the DAC converter; therefore, the channel separation data stream in each channel of the second DAI interface 131 will be converted from a digital signal to an analog signal by the DAC converter corresponding to the channel, and then driven by the power amplifier to play the speaker.
[0052] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.
[0053] In one embodiment, if Figure 2As shown, a SOC chip 1 is provided, which corresponds one-to-one with the method for outputting independent channels of multiple types of audio sources in the above-mentioned embodiment. The SOC chip 1 includes a DMA 12, a preset DAI, an audio codec 13 connected to at least two conversion and playback modules 2, and a CPU 11 for executing the method for outputting independent channels of multiple types of audio sources, wherein the DMA 12 includes a DMA buffer 121 connected to the CPU 11 and a DMA controller 122 connected to the DMA buffer 121; the preset DAI includes a first DAI interface 123 and a second DAI interface 131; the first DAI interface 123 is connected to the second DAI interface 131 via a physical DAI bus.
[0054] The specific definition of the SOC chip 1 can be found in the above definition of the method for outputting independent channels of multiple types of audio sources, which will not be repeated here. Each module in the above SOC chip 1 can be fully or partially implemented by software, hardware or a combination thereof.
[0055] In one embodiment, a car is provided, comprising the SOC chip 1 .
[0056] Those of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through computer-readable instructions, and the computer-readable instructions can be stored in a non-volatile readable storage medium or a volatile readable storage medium. When the computer-readable instructions are executed, they may include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.
[0057] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the system can be divided into different functional units or modules to complete all or part of the functions described above.
[0058] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.
Claims
1. A method for outputting independent channels of multiple types of sound sources, characterized in that: include: When playing audio data, wake up the producer threads corresponding to each stream type in the audio data; The audio data includes multiple audio streams of stream type; each of the producer threads corresponds to a different stream type; Extracting an audio stream from the audio data according to the stream type through the awakened producer thread, and putting the extracted audio stream into a FIFO buffer pool corresponding to the producer thread; Each of the producer threads corresponds to a FIFO buffer pool; Taking out audio streams from all the FIFO buffer pools through the consumer process thread, rearranging and combining all the taken out audio streams into a multi-channel audio data according to the DAI protocol, and then writing the multi-channel audio data into the DMA buffer; The multi-channel audio data in the DMA buffer is transmitted to the audio codec through a preset DAI for channel separation, and then the multi-channel audio data after channel separation is converted and played respectively through a preset number of conversion and playback modules; the preset number of the conversion and playback modules is equal to the number of the FIFO buffer pools and corresponds one to one.
2. The method for outputting multiple types of audio sources with independent channels as claimed in claim 1, characterized in that: The waking up the producer threads corresponding to the stream types in the audio data also includes: Get all the tream types in the audio data; The producer threads corresponding to the acquired stream types are awakened respectively, and the consumer process thread is awakened through the producer thread that is awakened first.
3. The method for outputting multiple types of audio sources with independent channels as claimed in claim 1, characterized in that: Before waking up the producer threads corresponding to the stream types in the audio data, the method further includes: After the system is turned on, a preset number of producer threads corresponding to different stream types are created, and a preset number of FIFO buffer pools corresponding to each producer thread are applied; Create the consumer process thread for taking out the audio stream from each of the FIFO buffer pools.
4. The method for outputting multiple types of audio sources with independent channels as claimed in claim 3, characterized in that: After creating a preset number of producer threads corresponding to different stream types, and applying for a preset number of FIFO buffer pools corresponding to each producer thread, the method further includes: Apply for a preset number of data transmission identifiers corresponding to different stream types, encapsulate each data transmission identifier and the corresponding producer thread and FIFO buffer pool into a data output module, and add the data output module to a global output linked list; Apply for a preset number of data buffer areas and a BUFFER corresponding to each of the FIFO buffer pools.
5. The method for outputting multiple types of audio sources with independent channels as claimed in claim 4, characterized in that: The process of taking out audio streams from all the FIFO buffer pools through the consumer process thread, rearranging and combining all the taken out audio streams into a multi-channel audio data according to the DAI protocol, and then writing the multi-channel audio data into the DMA buffer includes: Traversing the global output linked list through the consumer process thread, and marking all the data output modules in the global output linked list corresponding to each stream type in the audio data; Determine, through the consumer process thread, that the FIFO buffer pool in the marked data output module is not empty, extract the audio stream from the FIFO buffer pool that is not empty, and write the extracted audio stream into the data buffer area corresponding to the FIFO buffer pool; Determine that the FIFO buffer pool in the unmarked data output module is empty, and write 0 into the data buffer area corresponding to the empty FIFO buffer pool; After all the data buffers are written with data, all the retrieved audio streams are rearranged and combined into the multi-channel audio data and written into the BUFFER by the consumer process thread according to the DAI protocol; The multi-channel audio data in the BUFFER is written into a DMA buffer.
6. The method for outputting multiple types of audio sources with independent channels as claimed in claim 1, characterized in that: After putting the retrieved audio stream into the FIFO buffer pool corresponding to the producer thread, the method further includes: When the FIFO buffer pool is full, the producer thread is switched to a dormant state so that the producer thread stops putting the retrieved audio stream into the FIFO buffer pool.
7. The method for outputting multiple types of audio sources with independent channels as claimed in claim 6, characterized in that: After the audio stream is taken out from all the FIFO buffer pools by the consumer process thread, the method further includes: Determine the producer thread corresponding to the FIFO buffer pool of the taken-out audio stream, and when the determined producer thread is in a dormant state, send a data taking notification to the producer thread, so that the producer thread is awakened from the dormant state according to the data sending notification, and then continue to put the taken-out audio stream into the FIFO buffer pool.
8. The method for outputting multiple types of audio sources with independent channels as claimed in claim 1, characterized in that: The preset DAI includes a first DAI interface and a second DAI interface; The method further comprises: transmitting the multi-channel audio data in the DMA buffer to the audio codec through a preset DAI for channel separation, and then performing data conversion and playback on the multi-channel audio data after channel separation through each conversion and playback unit in the conversion and playback module. Writing the multi-channel audio data in the DMA buffer into the first DAI interface through a DMA controller; Transmitting the multi-channel audio data in the first DAI interface to the second DAI interface of the audio codec through a physical DAI bus according to the DAI protocol; Performing pulse code modulation channel data separation on the multi-channel audio data by the audio codec to obtain channel separation data streams corresponding to each of the tream types in the audio data; The audio codec determines the corresponding conversion and playback module according to the stream type of the channel separation data stream, and transmits each channel separation data to the corresponding conversion and playback module, so that the conversion and playback module converts the channel separation data into analog signals and plays them.
9. A SOC chip, characterized in that: It includes DMA, preset DAI, an audio codec connected to at least two conversion and playback modules, and a CPU for executing the method for independent channel output of multiple types of audio sources as described in any one of claims 1 to 8, wherein the DMA includes a DMA buffer connected to the CPU and a DMA controller connected to the DMA buffer; the preset DAI includes a first DAI interface and a second DAI interface; the first DAI interface is connected to the second DAI interface via a physical DAI bus.
10. An automobile, characterized in that: Includes the SOC chip as described in claim 9.
