Disclosure of Invention
In order to overcome the defects of the prior art, one of the purposes of the invention is to provide a method for recording with a channel by a USB device, which can solve the problems that in the prior art, after the channel of an all-in-one machine device is switched, the APP applied in other channels cannot realize recording and the like.
The invention also aims to provide a device for recording the USB equipment along with the channel, which can solve the problem that in the prior art, the APP applied to other channels cannot realize recording after the channel of the all-in-one machine equipment is switched.
The invention further aims to provide a storage medium which can solve the problem that in the prior art, after the channels of the all-in-one machine equipment are switched, the APP applied to other channels cannot realize recording and the like.
One of the purposes of the invention is realized by adopting the following technical scheme:
a method for recording with a channel by a USB device comprises the following steps:
a first switching step: after the first channel of the all-in-one machine equipment is switched to the second channel, the USB interface of the all-in-one machine equipment is switched to the second channel;
an application starting step: starting a recording application APP, and executing a second switching step when the recording application APP does not belong to the application in the second channel;
a second switching step: acquiring a channel to which the recording application APP belongs, acquiring an associated USB interface according to the recording application APP, and switching the associated USB interface to the channel to which the recording application APP belongs;
equipment selection: acquiring associated USB recording equipment mounted on each associated USB interface, matching the associated USB recording equipment according to a preset rule to obtain USB recording equipment to be used, and acquiring information of the USB recording equipment to be used from the system;
recording: and running the recording APP, and calling the USB recording equipment to be used according to the information of the USB recording equipment to be used to realize recording.
Further, still include: an equipment acquisition step: the method comprises the steps of obtaining information of USB recording equipment mounted on each USB interface of all-in-one equipment, obtaining corresponding Card ID, Card Name and connection state according to the information of each USB recording equipment, and storing each USB recording equipment in a custom equipment management list in a system according to priority.
Further, switching the USB interface of the all-in-one machine device to the second channel in the first switching step includes switching the USB interface to the second channel through a USB Switch;
switching the associated USB interface to the channel to which the recording application APP belongs in the second switching step specifically includes: and acquiring the associated USB Switch according to the associated USB interface, and switching the associated USB interface to the channel to which the recording application APP belongs through the associated USB Switch.
Further, the recording step further comprises: and (3) a recovery step: and after the recording is finished, switching the associated USB interface to the second channel by controlling the associated USB Switch, thereby recovering the USB recording equipment which can be identified by the system under the second channel.
Further, the first channel is an Android channel, and the second channel is any one of an OPS channel, a Type-C channel and an HDMI channel.
Further, the recording step further comprises: and resetting the data stream according to the USB recording equipment to be used to the Audio Record interface, and uploading the recording data to the application APP.
Further, the recording step further comprises: and calling an Audio Record interface to create a process, and acquiring recorded data from the corresponding sound card equipment according to the thread and returning the recorded data to the application APP.
Further, the device selecting step further comprises: and acquiring the equipment information input by the user to obtain the USB recording equipment to be used from the associated USB recording equipment.
The second purpose of the invention is realized by adopting the following technical scheme:
a device for recording sound with a channel of a USB device comprises a memory, a processor and a computer program which is stored on the memory and can run on the processor, wherein the computer program is a program for recording the sound with the channel of the USB device, and the processor realizes the steps of the method for recording the sound with the channel of the USB device when executing the program for recording the sound with the channel of the USB device.
The third purpose of the invention is realized by adopting the following technical scheme:
a storage medium being a computer readable storage medium having stored thereon a computer program being a program for a USB device to record with a channel, the program for the USB device to record with a channel when executed by a processor implementing the steps of a method for a USB device to record with a channel as employed in one of the objects of the present invention.
Compared with the prior art, the invention has the beneficial effects that:
when the recording application APP which does not belong to the current channel is started, part of the USB interfaces under the current channel are switched to the channel to which the recording application APP belongs, so that the recording application APP calls the USB equipment mounted on the corresponding USB interface under the channel to which the recording application APP belongs, and the recording operation is realized, and therefore the problem that in the prior art, after the channel of the all-in-one machine equipment is switched, the operation of the application APPs of other channels is interrupted or is in an equipment-free state and cannot be operated is solved.
Detailed Description
The present invention will be further described with reference to the accompanying drawings and the detailed description, and it should be noted that any combination of the embodiments or technical features described below can be used to form a new embodiment without conflict.
Example one
The invention provides a preferred embodiment, a method for recording sound along with a channel by USB equipment, which comprises the following steps:
and step S1, acquiring information of all USB recording devices connected with the all-in-one machine device and each USB recording device, and storing each USB recording device in a system corresponding to each channel of the all-in-one machine device according to the priority.
Generally, the source channels of the all-in-one machine device include an Android channel, an HDMI channel, an OPS channel, and a Type-C channel. Each channel corresponds to a corresponding device, such as an Android device, an OPS device, and the like. The USB interfaces of the all-in-one machine equipment are multiple, the channels followed by the USB interfaces are realized through the USB Switch, and the equipment under the corresponding channels identifies the USB equipment mounted on the USB interfaces. The channels in the embodiment all refer to information source channels of the all-in-one machine equipment.
Preferably, the USB interface is connected to a variety of USB devices, such as a recording device, a keyboard, a mouse, a speaker, and other devices. The invention mainly aims at a method for recording by a recording device following a channel, so that the USB device average value recording device is provided.
Preferably, step S1 further includes: the method comprises the steps of obtaining information of USB recording equipment mounted on each USB interface of all-in-one equipment, obtaining corresponding Card ID, Card Name and connection state according to the information of each USB recording equipment, and storing each USB recording equipment in a custom equipment management list in a system according to priority.
For example, when in an Android channel, a custom device management list is added to a usbsa manager (Android advanced audio management service) in an Android system to store a Card ID and a Card Name of each all-in-one device, and USB devices in the custom device management list are managed according to a connection state of each USB device.
And step S2, switching the first channel where the all-in-one machine device is located to the second channel, and then switching the USB interface of the all-in-one machine device to the second channel.
Preferably, the USB Switch is controlled to Switch the USB interface of the all-in-one device to the second channel.
The second channel and the first channel belong to different channels and are any one of the information source channels of the all-in-one machine equipment.
Preferably, in the present embodiment, the Android channel is switched to the OPS channel as an example to describe:
that is, the first channel is an Android channel, and the second channel is an OPS channel:
when the channel of the all-in-one machine device is switched, the USB interface of the all-in-one machine device is switched to the OPS channel by controlling the USB Switch, at the moment, the OPS device can identify the USB device mounted on the USB interface, and the USB devices not only comprise USB recording devices, but also comprise other devices such as a keyboard, a mouse and the like. Meanwhile, as the USB interface is switched to the OPS channel, for the Android device, the USB devices are removed, and the Android device system cannot detect any USB device.
Step S3, starting the recording application APP, and judging whether the recording application APP belongs to the second channel, if so, operating the recording application APP to complete corresponding operation; if not, step S5 is executed.
When running, the recording Application APP calls a corresponding recording device to record through a corresponding API (Application Program Interface). And the corresponding API interface is matched to the source channel. Therefore, for example, for a recording application APP in an Android system, the recording application APP needs to call a USB recording device to realize recording in an Android channel.
At this time, the recording operation cannot be realized because no USB device exists in the Android channel. Therefore, the USB interface associated with the USB recording equipment is switched to the channel where the application APP is located from the second channel, so that the recording application APP can identify the corresponding USB recording equipment to realize recording.
Step S4, obtaining a channel to which the recording application APP belongs, obtaining an associated USB interface according to the recording application APP, and further obtaining an associated USB Switch according to the associated USB interface.
Generally, one USB Switch controls the switching of multiple USB interfaces. The USB equipment connected with the USB interface comprises other USB equipment besides the USB recording equipment. In order to ensure that the system under the second channel runs normally, when the USB interface is switched to the channel to which the recording application APP belongs, not all the USB interfaces are switched, but the associated USB equipment called by the recording application APP is switched to the channel to which the application APP belongs, so that the USB recording equipment can be identified under the channel to which the recording application APP belongs.
And step S5, switching the associated USB interface to the channel to which the recording application APP belongs by controlling the associated USB Switch.
And step S6, acquiring the associated USB recording equipment mounted on the associated USB interface, and searching the USB recording equipment to be used from the system according to the preset rule and the associated USB recording equipment.
Since the USB Switch may control a plurality of USB interfaces, each USB interface may mount a USB device, where the USB device may be a USB recording device or other devices. Not all the USB recording devices in the all-in-one machine equipment are controlled by the same USB Switch, so that the USB recording devices mounted on the USB interfaces under the channels to which the recording applications APP belong are only part of the USB recording devices stored in the all-in-one machine equipment. Therefore, the mounted associated USB recording devices are obtained according to the associated USB interfaces, the associated USB recording devices can be identified and obtained under the channel to which the recording application APP belongs, and other USB recording devices can be identified and obtained under the second channel.
Generally, a recording application APP has a default value when calling a USB recording device, but the associated USB recording device in the present invention is not all USB recording devices in the system. Therefore, the USB recording equipment to be used can be obtained by matching the associated USB recording equipment through the preset rule, and then the information of the USB recording equipment to be used is obtained according to the information of each USB recording equipment stored in the system channel.
Preferably, the embodiment further obtains the USB recording device to be used by matching the device information input by the user from one or more associated USB recording devices, and then obtains the information of the USB recording device to be used from the system for subsequent invocation.
And step S7, running the recording application APP, and calling the USB recording equipment to be used according to the information of the USB recording equipment to be used to realize recording.
Because the USB recording equipment to be used is under the channel to which the recording application APP belongs, the recording can be realized by calling the USB recording equipment to be used.
Preferably, the step S7 further includes resetting the data stream according to the to-be-used USB recording device to the Audio Record interface, and uploading the recording data to the recording application APP. Specifically, a process is created by calling an Audio Record interface, and recorded data is fetched from corresponding sound card equipment according to a thread and returned to the application APP. The Audio Record interface is an API of Android standard recording, and a process is created after the recording application APP is started.
Preferably, after the recording operation is completed, the associated USB interface is switched to the current channel where the all-in-one machine device is located, that is, the method further includes:
and step S8, after the operation of running the recording application APP is finished, acquiring a channel where the all-in-one machine is located, and switching the associated USB interface to the channel where the all-in-one machine is located by controlling the USB Switch, so as to recover the mounting of the USB equipment under the channel where the all-in-one machine is located. Namely, after the recording is finished, the associated USB interface is restored to the channel where the current all-in-one machine device is located.
And the channel where the all-in-one machine equipment is located is a second channel, the associated USB interface is switched to the second channel, and the mounting of the USB equipment is recovered.
Example two
The invention provides a device for recording sound of a USB device along with a channel. As shown in fig. 2, an internal structure of the apparatus for recording audio with a channel by a USB device according to an embodiment of the present invention is schematically illustrated.
In this embodiment, the device for recording the sound with the channel by the USB device may be a PC (Personal Computer), or may also be a terminal device such as a smart phone, a tablet Computer, or a portable Computer. The device for recording the USB equipment along with the channel at least comprises: a processor 12, a communication bus 13, a network interface 14, and a memory 11.
The memory 11 includes at least one type of readable storage medium, which includes a flash memory, a hard disk, a multimedia card, a card type memory (e.g., SD or DX memory, etc.), a magnetic memory, a magnetic disk, an optical disk, and the like. The memory 11 may in some embodiments be an internal storage unit of an apparatus for USB device recording with a channel, for example a hard disk of the apparatus for USB device recording with a channel. The memory 11 may also be an external storage device of the apparatus for recording the USB device with the channel in other embodiments, such as a plug-in hard disk provided on the apparatus for recording the USB device with the channel, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), and the like. Further, the memory 11 may also include both an internal storage unit and an external storage device of an apparatus for recording with a channel by a USB device. The memory 11 may be used not only to store application software installed in an apparatus for recording with a USB device and various types of data, such as codes of a program for recording with a USB device, etc., but also to temporarily store data that has been output or is to be output.
Processor 12, which in some embodiments may be a Central Processing Unit (CPU), controller, microcontroller, microprocessor or other data Processing chip, is configured to execute program codes stored in memory 11 or process data, such as executing a program recorded by a USB device along with a channel.
The communication bus 13 is used to realize connection communication between these components.
The network interface 14 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface), and is typically used to establish a communication link between the device for recording with a channel of the USB device and other electronic devices.
Optionally, the apparatus for recording with channel by USB device may further include a user interface, the user interface may include a Display (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface may further include a standard wired interface and a wireless interface. Alternatively, in some embodiments, the display may be an LED display, a liquid crystal display, a touch-sensitive liquid crystal display, an OLED (Organic Light-Emitting Diode) touch device, or the like. The display, which may also be referred to as a display screen or display unit, is suitable for displaying information processed in a device for recording with a USB device along a channel and for displaying a visual user interface.
While FIG. 2 shows only one USB device channel-recording apparatus having components 11-14 and a USB device channel-recording program, those skilled in the art will appreciate that the configuration shown in FIG. 2 does not constitute a limitation of an apparatus for USB device channel-recording and may include fewer or more components than shown, or some components in combination, or a different arrangement of components.
In the embodiment of the apparatus for recording a sound with a channel by a USB device shown in fig. 2, a program for recording a sound with a channel by a USB device is stored in the memory 11; when the processor 12 executes the program recorded with the channel by the USB device stored in the memory 11, the following steps are implemented:
a first switching step: after the first channel of the all-in-one machine equipment is switched to the second channel, the USB interface of the all-in-one machine equipment is switched to the second channel;
an application starting step: starting a recording application APP, and executing a second switching step when the recording application APP does not belong to the application in the second channel;
a second switching step: acquiring a channel to which the recording application APP belongs, acquiring an associated USB interface according to the recording application APP, and switching the associated USB interface to the channel to which the recording application APP belongs;
equipment selection: acquiring associated USB recording equipment mounted on each associated USB interface, matching the associated USB recording equipment according to a preset rule to obtain USB recording equipment to be used, and acquiring information of the USB recording equipment to be used from the system;
recording: and running the recording APP, and calling the USB recording equipment to be used according to the information of the USB recording equipment to be used to realize recording.
Further, still include: an equipment acquisition step: the method comprises the steps of obtaining information of USB recording equipment mounted on each USB interface of all-in-one equipment, obtaining corresponding Card ID, Card Name and connection state according to the information of each USB recording equipment, and storing each USB recording equipment in a custom equipment management list in a system according to priority.
Further, switching the USB interface of the all-in-one machine device to the second channel in the first switching step includes switching the USB interface to the second channel through a USB Switch;
switching the associated USB interface to the channel to which the recording application APP belongs in the second switching step specifically includes: and acquiring the associated USB Switch according to the associated USB interface, and switching the associated USB interface to the channel to which the recording application APP belongs through the associated USB Switch.
Further, the recording step further comprises: and (3) a recovery step: and after the recording is finished, switching the associated USB interface to the second channel by controlling the associated USB Switch, thereby recovering the USB recording equipment which can be identified by the system under the second channel.
Further, the first channel is an Android channel, and the second channel is any one of an OPS channel, a Type-C channel and an HDMI channel.
Further, the recording step further comprises: and resetting the data stream according to the USB recording equipment to be used to the Audio Record interface, and uploading the recording data to the application APP.
Further, the recording step further comprises: and calling an Audio Record interface to create a process, and acquiring recorded data from the corresponding sound card equipment according to the thread and returning the recorded data to the application APP.
Further, the device selecting step further comprises: and acquiring the equipment information input by the user to obtain the USB recording equipment to be used from the associated USB recording equipment.
EXAMPLE III
The invention also provides a storage medium which is a computer readable storage medium and is stored with a computer program, wherein the computer program is a program recorded by the USB equipment along with the channel; when the program recorded by the USB equipment along with the channel is executed by the processor, the following steps are realized:
a first switching step: after the first channel of the all-in-one machine equipment is switched to the second channel, the USB interface of the all-in-one machine equipment is switched to the second channel;
an application starting step: starting a recording application APP, and executing a second switching step when the recording application APP does not belong to the application in the second channel;
a second switching step: acquiring a channel to which the recording application APP belongs, acquiring an associated USB interface according to the recording application APP, and switching the associated USB interface to the channel to which the recording application APP belongs;
equipment selection: acquiring associated USB recording equipment mounted on each associated USB interface, matching the associated USB recording equipment according to a preset rule to obtain USB recording equipment to be used, and acquiring information of the USB recording equipment to be used from the system;
recording: and running the recording APP, and calling the USB recording equipment to be used according to the information of the USB recording equipment to be used to realize recording.
Further, still include: an equipment acquisition step: the method comprises the steps of obtaining information of USB recording equipment mounted on each USB interface of all-in-one equipment, obtaining corresponding Card ID, Card Name and connection state according to the information of each USB recording equipment, and storing each USB recording equipment in a custom equipment management list in a system according to priority.
Further, switching the USB interface of the all-in-one machine device to the second channel in the first switching step includes switching the USB interface to the second channel through a USB Switch;
switching the associated USB interface to the channel to which the recording application APP belongs in the second switching step specifically includes: and acquiring the associated USB Switch according to the associated USB interface, and switching the associated USB interface to the channel to which the recording application APP belongs through the associated USB Switch.
Further, the recording step further comprises: and (3) a recovery step: and after the recording is finished, switching the associated USB interface to the second channel by controlling the associated USB Switch, thereby recovering the USB recording equipment which can be identified by the system under the second channel.
Further, the first channel is an Android channel, and the second channel is any one of an OPS channel, a Type-C channel and an HDMI channel.
Further, the recording step further comprises: and resetting the data stream according to the USB recording equipment to be used to the Audio Record interface, and uploading the recording data to the application APP.
Further, the recording step further comprises: and calling an Audio Record interface to create a process, and acquiring recorded data from the corresponding sound card equipment according to the thread and returning the recorded data to the application APP.
Further, the device selecting step further comprises: and acquiring the equipment information input by the user to obtain the USB recording equipment to be used from the associated USB recording equipment.
The above embodiments are only preferred embodiments of the present invention, and the protection scope of the present invention is not limited thereby, and any insubstantial changes and substitutions made by those skilled in the art based on the present invention are within the protection scope of the present invention.