Plug-and-play mobile operating system virtual microphone implementation method
By providing a Unix socket protocol interface and short-range data communication in the hardware abstraction layer of the operating system, the problem of inflexible utilization of microphone resources in mobile devices in existing technologies is solved, enabling plug-and-play and automatic switching, and improving the versatility and flexibility of the device.
Patent Information
- Application Number
- CN202410651680.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-24
- Publication Date
- 2024-09-06
AI Technical Summary
In existing technologies, mobile device microphones cannot flexibly utilize the microphone resources of other devices, requiring application adaptation, and cannot automatically switch when a microphone device is occupied, lacking versatility.
By providing a Unix socket protocol interface at the operating system's hardware abstraction layer, it leverages short-range data communication capabilities to connect plug-and-play microphone devices, provides audio data sampling rate and channel configuration, and implements audio recording and callbacks through socket control commands.
It enables flexible use of the microphone by upper-layer applications, supports multiple short-range connection methods, and can automatically switch between using the microphone of the device itself or other devices, improving the versatility and flexibility of the device.
Smart Images

Figure CN118612701A
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of microphone operation, and in particular to a method for realizing a plug-and-play mobile operating system virtual microphone. Background Art
[0002] In some special scenarios, such as when the microphone used in a meeting is damaged and the actual physical microphone cannot be used, or when the conference TV microphone is fixed and the speaker effect is not ideal for people far away, there are many smart devices with microphones now, such as commonly used mobile phones. By implementing a plug-and-play virtual microphone solution, the mobile operating system can directly use the microphone of any mobile device without any modification to the upper-layer applications of the operating system.
[0003] In the underlying operating system of the prior art, when the microphone device accessed by the upper-layer application is occupied, a virtual microphone device node will be automatically created. Then, when the current system microphone node is occupied, the upper-layer application needs to access the newly created microphone device. Then, the upper-layer application needs to use the API to access the new virtual microphone device. The virtual microphone node obtains the sound data of the physical microphone through the shared memory method. The prior art essentially uses the local microphone, and requires the application process to access the virtual microphone node according to the implementation. It cannot fully utilize the microphones of other mobile devices, and requires the application to adapt, which is not universal. Summary of the invention
[0004] To solve the above problems, the purpose of the present invention is to provide a plug-and-play mobile operating system microphone implementation method, aiming to provide a flexible method for using a microphone.
[0005] A method for implementing a plug-and-play mobile operating system virtual microphone, characterized in that it comprises the following steps: S1, providing a unix socket protocol interface in the hardware abstraction layer of the operating system, wherein the hardware abstraction layer is called by the audio service; S2, the protocol interface cooperates with the short-distance data communication capability provided by the operating system to connect to the plug-and-play microphone device; the short-distance data communication capability forwards the control instruction to the plug-and-play microphone device through the socket for operation control; S3, the hardware abstraction layer obtains the audio data of the audio service in the plug-and-play microphone device and reports the audio data to the upper-layer application.
[0006] Preferably, in step S2, the content of the protocol interface includes: S21, obtaining a plug-and-play microphone device; S22, setting the sampling rate of audio data; S23, setting channel data of audio data; S24, start audio recording; S25, end audio recording; S26, returns the data callback interface during the recording process.
[0007] Preferably, step S21 includes: After the operating system starts, the fixed address Unix socket is initialized, and the sk connectivity audioin socket is used as the listening address of the Unix socket; When accessing the microphone device, the upper layer application determines whether the listening address of the unix socket is connected. If so, it is considered that there is a plug-and-play microphone device. If not, the local microphone device is accessed.
[0008] Preferably, step S22 includes: The upper layer application sets the audio data sampling rate when accessing the local microphone device. If a plug-and-play microphone device is found in step S21, a set audio configure control command is sent through the socket; The plug-and-play microphone device processes the current control command and configures the sampling rate parameters of the corresponding audio data.
[0009] Preferably, step S23 includes: The upper layer application sets the audio channel of the audio data when accessing the local microphone device. If a microphone device of a plug-and-play device is found in step S21, a set audio channel control command is sent through the socket; The plug-and-play microphone device processes the current control command and configures the channel parameters of the corresponding audio data.
[0010] Preferably, step S24 includes: After steps S21 to S23 are completed, a start audio capture control command is sent through the socket; The plug-and-play microphone device processes the current control command and starts audio recording.
[0011] Preferably, step S25 includes: After steps S21 to S23 are completed, a stop audio capture control command is sent through the socket; The plug-and-play microphone device processes the current control command and stops audio recording.
[0012] Preferably, step S26 includes: After the processing of step S21 to step S24 is completed, the audio data obtained by the socket in step S21 and step S22 is monitored, and the data format of the audio data is a byte array and the length corresponding to the byte array; Returns a byte array as the audio data of the plug-and-play microphone device.
[0013] Beneficial effects of the present invention: 1. It is very flexible to enable upper-layer applications to use other microphones. It can be used as long as the peripheral device supports microphones and short-range communication protocols.
[0014] 2. Flexible switching between using the local microphone and other devices' microphones supports multiple connection methods such as Bluetooth, WiFi, p2p, USB, etc. You only need to connect peripheral devices over a short distance to use the microphones of other devices, and stop the short-distance connection to use the local microphone, instead of the traditional solution of connecting through Bluetooth pairing. BRIEF DESCRIPTION OF THE DRAWINGS
[0015] In order to more clearly illustrate the specific implementation methods of the present invention or the technical solutions in the prior art, the drawings required for use in the specific implementation methods or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some implementation methods of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0016] Figure 1 A step-by-step diagram for connecting plug-and-play microphone devices; Figure 2 Flowchart for connecting plug-and-play microphone devices; Figure 3 A flowchart for determining whether there is a plug-and-play microphone device. DETAILED DESCRIPTION
[0017] The technical scheme in the embodiment of the present invention is described clearly and completely below in conjunction with the accompanying drawings in the embodiment of the present invention. In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention can also be implemented in other ways different from those described herein, and those skilled in the art can make similar generalizations without violating the connotation of the present invention, so the present invention is not limited by the specific embodiments disclosed below.
[0018] As can be seen from the background technology, currently using the local microphone requires the application to implement the function of accessing the virtual microphone node according to the process, which cannot fully utilize the microphones of other mobile devices and requires the application to adapt, and is not universal.
[0019] The present invention provides a plug-and-play mobile operating system virtual microphone implementation method to overcome the above problems. In order to enable personnel in this technical field to better understand the present solution, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments.
[0020] Reference Figure 1 As shown, a plug-and-play mobile operating system virtual microphone implementation method includes: Step S1, providing a unix socket protocol interface in a hardware abstraction layer of an operating system, wherein the hardware abstraction layer is called by an audio service.
[0021] In this embodiment, a standard protocol interface in the form of a unix socket is provided in the hardware abstraction layer (HAL layer) of the operating system, and the protocol interface is configured in the local microphone device. The audio service provides an audio-related standard interface to the upper-layer application. The specific implementation of the protocol interface can also be achieved through a third-party application that integrates the protocol interface. The present invention mainly implements the protocol interface by the operating system, and requires the use of a third-party application code with a microphone function without any modification or recompilation. The upper-layer application is unaware of this, and there is no virtual microphone device node that requires the application to modify the corresponding logic for processing.
[0022] Step S2, refer to Figure 2 As shown, it is a flow chart of connecting a plug-and-play microphone device. The protocol interface cooperates with the short-distance data communication capability provided by the operating system and connects the plug-and-play microphone device through the connection module; the short-distance data communication capability forwards the control instruction to the plug-and-play microphone device through the socket for operation control. Among them, the short-distance data communication capability is a variety of short-distance communication methods provided by the operating system or third-party applications, including Bluetooth, WIFI, P2P, USB, etc.
[0023] Specifically, in step S2, the content of the protocol interface includes: Step S21, obtaining a plug-and-play microphone device; Step S22, setting the sampling rate of the audio data; Step S23, setting channel data of audio data; Step S24, start audio recording; Step S25, ending audio recording; Step S26, returning the data callback interface during the recording process.
[0024] Reference Figure 3 As shown, step S21, the acquisition of a plug-and-play microphone device includes: After the operating system starts, it will initialize the Unix socket with a fixed address and use sk connectivity audio in socket as the listening address of the Unix socket. When accessing the microphone device, the upper-layer application will determine whether the listening address of the unix socket is connected. If there is a connection, it is considered that there is a plug-and-play microphone device, otherwise it accesses the local microphone device.
[0025] Step S22, setting the sampling rate of the audio data, includes: When the upper-layer application accesses the local microphone device, it needs to set the audio data sampling rate. If a plug-and-play microphone device is found through step S21, a set audio configure control command will be sent through the socket. The plug-and-play microphone device needs to process the current control command and configure the corresponding audio data sampling rate parameters.
[0026] Step S23, setting the channel data of the audio data includes: When accessing the local microphone device, the upper-level application needs to set the audio channel of the audio data. If a plug-and-play microphone device is found through step S21, the set audio channel control command will be sent through the socket. The plug-and-play microphone device needs to process the current control command and configure the corresponding channel parameters of the audio data.
[0027] Step S24, starting audio recording, includes: After steps S21 to S23 are completed, a start audio capture control command will be sent through the socket. The plug-and-play microphone device needs to process the current control command and start audio recording.
[0028] Step S25, ending the audio recording, includes: After steps S21 to S23 are completed, a stop audio capture control command will be sent through the socket. The plug-and-play device needs to process the current control command and stop audio recording.
[0029] Step S26, the data callback interface returned during the recording process includes: After the processing of steps S21 to S24 is completed, the audio data obtained by the socket in steps S21 and S22 will be monitored. The data format of the audio data is a byte array and the length corresponding to the byte array, and the byte array is returned as the audio data of the plug-and-play microphone device.
[0030] Step S3: The hardware abstraction layer obtains audio data of the audio service in the plug-and-play microphone device, and reports the audio data to the upper layer application.
[0031] In this embodiment, when the hardware abstraction layer of the operating system finds that an application that implements the protocol interface obtains audio data of a plug-and-play microphone device, it directly reports the audio data obtained through the protocol interface to the upper-level application, keeping consistent with the audio data format and interface reported by the original operating system hardware abstraction layer (HAL layer).
[0032] The beneficial effects of this solution are: the hardware abstraction layer provides hardware standard operation interfaces, and the upper-layer applications access physical hardware devices through these standard interfaces without directly accessing the hardware devices. Because the upper-layer applications access the hardware abstraction layer standard interfaces, this solution does not perceive whether the hardware abstraction layer specifically accesses the local hardware or the plug-and-play hardware device, so the upper-layer applications can achieve plug-and-play microphone device access without modification.
[0033] Although the present invention has been described using the above preferred embodiments, they are not intended to limit the scope of protection of the present invention. Any person skilled in the art may make various changes and modifications to the above embodiments without departing from the spirit and scope of the present invention. The scope of protection of the present invention shall be based on the definition of the claims.
Claims
1. A plug-and-play mobile operating system virtual microphone implementation method, characterized in that: The following steps are involved: S1, providing a unix socket protocol interface in the hardware abstraction layer of the operating system, wherein the hardware abstraction layer is called by the audio service; S2, the protocol interface cooperates with the short-distance data communication capability provided by the operating system to connect to the plug-and-play microphone device; the short-distance data communication capability forwards the control instruction to the plug-and-play microphone device through the socket for operation control; S3, the hardware abstraction layer obtains the audio data of the audio service in the plug-and-play microphone device and reports the audio data to the upper-layer application.
2. The method for implementing a plug-and-play mobile operating system virtual microphone according to claim 1, characterized in that: In step S2, the content of the protocol interface includes: S21, obtaining a plug-and-play microphone device; S22, setting the sampling rate of audio data; S23, setting channel data of audio data; S24, start audio recording; S25, end audio recording; S26, returns the data callback interface during the recording process.
3. The method for implementing a plug-and-play mobile operating system virtual microphone according to claim 2, characterized in that: Step S21 includes: After the operating system starts, initialize the Unix socket with a fixed address, and use sk connectivity audio insocket as the listening address of the Unix socket; When accessing the microphone device, the upper layer application determines whether the listening address of the unix socket is connected. If so, it is considered that there is a plug-and-play microphone device. If not, the local microphone device is accessed.
4. The method for implementing a plug-and-play mobile operating system virtual microphone according to claim 2, characterized in that: Step S22 includes: The upper layer application sets the audio data sampling rate when accessing the local microphone device. If a plug-and-play microphone device is found in step S21, a set audio configure control command is sent through the socket; The plug-and-play microphone device processes the current control command and configures the sampling rate parameters of the corresponding audio data.
5. The method for implementing a plug-and-play mobile operating system virtual microphone according to claim 2, characterized in that: Step S23 includes: The upper layer application sets the audio channel of the audio data when accessing the local microphone device. If a microphone device of a plug-and-play device is found in step S21, a set audio channel control command is sent through the socket; The plug-and-play microphone device processes the current control command and configures the channel parameters of the corresponding audio data.
6. The method for implementing a plug-and-play mobile operating system virtual microphone according to claim 2, characterized in that: Step S24 includes: After steps S21 to S23 are completed, a start audio capture control command is sent through the socket; The plug-and-play microphone device processes the current control command and starts audio recording.
7. The method for implementing a plug-and-play mobile operating system virtual microphone according to claim 2, characterized in that: Step S25 includes: After steps S21 to S23 are completed, a stop audio capture control command is sent through the socket; The plug-and-play microphone device processes the current control command and stops audio recording.
8. The method for implementing a plug-and-play mobile operating system virtual microphone according to claim 2, characterized in that: Step S26 includes: After the processing of step S21 to step S24 is completed, the audio data obtained by the socket in step S21 and step S22 is monitored, and the data format of the audio data is a byte array and the length corresponding to the byte array; Returns a byte array as the audio data of the plug-and-play microphone device.
