Peripheral device allocation method and related apparatus, device and storage medium
By creating a resource domain in the user space of the terminal device and binding it with an audio peripheral identifier, the problem of audio interference when multiple users use the device simultaneously is solved, the directional routing of audio streams is realized, and the independence of users is improved.
Patent Information
- Application Number
- CN202611294656.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-25
- Publication Date
- 2026-11-24
AI Technical Summary
In scenarios where a device is used for multiple purposes, existing technologies cannot eliminate audio interference when multiple users use it independently at the same time, leading to audio interference problems between users.
By triggering configuration commands in the user space of the terminal device, a resource domain associated with the user space is created and the peripheral identifier of the audio peripheral is bound. Combined with the process set, the target program and space are selected in response to the audio commands of the application, the target peripheral is determined, and a three-level mapping relationship is formed to realize the directional routing of the audio stream.
When multiple users use it at the same time, it effectively eliminates audio interference, enhances the independence of each user, ensures that the audio stream is directed to the corresponding audio peripheral, and avoids interference.
Smart Images

Figure CN123157285A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of application technology, and in particular to a peripheral allocation method and related apparatus, devices and storage media. Background Technology
[0002] In real-world scenarios, devices such as tablets may serve multiple purposes. For example, at 7 p.m., during study time, a 10-year-old girl might need to practice English listening and repeat after the teacher, while her 6-year-old brother might want to listen to a story.
[0003] Currently, in practical scenarios where a single device is used for multiple purposes, to avoid interference and conflicts, it can usually only be used in shifts, meaning that multiple users cannot use it independently at the same time. Therefore, how to minimize audio interference between users when using the device simultaneously and improve the independence of each user's use in such scenarios has become an urgent problem to be solved. Summary of the Invention
[0004] The main technical problem addressed by this application is to provide a peripheral allocation method and related devices, equipment and media that can minimize audio interference between users when using the device simultaneously in multi-user scenarios, thereby improving the independence of each user when using the device simultaneously.
[0005] To address the aforementioned technical problems, a first aspect of this application provides a peripheral allocation method, comprising: creating a resource domain associated with the user space and binding a peripheral identifier of an audio peripheral in the resource domain based on a configuration instruction triggered in the user space of a terminal device; wherein the configuration instruction includes the peripheral identifier of the audio peripheral, and a process set is defined in the resource domain; binding the process identifier of an application to the process set in the resource domain associated with the user space based on a startup instruction of an application in the user space of the terminal device; responding to an audio instruction from an application in the user space, selecting the application that issued the audio instruction as the target program, selecting the user space where the target program resides as the target space, and querying the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio instruction; wherein the audio instruction is a playback instruction and / or a recording instruction.
[0006] To address the aforementioned technical problems, a second aspect of this application provides a peripheral allocation device, comprising: an initial creation module, a process binding module, and a peripheral distribution module. The initial creation module is configured to create a resource domain associated with the user space and bind a peripheral identifier of an audio peripheral to the resource domain based on a configuration instruction triggered in the user space of a terminal device; wherein the configuration instruction includes the peripheral identifier of the audio peripheral, and a process set is defined in the resource domain. The process binding module is configured to bind the process identifier of an application to the process set in the resource domain associated with the user space based on a startup instruction of an application in the user space of the terminal device. The peripheral distribution module is configured to, in response to an audio instruction from an application in the user space, select the application that issued the audio instruction as the target program, select the user space where the target program resides as the target space, and query the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio instruction; wherein the audio instruction is a playback instruction and / or a recording instruction.
[0007] To address the aforementioned technical problems, a third aspect of this application provides a computer device, including a communication circuit, a memory, and a processor. The communication circuit and the memory are respectively coupled to the processor. The communication circuit is used for communication with audio peripherals. The memory stores at least program instructions, and the processor is used to execute the program instructions to implement the peripheral allocation method in the first aspect.
[0008] To address the aforementioned technical problems, a fourth aspect of this application provides a computer-readable storage medium storing program instructions executable by a processor, the program instructions being used to implement the peripheral allocation method of the first aspect described above.
[0009] The above scheme, based on configuration instructions triggered in the user space of the terminal device, creates a resource domain associated with the user space and binds a peripheral identifier of the audio peripheral to the resource domain. The configuration instructions include the peripheral identifier of the audio peripheral, and the resource domain defines a set of processes. Then, based on the application's startup instructions in the user space of the terminal device, it binds the application's process identifier to the process set in the resource domain associated with the user space. In response to audio instructions from the application in the user space, it selects the application that issued the audio instruction as the target program, selects the user space where the target program resides as the target space, and queries the resource domain associated with the target space based on the target program's process identifier. The system identifies the target peripheral for executing audio commands, where the audio commands are playback and / or recording commands. When a configuration command is triggered in the user space of the terminal device, a resource domain associated with the user space is created, and the peripheral identifier of the audio peripheral is bound to this resource domain. Subsequently, the process identifier of the application is bound to the process set within the resource domain. This forms a three-level mapping relationship of "process identifier," "resource domain," and "peripheral identifier." Based on this, the system can respond to audio command queries from any application in any user space to determine the target peripheral for executing the audio command. This allows the audio stream from any application in any user space to be directed to the audio peripheral associated with the corresponding user space. Therefore, in real-world scenarios where multiple users operate a single device, this approach minimizes audio interference when multiple users are using the device simultaneously, enhancing the independence of each user's audio usage. Attached Figure Description
[0010] Figure 1 This is a flowchart illustrating an embodiment of the peripheral allocation method of this application; Figure 2 This is a schematic diagram of a process of one embodiment of the peripheral allocation method of this application; Figure 3a This is a schematic diagram of the framework of an embodiment of the audio isolation system of this application; Figure 3b This is a timing diagram of an embodiment where the audio command in this application is a playback command; Figure 3c This is a timing diagram of an embodiment where the audio command in this application is a recording command; Figure 4 This is a schematic diagram of the framework of an embodiment of the peripheral distribution device of this application; Figure 5 This is a schematic diagram of the framework of an embodiment of the computer device of this application; Figure 6 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0011] The embodiments of this application will now be described in detail with reference to the accompanying drawings.
[0012] In the following description, specific details such as particular system architectures, interfaces, and technologies are presented for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of this application.
[0013] In this paper, the terms "system" and "network" are often used interchangeably. The term "and / or" describes the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, or B alone. Additionally, the slash " / " generally indicates that the preceding and following related objects have an "or" relationship. Furthermore, "many" in this paper indicates two or more objects.
[0014] Please refer to the following: Figure 1 and Figure 2 , Figure 1 This is a flowchart illustrating an embodiment of the peripheral allocation method of this application. Figure 2 This is a schematic diagram illustrating a process of one embodiment of the peripheral allocation method of this application. It should be noted that the process operations in this embodiment can be executed by an electronic device with computing capabilities or related devices containing electronic devices. For example, the process operations in this embodiment can be executed by a terminal device (e.g., a mobile phone, tablet computer, learning machine, etc.). The specific structure and type of the electronic device and related devices containing electronic devices are not limited here. Specifically, the embodiments of this disclosure may include the following steps: Step S11: Based on the configuration instructions triggered in the user space of the terminal device, create a resource domain associated with the user space and bind the peripheral identifier of the audio peripheral in the resource domain.
[0015] In this embodiment, the configuration instruction may include the peripheral identifier of the audio peripheral, and a process set may be defined in the resource domain. For ease of description, the process set can be denoted as pidList. It should be noted that one user can correspond to one resource domain, and the resource domain can be a system abstraction layer that binds the user's dedicated audio peripheral. Moreover, the resource domain can be independent of the user system of the terminal device (e.g., the Android User system). Various resource domains associated with different user spaces can run concurrently under the same system user (e.g., Android User).
[0016] In one implementation scenario, the terminal device may include, but is not limited to, tablet computers, learning machines, smartphones, etc., without specifying the specific type of terminal device.
[0017] In one implementation scenario, a user space is an operating environment unique to each user. Different users can use different user spaces. For example, separate user spaces can be pre-configured on the terminal device for different users (e.g., each can be considered an independent "sandbox" for application execution). For instance, three user spaces can be configured on the terminal device, each belonging exclusively to user A, user B, and user C. It should be noted that the applications running in different user spaces can be the same, different, or partially the same and partially different; this is not limited here.
[0018] In one implementation scenario, configuration commands can be triggered by clicking on the user interface of the terminal device or by voice; there is no specific limitation. It should be noted that configuration commands are used to configure the resource domain corresponding to the user space and bind audio peripherals.
[0019] In one implementation scenario, audio peripherals may include, but are not limited to: headphones for audio output, headsets for audio input and output, microphones for audio input, etc., without specifying the specific type of audio peripheral. Furthermore, the communication connection between the audio peripheral and the terminal device can be achieved through either wired communication (e.g., a 3.5mm jack) or wireless communication (e.g., Bluetooth), without specifying the connection method between the audio peripheral and the terminal device.
[0020] In one implementation scenario, in addition to defining process sets, resource domains can also define user space identifiers. Before binding process identifiers, the space identifiers corresponding to the resource domains to which the process identifier should be bound can be read in the following priority order: first, the space identifiers bound to the UI (User Interface) container that started the current process (e.g., including but not limited to split-screen windows, floating windows, independent screen areas, etc.) are read; second, the space identifiers corresponding to the resource domains of the parent process of the current process are read; and lastly, the space identifiers corresponding to the default resource domains are read. It should be noted that the default resource domain can be configured to use the system global audio route. For ease of description, the space identifier can be denoted as SpaceID.
[0021] In one implementation scenario, the resource domain can also define a first field, which can store the peripheral identifier of the audio peripheral used for audio output, used to determine the target peripheral when the audio command is a playback command. For ease of description, the first field can be denoted as AudioDeviceInfo outDevice.
[0022] In one implementation scenario, the resource domain can also define a second field. This second field stores the peripheral identifier of the audio peripheral used for audio input, which is used to determine the target peripheral when the audio command is a recording command. For ease of description, the second field can be denoted as AudioDeviceInfo inDevice.
[0023] In one implementation scenario, a resource domain can also define a third field, which can store a status identifier representing the current state of the resource domain (e.g., running, hibernating, destroyed, etc.). For ease of description, the third field can be denoted as "status".
[0024] In one implementation scenario, a resource domain can be represented by the following data structure: ResourceDomain { int domainID; int SpaceID; List <int>pidList; AudioDeviceInfo outDevice; AudioDeviceInfo in Device; FocusStack focusStack; int status; } It should be noted that in the above resource domain data structure, domainID represents the identifier of the resource domain, and FocusStack represents the domain-independent audio focus stack. Audio focus represents the "independent playback token" issued by the system to the application, and its core purpose is to ensure that only a "limited number" of applications (e.g., one in the Android system) are playing at the same time.
[0025] In one implementation scenario, please refer to the following: Figure 2 and Figure 3a , Figure 3a This is a schematic diagram of the framework of an embodiment of the audio isolation system of this application. Figure 2 and Figure 3a Taking the Android system as an example, when the configuration command represents configuring a user space for child A and binding Bluetooth headset A, the following can be executed: ResourceDomainManager.createDomain(SpaceID=1,outDevice=Bluetooth headset A, inDevice=null), which generates a resource domain: Domain 101{SpaceID=1,outDevice=Bluetooth headset A,pidList=[]}. It should be noted that ResourceDomainManager represents the resource domain manager, which is added to the original system of the terminal device in this embodiment (that is, it does not change the existing framework of the original system, but only adds to the original system, and does not change the original running logic of the original system; for details, please refer to the following related descriptions). It is mainly responsible for creation, destruction, and registry maintenance. createDomain represents the domain creation function defined in the resource domain manager, which is used to create resource domains. It contains three input parameters (i.e., SpaceID, outDevice, and inDevice). In addition, the resource domain manager can define other functions, such as the bindProcess(PID, SpaceID) function for binding processes, the getDomainbyPid(PID) function for querying the resource domain bound to a process, and the function for maintaining the global registry map.<PID,DomainID> This refers to the mapping relationship between processes and their bound resource domains. In addition to the native system, other modules can be added, such as the AudioRouteManager, which is mainly responsible for intercepting playback / recording, matching processes to domains, and automatically routing to bound devices (e.g., calling the preference specification function setPreferredDevice(domain.outDevice) to set audio playback through the output device defined in the resource domain). Another example is the DomainFocusManager, which is mainly responsible for focus management. For details, please refer to the relevant descriptions later. It will not be elaborated here.
[0026] Step S12: Based on the application's startup command in the user space of the terminal device, bind the application's process identifier within the process set in the resource domain associated with the user space.
[0027] In one implementation scenario, when an application is launched in user space, its process ID can be bound to the process set within the resource domain associated with user space. For example, referring to the aforementioned resource domain data structure, the process ID of the application that triggered the launch command can be updated in the `pidList` field of that data structure.
[0028] In one implementation scenario, please continue to refer to [the relevant documentation]. Figure 2 and Figure 3a Taking the native Android system as an example, when application B in the aforementioned user space 1 (i.e., SpaceID=1) of the terminal device triggers a startup command, the native system can execute AMS.startActivity(intent), from which SpaceID=1 can be extracted, thus determining that it is an application in user space 1 that triggered the startup command. It should be noted that AMS (Activity Manager Service) is a core service of the Android system, responsible for managing the startup, switching, and lifecycle of the four major components: Activity, Service, BroadcastReceiver, and ContentProvider. startActivity(intent) represents the intent to start a new Activity page. Based on this, the native system can create a process PID=1234, at which point it can trigger the execution of: ResourceDomainManager.bindProcess(1234, SpaceID=1), which will update PID=1234 to the resource domain Domain101 associated with the user space of SpaceID=1. At this time, Domain 101{pidList=
[1234] }, that is, a mapping can be established from PID 1234 to Domain 101. It should be noted that bindProcess represents the process binding function defined in the resource domain manager, which is used to bind a process to a resource domain associated with a certain user space. It can contain two input parameters (i.e., PID and SpaceID).
[0029] Step S13: In response to an audio command from an application in user space, select the application that issued the audio command as the target program, select the user space where the target program is located as the target space, and query the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio command.
[0030] In this embodiment, the audio command can be a playback command and / or a recording command. In practical applications, if only one application in a user space issues an audio command, the application issuing the audio command can be selected as the target program, and one of the user spaces (i.e., the user space where the target program resides) can be selected as the target space; alternatively, if multiple applications in multiple user spaces issue audio commands, each application issuing the audio command can be selected as the target program, and multiple user spaces (i.e., the user spaces where each target program resides) can be selected as the target space, without limitation. Of course, when multiple user spaces are selected as target spaces, since the audio command is routed through a resource domain (i.e., the audio stream of the audio command is routed to the target peripheral), audio interference when multiple users use the device simultaneously can be minimized, improving the independence of simultaneous use by each user. Furthermore, after determining the target peripheral for executing the audio command, a data channel can be established between the program process of the target application and the target peripheral for audio playback and / or audio acquisition.
[0031] In one implementation scenario, as one possible example, an audio command for any target program can be a play command (e.g., in listening software, clicking on a listening passage triggers a play command); as another possible example, an audio command for any target program can also be a recording command (e.g., in dubbing software, a recording command can be triggered to meet the dubbing needs of a particular line); as yet another possible example, an audio command for any target program can also include both play and recording commands (e.g., in spoken dialogue software, both play and recording commands can be triggered simultaneously to meet the needs of spoken dialogue with an online teacher or robot). It should be noted that the above examples are merely a few possible examples of audio commands in practical applications; other possible scenarios are not limited here, nor will they be listed in detail.
[0032] In one implementation scenario, when different applications in different user spaces issue audio commands, for any given audio command, the steps of selecting the application that issued the audio command as the target program and selecting the user space where the target program resides as the target space can be executed. It should be noted that different applications in different user spaces can issue audio commands separately, or the same application in different user spaces (e.g., applications with the same name released by the same vendor) can issue audio commands separately; there is no limitation on the application from which each audio command originates. Furthermore, the timing of the issuance of each audio command can be the same (i.e., simultaneously or almost simultaneously), or sequentially; there is no limitation on the timing of the issuance of each audio command. In addition, the command types of each audio command can be the same (e.g., all are play commands, or all are record commands), or the command types of each audio command can be different (e.g., one or some are play commands, others are record commands). Based on this, for any audio command and the target program and target peripheral associated with the audio command, the step of querying the resource domain associated with the target space based on the process identifier of the target program can be executed to determine the target peripheral for executing the audio command. For ease of description, let's take two user spaces as an example. In user space A, application A issues an audio command (labeled 01 for distinction), and in user space B, application B also issues an audio command (labeled 02 for distinction). For audio command "01", application A, which issued the command, can be selected as a target program, and user space A, where this target program resides, can be selected as a target space. Similarly, for audio command "02", application B, which issued the command, can be selected as another target program, and user space B, where this target program resides, can be selected as another target space. Based on this, for audio instruction "01" and the target program (i.e., application A) and target space (i.e., user space A) associated with audio instruction "01", a step can be performed to query the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio instruction (e.g., determining that the target peripheral for executing audio instruction "01" is "Bluetooth headset C"). Similarly, for audio instruction "02" and the target program (i.e., application B) and target space (i.e., user space B) associated with audio instruction "02", a step can be performed to query the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio instruction (e.g., determining that the target peripheral for executing audio instruction "02" is "Bluetooth headset D").Therefore, when using the process described in this embodiment, the audio interference between users simultaneously can be minimized in "one device for multiple uses" scenarios, thus improving the independence of each user's simultaneous use. It should be noted that for any audio command, determining the target peripheral for executing the audio command means that the audio stream of this audio command will subsequently be routed to the target peripheral. Taking the aforementioned example, for audio command "01", the audio stream of audio command "01" can be routed to the target peripheral "Bluetooth headset C", and for audio command "02", the audio stream of audio command "02" can be routed to the target peripheral "Bluetooth headset D".
[0033] In one implementation scenario, as mentioned earlier, the terminal device can add an audio routing manager (e.g., the aforementioned AudioRouteManager) and a resource domain manager (e.g., ResourceDomainManager) on top of the native system. Based on this, the two can cooperate to determine the target peripheral. For example, the native system's audio service can generate a channel creation function in response to an audio command. This channel creation function can contain the process identifier of the target program, used to create a transmission channel between the target program and the audio peripheral. Based on this, the audio routing manager can intercept the channel creation function, read the process identifier from the function as the query identifier, and send an information query request to the resource domain manager. This information query request contains the query identifier. Based on this, the resource domain manager can query the peripheral identifier bound to the resource domain of the query identifier as the target identifier and return the target identifier to the audio routing manager. Further, the audio routing manager can return the target identifier to the native system's audio service. Based on this, the native system's audio service can send a preference specification function containing the target identifier to the audio peripheral corresponding to the target identifier. Therefore, it can be seen that by adding an audio route manager and a resource domain manager on the basis of the native system, and the two working together through the above process to determine the target peripheral, the underlying framework of the native system is not changed (e.g., the audio service still generates channel creation functions and still sends preference specification functions containing target identifiers). Furthermore, there is no need to change the underlying code of the application, so that the new module can transparently take over the decision-making power of audio devices without the application being aware of it.
[0034] In one implementation scenario, please refer to the following: Figure 3b , Figure 3b This is a timing diagram of an embodiment where the audio command in this application is a playback command. Figure 3b As shown, when the native system is Android and the audio command is a playback command, the Android system's AudioService service can respond to playback commands (e.g., Figure 3b The `createAudioTrack()` function is generated from the `MediaPlayer.start()` function (the specific meaning of which can be found in the relevant technical details of the Android system). The `createAudioTrack()` function contains the process identifier of the target program (e.g., PID 1234) and is used to create a transmission channel between the target program and the audio peripheral. The audio routing manager can intercept the `createAudioTrack()` function and read the process identifier in the `createAudioTrack()` function as the query identifier (e.g., PID 1234). It can also send information query requests to the resource domain manager, and the information query request can contain the query identifier (e.g., PID 1234). The resource domain manager can query the resource domain bound to the query identifier (e.g., PID 1234). For example, the resource domain can be obtained by querying the built-in function `getDomainbyPid(1234)`. The peripheral identifier bound in 101) serves as the target identifier (e.g., outDevice=Bluetooth Headset A), and can be fed back to the audio routing manager; the audio routing manager can feed back the target identifier to the native system's audio service; the native system's audio service can send the audioTrack.setPreferredDevice() function containing the target identifier (e.g., Bluetooth Headset A) to the audio peripheral corresponding to the target identifier (e.g., Bluetooth Headset A). In this way, the playback command of the target application in the target space can be directed to the audio peripheral specified by the resource domain associated with the target space, which helps to avoid interference between the audio played by other users as much as possible during the audio playback process.
[0035] In a specific implementation scenario, AMS can also intercept system calls such as startActivity, startService (i.e., starting a service, mainly used to execute one-time or continuous background tasks), and bindService (i.e., binding a service, mainly used for bidirectional data interaction with the Service) during this process. The new process can automatically inherit the resource domain ownership of the parent process. In other words, the audio binding relationship is not lost due to application page navigation, service startup, or cross-application calls.
[0036] In a specific implementation scenario, when the target peripheral device is disconnected, all audio in the resource domain bound to it can be paused. After the target device is reconnected, the routing can be restored, and then all audio in the resource domain bound to it can be replayed.
[0037] In a specific implementation scenario, as mentioned above, after querying the resource domain bound to the query identifier "PID=1234" as "Domain=101" based on the aforementioned operation, the peripheral identifier "outDevice=Bluetooth Headset A" of the audio peripheral (output peripheral) bound in this resource domain "Domain=101" can be used as the target identifier. Then, the audio stream played by the program process "PID=1234" can be played through the audio peripheral of the target identifier "outDevice=Bluetooth Headset A". Based on this, if the target application is subsequently redirected or otherwise manipulated in this user space, causing the query identifier to change to "PID=1235", since its parent process is "PID=1234", it can automatically inherit the resource domain "Domain 101" of the aforementioned program process "PID=1234" (i.e., the process set pidList in resource domain "Domain 101" is [1234, 1235]). Therefore, the peripheral identifier "outDevice=Bluetooth Headset A" of the audio peripheral (output peripheral) bound in this resource domain "Domain=101" can still be used as the target identifier. Then, the audio stream played by the program process "PID=1235" will be played through the audio peripheral of the target identifier "outDevice=Bluetooth Headset A". Unlike the previous scenario, if an application is subsequently opened in another user space, and its query identifier is "PID=5678", and its bound resource domain is "Domain102" (i.e., the process set pidList in resource domain "Domain 102" is
[5678] ), the peripheral identifier "outDevice=Bluetooth Headset B" of the audio peripheral (output peripheral) bound to this resource domain can be used as the target identifier. Then, the audio stream from process "PID=5678" can be played through the audio peripheral of the target identifier "outDevice=Bluetooth Headset B". Therefore, there is no interference between the two users during audio playback. Of course, the above example is only one possible case where the audio command is a playback command in practical applications. Other possible scenarios are not limited here, nor will they be listed in detail.
[0038] In one implementation scenario, please refer to the following: Figure 3c , Figure 3c This is a timing diagram of an embodiment where the audio command in this application is a recording command. Figure 3c As shown, when the native system is Android and the audio command is a recording command, the Android system's AudioService service can respond to the recording command (e.g., Figure 3c The `AudioRecord.startRecording()` function generates the `createAudioRecord()` function (the specific meaning of which can be found in the relevant technical details of the Android system). The `createAudioRecord()` function can contain the process identifier of the target program (e.g., PID 1234) and is used to create a transmission channel between the target program and the audio peripheral. The audio routing manager can intercept the `createAudioRecord()` function and read the process identifier in the `createAudioRecord()` function as the query identifier (e.g., PID 1234). It can also send information query requests to the resource domain manager, and the information query request can contain the query identifier (e.g., PID 1234). The resource domain manager can query the resource domain bound to the query identifier (e.g., PID 1234). For example, the resource domain can be obtained by querying the domain using the built-in function `getDomainbyPid(1234)`. The peripheral identifier bound in 101) serves as the target identifier (e.g., inDevice=USB microphone A), and can be fed back to the audio routing manager; the audio routing manager can feed back the target identifier to the native system's audio service; the native system's audio service can send the audioRecord.setPreferredDevice() function containing the target identifier (e.g., USB microphone A) to the audio peripheral corresponding to the target identifier (e.g., USB microphone A). In this way, the recording command of the target application in the target space can be directed to the audio peripheral specified by the resource domain associated with the target space, which helps to avoid interference between the audio collected by other users as much as possible during the audio acquisition process.
[0039] In a specific implementation scenario, similar to the aforementioned audio commands being playback commands, AMS can also intercept system calls such as startActivity, startService (i.e., starting a service, mainly used to execute one-time or continuous background tasks), and bindService (i.e., binding a service, mainly used for bidirectional data interaction with the Service) during this process. The new process can automatically inherit the resource domain ownership of the parent process. In other words, the audio binding relationship is not lost due to application page navigation, service startup, or cross-application calls. In addition, when the target peripheral device is disconnected, all audio in the resource domain bound to it can be paused. After the target device is reconnected, the routing can be restored, and at this time, all audio in the resource domain bound to it can be re-captured.
[0040] In a specific implementation scenario, as mentioned earlier, after querying the resource domain bound to the query identifier "PID=1234" as "Domain=101" based on the aforementioned operations, the peripheral identifier "inDevice=USBMicrophoneA" of the audio peripheral (input peripheral) bound to this resource domain "Domain=101" can be used as the target identifier. Then, the program process "PID=1234" can capture audio streams through "USB MicrophoneA". Furthermore, if another user subsequently triggers a target program to capture audio in their dedicated user space, they can query based on their query identifier (PID=5678) to determine the resource domain bound to it, "Domain 102". The peripheral identifier "inDevice=USBMicrophoneB" of the audio peripheral (input peripheral) bound to this resource domain can be used as the target identifier. Then, the program process "PID=5678" can capture audio streams through "USB MicrophoneB". Therefore, it is evident that there is no interference between the two users during the audio capture process. Of course, the above example is only one possible case where the audio command is a recording command in actual application. Other possible cases are not limited here, nor will they be listed one by one.
[0041] The above scheme, based on configuration instructions triggered in the user space of the terminal device, creates a resource domain associated with the user space and binds a peripheral identifier of the audio peripheral to the resource domain. The configuration instructions include the peripheral identifier of the audio peripheral, and the resource domain defines a set of processes. Then, based on the application's startup instructions in the user space of the terminal device, it binds the application's process identifier to the process set in the resource domain associated with the user space. In response to audio instructions from the application in the user space, it selects the application that issued the audio instruction as the target program, selects the user space where the target program resides as the target space, and queries the resource domain associated with the target space based on the target program's process identifier. The system identifies the target peripheral for executing audio commands, where the audio commands are playback and / or recording commands. When a configuration command is triggered in the user space of the terminal device, a resource domain associated with the user space is created, and the peripheral identifier of the audio peripheral is bound to this resource domain. Subsequently, the process identifier of the application is bound to the process set within the resource domain. This forms a three-level mapping relationship between "process identifier," "resource domain," and "peripheral identifier." Based on this, the system can respond to audio command queries from any application in any user space to determine the target peripheral for executing the audio command. This allows the audio stream from any application in any user space to be directed to the audio peripheral associated with the corresponding user space. Therefore, in multi-user scenarios, this approach minimizes audio interference when multiple users are using the device simultaneously, enhancing the independence of each user's audio usage.
[0042] In some disclosed embodiments, in response to a focus request from any application in any user space, the resource domain to which the application issuing the focus request belongs can be determined as the target domain. Within the target domain, the native focus defined by the terminal device's native system is executed. In resource domains outside the target domain, it is determined whether to preempt based on the focus level of the focus request. It should be noted that the implementation logic of native focus can be found in the technical details of media focus control in native systems such as Android, and will not be elaborated here. This method executes native focus within a resource domain, and determines whether to preempt based on the focus level of the focus request when crossing resource domains. Compared to global native focus, it can perceive resource domains during media focus control.
[0043] In a specific implementation scenario, please refer to Table 1, which is a schematic table of an embodiment of media focus control in this application. As shown in Table 1, when the native system is an Android system, the focus request can be detected as AUDIOFOCUS_GAIN, AUDIOFOCUS_GAIN_TRANSIENT, or AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE. In response to the focus request being either AUDIOFOCUS_GAIN or AUDIOFOCUS_GAIN_TRANSIENT, it can be determined that no preemption will occur in any resource domain outside the target domain. Conversely, in response to the focus request being AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE, it can be determined that global preemption will occur in any resource domain outside the target domain. It should be noted that AUDIOFOCUS_GAIN, AUDIOFOCUS_GAIN_TRANSIENT, and AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE are all audio focus mechanisms in the Android system. The main difference lies in the expected time occupied and whether other applications are allowed to continue speaking. The first indicates long-term exclusive use, the second indicates short-term exclusive use, and the third indicates short-term exclusive use and exclusion of other applications. For details, please refer to the technical details of these three in the Android system, which will not be elaborated here.
[0044] Table 1. Schematic diagram of an embodiment of media focus control in this application.
[0045] Therefore, when the focus request is either AUDIOFOCUS_GAIN or AUDIOFOCUS_GAIN_TRANSIENT, all resource domains outside the target domain do not need to preempt. That is, if an application is playing audio and / or capturing audio in the user space associated with a resource domain outside the target domain, it will not be paused. Conversely, when the focus request is AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE, global preemption occurs in all resource domains outside the target domain. That is, if an application is playing audio and / or capturing audio in the user space associated with a resource domain outside the target domain, all of them need to be paused.
[0046] In a specific implementation scenario, please refer to the relevant documents. Figure 3a As mentioned earlier, terminal devices can add a domain focus manager on top of the native system. The domain focus manager can operate on resource domains outside the target domain. That is, within the target domain, it can be controlled by the native focus of the native system, while in resource domains outside the target domain, it can be controlled by the domain focus manager. It should be noted that the control logic of the domain focus manager can be referred to Table 1 above and its related text description, and will not be repeated here.
[0047] In some disclosed embodiments, in response to a reconfiguration command triggered in any user space of the terminal device, a new peripheral identifier can be rebound in the resource domain associated with the corresponding user space. The reconfiguration command may include a new peripheral identifier, which belongs to a newly replaced audio peripheral. It should be noted that the specific rebinding process can be found in the descriptions of peripheral identifier binding in the aforementioned disclosed embodiments, and will not be repeated here. Furthermore, when rebinding a new peripheral identifier, the original peripheral identifier can be replaced by an overwrite operation. For example, if the original peripheral identifier is "USB microphone A" and the new peripheral identifier is "USB microphone B", then after rebinding, the data structure of the resource domain is updated from "AudioDeviceInfo inDevice=USB microphone A" to "AudioDeviceInfo inDevice=USB microphone B".
[0048] In some disclosed embodiments, please refer to the following references. Figure 2 When all applications in the user space associated with the resource domain are shut down, the status flag of the resource domain (e.g., the data structure "status" in the aforementioned disclosed embodiment) can be updated to "hibernate". However, at this time, fields such as SpaceID, outDevice, and inDevice in the resource domain can be retained (i.e., these fields can be persisted), and the process set pidList (i.e., pidList=[]) can be cleared. When any application in the user space associated with the resource domain starts here, the resource domain can be automatically reused, and the status flag of the resource domain can be updated to "running", and the process flag of the newly started application can be bound to the process set pidList (i.e., pidList=[new PID]).
[0049] In some disclosed embodiments, to facilitate understanding of the technical solutions of the above-disclosed embodiments of this application, the following example illustrates a possible scenario in a practical application: two children want to use a terminal device simultaneously, one to listen to English listening exercises and the other to listen to music. Based on the technical solutions of the above-disclosed embodiments of this application, a user space and associated resource domain can be configured for one child, and an audio peripheral "Bluetooth Headset A" (e.g., SpaceID=1, Domain 101) can be bound. A user space and associated resource domain can be configured for the other child, and an audio peripheral "USB Headset B" (e.g., SpaceID=2, Domain 102) can be bound. When the English listening application is launched in the UI container of the first child's user space (i.e., SpaceID=1), the AMS can bind its process ID (e.g., PID=1234) to the process set of its resource domain (i.e., Domain 101). When the music listening application is launched in the UI container of the second child's user space (i.e., SpaceID=2), the AMS can bind its process ID (e.g., PID=5678) to the process set of its resource domain (i.e., Domain 102). Based on this, since the English listening application can establish a data channel with Bluetooth headset A based on the mapping relationship between its process ID (PID=1234), the resource domain (Domain 101) bound to this process ID, and the audio peripheral (Bluetooth headset A) bound to this resource domain, the audio stream from the English listening application can then be played directly through this data channel by Bluetooth headset A. Similarly, since the music listening application can establish a data channel with USB headset B based on the mapping relationship between its process ID (PID=5678), the resource domain (Domain 102) bound to this process ID, and the audio peripheral (USB headset B) bound to this resource domain, the audio stream from the music listening application can then be played directly through this data channel by USB headset B. In this way, two children can simultaneously listen to English and music on the same terminal device without interference, and since the resource domain is decoupled from the account system (e.g., the Android User system), there is no need to switch accounts. In addition, when a focus request AUDIOFOCUS_GAIN is issued in the user space associated with the first resource domain (Domain 101), it can be granted directly. When a focus request AUDIOFOCUS_GAIN is also issued in the user space associated with the second resource domain (Domain 102), according to the aforementioned description of media focus control, it can also be held concurrently without preemption.
[0050] In some disclosed embodiments, to facilitate understanding of the technical solutions of the above-disclosed embodiments of this application, the following example illustrates another possible scenario in practical application: two children want to use a terminal device simultaneously, one for English reading aloud recording and the other for listening to musical stories. Based on the technical solutions of the above-disclosed embodiments of this application, a user space and associated resource domain can be configured for one child, and an output peripheral "USB headset A" and an input peripheral "USB microphone A" can be bound (e.g., SpaceID=1, Domain 101). A user space and associated resource domain can be configured for the other child, and an output peripheral "Bluetooth headset B" and an input peripheral "null" can be bound (e.g., SpaceID=2, Domain 102). When the English reading aloud recording application is launched in the UI container of the first child's user space (i.e., SpaceID=1), AMS can bind its process identifier (e.g., PID=1234) to its resource domain (i.e., Domain). The process set of 101, which launches the music story application in the UI container of the second child's user space (i.e., SpaceID=2), can bind its process ID (e.g., PID=5678) to the process set of its resource domain (i.e., Domain 102). Based on this, the English reading aloud recording application can establish a data output channel with USB headset A based on the mapping relationship between its process ID (PID=1234), the resource domain (Domain 101) bound to this process ID, the output peripheral (USB headset A) bound to this resource domain, and the input peripheral (USB microphone A) bound to this resource domain. Then, the audio stream from the English reading aloud recording application can be directly played by USB headset A through this data channel. Similarly, the music story listening application can establish a data channel with Bluetooth headset B based on the mapping relationship between its process ID (PID=5678), the resource domain (Domain 102) bound to this process ID, and the audio peripheral (Bluetooth headset B) bound to this resource domain. Then, the audio stream from the music story listening application can be directly played by Bluetooth headset B through this data channel. In this way, the first child's reading aloud recording only includes their own pronunciation and does not include the background music from the second child; the two audio streams and recordings are completely isolated.
[0051] It should be noted that the two examples above are merely two possible implementation examples in practical applications. Other possible scenarios are not limited here (e.g., three resource domains can be configured for three users and each bound to an audio peripheral), nor will they be listed one by one.
[0052] Please see Figure 4 , Figure 4 This is a schematic diagram of a framework of an embodiment of the peripheral allocation device of this application. The peripheral allocation device 40 includes: an initial creation module 41, a process binding module 42, and a peripheral distribution module 43. The initial creation module 41 is used to create a resource domain associated with the user space and bind the peripheral identifier of the audio peripheral in the resource domain based on a configuration instruction triggered in the user space of the terminal device; wherein, the configuration instruction includes the peripheral identifier of the audio peripheral, and a process set is defined in the resource domain; the process binding module 42 is used to bind the process identifier of the application in the process set in the resource domain associated with the user space based on the startup instruction of the application in the user space of the terminal device; the peripheral distribution module 43 is used to respond to the audio instruction of the application in the user space, select the application that issued the audio instruction as the target program, select the user space where the target program is located as the target space, and query the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio instruction; wherein, the audio instruction is a playback instruction and / or a recording instruction.
[0053] In the above scheme, the peripheral device allocation device 40 creates a resource domain associated with the user space and binds a peripheral identifier of the audio peripheral to the resource domain based on a configuration instruction triggered in the user space of the terminal device. The configuration instruction includes the peripheral identifier of the audio peripheral, and a process set is defined in the resource domain. Based on the application's startup instruction in the user space of the terminal device, the application's process identifier is bound to the process set in the resource domain associated with the user space. Then, in response to the audio instruction from the application in the user space, the application issuing the audio instruction is selected as the target program, and the user space where the target program resides is selected as the target space. Finally, based on the target program's process identifier, the process is allocated in the resource domain associated with the target space. The system queries the target peripheral for executing audio commands, which are either playback or recording commands. When a configuration command is triggered in the user space of the terminal device, a resource domain associated with the user space is created, and the peripheral identifier of the audio peripheral is bound to this resource domain. Subsequently, the process identifier of the application is bound to the process set within the resource domain. This forms a three-level mapping relationship between "process identifier," "resource domain," and "peripheral identifier." Based on this, the system can respond to audio commands from any application in any user space and determine the target peripheral for executing the audio command. This allows the audio stream from any application in any user space to be directed to the audio peripheral associated with the corresponding user space. Therefore, in real-world scenarios where multiple users use a single device, this approach minimizes audio interference when multiple users are using the device simultaneously, enhancing the independence of each user's audio usage.
[0054] In some disclosed embodiments, the terminal device adds an audio routing manager and a resource domain manager on top of the native system. The peripheral distribution module 43 includes a channel creation submodule, which is used by the native system's audio service to generate a channel creation function in response to an audio command. The channel creation function contains the process identifier of the target program and is used to create a transmission channel between the target program and the audio peripheral. The peripheral distribution module 43 includes an interception query submodule, which is used by the audio routing manager to intercept the channel creation function, read the process identifier in the channel creation function as the identifier to be queried, and send an information query request to the resource domain manager. The information query request contains the identifier to be queried. The peripheral distribution module 43 includes a query feedback submodule, which is used by the resource domain manager to query the peripheral identifier bound to the resource domain to which the identifier to be queried is bound as the target identifier and feeds back the target identifier to the audio routing manager. The peripheral distribution module 43 includes an identifier feedback submodule, which is used by the audio routing manager to feed back the target identifier to the audio service of the native system. The peripheral distribution module 43 includes a preference specification submodule, which is used by the native system's audio service to send a preference specification function containing the target identifier to the audio peripheral corresponding to the target identifier.
[0055] In some disclosed embodiments, when the native system is an Android system and the audio command is a playback command, the peripheral device routing module 43 is specifically used to execute: the Android system's AudioService service generates a createAudioTrack() function in response to the playback command; wherein, the createAudioTrack() function contains the process identifier of the target program, used to create a transmission channel between the target program and the audio peripheral; the audio routing manager intercepts the createAudioTrack() function, reads the process identifier in the createAudioTrack() function as the query identifier, and sends an information query request to the resource domain manager; wherein, the information query request contains the query identifier; the resource domain manager queries the peripheral identifier bound in the resource domain to which the query identifier is bound as the target identifier, and feeds back the target identifier to the audio routing manager; the audio routing manager feeds back the target identifier to the native system's audio service; the native system's audio service sends the audioTrack.setPreferredDevice() function containing the target identifier to the audio peripheral corresponding to the target identifier.
[0056] In some disclosed embodiments, when the native system is an Android system and the audio command is a recording command, the peripheral routing module 43 is specifically used to execute: the Android system's AudioService service generates a createAudioRecord() function in response to the recording command; wherein, the createAudioRecord() function contains the process identifier of the target program, used to create a transmission channel between the target program and the audio peripheral; the audio routing manager intercepts the createAudioRecord() function, reads the process identifier in the createAudioRecord() function as the identifier to be queried, and sends an information query request to the resource domain manager; wherein, the information query request contains the identifier to be queried; the resource domain manager queries the peripheral identifier bound in the resource domain to which the identifier to be queried is bound as the target identifier, and feeds back the target identifier to the audio routing manager; the audio routing manager feeds back the target identifier to the audio service of the native system; the audio service of the native system sends an audioRecord.setPreferredDevice() function containing the target identifier to the audio peripheral corresponding to the target identifier.
[0057] In some disclosed embodiments, the peripheral allocation device 40 includes a focus request module, which, in response to a focus request from any application in any user space, determines the resource domain to which the application issuing the focus request belongs, as the target domain; the peripheral allocation device 40 includes a preemption decision module, which executes the native focus defined by the native system of the terminal device within the target domain, and determines whether to preempt in each resource domain outside the target domain based on the focus level of the focus request.
[0058] In some disclosed embodiments, when the native system is an Android system, the preemption decision module includes a request detection submodule, used to detect that the focus request is AUDIOFOCUS_GAIN, AUDIOFOCUS_GAIN_TRANSIENT, or AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE; the preemption decision module includes a first response submodule, used to determine that no preemption will be performed in any resource domain outside the target domain in response to a focus request of AUDIOFOCUS_GAIN or AUDIOFOCUS_GAIN_TRANSIENT; the preemption decision module includes a second response submodule, used to determine that global preemption will be performed in all resource domains outside the target domain in response to a focus request of AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE.
[0059] In some publicly disclosed embodiments, the terminal device adds a domain focus manager on top of the native system. The domain focus manager operates on various resource domains outside the target domain.
[0060] In some disclosed embodiments, the peripheral allocation device 40 includes a reconfiguration module for rebinding a new peripheral identifier in the resource domain associated with the corresponding user space in response to a reconfiguration instruction triggered in any user space of the terminal device; wherein the reconfiguration instruction includes a new peripheral identifier, and the new peripheral identifier belongs to a newly replaced audio peripheral.
[0061] In some disclosed embodiments, when different applications in different user spaces issue audio commands, the peripheral device splitting module 43 is specifically configured to: for any audio command, execute the steps of selecting the application that issued the audio command as the target program and selecting the user space where the target program is located as the target space; for any audio command and the target program and target peripheral associated with the audio command, execute the steps of querying the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio command.
[0062] In some publicly available embodiments, different users use different user spaces.
[0063] In some disclosed embodiments, the resource domain also defines a space identifier for the user space. Before binding the process identifier, the space identifier corresponding to the resource domain to which the process identifier should be bound is read first according to the target priority order: the space identifier bound to the UI container that started the current process is read first, the space identifier corresponding to the resource domain to which the parent process of the current process belongs is read second, and the space identifier corresponding to the default resource domain is read last.
[0064] In some disclosed embodiments, the resource domain defines a first field that stores the peripheral identifier of the audio peripheral used for audio output, which is used to determine the target peripheral when the audio command is a playback command.
[0065] In some disclosed embodiments, the resource domain defines a second field that stores the peripheral identifier of the audio peripheral used for audio input, which is used to determine the target peripheral when the audio command is a recording command.
[0066] In some publicly available embodiments, the resource domain is defined with a third field, which stores a status identifier that represents the current state of the resource domain.
[0067] Please see Figure 5 , Figure 5 This is a schematic diagram of a framework of an embodiment of the computer device of this application. The computer device 50 includes a communication circuit 53, a memory 51, and a processor 52. The communication circuit 53 and the memory 51 are respectively coupled to the processor 52. The communication circuit 53 is used for communication connection with audio peripherals. The memory 51 stores at least program instructions. The processor 52 is used to execute the program instructions to implement the steps in any of the above-described peripheral allocation method embodiments. For details, please refer to the foregoing disclosed embodiments, which will not be repeated here. The computer device 50 can be an electronic device that executes computer program instructions. Exemplarily, the computer device 50 can include, but is not limited to, mobile phones, tablet computers, learning machines, etc., and the specific type of the computer device 50 is not limited here.
[0068] Specifically, processor 52 controls itself, as well as memory 51 and communication circuit 53, to implement the steps in any of the peripheral allocation method embodiments described above. Processor 52 can also be referred to as a CPU (Central Processing Unit). Processor 52 may be an integrated circuit chip with signal processing capabilities. Processor 52 can also be a general-purpose processor, digital signal processor (DSP), application-specific integrated circuit (ASIC), field-programmable gate array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. A general-purpose processor can be a microprocessor or any conventional processor. Furthermore, processor 52 can be implemented using integrated circuit chips.
[0069] In the above scheme, the computer device 50 implements the steps of any of the above peripheral allocation method embodiments. When a configuration instruction is triggered in the user space of the terminal device, a resource domain associated with the user space is created, and a peripheral identifier for the audio peripheral is bound to this resource domain. Subsequently, the process identifier of the application is bound to the process set within the resource domain. This forms a three-level mapping relationship of "process identifier," "resource domain," and "peripheral identifier." Based on this, in response to audio instruction queries from any application in any user space, the target peripheral for executing the audio instruction can be determined. Thus, the audio stream of any application in any user space can be directed to the audio peripheral associated with the corresponding user space. Therefore, in real-world scenarios where multiple users use the device simultaneously, audio interference can be minimized, improving the independence of each user's simultaneous use.
[0070] Please see Figure 6 , Figure 6 This is a schematic diagram of a framework of an embodiment of the computer-readable storage medium of this application. The computer-readable storage medium 60 stores program instructions 61 that can be executed by a processor. The program instructions 61 are used to implement the steps in any of the peripheral allocation method embodiments described above.
[0071] The above scheme, implemented by the computer-readable storage medium 60, achieves the steps in any of the peripheral allocation method embodiments described above. When a configuration instruction is triggered in the user space of the terminal device, a resource domain associated with the user space is created, and a peripheral identifier for the audio peripheral is bound to this resource domain. Subsequently, the process identifier of the application is bound to the process set within the resource domain. This forms a three-level mapping relationship of "process identifier," "resource domain," and "peripheral identifier." Based on this, in response to audio instruction queries from any application in any user space, the target peripheral for executing the audio instruction can be determined. Thus, the audio stream of any application in any user space can be directed to the audio peripheral associated with the corresponding user space. Therefore, in real-world scenarios where multiple users use a single device, audio interference when multiple users are using the device simultaneously can be minimized, improving the independence of each user's simultaneous use.
[0072] In some embodiments, the functions or modules of the apparatus provided in this disclosure can be used to perform the methods described in the above method embodiments. The specific implementation can be referred to the description of the above method embodiments, and for the sake of brevity, it will not be repeated here.
[0073] The description of the various embodiments above tends to emphasize the differences between the various embodiments. The similarities or similarities between them can be referred to, and for the sake of brevity, they will not be repeated here.
[0074] In the several embodiments provided in this application, it should be understood that the disclosed methods and apparatus can be implemented in other ways. For example, the apparatus implementations described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0075] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0076] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0077] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods of various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0078] If the technical solution of this application involves personal information, the product using this technical solution has clearly informed the user of the personal information processing rules and obtained the user's voluntary consent before processing the personal information. If the technical solution of this application involves sensitive personal information, the product using this technical solution has obtained the user's separate consent before processing the sensitive personal information, and also meets the requirement of "express consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set up to inform users that they have entered the scope of personal information collection and that personal information will be collected. If an individual voluntarily enters the collection scope, it is deemed that they have agreed to the collection of their personal information; or on the personal information processing device, the personal information processing rules are clearly informed through signs / information, and authorization is obtained through pop-up information or by asking the individual to upload their personal information; wherein, the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the types of personal information processed.< / int>
Claims
1. A peripheral device allocation method, characterized in that, include: Based on a configuration instruction triggered in the user space of a terminal device, a resource domain associated with the user space and a peripheral identifier of an audio peripheral bound in the resource domain are created; wherein, the configuration instruction includes the peripheral identifier of the audio peripheral, and a set of processes is defined in the resource domain; Based on the launch command of the application in the user space of the terminal device, the process identifier of the application is bound in the process set in the resource domain associated with the user space; In response to an audio command from the application in the user space, the application that issued the audio command is selected as the target program, and the user space where the target program resides is selected as the target space. Based on the process identifier of the target program, a query is performed in the resource domain associated with the target space to determine the target peripheral for executing the audio command; wherein the audio command is a playback command and / or a recording command.
2. The method according to claim 1, characterized in that, The terminal device adds an audio routing manager and a resource domain manager to the native system. The process identifier of the target program is used to query the resource domain associated with the target space to determine the target peripheral device for executing the audio instructions, including: The native system's audio service generates a channel creation function in response to the audio command; wherein, the channel creation function contains the process identifier of the target program and is used to create a transmission channel between the target program and the audio peripheral. The audio routing manager intercepts the channel creation function, reads the process identifier in the channel creation function as the query identifier, and sends an information query request to the resource domain manager; wherein the information query request contains the query identifier. The resource domain manager queries the peripheral identifier bound to the resource domain to which the identifier to be queried is bound as the target identifier, and returns the target identifier to the audio routing manager; The audio routing manager feeds back the target identifier to the audio service of the native system; The native system's audio service sends a preference specification function containing the target identifier to the audio peripheral corresponding to the target identifier.
3. The method according to claim 2, characterized in that, When the native system is Android and the audio command is a playback command, the method includes: The Android system's AudioService service generates a createAudioTrack() function in response to the playback command; wherein, the createAudioTrack() function contains the process identifier of the target program and is used to create a transmission channel between the target program and the audio peripheral. The audio routing manager intercepts the createAudioTrack() function, reads the process identifier in the createAudioTrack() function as the query identifier, and sends an information query request to the resource domain manager; wherein, the information query request contains the query identifier; The resource domain manager queries the peripheral identifier bound to the resource domain to which the identifier to be queried is bound as the target identifier, and returns the target identifier to the audio routing manager; The audio routing manager feeds back the target identifier to the audio service of the native system; The native system's audio service sends the audioTrack.setPreferredDevice() function, which contains the target identifier, to the audio peripheral device corresponding to the target identifier.
4. The method according to claim 2, characterized in that, When the native system is Android and the audio command is a recording command, the method includes: The AudioService service of the Android system generates a createAudioRecord() function in response to the recording command; wherein, the createAudioRecord() function contains the process identifier of the target program and is used to create a transmission channel between the target program and the audio peripheral. The audio routing manager intercepts the createAudioRecord() function, reads the process identifier in the createAudioRecord() function as the query identifier, and sends an information query request to the resource domain manager; wherein, the information query request contains the query identifier; The resource domain manager queries the peripheral identifier bound to the resource domain to which the identifier to be queried is bound as the target identifier, and returns the target identifier to the audio routing manager; The audio routing manager feeds back the target identifier to the audio service of the native system; The native system's audio service sends an audioRecord.setPreferredDevice() function containing the target identifier to the audio peripheral device corresponding to the target identifier.
5. The method according to claim 1, characterized in that, The method further includes: In response to a focus request from any of the applications in any of the user spaces, the resource domain to which the application that issued the focus request belongs is determined as the target domain; Within the target domain, the native focus defined by the terminal device's native system is executed, and in each resource domain outside the target domain, it is determined whether to preempt based on the focus level of the focus request.
6. The method according to claim 5, characterized in that, When the native system is Android, determining whether to preempt based on the focus level of the focus request includes: The focus request is detected as AUDIOFOCUS_GAIN, AUDIOFOCUS_GAIN_TRANSIENT, or AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE. In response to the focus request being either AUDIOFOCUS_GAIN or AUDIOFOCUS_GAIN_TRANSIENT, it is determined that no preemption will occur in any resource domain outside the target domain. In response to the focus request being AUDIOFOCUS_GAIN_TRANSIENT_EXCLUSIVE, global preemption is determined in each resource domain outside the target domain.
7. The method according to claim 5, characterized in that, The terminal device adds a domain focus manager on top of the native system. The domain focus manager operates on various resource domains other than the target domain.
8. The method according to claim 1, characterized in that, The method further includes: In response to a reconfiguration instruction triggered in any of the user spaces of the terminal device, a new peripheral identifier is rebound in the resource domain associated with the corresponding user space; wherein the reconfiguration instruction includes the new peripheral identifier, and the new peripheral identifier belongs to a newly replaced audio peripheral.
9. The method according to claim 1, characterized in that, When the audio command is issued by applications in different user spaces, selecting the application that issued the audio command as the target program and selecting the user space where the target program resides as the target space includes: For any of the aforementioned audio commands, the steps of selecting the application that issued the audio command as the target program and selecting the user space where the target program resides as the target space are executed respectively; The step of querying the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio instructions includes: For any of the audio instructions and the target program and target peripheral associated with the audio instructions, the step of querying the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral for executing the audio instructions is executed.
10. The method according to any one of claims 1 to 9, characterized in that, Different users use different user spaces; And / or, the resource domain also defines the space identifier of the user space. Before binding the process identifier, the space identifier corresponding to the resource domain to which the process identifier should be bound is read first according to the target priority order: the space identifier bound to the UI container that started the current process is read first, the space identifier corresponding to the resource domain to which the parent process of the current process belongs is read second, and the space identifier corresponding to the default resource domain is read last. And / or, the resource domain defines a first field, which stores the peripheral identifier of the audio peripheral for audio output, and is used to determine the target peripheral when the audio instruction is the playback instruction; And / or, the resource domain defines a second field, the second field storing the peripheral identifier of the audio peripheral for audio input, used to determine the target peripheral when the audio instruction is the recording instruction; And / or, the resource domain is defined with a third field, which stores a status identifier representing the current state of the resource domain.
11. A peripheral distribution device, characterized in that, include: An initial creation module is used to create a resource domain associated with the user space and a peripheral identifier of an audio peripheral bound in the resource domain, based on a configuration instruction triggered in the user space of the terminal device; wherein the configuration instruction includes the peripheral identifier of the audio peripheral, and a set of processes is defined in the resource domain; A process binding module is used to bind the process identifier of an application to the process set in the resource domain associated with the user space based on the application's startup command in the user space of the terminal device. The peripheral device routing module is configured to respond to an audio command from any application in any of the user spaces, select the application that issued the audio command as the target program, select the user space where the target program is located as the target space, and query the resource domain associated with the target space based on the process identifier of the target program to determine the target peripheral device for executing the audio command; wherein the audio command is a playback command and / or a recording command.
12. A computer device, characterized in that, The device includes a communication circuit, a memory, and a processor. The communication circuit and the memory are respectively coupled to the processor. The communication circuit is used to communicate with an audio peripheral. The memory stores at least program instructions. The processor is used to execute the program instructions to implement the peripheral allocation method according to any one of claims 1 to 11.
13. The computer device according to claim 12, characterized in that, The computer equipment includes a learning machine.
14. A computer-readable storage medium, characterized in that, The device stores program instructions that can be executed by a processor, the program instructions being used to implement the peripheral allocation method according to any one of claims 1 to 11.
