Audio service starting method and electronic device
By defining the exception handling strategy and hardware abstraction module identification in the audio startup configuration file, the problem of the audio service being unable to start due to hardware resource exceptions is solved, and the normal operation and efficient development of the device under abnormal conditions are realized.
Patent Information
- Application Number
- CN202410405364.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-07
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2044-04-07
AI Technical Summary
In electronic devices, the startup of audio services relies on the close cooperation of multiple software modules and hardware resources. When hardware resources are abnormal, the audio services cannot be started, causing system service failure and affecting development efficiency and user experience.
By defining the identification and exception handling strategy of the target audio hardware abstraction module in the audio startup configuration file, loading the adapted hardware abstraction module, recording the number of startups and duration, restarting the service and adding 1 until the policy conditions are met, ensuring audio The service started successfully.
Even if the hardware resources are abnormal, the audio service can be started normally, improving development efficiency and user experience, and ensuring that the device can still operate normally under abnormal conditions.
Smart Images

Figure CN118093272B
Abstract
Description
Technical Field
[0001] The present application relates to the field of audio processing technology, and in particular to an audio service startup method and an electronic device. Background Art
[0002] At present, with the intelligent development of electronic devices such as mobile phones and tablets, audio services have become an indispensable service in the system services of electronic devices. Audio services are mainly responsible for managing the audio functions of electronic devices, such as audio input or output. In specific applications, the realization of audio functions usually depends on the close cooperation between multiple audio-related software modules and hardware resources in electronic devices. Therefore, when an abnormality occurs in the hardware resources that the audio service relies on, the audio service will fail to start, and the failure to start the audio service will cause the failure to start the system service, and the failure to start the system service will cause the electronic device to fail to operate normally. In this way, not only will the development efficiency of electronic devices in development scenarios be reduced, but also the electronic devices will not be able to be used normally in usage scenarios, reducing the user experience. Summary of the invention
[0003] The embodiments of the present application provide an audio service startup method and an electronic device, which can enable the electronic device to operate normally even when the target audio hardware resources are abnormal, thereby not only improving the development efficiency of the electronic device in the development scenario, but also improving the user experience of the electronic device in the usage scenario.
[0004] In a first aspect, an embodiment of the present application provides an audio service startup method, comprising: obtaining an audio startup configuration file, and parsing a first identifier of a target audio hardware abstract module adapted to a current software system and an exception handling strategy when an audio hardware resource is abnormal from the audio startup configuration file; in the process of starting the audio service according to an audio control instruction, loading the target audio hardware abstract module according to the first identifier, and obtaining the number of startup times and the duration of the startup process corresponding to the audio control instruction; when the number of startup times and the duration of the startup process do not meet the processing conditions corresponding to the exception handling strategy, initializing the target audio hardware resources corresponding to the audio control instruction through the target audio hardware abstract module; in the process of initializing the target audio hardware resources, when an abnormality of the target audio hardware resources is detected, restarting the audio service and adding 1 to the number of startup times; when the number of startup times and the duration of the startup process meet the processing conditions, obtaining a preset initialization result for the target audio hardware resource according to the exception handling strategy; the preset initialization result is used to successfully start the audio service.
[0005] According to the audio service startup method provided by the embodiment of the present application, by configuring the first identifier of the target audio hardware abstract module and the exception handling strategy when the audio hardware resource is abnormal in the audio startup configuration file, the electronic device can load the target audio hardware abstract module adapted to the current software system according to the first identifier in the process of starting the audio service according to the audio control instruction, and provide basic guarantee for the normal startup of the audio hardware resource of the audio service. By obtaining the startup number and startup process duration of the audio service corresponding to the audio control instruction when loading the target audio hardware abstract module; when the startup number and startup process duration do not meet the processing conditions corresponding to the exception handling strategy, the target audio hardware resource corresponding to the audio control instruction is initialized, and when the target audio hardware resource is detected to be abnormal, the audio service is restarted, and the startup number is increased by 1, which can improve the probability of successful startup of the audio service. By obtaining the preset initialization result for the target audio hardware resource according to the exception handling strategy when the startup number and startup process duration meet the processing conditions, even if the target audio hardware resource is abnormal, the audio service can be successfully started, so that the electronic device can also operate normally when the target audio hardware resource is abnormal. In this way, in the development scenario of electronic devices, even if the target audio hardware resources are abnormal, since the electronic devices can operate normally, developers can not only carry out development work normally, but also collect test users' feedback on various functions normally, which is convenient for developers to locate and optimize problems in electronic devices, thereby improving the development efficiency of electronic devices. In the use scenario of electronic devices, even if the target audio hardware resources are abnormal, users can still use electronic devices normally, thus improving the user experience.
[0006] The audio startup configuration file may be used to define the startup strategy of the audio hardware abstraction module.
[0007] Exemplarily, the startup strategy of the audio hardware abstraction module may include: a first identifier of the target audio hardware abstraction module adapted to the current software system of the electronic device, the startup timing of the target audio hardware abstraction module, the resources required for starting the target audio hardware abstraction module, and an exception handling strategy when audio hardware resources are abnormal.
[0008] Exemplarily, the first identifier may be a name or number of a target audio hardware abstract module.
[0009] It can be understood that since the hardware abstraction layer of the software system of the electronic device can be configured with multiple audio hardware abstraction modules for adapting to different software systems, each audio hardware abstraction module can be configured with a different identifier. Therefore, in order to ensure that the electronic device can realize the audio function, the first identifier of the target audio hardware abstraction module adapted to the current software system can be defined in the audio startup configuration file in advance. In this way, when the electronic device realizes the audio function, it can load the target audio hardware abstraction module adapted to the current software system through the first identifier, which provides a basic guarantee for the normal realization of the audio function.
[0010] The exception handling strategy for audio hardware resource exceptions can be understood as the way in which the electronic device handles the exception when an audio hardware resource exception occurs and the target audio hardware abstraction module cannot be initialized.
[0011] Exemplarily, the exception handling strategy when the audio hardware resource is abnormal may include but is not limited to the following strategies:
[0012] Strategy 1 defines a preset counter with an initial value of 0 to record the number of times the audio service is started. When an abnormality in the target audio hardware resource is detected, the value of the preset counter is incremented by 1.
[0013] Strategy 2: When the duration of the startup process of the audio service is greater than or equal to the preset duration, or when the duration of the startup process of the audio service is less than the preset duration and the number of startup times of the audio service is greater than or equal to the preset number of times, the first identifier of the target audio hardware abstract module is modified to the target identifier, and the audio service is started for the last time, and the value of the preset counter and the value of the preset timer are both set to 0.
[0014] The preset timer may be used to record the duration of the audio service startup process. The duration of the audio service startup process may refer to the duration from the first startup of the audio service according to the audio control instruction to the current time.
[0015] Strategy 3: During the last start of the audio service, the preset file library is loaded according to the target identifier. The preset file library only includes the function interface corresponding to the target audio hardware resource, and the specific implementation of all functions corresponding to the target audio hardware resource is empty.
[0016] The preset duration and the preset number of times can be set according to actual needs. For example, the preset duration can be 1 minute, and the preset number of times can be 5 times. The embodiment of the present application does not limit the values of the preset duration and the preset number of times.
[0017] The above exception handling strategy enables the electronic device to normally start the audio service when the audio hardware resources are abnormal, thereby normally starting the system service, ensuring that the electronic device can also operate normally when the audio hardware resources are abnormal.
[0018] In a specific application, the audio startup configuration file may be a text file or a document file, etc. The present application embodiment does not limit the file format of the audio startup configuration file. For example, in the case where the audio startup configuration file is a text file, the electronic device may adopt a parsing method corresponding to the text file to parse the first identifier of the target audio hardware abstract module adapted to the current software system and the exception handling strategy when the audio hardware resource is abnormal from the audio startup configuration file.
[0019] Optionally, the electronic device may obtain and parse an audio startup configuration file during a power-on initialization process.
[0020] The audio control instruction may be generated by an application in the application layer of the software system of the electronic device. Exemplarily, the audio control instruction may be generated by the application when an audio function needs to be implemented. For example, a music playback application may generate a music playback instruction when music needs to be played; a recording application may generate a recording instruction when recording needs to be performed, etc.
[0021] Since the audio function of the electronic device needs to be realized through the audio service, no matter what kind of audio control instruction the application generates, the electronic device needs to start the audio service according to the audio control instruction to realize the corresponding audio function. Based on this, the electronic device can start the audio service according to the audio control instruction after the application generates the audio control instruction.
[0022] Optionally, when the electronic device starts the audio service for the first time according to the audio control instruction, it can also start a preset timer to record the duration of the audio service startup process through the preset timer.
[0023] Since the activation of the audio service ultimately depends on the activation of the audio hardware resources in the hardware system, for example, the activation of the music playback function depends on the activation of the speaker in the hardware system, and the activation of the recording function depends on the activation of the microphone in the hardware system, etc., and the audio hardware resources need to be activated by the audio hardware abstraction module in the hardware abstraction layer, therefore, when the electronic device is in the process of activating the audio service, it can load the target audio hardware abstraction module according to the first identifier of the target audio hardware abstraction module.
[0024] It is understandable that the purpose of the electronic device loading the target audio hardware abstraction module is to enable the target audio hardware abstraction module to initialize the target audio hardware resources corresponding to the audio control instruction so as to implement the audio function corresponding to the audio control instruction through the target audio hardware resources.
[0025] Exemplarily, the electronic device loads the target audio hardware abstract module according to the first identifier, which may specifically include: the electronic device loads the default library file corresponding to the target audio hardware abstract module. Among them, the default library file may include the function interface corresponding to each target audio hardware resource and the specific implementation of the function. It should be noted that, when all target audio hardware resources are normal, the functions corresponding to all target audio hardware resources in the default file library can be successfully called, that is, the target audio hardware resources can be successfully initialized, in which case the default library file can be successfully loaded, so that the audio service can be successfully started. In the case where at least one target audio hardware resource is abnormal, the function corresponding to the at least one target audio hardware resource in the default file library cannot be successfully called, that is, the target audio hardware resource cannot be successfully initialized, resulting in the default library file cannot be successfully loaded.
[0026] Since the target audio hardware resources cannot be successfully initialized when the target audio hardware resources are abnormal, the audio service cannot be successfully started. Therefore, in order to increase the probability of successful audio service startup, the embodiment of the present application allows the audio service to be started a preset number of times under one audio control instruction. In addition, in order to avoid the audio service startup operation being unresponsive for a long time, the embodiment of the present application can also limit the duration of the audio service startup process, for example, the duration of the audio service startup process can be limited to not exceed a preset duration, etc.
[0027] Based on this, in order to determine whether the number of times the audio service is started reaches a preset number, and / or whether the duration of the audio service startup process reaches a preset duration, the electronic device can obtain the number of times the audio service is started and the duration of the startup process corresponding to the audio control instruction during the process of starting the audio service.
[0028] Exemplarily, the electronic device may obtain a current value of a preset counter from the audio startup configuration file, and may determine the current value of the preset counter as the number of startups of the audio service.
[0029] Exemplarily, the electronic device may determine the current value of the preset timer as the duration of the startup process of the audio service.
[0030] After obtaining the number of startup times and the duration of the startup process of the audio service, the electronic device can determine whether the number of startup times and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy.
[0031] Among them, the processing conditions corresponding to the exception handling strategy may include the restriction conditions on the number of startups and the duration of the startup process in the above-mentioned strategy 2, that is, the processing conditions corresponding to the exception handling strategy may include: the duration of the startup process of the audio service is greater than or equal to the preset duration; or, the duration of the startup process of the audio service is less than the preset duration, and the number of startups of the audio service is greater than or equal to the preset number.
[0032] Based on this, the number of times the audio service is started and the duration of the startup process satisfy the processing conditions corresponding to the exception handling strategy, which may include: the duration of the startup process of the audio service is greater than or equal to the preset duration; or, the duration of the startup process of the audio service is less than the preset duration, and the number of times the audio service is started is greater than or equal to the preset number of times.
[0033] The number of startup times and the duration of the startup process of the audio service do not meet the processing conditions corresponding to the exception handling strategy, which may include: the duration of the startup process of the audio service is less than the preset duration, and the number of startup times of the audio service is less than the preset number.
[0034] For example, assuming that the audio control instruction is an audio playback instruction, since the audio playback instruction is used to implement the audio playback function, and the implementation of the audio playback function needs to rely on the audio digital processor and speakers in the audio hardware resources, therefore, in this case, the target audio hardware resources may include an audio digital processor and speakers, etc.
[0035] It should be noted that, during the process of initializing the target audio hardware resources, the target audio hardware abstraction module needs to detect the status of the target audio hardware resources to determine whether the target audio hardware resources can be initialized successfully.
[0036] Exemplarily, the status of the target audio hardware resource may include abnormal and normal.
[0037] Optionally, when the target audio hardware abstract module detects that the target audio hardware resources are normal, the audio service will be successfully started, so that the electronic device can normally implement the audio function corresponding to the audio instruction. In addition, when the target audio hardware abstract module detects that the target audio hardware resources are normal, the electronic device can set the value of the preset counter and the value of the preset timer to 0, so that the electronic device can subsequently execute the exception handling strategy normally.
[0038] Optionally, when the target audio hardware abstraction module detects that the target audio hardware resources are abnormal, the electronic device may restart the audio service and increase the number of startup times of the audio service by 1.
[0039] It is understandable that since the current number of audio service startups and the duration of the startup process do not meet the processing conditions corresponding to the exception handling strategy, the electronic device can restart the audio service and increase the number of startups by 1 when it detects an abnormality in the target audio hardware resources during the process of initializing the target audio hardware resources.
[0040] It should be noted that each time the electronic device restarts the audio service, it loops and executes the steps of loading the target audio hardware abstract module according to the first identifier, obtaining the number of startups and the duration of the startup process of the audio service, determining whether the number of startups and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy, and initializing the target audio hardware resources through the target audio hardware abstract module when the processing conditions corresponding to the exception handling strategy are not met. In the process of initializing the target audio hardware resources, when an abnormality of the target audio hardware resources is detected, the audio service is restarted, and the number of startups of the audio service is increased by 1, until the number of startups and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy, or until the target audio hardware resources are detected to be normal. That is, the electronic device restarts the audio service, which means that the electronic device restarts the audio service in the default manner. That is, when the electronic device initializes the target audio hardware resources through the target audio hardware abstract module during the process of starting the audio service, the default library file is loaded.
[0041] It should be noted that the last time the audio service is started refers to the last time the audio service is started after the number of times the audio service is started and the duration of the start process meet the processing conditions.
[0042] In an optional implementation method of the first aspect, a preset initialization result for the target audio hardware resources is obtained according to an exception handling strategy, including: changing the first identifier to the target identifier and starting the audio service for the last time; during the last start of the audio service, loading the preset library file according to the target identifier to obtain the preset initialization result; the preset library file only includes the function interface corresponding to the target audio hardware resources, and the specific implementations of all functions corresponding to the target audio hardware resources are empty.
[0043] According to the audio service startup method provided by the embodiment of the present application, by modifying the first identifier of the audio hardware abstract module to the target identifier, the electronic device can directly load the preset library file according to the target identifier during the last startup of the audio service. Since the preset library file only includes the function interface corresponding to the target audio hardware resource, and the specific implementations of all functions corresponding to the target audio hardware resource are empty, therefore, by loading the preset library file to return the preset initialization result, although the corresponding audio function cannot be realized, it can ensure that the target audio hardware resource can be initialized successfully, and then it can ensure that the audio service can be successfully started, so that the system service can be successfully started, and it is ensured that the electronic device can operate normally.
[0044] In an optional implementation of the first aspect, when the number of startup times and the duration of the startup process meet the processing conditions, a preset initialization result for the target audio hardware resource is obtained according to an exception handling strategy, including: when the duration of the startup process is greater than or equal to the preset duration, the preset initialization result for the target audio hardware resource is obtained according to the exception handling strategy; or, when the duration of the startup process is less than the preset duration and the number of startup times is greater than or equal to the preset number, the preset initialization result for the target audio hardware resource is obtained according to the exception handling strategy.
[0045] According to the audio service startup method provided in the embodiment of the present application, when the startup process of the audio service lasts for a duration greater than or equal to a preset duration, even if the number of startups of the audio service is less than the preset number, the electronic device will obtain the preset initialization result for the target audio hardware resource according to the exception handling strategy, so that the audio service is successfully started. Therefore, it can be avoided that the electronic device is unresponsive for a long time when starting the audio service, thereby improving the user experience. In addition, when the number of startups of the audio service is greater than or equal to the preset number, it means that the electronic device has started the audio service a preset number of times under the audio control instruction, and each time it detects an abnormality in the target audio hardware resource, resulting in the audio service being unable to be successfully started. In this case, the electronic device can obtain the preset initialization result for the target audio hardware resource by executing the exception handling strategy, so that the audio service can be successfully started, and then the system service can be successfully started, so as to ensure that the electronic device can operate normally.
[0046] In an optional implementation of the first aspect, when the number of startup times and the duration of the startup process do not meet the processing conditions corresponding to the exception handling strategy, the target audio hardware resources corresponding to the audio control instruction are initialized through the target audio hardware abstraction module, including: when the duration of the startup process is less than the preset duration and the number of startup times is less than the preset number, the target audio hardware resources corresponding to the audio control instruction are initialized through the target audio hardware abstraction module.
[0047] In an optional implementation manner of the first aspect, it also includes: when the number of startup times and the duration of the startup process meet the processing conditions corresponding to the exception handling strategy, the number of startup times and the duration of the startup process are both set to 0.
[0048] According to the audio service startup method provided in the embodiment of the present application, the electronic device can normally execute the exception handling strategy the next time it encounters an exception in the target audio hardware resources, thereby ensuring that the electronic device can operate normally.
[0049] In an optional implementation manner of the first aspect, the method further includes: during the process of initializing the target audio hardware resources, when it is detected that the target audio hardware resources are normal, setting the number of startup times and the duration of the startup process to 0.
[0050] According to the audio service startup method provided in the embodiment of the present application, it can be ensured that the electronic device can subsequently execute the exception handling strategy normally.
[0051] In an optional implementation of the first aspect, an audio startup configuration file is obtained, and a first identifier of a target audio hardware abstract module adapted to a current software system and an exception handling strategy when audio hardware resources are abnormal are parsed from the audio startup configuration file, including: starting an initialization process during a power-on initialization process; obtaining an audio startup configuration file through the initialization process, and parsing a first identifier of a target audio hardware abstract module adapted to a current software system and an exception handling strategy when audio hardware resources are abnormal are parsed from the audio startup configuration file.
[0052] The initialization process may be the bus process that is first started during the initialization process of powering on the electronic device, and other processes except the initialization process may be started by the initialization process.
[0053] According to the audio service startup method provided in the embodiment of the present application, the first identifier of the target audio hardware abstract module adapted to the current software system and the exception handling strategy when the audio hardware resources are abnormal are obtained and parsed by starting the initialization process during the power-on initialization process. This can ensure that the electronic device can successfully start the audio service according to the exception handling strategy when the audio hardware resources are abnormal during the power-on process or during the entire operation process after power-on, thereby ensuring that the electronic device will not be unable to operate normally due to abnormal audio hardware resources during the power-on process or during the entire operation process after power-on, thereby improving the ability of the electronic device to resist audio hardware resource abnormalities, and thereby improving the stability of the operation of the electronic device.
[0054] In a second aspect, an embodiment of the present application provides an electronic device, including: one or more processors, and a memory;
[0055] The memory is coupled to one or more processors, and the memory is used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the audio service startup method as any implementation of the first aspect mentioned above.
[0056] In a third aspect, an embodiment of the present application provides a computer-readable storage medium, which includes instructions. When the instructions are executed on an electronic device, the electronic device executes an audio service startup method as implemented in any of the first aspects above.
[0057] In a fourth aspect, an embodiment of the present application provides a computer executable program product. When the computer executable program product runs on an electronic device, the electronic device executes the audio service startup method of any implementation of the first aspect.
[0058] In a fifth aspect, an embodiment of the present application provides a chip system, which is applied to an electronic device. The chip system includes one or more processors, and the one or more processors are used to call computer instructions to enable the electronic device to execute an audio service startup method such as any implementation method of the first aspect mentioned above.
[0059] It can be understood that the beneficial effects of the second to fifth aspects mentioned above can be found in the relevant description of the first aspect mentioned above, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS
[0060] Figure 1 A schematic diagram of a scenario in which an electronic device in the prior art implements an audio function;
[0061] Figure 2 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0062] Figure 3 A schematic architecture diagram of a software system of an electronic device provided in an embodiment of the present application;
[0063] Figure 4 A schematic flow chart of a method for starting an audio service provided in an embodiment of the present application;
[0064] Figure 5 A specific implementation flow chart of S401 in an audio service startup method provided in an embodiment of the present application;
[0065] Figure 6 A specific implementation flow chart of S405 in an audio service startup method provided in an embodiment of the present application;
[0066] Figure 7 A schematic diagram of a scenario in which an electronic device according to an embodiment of the present application implements an audio function;
[0067] Figure 8 A schematic diagram of the interaction process between various audio-related software and hardware modules during the implementation of an audio service startup method provided in an embodiment of the present application. DETAILED DESCRIPTION
[0068] It should be noted that the terms used in the implementation methods of the embodiments of the present application are only used to explain the specific embodiments of the present application, and are not intended to limit the present application. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in this article is only a description of the association relationship of the associated objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, unless otherwise specified, "multiple" means two or more than two, "at least one" and "one or more" mean one, two or more than two.
[0069] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, it is defined that the "first" and "second" features may explicitly or implicitly include one or more of the features.
[0070] References to "one embodiment" or "some embodiments" etc. described in this specification mean that a particular feature, structure or characteristic described in conjunction with the embodiment is included in one or more embodiments of the present application. Thus, the phrases "in one embodiment", "in some embodiments", "in some other embodiments", "in some other embodiments", etc. that appear at different places in this specification do not necessarily refer to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized in other ways. The terms "including", "comprising", "having" and their variations all mean "including but not limited to", unless otherwise specifically emphasized in other ways.
[0071] At present, with the development of intelligent electronic devices such as mobile phones and tablets, audio server has become an indispensable service in the system server of electronic devices. Audio server is mainly responsible for managing the audio functions of electronic devices, such as audio input or audio output. The realization of audio functions usually depends on the close cooperation between multiple audio-related software modules and hardware resources in electronic devices.
[0072] Exemplarily, the audio-related software modules in the electronic device may include a system service module, an audio service module, and an audio hardware abstraction layer (audio HAL) module, etc. The audio-related hardware resources in the electronic device may include an audio codec (audio codec), an audio digital signal processor (audio digital signal processor, ADSP), a Bluetooth chip, a smart power amplifier (smart PA), a speaker, a microphone, and an audio external device (such as a headset or a speaker, etc.), etc.
[0073] Taking the output of audio by an electronic device as an example, illustratively, when the electronic device needs to output audio, the coordination process between the audio-related software modules and hardware resources in the electronic device can be as follows: the audio application calls the audio service module in the system service module, the audio service module calls the corresponding audio hardware abstract module, the audio hardware abstract module calls the corresponding audio digital processor, the audio digital processor calls the corresponding speaker, and the speaker outputs the audio signal to be played, thereby realizing audio output. It can be seen that the coupling relationship between the various audio-related software modules and hardware resources in the electronic device is strong. Therefore, in the case of an abnormality in the audio-related hardware resources, such as damage to the audio digital processor, it will cause the audio service to fail to start, and the failure of the audio service to start will further cause the failure of the system service to start, and the failure of the system service to start will further cause the electronic device to fail to operate normally (such as freezing), so that it will not only reduce the development efficiency of the electronic device in the development scenario, but also make the electronic device unable to be used normally in the use scenario, reducing the user's experience.
[0074] For ease of explanation, audio-related hardware resources are uniformly described as audio hardware resources below. The following are several development scenarios where the development efficiency of electronic devices is reduced due to abnormal audio hardware resources:
[0075] For example, in the initial stage of electronic device development, developers need to first develop the minimum startup function on the electronic device without any software system installed. The minimum startup function refers to the most basic function that enables the electronic device to start normally. Since the minimum startup function usually includes the audio function, when the audio function cannot be implemented normally due to an abnormality in the audio hardware resources, the electronic device cannot normally implement the minimum startup function, which will cause the electronic device to fail to start normally, and then the developer will be unable to perform subsequent development operations, reducing the development efficiency of the electronic device.
[0076] For example, after completing the development of the minimum startup function and entering the development stage of other functions, since the overall function of the electronic device is relatively weak at this stage, the anti-abnormal ability is relatively lacking, and a large number of function modifications from different developers are incorporated into the electronic device every day, therefore, at this stage, the audio hardware resources are prone to abnormalities due to function modifications. For example, when there is a problem with the function modification itself, or when there is a conflict between multiple function modifications from different developers, the audio hardware resources may be abnormal. As mentioned above, once the audio hardware resources are abnormal, it will cause the electronic device to fail to operate normally, which will affect the development progress of other functions, and then reduce the development efficiency of the electronic device.
[0077] For example, after completing the development of most functions and entering the internal testing phase or the user testing phase, although the overall functions of the electronic device are relatively stable at this stage, the audio hardware resources may still be abnormal due to their own failures or user operations. For example, when a user turns on multiple audio applications, the audio hardware resources may be abnormal due to the multiple audio applications grabbing resources. As mentioned above, once an abnormality occurs in the audio hardware resources, the electronic device will not be able to operate normally. This will not only affect the user experience of the test user, but also cause the developer to be unable to collect the test user's feedback on the problems of each function, thereby failing to effectively locate the problem, which will reduce the development efficiency of the electronic device.
[0078] In addition, in the use scenarios of electronic devices, for example, during the boot process of the electronic device, if the audio hardware resources are abnormal, the electronic device will not be able to boot normally; during the operation of the electronic device, if the audio hardware resources are abnormal, the electronic device will not be able to operate normally. The failure of the electronic device to boot or operate normally will cause the user to be unable to use the electronic device normally, thereby reducing the user's experience.
[0079] For example, see Figure 1 , which is a schematic diagram of a scenario in which an electronic device in the prior art implements an audio function.
[0080] like Figure 1 As shown in (a) in FIG. 1 , when a user needs to play music, the user can click on the play button 001 in the music playing application. In response to the click, the music playing application can start the audio service to play the music.
[0081] Since the start of the audio service depends on the underlying audio hardware resources, such as the audio digital processor and / or the speaker, etc., if the audio hardware resources are abnormal, such as the speaker is damaged, the audio service cannot be started normally, which will eventually cause the electronic device to not operate normally. For example, after the user clicks the play button 001, due to the abnormal audio hardware resources, the electronic device may enter the following Figure 1 The freezing state shown in (b) causes the user to be unable to use the electronic device normally.
[0082] In view of this, the embodiment of the present application provides an audio service startup method, by configuring the first identifier of the target audio hardware abstract module and the exception handling strategy when the audio hardware resource is abnormal in the audio startup configuration file, so that the electronic device can load the target audio hardware abstract module adapted to the current software system according to the first identifier when starting the audio service according to the audio control instruction, and provide basic guarantee for the normal startup of the audio hardware resource for the audio service. By obtaining the startup number and startup process duration of the audio service corresponding to the audio control instruction when loading the target audio hardware abstract module; when the startup number and startup process duration do not meet the processing conditions corresponding to the exception handling strategy, the target audio hardware resource corresponding to the audio control instruction is initialized, and when the target audio hardware resource is detected to be abnormal, the audio service is restarted, and the startup number is increased by 1, which can improve the probability of successful startup of the audio service. By obtaining the preset initialization result for the target audio hardware resource according to the exception handling strategy when the startup number and startup process duration meet the processing conditions, even if the target audio hardware resource is abnormal, the audio service can be successfully started, so that the electronic device can also operate normally when the target audio hardware resource is abnormal. In this way, in the development scenario of electronic devices, even if the target audio hardware resources are abnormal, since the electronic devices can operate normally, developers can not only carry out development work normally, but also collect test users' feedback on various functions normally, which is convenient for developers to locate and optimize problems in electronic devices, thereby improving the development efficiency of electronic devices. In the use scenario of electronic devices, even if the target audio hardware resources are abnormal, users can still use electronic devices normally, thus improving the user experience.
[0083] The execution subject of the audio service startup method provided in the embodiment of the present application may be an electronic device. The electronic device may also be referred to as a terminal, user equipment (UE), mobile station (MS) or mobile terminal (MT), etc. Exemplarily, the electronic device may include a mobile phone, a smart TV, a wearable device (such as a smart bracelet, a smart watch or smart glasses, etc.), a tablet computer (pad), an augmented reality (AR) device, a virtual reality (VR) device, a laptop computer, an ultra-mobile personal computer (UMPC), a netbook and a personal digital assistant (PDA), etc. The embodiment of the present application does not limit the specific device form of the electronic device.
[0084] For example, see Figure 2 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.
[0085] like Figure 2 As shown, the electronic device 100 may include a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. Among them, the sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.
[0086] The processor 110 may include one or more processing units, for example, the processor 110 may include an application processor (AP), a modem processor, a graphics processor (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0087] The controller can generate operation control signals according to the instruction operation code and timing signal to complete the control of instruction fetching and execution.
[0088] The processor 110 may also be provided with a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. The memory may store instructions or data that the processor 110 has just used or cyclically used. If the processor 110 needs to use the instruction or data again, it may be directly called from the memory. This avoids repeated access, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0089] The electronic device 100 can implement audio functions, such as music playback, recording, etc., through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.
[0090] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be arranged in the processor 110, or some functional modules of the audio module 170 can be arranged in the processor 110. The audio module 170 can include, for example, an audio codec, an audio digital processor, a Bluetooth chip, an intelligent power amplifier, etc.
[0091] The speaker 170A, also called a "speaker", is used to convert an audio electrical signal into a sound signal. The electronic device 100 can listen to music or listen to a hands-free call through the speaker 170A.
[0092] The receiver 170B, also called a "earpiece", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be received by placing the receiver 170B close to the human ear.
[0093] Microphone 170C, also called "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to microphone 170C to input the sound signal into microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to collect sound signals, reduce noise, identify the sound source, realize directional recording function, etc.
[0094] The earphone interface 170D is used to connect a wired earphone and can be a USB interface 130 or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0095] The above is an exemplary description of the structure of the electronic device 100. It is understood that in other embodiments, the electronic device 100 may include more or fewer components than shown in the figure, or may combine some components, or split some components, or may have a different arrangement of components. The components shown in the figure may be implemented in hardware, software, or a combination of software and hardware.
[0096] The software system of the electronic device 100 with the above hardware system can adopt a layered architecture, an event-driven architecture, a micro-core architecture, a micro-service architecture, or a cloud architecture, etc. The embodiment of the present application takes the Android system with a layered architecture as an example to exemplify the software system of the electronic device 100.
[0097] See also Figure 3 , which is a schematic architecture diagram of a software system of an electronic device 100 provided in an embodiment of the present application.
[0098] like Figure 3As shown in Figure 1, the layered architecture can divide the software into several layers, each layer has a clear role and division of labor, and the layers communicate with each other through software interfaces. For example, the layered architecture can divide the Android system into five layers, from top to bottom: application (APP) layer, application framework layer, system layer, hardware abstraction layer (HAL) and kernel layer.
[0099] The application layer may include a series of application packages, such as telephone, recording, audio player, video player, podcast, map, etc. For ease of explanation, the application package may be referred to as application in the following.
[0100] The application framework layer provides an application programming interface (API) and a programming framework for applications in the application layer. The application framework layer may include some predefined functions.
[0101] Exemplarily, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.
[0102] The system layer can include Android runtime, system library, initialization (init) module, system service module, etc.
[0103] The Android runtime can include a core library and a virtual machine. The Android runtime is mainly responsible for the scheduling and management of the Android system. The core library consists of two parts: one is the function that the Java language needs to call, and the other is the Android core library. The application layer and the application framework layer run in the virtual machine. The virtual machine executes the Java files of the application layer and the application framework layer as binary files. The virtual machine is used to perform object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0104] The system library can include multiple functional modules, such as surface manager, media libraries, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.
[0105] The initialization module can be used to start the initialization process of the electronic device during the initialization process of the electronic device.
[0106] The system service module may include an audio service module, a video service module, etc.
[0107] The audio service module can be used to manage the audio functions of the electronic device 100, such as music playing, recording, etc.
[0108] The hardware abstraction layer may include one or more audio hardware abstraction modules. Different audio hardware abstraction modules may be adapted to different software systems. Exemplarily, in order to distinguish different audio hardware abstraction modules, different identifiers may be configured for different audio hardware abstraction modules. The identifier of the audio hardware abstraction module may be, for example, the name of the audio hardware abstraction module.
[0109] The audio hardware abstraction module can be used to manage audio hardware resources in the hardware system of the electronic device, such as audio codecs, audio digital processors, Bluetooth chips, and smart amplifiers.
[0110] The kernel layer is the layer between hardware and software. The kernel layer can include display drivers, camera drivers, audio drivers, sensor drivers, etc.
[0111] It should be noted that Figure 3 Only modules related to the embodiments of the present application are shown. In other embodiments, each layer may also include any other possible modules, and each module may also include one or more sub-modules, which are not limited in the present application.
[0112] The following will be combined with the accompanying drawings to illustrate the audio service startup method provided by the embodiment of the present application through multiple exemplary embodiments. The audio service startup method in the following embodiments can be implemented in an electronic device having the above-mentioned hardware system and software system. The hardware system diagram of the electronic device can be as follows: Figure 2 As shown, the software system can be Figure 3 As shown, but not limited to this.
[0113] See also Figure 4 , is a schematic flow chart of an audio service startup method provided in an embodiment of the present application. Figure 4 The audio service startup method may include S401 to S405, which are described in detail as follows:
[0114] S401, the electronic device obtains an audio startup configuration file, and parses the first identifier of a target audio hardware abstraction module adapted to the current software system and an exception handling strategy when an audio hardware resource is abnormal from the audio startup configuration file.
[0115] The audio startup configuration file may be used to define the startup strategy of the audio hardware abstraction module.
[0116] Exemplarily, the startup strategy of the audio hardware abstraction module may include: a first identifier of the target audio hardware abstraction module adapted to the current software system of the electronic device, the startup timing of the target audio hardware abstraction module, the resources required for starting the target audio hardware abstraction module, and an exception handling strategy when audio hardware resources are abnormal.
[0117] Exemplarily, the first identifier may be a name or number of a target audio hardware abstract module.
[0118] It can be understood that since the hardware abstraction layer of the software system of the electronic device can be configured with multiple audio hardware abstraction modules for adapting to different software systems, each audio hardware abstraction module can be configured with a different identifier. Therefore, in order to ensure that the electronic device can realize the audio function, the first identifier of the target audio hardware abstraction module adapted to the current software system can be defined in the audio startup configuration file in advance. In this way, when the electronic device realizes the audio function, it can load the target audio hardware abstraction module adapted to the current software system through the first identifier, which provides a basic guarantee for the normal realization of the audio function.
[0119] The exception handling strategy for audio hardware resource exceptions can be understood as the way in which the electronic device handles the exception when an audio hardware resource exception occurs and the target audio hardware abstraction module cannot be initialized.
[0120] Exemplarily, the exception handling strategy when the audio hardware resource is abnormal may include but is not limited to the following strategies:
[0121] Strategy 1 defines a preset counter with an initial value of 0 to record the number of times the audio service is started. When an abnormality in the target audio hardware resource is detected, the value of the preset counter is incremented by 1.
[0122] Strategy 2: When the duration of the startup process of the audio service is greater than or equal to the preset duration, or when the duration of the startup process of the audio service is less than the preset duration and the number of startup times of the audio service is greater than or equal to the preset number of times, the first identifier of the target audio hardware abstract module is modified to the target identifier, and the audio service is started for the last time, and the value of the preset counter and the value of the preset timer are both set to 0.
[0123] The preset timer may be used to record the duration of the audio service startup process. The duration of the audio service startup process may refer to the duration from the first startup of the audio service according to the audio control instruction to the current time.
[0124] Strategy 3: During the last start of the audio service, the preset file library is loaded according to the target identifier. The preset file library only includes the function interface corresponding to the target audio hardware resource, and the specific implementation of all functions corresponding to the target audio hardware resource is empty.
[0125] The preset duration and the preset number of times can be set according to actual needs. For example, the preset duration can be 1 minute, and the preset number of times can be 5 times. The embodiment of the present application does not limit the values of the preset duration and the preset number of times.
[0126] The above exception handling strategy enables the electronic device to normally start the audio service when the audio hardware resources are abnormal, thereby normally starting the system service, ensuring that the electronic device can also operate normally when the audio hardware resources are abnormal.
[0127] In a specific application, the audio startup configuration file may be a text file or a document file, etc. The present application embodiment does not limit the file format of the audio startup configuration file. For example, in the case where the audio startup configuration file is a text file, the electronic device may adopt a parsing method corresponding to the text file to parse the first identifier of the target audio hardware abstract module adapted to the current software system and the exception handling strategy when the audio hardware resource is abnormal from the audio startup configuration file.
[0128] Optionally, the electronic device may obtain and parse an audio startup configuration file during a power-on initialization process.
[0129] Based on this, S401 may specifically include the following: Figure 5 The S4011~S4012 shown are described in detail as follows:
[0130] S4011, the electronic device starts an initialization process during the power-on initialization process.
[0131] S4012, the electronic device obtains an audio startup configuration file through an initialization process, and parses the first identifier of the target audio hardware abstraction module adapted to the current software system and an exception handling strategy when an audio hardware resource is abnormal from the audio startup configuration file.
[0132] The initialization process may be a bus process that is first started during the initialization process of the electronic device. Other processes except the initialization process may be started by the initialization process.
[0133] The embodiment of the present application obtains and parses the first identifier of the target audio hardware abstract module adapted to the current software system and the exception handling strategy when the audio hardware resources are abnormal by starting the initialization process during the power-on initialization process, thereby ensuring that the electronic device can successfully start the audio service according to the exception handling strategy when the audio hardware resources are abnormal during the power-on process or during the entire operation process after power-on, thereby ensuring that the electronic device will not be unable to operate normally due to abnormal audio hardware resources during the power-on process or during the entire operation process after power-on, thereby improving the ability of the electronic device to resist audio hardware resource abnormalities, and then improving the stability of the operation of the electronic device.
[0134] S402: When starting an audio service according to an audio control instruction, the electronic device loads a target audio hardware abstraction module according to a first identifier, and obtains a start count and a start duration of the audio service corresponding to the audio control instruction.
[0135] The audio control instruction may be generated by an application in the application layer of the software system of the electronic device. Exemplarily, the audio control instruction may be generated by the application when an audio function needs to be implemented. For example, a music playback application may generate a music playback instruction when music needs to be played; a recording application may generate a recording instruction when recording needs to be performed, etc.
[0136] Since the audio function of the electronic device needs to be realized through the audio service, no matter what kind of audio control instruction the application generates, the electronic device needs to start the audio service according to the audio control instruction to realize the corresponding audio function. Based on this, the electronic device can start the audio service according to the audio control instruction after the application generates the audio control instruction.
[0137] Optionally, when the electronic device starts the audio service for the first time according to the audio control instruction, it can also start a preset timer to record the duration of the audio service startup process through the preset timer.
[0138] Since the activation of the audio service ultimately depends on the activation of the audio hardware resources in the hardware system, for example, the activation of the music playback function depends on the activation of the speaker in the hardware system, and the activation of the recording function depends on the activation of the microphone in the hardware system, etc., and the audio hardware resources need to be activated by the audio hardware abstraction module in the hardware abstraction layer, therefore, when the electronic device is in the process of activating the audio service, it can load the target audio hardware abstraction module according to the first identifier of the target audio hardware abstraction module.
[0139] It is understandable that the purpose of the electronic device loading the target audio hardware abstraction module is to enable the target audio hardware abstraction module to initialize the target audio hardware resources corresponding to the audio control instruction so as to implement the audio function corresponding to the audio control instruction through the target audio hardware resources.
[0140] Exemplarily, the electronic device loads the target audio hardware abstract module according to the first identifier, which may specifically include: the electronic device loads the default library file corresponding to the target audio hardware abstract module. Among them, the default library file may include the function interface corresponding to each target audio hardware resource and the specific implementation of the function. It should be noted that, when all target audio hardware resources are normal, the functions corresponding to all target audio hardware resources in the default file library can be successfully called, that is, the target audio hardware resources can be successfully initialized, in which case the default library file can be successfully loaded, so that the audio service can be successfully started. In the case where at least one target audio hardware resource is abnormal, the function corresponding to the at least one target audio hardware resource in the default file library cannot be successfully called, that is, the target audio hardware resource cannot be successfully initialized, resulting in the default library file cannot be successfully loaded.
[0141] Since the target audio hardware resources cannot be successfully initialized when the target audio hardware resources are abnormal, the audio service cannot be successfully started. Therefore, in order to increase the probability of successful audio service startup, the embodiment of the present application allows the audio service to be started a preset number of times under one audio control instruction. In addition, in order to avoid the audio service startup operation being unresponsive for a long time, the embodiment of the present application can also limit the duration of the audio service startup process, for example, the duration of the audio service startup process can be limited to not exceed a preset duration, etc.
[0142] Based on this, in order to determine whether the number of times the audio service is started reaches a preset number, and / or whether the duration of the audio service startup process reaches a preset duration, the electronic device can obtain the number of times the audio service is started and the duration of the startup process corresponding to the audio control instruction during the process of starting the audio service.
[0143] Exemplarily, the electronic device may obtain a current value of a preset counter from the audio startup configuration file, and may determine the current value of the preset counter as the number of startups of the audio service.
[0144] Exemplarily, the electronic device may determine the current value of the preset timer as the duration of the startup process of the audio service.
[0145] After obtaining the number of startup times and the duration of the startup process of the audio service, the electronic device can determine whether the number of startup times and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy.
[0146] Among them, the processing conditions corresponding to the exception handling strategy may include the restriction conditions on the number of startups and the duration of the startup process in the above-mentioned strategy 2, that is, the processing conditions corresponding to the exception handling strategy may include: the duration of the startup process of the audio service is greater than or equal to the preset duration; or, the duration of the startup process of the audio service is less than the preset duration, and the number of startups of the audio service is greater than or equal to the preset number.
[0147] Based on this, the number of times the audio service is started and the duration of the startup process satisfy the processing conditions corresponding to the exception handling strategy, which may include: the duration of the startup process of the audio service is greater than or equal to the preset duration; or, the duration of the startup process of the audio service is less than the preset duration, and the number of times the audio service is started is greater than or equal to the preset number of times.
[0148] The number of startup times and the duration of the startup process of the audio service do not meet the processing conditions corresponding to the exception handling strategy, which may include: the duration of the startup process of the audio service is less than the preset duration, and the number of startup times of the audio service is less than the preset number.
[0149] Optionally, when the number of startup times and the duration of the startup process of the audio service do not meet the processing conditions corresponding to the exception handling strategy, the electronic device may execute S403 to S404.
[0150] Optionally, when the number of startup times and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy, the electronic device may execute S405.
[0151] S403: When the number of startup times and the duration of the startup process do not satisfy the processing conditions corresponding to the exception handling strategy, the electronic device initializes the target audio hardware resources corresponding to the audio control instruction through the target audio hardware abstract module.
[0152] In a specific implementation, S403 may include the following steps:
[0153] When the duration of the startup process is less than the preset duration and the number of startups is less than the preset number of times, the electronic device initializes the target audio hardware resources corresponding to the audio control instruction through the target audio hardware abstract module.
[0154] For example, assuming that the audio control instruction is an audio playback instruction, since the audio playback instruction is used to implement the audio playback function, and the implementation of the audio playback function needs to rely on the audio digital processor and speakers in the audio hardware resources, therefore, in this case, the target audio hardware resources may include an audio digital processor and speakers, etc.
[0155] It should be noted that, during the process of initializing the target audio hardware resources, the target audio hardware abstraction module needs to detect the status of the target audio hardware resources to determine whether the target audio hardware resources can be initialized successfully.
[0156] Exemplarily, the status of the target audio hardware resource may include abnormal and normal.
[0157] Optionally, when the target audio hardware abstract module detects that the target audio hardware resources are normal, the audio service will be successfully started, so that the electronic device can normally implement the audio function corresponding to the audio instruction. In addition, when the target audio hardware abstract module detects that the target audio hardware resources are normal, the electronic device can set the value of the preset counter and the value of the preset timer to 0 to ensure that the electronic device can subsequently execute the exception handling strategy normally.
[0158] Optionally, when the target audio hardware abstraction module detects that the target audio hardware resources are abnormal, the electronic device may execute S404.
[0159] S404: When the electronic device detects that the target audio hardware resource is abnormal during the process of initializing the target audio hardware resource, it restarts the audio service and increases the number of times the audio service is started by 1.
[0160] It is understandable that since the current number of audio service startups and the duration of the startup process do not meet the processing conditions corresponding to the exception handling strategy, the electronic device can restart the audio service and increase the number of startups by 1 when it detects an abnormality in the target audio hardware resources during the process of initializing the target audio hardware resources.
[0161] It should be noted that each time the electronic device restarts the audio service, it loops and executes the steps of loading the target audio hardware abstract module according to the first identifier, obtaining the number of startups and the duration of the startup process of the audio service, determining whether the number of startups and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy, and initializing the target audio hardware resources through the target audio hardware abstract module when the processing conditions corresponding to the exception handling strategy are not met. In the process of initializing the target audio hardware resources, when the target audio hardware resources are detected to be abnormal, the audio service is restarted, and the number of startups of the audio service is increased by 1, until the number of startups and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy, or until the target audio hardware resources are detected to be normal. That is, in S404, the electronic device restarts the audio service, which means that the electronic device restarts the audio service in a default manner. That is, when the electronic device initializes the target audio hardware resources through the target audio hardware abstract module during the process of starting the audio service, the default library file is loaded.
[0162] S405: When the number of startup times and the duration of the startup process satisfy processing conditions corresponding to the exception processing strategy, the electronic device obtains a preset initialization result for the target audio hardware resource according to the exception processing strategy.
[0163] In a specific implementation, S405 may include the following steps:
[0164] When the duration of the audio service startup process is greater than or equal to the preset duration, a preset initialization result for the target audio hardware resource is obtained according to the exception handling strategy; or,
[0165] When the duration of the audio service startup process is less than the preset duration and the number of startups of the audio service is greater than or equal to the preset number, a preset initialization result for the target audio hardware resource is obtained according to the exception handling strategy.
[0166] Among them, the preset initialization result for the target audio hardware resource can enable the audio service to be successfully started.
[0167] Since, when the duration of the audio service startup process is greater than or equal to the preset duration, even if the audio service is started less than the preset number of times, the electronic device will obtain the preset initialization result for the target audio hardware resource according to the exception handling strategy, so that the audio service is successfully started, thus avoiding the electronic device from being unresponsive for a long time when starting the audio service, thereby improving the user experience. In addition, when the number of times the audio service is started is greater than or equal to the preset number of times, it means that the electronic device has started the audio service a preset number of times under the audio control instruction, and each time it detects an abnormality in the target audio hardware resource, resulting in the audio service being unable to be successfully started. In this case, the electronic device can obtain the preset initialization result for the target audio hardware resource by executing the exception handling strategy, so that the audio service can be successfully started, and then the system service can be successfully started, so as to ensure that the electronic device can operate normally.
[0168] In a specific implementation, in S405, a preset initialization result for the target audio hardware resource is obtained according to the exception handling strategy, which may specifically include: Figure 6 The S4051~S4052 shown are described in detail as follows:
[0169] S4051, the electronic device modifies the first identifier of the target audio hardware abstract module to the target identifier, and starts the audio service for the last time.
[0170] S4052: During the last start-up of the audio service, the electronic device loads the preset library file according to the target identifier to obtain a preset initialization result.
[0171] The target identifier may be set according to actual needs. For example, the target identifier may be default.
[0172] It should be noted that the last time the audio service is started refers to the last time the audio service is started after the number of times the audio service is started and the duration of the start process meet the processing conditions.
[0173] The preset library file only includes the function interface corresponding to the target audio hardware resource, and the specific implementations of all functions corresponding to the target audio hardware resource are empty.
[0174] The embodiment of the present application modifies the first identifier of the audio hardware abstract module into a target identifier, so that the electronic device can directly load the preset library file according to the target identifier during the last process of starting the audio service. Since the preset library file only includes the function interface corresponding to the target audio hardware resource, and the specific implementations of all functions corresponding to the target audio hardware resource are empty, therefore, by loading the preset library file to return the preset initialization result, although the corresponding audio function cannot be realized, it can ensure that the target audio hardware resource can be initialized successfully, and then it can ensure that the audio service can be successfully started, so that the system service can be successfully started, and the normal operation of the electronic device is ensured.
[0175] In other embodiments of the present application, when the number of times the audio service is started and the duration of the startup process meet the processing conditions corresponding to the exception handling strategy, the electronic device can set the value of the preset counter and the value of the preset timer to 0, so that the electronic device can execute the exception handling strategy normally the next time it encounters an exception in the target audio hardware resources, thereby ensuring that the electronic device can operate normally.
[0176] See also Figure 7 , is a schematic diagram of a scenario in which an electronic device implements an audio function provided in an embodiment of the present application.
[0177] like Figure 7 As shown in (a) in FIG. 1 , when a user needs to play music, the user can click on the play button 001 in the music playing application. In response to the click, the music playing application can start the audio service to play the music.
[0178] Different from the prior art, even in the case of abnormal audio hardware resources, the electronic device can start the audio service normally by executing the above-mentioned audio service startup method, but the corresponding audio function cannot be realized, thereby ensuring that the electronic device can operate normally without entering a state such as a freeze.
[0179] For example, after the user clicks the play button 001, in the case of an abnormal audio hardware resource, the electronic device may display the following Figure 7 The prompt message "Sorry, the playback function is not supported at the moment" as shown in (b) in the figure.
[0180] The following combination Figure 3 The software system shown in the figure illustrates the interaction process between various software modules of the electronic device during the implementation of the above-mentioned audio service startup method. Figure 8 , which is a schematic diagram of the interaction process between various audio-related software and hardware modules during the implementation of an audio service startup method provided in an embodiment of the present application.
[0181] like Figure 8 As shown, the electronic device may include an initialization module, a system service module, an audio service module, an audio hardware abstraction module, and audio hardware resources. Among them, the initialization module, the system service module, and the audio service module may be located in the system layer of the software system of the electronic device. The audio hardware abstraction module may be located in the hardware abstraction layer of the software system of the electronic device. The audio hardware resources may be located in the hardware system of the electronic device.
[0182] Exemplarily, in the implementation process of the audio startup method, the interaction process between the initialization module, the system service module, the audio service module, the audio hardware abstraction module and the audio hardware resources may include S801 to S807, which are described in detail as follows:
[0183] S801, an initialization module obtains an audio startup configuration file, and parses a first identifier of a target audio hardware abstraction module adapted to a current software system and an exception handling strategy when an audio hardware resource is abnormal from the audio startup configuration file.
[0184] Specifically, after being started, the initialization module can obtain the audio startup configuration file through the initialization process, and parse the first identifier of the target audio hardware abstract module adapted to the current software system and the exception handling strategy when the audio hardware resource is abnormal from the audio startup configuration file. The initialization module can be started by the electronic device during the power-on initialization process.
[0185] It should be noted that the current software system may refer to the software system currently running in the electronic device.
[0186] S802: The system service module starts the audio service upon receiving the audio control instruction.
[0187] The audio control instructions may come from an application in an application layer of the software system.
[0188] Exemplarily, when the audio application in the application layer needs to output audio, the audio application can send an audio output instruction to the system service module. The system service module can start the audio service upon receiving the audio output instruction.
[0189] Specifically, the system service module can start the audio service by calling the audio service module.
[0190] S803: During the process of starting the audio service, the audio service module loads the target audio hardware abstraction module according to the first identifier, and obtains the number of times the audio service corresponding to the audio control instruction is started and the duration of the starting process.
[0191] Exemplarily, the audio service module may determine the current value of a preset counter in the audio startup configuration file as the number of startup times of the audio service.
[0192] Optionally, when the audio service module starts the audio service for the first time, it can also start a preset timer to record the duration of the startup process of the audio service through the preset timer. Based on this, the audio service module can determine the current value of the preset timer as the duration of the startup process of the audio service.
[0193] After the audio service module obtains the number of startup times and the duration of the startup process of the audio service, it can determine whether the number of startup times and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy.
[0194] Among them, the number of times the audio service is started and the duration of the startup process meet the processing conditions corresponding to the exception handling strategy, which may include: the duration of the startup process of the audio service is greater than or equal to the preset duration; or, the duration of the startup process of the audio service is less than the preset duration, and the number of times the audio service is started is greater than or equal to the preset number of times.
[0195] The number of startup times and the duration of the startup process of the audio service do not meet the processing conditions corresponding to the exception handling strategy, which may include: the duration of the startup process of the audio service is less than the preset duration, and the number of startup times of the audio service is less than the preset number.
[0196] Optionally, when the number of startup times and the duration of the startup process of the audio service do not meet the processing conditions corresponding to the exception handling strategy, S804 may be executed.
[0197] Optionally, if the number of startup times and the duration of the startup process of the audio service meet the processing conditions corresponding to the exception handling strategy, S807 may be executed.
[0198] S804: When the number of startup times and the duration of the startup process do not satisfy the processing conditions corresponding to the exception handling strategy, the target audio hardware abstraction module initializes the target audio hardware resources corresponding to the audio control instruction.
[0199] It should be noted that the target audio hardware abstraction module may detect the state of the target audio hardware resource during the process of initializing the target audio hardware resource. Exemplarily, the state of the audio hardware resource may include normal and abnormal.
[0200] In an optional implementation, when the target audio hardware abstraction module detects that the target audio hardware resources are abnormal, S805 to S806 may be executed.
[0201] In another optional implementation, when the target audio hardware abstraction module detects that the target audio hardware resources are normal, the initialization module may set the values of the preset counter and the preset timer to 0.
[0202] It should be noted that the process of initializing the target audio hardware resources corresponding to the audio control instruction can refer to the relevant description in S403 in the above embodiment, which will not be repeated here.
[0203] S805: When the target audio hardware abstraction module detects that the target audio hardware resource is abnormal, the target audio hardware abstraction module sends a restart instruction to the initialization module, wherein the restart instruction is used to prompt the initialization module to restart the audio service.
[0204] S806: The initialization module restarts the audio service according to the restart instruction, and increases the number of startup times of the audio service by 1.
[0205] Specifically, the initialization module can control the system service module to restart the audio service.
[0206] It should be noted that the process of restarting the audio service may be specifically referred to the relevant description in S404 in the above embodiment, which will not be described in detail here.
[0207] S807: When the number of startup times and the duration of the startup process meet the normal processing conditions, the initialization module obtains a preset initialization result for the target audio hardware resource according to the abnormal processing strategy.
[0208] Among them, the preset library file only includes the function interface corresponding to the target audio hardware resource, and the specific implementations of all functions corresponding to the target audio hardware resource are empty.
[0209] In a specific implementation, S807 may include S8071~S8072, which are described in detail as follows:
[0210] S8071: When the number of startup times and the duration of the startup process meet the normal processing conditions, the initialization module changes the first identifier to the target identifier and controls the system service module to start the audio service for the last time.
[0211] S8072: During the last start of the audio service, the audio service module loads the preset library file according to the target identifier to obtain a preset initialization result.
[0212] It should be noted that the process of obtaining the preset initialization result for the target audio hardware resource according to the exception handling strategy may specifically refer to the relevant description in S405 in the above embodiment, which will not be described in detail here.
[0213] It should be noted that S804 to S806 and S807 are parallel steps.
[0214] Based on the same technical concept, an embodiment of the present application also provides a computer-readable storage medium, which stores a computer-executable program. When the computer-executable program is called by a computer, the computer executes one or more steps in any of the above method embodiments.
[0215] Based on the same technical concept, the embodiment of the present application also provides a chip system, including a processor, the processor is coupled to a memory, and the processor executes a computer executable program stored in the memory to implement one or more steps in any of the above method embodiments. The chip system can be a single chip, or a chip module composed of multiple chips.
[0216] Based on the same technical concept, an embodiment of the present application also provides a computer executable program product. When the computer executable program product runs on an electronic device, the electronic device executes one or more steps in any of the above method embodiments.
[0217] In the above embodiments, the description of each embodiment has its own emphasis. For the parts not described or recorded in detail in a certain embodiment, please refer to the relevant description of other embodiments. It should be understood that the size of the sequence number of each step in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0218] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present application is generated in whole or in part. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions may be stored in a computer-readable storage medium or transmitted through the computer-readable storage medium. The computer instructions may be transmitted from one website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium may be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium may be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid state disk (SSD)), etc.
[0219] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.
[0220] The above is only a specific implementation of the embodiment of the present application, but the protection scope of the embodiment of the present application is not limited thereto, and any changes or replacements within the technical scope disclosed in the embodiment of the present application should be included in the protection scope of the embodiment of the present application. Therefore, the protection scope of the embodiment of the present application should be based on the protection scope of the claims.
Claims
1. A method for starting an audio service, characterized in that: include: Acquire an audio startup configuration file, and parse the first identifier of a target audio hardware abstraction module adapted to the current software system and an exception handling strategy when an audio hardware resource is abnormal from the audio startup configuration file; In the process of starting the audio service according to the audio control instruction, the target audio hardware abstraction module is loaded according to the first identifier, and the number of startup times and the duration of the startup process of the audio service corresponding to the audio control instruction are obtained; In the case where the number of startup times and the duration of the startup process do not satisfy the processing conditions corresponding to the exception handling strategy, initializing the target audio hardware resources corresponding to the audio control instruction through the target audio hardware abstraction module; During the process of initializing the target audio hardware resource, if an abnormality of the target audio hardware resource is detected, restarting the audio service and adding 1 to the number of startup times; When the number of startup times and the duration of the startup process meet the processing conditions, a preset initialization result for the target audio hardware resource is obtained according to the exception handling strategy; the preset initialization result is used to successfully start the audio service and fail to implement the corresponding audio function; Obtaining a preset initialization result for the target audio hardware resource according to the exception handling strategy, including: Modify the first identifier to a target identifier, and start the audio service for the last time; the last time the audio service is started refers to the last time the audio service is started after the number of starts and the duration of the start process meet the processing condition; During the last startup of the audio service, the preset library file is loaded according to the target identifier to obtain a preset initialization result; the preset library file only includes the function interface corresponding to the target audio hardware resource, and the specific implementations of all functions corresponding to the target audio hardware resource are empty.
2. The audio service startup method according to claim 1, characterized in that: When the number of startup times and the duration of the startup process meet the processing conditions, obtaining a preset initialization result for the target audio hardware resource according to the exception handling strategy includes: When the duration of the startup process is greater than or equal to the preset duration, obtaining a preset initialization result for the target audio hardware resource according to the exception handling strategy; or, When the duration of the startup process is less than the preset duration and the number of startups is greater than or equal to the preset number, a preset initialization result for the target audio hardware resource is obtained according to the exception handling strategy.
3. The audio service startup method according to claim 1, characterized in that: When the number of startup times and the duration of the startup process do not satisfy the processing conditions corresponding to the exception handling strategy, initializing the target audio hardware resources corresponding to the audio control instruction through the target audio hardware abstract module includes: When the duration of the startup process is less than the preset duration and the number of startups is less than the preset number of times, the target audio hardware resources corresponding to the audio control instruction are initialized through the target audio hardware abstract module.
4. The audio service startup method according to claim 1, characterized in that: Also includes: In the case where the number of startup times and the duration of the startup process meet the processing conditions corresponding to the exception handling strategy, the number of startup times and the duration of the startup process are both set to 0.
5. The audio service startup method according to claim 1, characterized in that: Also includes: During the process of initializing the target audio hardware resource, when it is detected that the target audio hardware resource is normal, the number of startup times and the duration of the startup process are both set to 0.
6. The audio service startup method according to any one of claims 1 to 4, characterized in that: Obtaining an audio startup configuration file, and parsing a first identifier of a target audio hardware abstraction module adapted to the current software system and an exception handling strategy when an audio hardware resource is abnormal from the audio startup configuration file, including: Start the initialization process during the power-on initialization process; The audio startup configuration file is obtained through the initialization process, and the first identifier of the target audio hardware abstract module adapted to the current software system and the exception handling strategy when the audio hardware resource is abnormal are parsed from the audio startup configuration file.
7. An electronic device, characterized in that: include: one or more processors, and memory; The memory is coupled to the one or more processors, and the memory is used to store computer program codes, wherein the computer program codes include computer instructions, and the one or more processors call the computer instructions to enable the electronic device to perform the method as claimed in any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that: The computer-readable storage medium comprises instructions, and when the instructions are executed on an electronic device, the electronic device executes the method as claimed in any one of claims 1 to 6.
9. A chip system, characterized in that: The chip system is applied to an electronic device, and the chip system includes one or more processors, and the one or more processors are used to call computer instructions so that the electronic device executes the method as described in any one of claims 1 to 6.
