CN111782177B - Rtos-based audio stream output method - Google Patents

Rtos-based audio stream output method Download PDF

Info

Publication number
CN111782177B
CN111782177B CN202010663697.6A CN202010663697A CN111782177B CN 111782177 B CN111782177 B CN 111782177B CN 202010663697 A CN202010663697 A CN 202010663697A CN 111782177 B CN111782177 B CN 111782177B
Authority
CN
China
Prior art keywords
layer
audio
voice data
buffer area
data
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010663697.6A
Other languages
Chinese (zh)
Other versions
CN111782177A (en
Inventor
李重
王利平
权良民
程龙
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Anhui Xinzhi Technology Co ltd
Original Assignee
Anhui Xinzhi Technology Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Anhui Xinzhi Technology Co ltd filed Critical Anhui Xinzhi Technology Co ltd
Priority to CN202010663697.6A priority Critical patent/CN111782177B/en
Publication of CN111782177A publication Critical patent/CN111782177A/en
Application granted granted Critical
Publication of CN111782177B publication Critical patent/CN111782177B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/16Sound input; Sound output

Abstract

The invention discloses an audio stream output method based on rtos, which comprises the steps that an application layer calls an I/O Device Framework layer packaged function interface, continuous voice data are transmitted to a next layer of a Resmple layer for resampling treatment; the Audio Framework reads the resampled data, sends the resampled data to a BSP Audio Driver layer, and finally invokes the HW Driver to send the data out through a bottom hardware interface; the invention improves the real-time and stability of audio stream output based on a real-time operating system, reduces the system coupling, and enables the data of an application layer to be stably output to a bottom hardware interface in real time through the multi-layer design by using independent task processing of each layer; the method not only simplifies the data processing flow of application development, but also makes the drive development more modularized, improves the portability of the whole audio drive, and is beneficial to the convenience of business layer expansion and maintenance.

Description

Rtos-based audio stream output method
Technical Field
The invention relates to the technical field of audio stream processing, in particular to an audio stream output method based on rtos.
Background
rtos is different from linux, android and windows systems, has small volume and simple functions, and is commonly used in the fields of Internet of things, industrial control and the like; the system is limited by small volume of software and hardware, insufficient computing capability, narrow application range and the like, and various new technologies, new architectures and new applications have limited support for the system. At present, the processing method of the audio stream on rtos is basically that an application layer code directly operates bottom layer hardware, no hierarchy exists, a developer needs to know upper layer software and a bottom layer hardware mechanism, development difficulty is high, portability does not exist, and the application developer directly operates the bottom layer hardware to have great risks for a system. Unlike linux, there is an alsa framework to build the output control of the entire audio stream.
In order to solve the above-mentioned defect, a technical scheme is provided.
Disclosure of Invention
The invention aims to provide an audio stream output method based on rtos, which refers to a linux system audio framework and introduces the framework into the field of an embedded real-time operating system, so that rtos application developers can directly call an upper interface without concern of underlying audio processing logic, and can output voice data in real time and stably.
The technical problems to be solved by the invention are as follows:
how to solve the problem of the existing stable output method of the audio stream under rtos through an effective method. The current output of the audio stream under rtos is basically that the application layer directly transmits the audio stream to the bottom hardware, no hierarchy exists, a developer needs to know the upper software and the mechanism of the bottom hardware, the development difficulty is high, portability does not exist, and the application developer directly operates the bottom hardware to have great risk to the system.
The aim of the invention can be achieved by the following technical scheme:
an audio stream output method based on rtos includes the following steps:
step one, the application layer transfers continuous voice data to the next layer of the Resmple layer by calling the function interface encapsulated by the I/O Device Framework layer, such as open, start, write;
step two, after receiving the data of the application layer, the Resmple layer decides whether to carry out resampling processing according to the configuration parameters, and then writes the data into an allocated buffer area 0;
step three, the Audio frame layer reads voice data from the buffer area 0, writes the voice data into the buffer area 1, checks whether the ping-pong buffer area is empty, and moves the data in the buffer area 1 into the ping-pong buffer area;
step four, the BSP Audio Driver layer reads voice data from the ping-pong buffer area, writes the voice data into the HW Driver layer, triggers the Audio frame layer to move the data in the buffer area 1 into the ping-pong buffer area, and simultaneously acquires parameter information such as volume, audio path and the like, and configures the parameter information;
step five, the HW Driver layer writes the final voice data into the DMA, and finally sends out the final voice data through the bottom audio interface so as to finish the output of the whole audio stream;
further, the audio stream is equivalent to a pcm format data stream; rtos is equivalent to a real-time operating system.
Further, the I/O Device Framework layer mainly implements an I/O device management interface, so that a voice stream can be written into an audio device. Some mainstream rtos have encapsulated I/O Device Framework layer interfaces, such as open, start, write, which can be used directly.
Furthermore, the Resample layer mainly realizes the resampling function of the voice stream, and a pcm device needs to be registered for the I/O Device Framework layer to open. The layer has no platform dependence.
Further, the Audio Framework layer is mainly used for constructing the whole Audio driving Framework and is used for connecting the Resmple layer and the BSP Audio Driver. The layer has no platform dependence.
Furthermore, the BSP Audio Driver layer mainly transmits the voice stream to the HW Driver layer, and the layer needs to register a sound card device for binding the pcm device in the second step. The layer has platform correlation, and the initialization of the system clock and the sound card is realized in the layer.
Furthermore, the HW Driver layer is the bottommost layer, mainly realizes the controller drive of the audio, and has platform correlation.
The invention has the beneficial effects that:
the invention is applied to how to stably and effectively output the audio stream of the embedded real-time operating system in real time, and introduces the audio stream into the field of the embedded real-time operating system according to the existing framework of the linux system, and each layer uses independent task processing through multi-layer software design, so that rtos application developers can directly call an upper interface without concern of underlying audio processing logic at all, and can output voice data in real time and stably. The method not only simplifies the data processing flow of application development and reduces the system coupling, but also makes the drive development more modularized, improves the portability of the whole audio drive, is beneficial to the convenience of business layer expansion and maintenance, and reduces the project development period.
Drawings
For the convenience of those skilled in the art, the present invention will be further described with reference to the accompanying drawings;
FIG. 1 is a block diagram of a multi-layer software output flow of the present invention.
Detailed Description
The following gives a preferred embodiment of the present invention with reference to the accompanying drawings, to describe in detail the technical scheme of the present invention:
as shown in fig. 1, an rtos-based audio stream output method includes the following steps:
step one, the application layer transfers continuous voice data to the next layer of the Resmple layer by calling the function interface encapsulated by the I/O Device Framework layer, such as open, start, write;
wherein the audio stream is equivalent to a pcm format data stream; rtos is equivalent to a real-time operating system;
furthermore, the I/O Device Framework layer mainly realizes an I/O device management interface, so that voice streams can be written into registered audio devices; some mainstream rtos have encapsulated I/O Device Framework layer interfaces, such as open, start, write, which can be modified and used on the basis; note that if rtos is a preemptive kernel based on task priority, the write must use a blocking approach, otherwise other tasks will not get the CPU when writing the audio stream in cycles;
step two, after receiving the data of the application layer, the Resmple layer decides whether to carry out resampling processing according to the configuration parameters, and then writes the data into an allocated buffer area 0;
the re layer mainly realizes the resampling function of the voice stream, a pcm device is required to be registered for opening the I/O Device Framework layer, and the size of the buffer zone 0 is required to be dynamically configured according to the transmission rate of the actual audio interface; the layer has no platform correlation, and is convenient to transplant between platforms;
furthermore, the resampling of the voice stream can refer to the ala frame of the linux system, and some simple resampling algorithms can be found from the internet to be debugged and realized;
step three, the Audio frame layer reads voice data from the buffer area 0, writes the voice data into the buffer area 1, checks whether the ping-pong buffer area is empty, and moves the data in the buffer area 1 into the ping-pong buffer area;
the Audio Framework layer is mainly used for constructing the whole Audio driving Framework and is used for connecting the Resmple layer and the BSP Audio Driver; the size of the buffer 1 needs to be matched with the buffer 0, and the size of the ping-pong buffer is related to the size of one-time DMA (direct memory access) carrying of hardware; the layer has no platform correlation, and is convenient to transplant between platforms;
step four, the BSP Audio Driver layer reads voice data from the ping-pong buffer area, writes the voice data into the HW Driver layer, triggers the Audio frame layer to move the data in the buffer area 1 into the ping-pong buffer area, and simultaneously acquires parameter information such as volume, audio path and the like, and configures the parameter information;
the BSP Audio Driver layer mainly transmits the voice stream to the HW Driver layer, and the layer needs to register a sound card device for binding pcm devices in the second step; the layer has platform correlation, and configuration of parameter information such as volume, audio path and the like, and initialization of a system clock and a sound card are realized in the layer;
further, after data is written into the HW Driver layer, the Audio frame layer needs to be triggered to move the data in the buffer area 1 into the ping-pong buffer area each time, so that the buffer area is guaranteed to be provided with data at the moment in the ping-pong buffer area;
furthermore, the configuration of parameter information such as volume and audio path is that when the system has an externally controllable DAC device, the system can be used for adjusting the volume and selecting different audio paths to output voice;
step five, the HW Driver layer writes the final voice data into the DMA, and finally sends out the final voice data through the bottom audio interface so as to finish the output of the whole audio stream;
the HW Driver layer is the bottommost layer and mainly realizes the controller driving of the audio, the layer has platform correlation, and the difference of different controller driving can be larger;
working principle: in the field of real-time operating systems, the limitation of embedded software and hardware environments is limited, the support of the real-time operating system on an audio function module is very limited, an alsa framework similar to linux is difficult to find to manage the whole audio, and only a set of audio frameworks suitable for rtos can be developed to manage the stable output of the whole audio stream based on the current rtos environment. The multi-layer driver software architecture is correspondingly designed to manage the whole audio stream based on the multitasking of rtos. Each layer uses independent task processing, improves the real-time performance of the system, and ensures that rtos application developers can directly call an upper layer interface without concern for underlying audio processing logic, so that voice data can be output in real time and stably. The method not only simplifies the data processing flow of application development and reduces the system coupling, but also makes the drive development more modularized, improves the portability of the whole audio drive, is beneficial to the convenience of business layer expansion and maintenance, and reduces the project development period.
The foregoing is merely illustrative of the structures of this invention and various modifications, additions and substitutions for those skilled in the art can be made to the described embodiments without departing from the scope of the invention or from the scope of the invention as defined in the accompanying claims.

Claims (1)

1. An rtos-based audio stream output method is characterized by comprising the following steps:
step one: the application layer transmits continuous voice data to the next layer of the Resmple layer by calling the function interface encapsulated by the I/O Device Framework layer, wherein the function interface comprises open, start and write; rtos is a preemptive kernel based on task priority, where write uses blocking;
step two: the method comprises the steps that after voice data of an application layer are received by a response layer, resampling is conducted according to configuration parameters, and then the voice data are written into an allocated buffer area 0; the size of the buffer zone 0 is dynamically configured according to the transmission rate of an actual audio interface, and a Resmple layer has no platform correlation;
step three: the Audio frame layer reads voice data from the buffer area 0, writes the voice data into the buffer area 1, checks whether the ping-pong buffer area is empty, and moves the voice data of the buffer area 1 into the ping-pong buffer area; the size of the buffer zone 1 is matched with the size of the buffer zone 0, the size of the ping-pong buffer zone is related to the size of one-time DMA (direct memory access) carrying of hardware, and an Audio frame work layer has no platform correlation;
step four, the BSP Audio Driver layer reads voice data from the ping-pong buffer area, writes the voice data into the HW Driver layer, triggers the Audio frame work layer to move the voice data of the buffer area 1 into the ping-pong buffer area, and simultaneously acquires and configures the parameter information of volume and Audio path; the configuration of parameter information of volume and audio path is that when the system has an externally controllable DAC device, the volume is adjusted and different audio paths are selected to output voice;
step five: the HW Driver layer writes the final voice data into the DMA and sends the final voice data out through a bottom audio interface so as to finish the output of the whole audio stream;
the audio stream is a pcm format data stream; rtos is a real-time operating system;
the I/O Device Framework layer is used for realizing an I/O device management interface and writing a voice stream into the audio device;
the Resample layer is used for resampling the voice stream, registering one pcm device and opening the I/O Device Framework layer;
the Audio Framework layer is used for constructing the whole Audio driving Framework and connecting the Resamplelayer and the BSP Audio Driver layer;
the BSP Audio Driver layer is used for transmitting the voice stream to the HW Driver layer, registering a sound card device, binding the sound card device with the pcm device, and initializing a clock and a sound card;
the HW Driver layer is the bottommost layer and is used for realizing the controller drive of the audio, and has platform correlation.
CN202010663697.6A 2020-07-10 2020-07-10 Rtos-based audio stream output method Active CN111782177B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010663697.6A CN111782177B (en) 2020-07-10 2020-07-10 Rtos-based audio stream output method

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010663697.6A CN111782177B (en) 2020-07-10 2020-07-10 Rtos-based audio stream output method

Publications (2)

Publication Number Publication Date
CN111782177A CN111782177A (en) 2020-10-16
CN111782177B true CN111782177B (en) 2023-10-03

Family

ID=72768286

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010663697.6A Active CN111782177B (en) 2020-07-10 2020-07-10 Rtos-based audio stream output method

Country Status (1)

Country Link
CN (1) CN111782177B (en)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2323292A1 (en) * 2009-11-12 2011-05-18 SiTel Semiconductor B.V. Resampler with automatic detecting and adjusting the resampling ratio
CN106293659A (en) * 2015-05-21 2017-01-04 阿里巴巴集团控股有限公司 A kind of audio frequency real-time processing method, device and intelligent terminal
CN106528040A (en) * 2016-11-02 2017-03-22 福建星网视易信息系统有限公司 Method and apparatus for improving audio quality of android device
CN107992282A (en) * 2017-11-29 2018-05-04 珠海市魅族科技有限公司 Audio data processing method and device, computer installation and readable storage devices

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20050100023A1 (en) * 2003-11-07 2005-05-12 Buckwalter Paul B. Isochronous audio network software interface
US7706901B2 (en) * 2004-10-01 2010-04-27 Microsoft Corporation Low latency real-time audio streaming
US10776072B2 (en) * 2016-03-29 2020-09-15 Intel Corporation Technologies for framework-level audio device virtualization
US10330932B2 (en) * 2017-07-14 2019-06-25 Realwear, Incorporated Multi-process access to a single-process resource

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP2323292A1 (en) * 2009-11-12 2011-05-18 SiTel Semiconductor B.V. Resampler with automatic detecting and adjusting the resampling ratio
CN106293659A (en) * 2015-05-21 2017-01-04 阿里巴巴集团控股有限公司 A kind of audio frequency real-time processing method, device and intelligent terminal
CN106528040A (en) * 2016-11-02 2017-03-22 福建星网视易信息系统有限公司 Method and apparatus for improving audio quality of android device
CN107992282A (en) * 2017-11-29 2018-05-04 珠海市魅族科技有限公司 Audio data processing method and device, computer installation and readable storage devices

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
面向Wi-Fi音频应用的嵌入式Linux音频驱动设计;陈熹等;电子设计工程;第95-100页 *

Also Published As

Publication number Publication date
CN111782177A (en) 2020-10-16

Similar Documents

Publication Publication Date Title
Schmidt et al. A high-performance end system architecture for real-time CORBA
US7080386B2 (en) Architecture with digital signal processor plug-ins for general purpose processor media frameworks
US7669002B1 (en) System and method for providing an application with memory access methods
US7950022B1 (en) Techniques for use with device drivers in a common software environment
JP5149258B2 (en) Robot component management device
CN101630343B (en) Simulation method and simulation system
CN111782177B (en) Rtos-based audio stream output method
CN102104508B (en) M module low-level (LL) driver layer realization method for M module-based local area network (LAN)-based extensions for instrumentation (LXI) equipment
Barnes et al. RMoX: a Raw Metal occam Experiment
CN102567071A (en) Virtual serial port system and communication method for same
JPH05189192A (en) Apparatus and method for display adaptor interface
US7950025B1 (en) Common software environment
Wells et al. Hardware and software considerations for implementing hardware-in-the loop traffic simulation
Schmidt et al. Developing flexible and high-performance Web servers with frameworks and patterns
Gantel et al. Dataflow programming model for reconfigurable computing
CN110109849B (en) CAN equipment driving device and method based on PCI bus
KR100605067B1 (en) Application controlled data flow between processing tasks
Pava et al. Real time platform middleware for transparent prototyping of haptic applications
WO2018192177A1 (en) Ros and orocos-based robot control method and system
Lockhart RTC: a distributed real-time control system toolkit
RU2511611C2 (en) Data flow network
Song et al. A distributed real-time system framework design for multi-robot cooperative systems using real-time CORBA
Matia Kernel Corner Writing a Linux Driver
Pappas Implementation and evaluation of (mu) C/OS for the Handy board
Yin et al. Implementing high performance remote method invocation in cca

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant