harmony 鸿蒙Shared Audio Input
Shared Audio Input
Audio input sources usually consist of audio data captured by built-in microphones, external devices, or remote distributed devices. They can also be audio data sent by other applications to the system for playback. Depending on the audio source, audio input can be categorized into two types: internal recording and external recording.
- Internal recording audio input: This type uses audio data within the system as the source, commonly referred to as internal recording. The corresponding stream is known as the internal recording stream.
Common examples of internal recording audio include audio data captured during screen recording (such as sounds played by other applications) and audio data intended for playback on other devices.
- External recording audio input: This type captures external sounds through audio interfaces as the source, commonly referred to as external recording. The corresponding stream is known as the external recording stream.
Typical examples of external recording include audio recording with a voice recorder, voice activation and recognition for voice assistants, and audio recording transmitted to the other end during a VoIP call.
Usually, when an application requests audio recording, it exclusively occupies the audio input. However, there are scenarios where two or more applications may request audio recording simultaneously or consecutively, all wishing to obtain data from the audio input within the same time frame. This situation is known as concurrent recording, which is further divided into concurrent existence and concurrent operation.
- Concurrent existence refers to the state where one or more different audio recording clients (AudioCapturer) created by applications exist simultaneously within the same time frame.
- Concurrent operation refers to the state where, on the basis of concurrent existence, the audio streams initiated by different audio recording clients (AudioCapturer) are all in the running state within the same time frame, meaning these clients are recording audio simultaneously.
When concurrent recording occurs, each application requesting audio recording wants to obtain the audio input data. This presents the challenge of transmitting the same audio source to multiple applications simultaneously.
Concurrent Recording
Previously, the system did not support concurrent recording of different audio stream types between different applications, which was strictly controlled by audio focus strategies.
Concurrent recording between internal and external audio inputs is not subject to this limitation if permitted by security and privacy policies. For example, when an internal recording stream is enabled in a screen recording application, it is possible to simultaneously use a voice recorder for recording or a voice assistant for voice recognition.
The current system version has relaxed some restrictions on concurrent recording between different audio stream types, allowing multiple audio streams to obtain audio data simultaneously. However, since the data originates from the same audio input, the audio effects will be the same. This may partially meet the needs for concurrent recording.
Priority Adjustment Scheme
In most cases, the quality of audio data depends on the optimization processing strategy of the system for audio input data.
When an application initiates audio recording, the system identifies the audio scenario based on the audio stream type and other related parameters sent by the application, and selects an appropriate processing strategy to handle the input data. For instance, when an application initiates a VoIP call, the system performs noise reduction and voice enhancement optimizations on the VoIP audio stream.
Some audio recording stream types only need to obtain audio input data, whereas others heavily rely on the system’s optimization processing. Improper handling may lead to a poor experience. Therefore, for these audio recording stream types, it is necessary to ensure that the system can still configure appropriate optimization processing strategies during concurrent recording. To this end, the system configures priorities for these audio recording stream types and adds a priority adjustment scheme on top of the existing audio focus strategies.
The principle of this adjustment is to prioritize the optimization strategies corresponding to high-priority audio recording stream types for processing audio input data.
Recording Concurrency Strategy
The current concurrent recording strategy generally follows the following principles:
- Whether multiple audio streams can obtain audio input data simultaneously during concurrent recording depends on the audio focus strategies of the respective audio stream types. You need to ensure proper focus adaptation.
- The quality of audio input data is determined by the optimization processing strategy selected by the system based on the current priority adjustment scheme. It is recommended that you inform users that the quality of the recording data may be affected during concurrent recording.
Usage Suggestion
The system has implemented preliminary management for concurrent recording scenarios through a dual mechanism of audio focus strategies and priority adjustment. Although the system now allows limited concurrent recording for some different audio stream types, the following key points should be noted:
Limitations of Concurrent Recording
- Uncontrollable audio quality: During concurrent recording, multiple audio streams obtain audio input data from the same source, which may affect audio quality.
- System overhead: Concurrent recording may increase system overhead.
Recommendations
- Understand audio focus strategies and ensure proper focus adaptation, handling audio focus changes promptly.
- Avoid concurrent recording scenarios whenever possible. Design applications to minimize overlap with other recording tasks. If necessary, display a message to users such as “Another recording task is currently in progress.”
If concurrent recording is unavoidable, clearly inform users that audio quality may be affected. - Select the appropriate recording stream type, as different types correspond to different system optimization strategies. You are advised to select the appropriate recording stream type based on your service requirements. - If recording is no longer required, stop and release recording resources promptly to avoid impacting other audio streams and to reduce unnecessary system overhead. - Application implementation should not overly rely on fixed concurrent recording rules but should adapt based on the status returned by system interfaces.
你可能感兴趣的鸿蒙文章
harmony 鸿蒙Developing Audio Call
harmony 鸿蒙Audio Effect Management
harmony 鸿蒙Global Audio Input Device Management
harmony 鸿蒙Introduction to Audio Kit
harmony 鸿蒙Audio Latency Management
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦