An audio service architecture, access method, electronic device and chip system
By separating the native and extended features of the audio service architecture in the Android open-source project, and adopting a separate audio service architecture and access method, the problems of excessive coupling between self-developed features and native features and the lengthy call chain are solved, thereby simplifying the call chain and reducing maintenance costs.
Patent Information
- Application Number
- CN202411320207.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-20
- Publication Date
- 2026-02-06
- Estimated Expiration
- 2044-09-20
AI Technical Summary
In the Android open source project, the coupling between self-developed features and native features is too high, the logical structure is complex, and the call chain is lengthy, which leads to a lot of analysis and adaptation work when upgrading AOSP, and increases the maintenance difficulty.
By separating the native and extended features in the audio service architecture, and adopting native and extended features of the audio service, including native interface classes, external extended interface classes, and extended implementation classes, the coupling is reduced. Furthermore, by accessing the native implementation classes through extended interface functions, the dependencies between modules are reduced, and the call chain is simplified.
It reduces the coupling between native and extended features, simplifies the call chain, reduces the maintenance cost and difficulty during AOSP upgrades, and improves the stability and scalability of the system.
Smart Images

Figure CN120428946B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of electronic devices, and in particular to an audio service architecture, an access method, an electronic device, and a chip system. BACKGROUND
[0002] The Android Open Source Project (AOSP) contains the core components and tools of the Android system, such as the operating system kernel, the application framework, system services, and the like. Developers can perform secondary development based on the AOSP, thereby customizing some self-developed features (or extended features).
[0003] There can be problems such as excessively high coupling, complex logical structure, and long call link between the self-developed features and the native features. In particular, when the AOSP is upgraded, in order to avoid conflicts between the upgraded native features and the self-developed features, a large amount of analysis and adaptation work needs to be performed by the developers. Meanwhile, as the self-developed features increase, the native class becomes a super class, and it is not convenient to upgrade and maintain the AOSP and extend the self-developed features. SUMMARY
[0004] The present application provides an audio service architecture, an access method, an electronic device, and a chip system, which can reduce the coupling between the native features and the self-developed features, simplify the logical structure of the native features and the self-developed features, and shorten the call link between the native features and the self-developed features.
[0005] To achieve the above-mentioned purpose, the first aspect of the present application provides an audio service architecture, comprising:
[0006] a native feature of an audio service and an extended feature of the audio service;
[0007] The native feature of the audio service comprises a native interface class and a native implementation class. The native interface class is used to declare a native interface function. The native implementation class comprises an instance of the native interface function, and the instance of the native interface function is accessed through the native interface function.
[0008] The extended feature of the audio service comprises an external extension interface class, an internal extension interface class, and an extension implementation class. The external extension interface class is used to declare an external extension interface function, and the internal extension interface class is used to declare an internal extension interface function. The extension implementation class comprises an instance of the internal extension interface function, and the instance of the internal extension interface function is accessed through the internal extension interface function. The external extension interface function is also used to access the instance of the native interface function when called.
[0009] In the present application, native features and extended features in the audio service architecture are separated, and the coupling degree of the native features and the extended features is reduced; the extended features are divided into an extended interface class and an extended implementation class, an extended interface function is extended in the extended interface class, and the native implementation class is accessed through the extended interface function, so that the extension of the external interface of the native module is realized; the extended interface function instance is extended in the extended implementation class, so that the extension of the internal function is realized; when accessing the extended internal function, the extended interface function in the extended interface class is still required to access the extended interface function instance in the extended implementation class, so that the interface and implementation of the extended function are separated, the dependence on specific implementation classes between modules is reduced, and the extensibility and maintainability are improved; when accessing the implementation class, the mode of calling the interface function is used to realize, and the length of the calling link is shortened.
[0010] Since the extended features and the native features are separated and the coupling degree is low, when the AOSP is upgraded, the maintenance cost can be reduced.
[0011] As an implementation manner of the first aspect, the native interface class inherits the external extension interface function in the external extension interface class, and the instance of the native interface function is also accessed through the external extension interface function inherited by the native interface class.
[0012] In the present application, the extended interface function inherited in the native interface class is accessed through the inheritance mode, and the instance corresponding to the extended interface function can also be accessed without using the friend class access, the boundaries of various modules are clear, and the stability of the AOSP system is improved.
[0013] In a second aspect, an access method is provided, applied to an electronic device using the audio service architecture of any one of the first aspect, and the access method comprises:
[0014] The first module calls a first external extension interface function in the external extension interface class to send a first access request to an instance of a first native interface function corresponding to the first external extension interface function, and the first module is a module outside the audio service architecture;
[0015] The instance of the first native interface function obtains a first processing result corresponding to the first access request based on the first access request;
[0016] The instance of the first native interface function returns the first processing result to the first module through the first extended interface function.
[0017] In the present application, the part of the interface that is not opened by the native is extended and opened, so that the instance of the corresponding native interface function can be accessed through the external extension interface function, and more information can be obtained.
[0018] As another implementation form of the second aspect, the native interface class inherits the outward extension interface function in the outward extension interface class; and the method further includes:
[0019] The first module calls the first outward extension interface function inherited in the native interface class to send a second access request to an instance of a first native interface function corresponding to the first outward extension interface function, the first module being a module other than the audio service architecture;
[0020] The instance of the first native interface function obtains a second processing result corresponding to the second access request based on the second access request;
[0021] The instance of the first native interface function returns the second processing result to the first module through the first outward extension interface function.
[0022] In the present application, the extension interface function inherited in the native interface class is accessed through inheritance, and the instance corresponding to the extension interface function can also be accessed, without using a friend class to access, the boundaries of various modules are clear, and the stability of the AOSP system is improved.
[0023] As another implementation form of the second aspect, the first outward extension interface function is used to obtain a data format of an audio channel, and the instance of the first native interface function is located in a PlaybackThread; and the native interface class includes IAfPlaybackThread.
[0024] As another implementation form of the second aspect, the method further includes:
[0025] The second module calls a second native interface function in the native interface class to send a third access request to an instance of a second native interface function corresponding to the second native interface function;
[0026] The instance of the second native interface function accesses a second inward extension interface function in the inward extension interface class based on the third access request to send a fourth access request to an instance of the second inward extension interface function, the fourth access request and the third access request being the same in request matters;
[0027] The instance of the second inward extension interface function processes the fourth access request.
[0028] In the present application, the extension of internal functions is also implemented, wherein the extension of internal functions can enable the audio service to provide more audio-related functions, and meanwhile, the internal functions are interacted through the extended internal interface and the native characteristics, so that the invasive modification of the native code is avoided, the extension characteristics and the native characteristics can be decoupled and separated, and the maintenance difficulty of the AOSP is reduced.
[0029] As another implementation form of the first aspect, the native interface class comprises IAfPlaybackThread, the second native interface function is addtrack(), which is used to increase the number of playing audio, the instance of the second native interface function is located in PlaybackThread, and the second internal extension interface function is used to notify the increase of the number of playing audio tracks.
[0030] As another implementation form of the first aspect, the method further comprises:
[0031] The third module calls a third external extension interface function in the external extension interface class to send a fifth access request to an instance of a third native interface function corresponding to the third external extension interface function, and the third module is a module outside the audio service architecture;
[0032] The instance of the third native interface function calls a fourth internal extension interface function based on the fifth access request to send a sixth access request to an instance of the fourth internal extension interface function, and the sixth access request and the fifth access request have the same request matter;
[0033] The instance of the fourth internal extension interface function processes the sixth access request to obtain a third processing result corresponding to the sixth access request;
[0034] The instance of the fourth internal extension interface function sends the third processing result to the third module.
[0035] In the present application, other functions not provided by the native characteristics can be realized by using the extended external interface and the extended internal function, so that the system is more friendly, and the user experience is improved.
[0036] As another implementation form of the first aspect, the third external extension interface function is used to query a Bluetooth A2DP playing path, the instance of the third native interface function is located in PlaybackThread, and the fourth internal interface function is used to query the Bluetooth A2DP playing path.
[0037] In a third aspect, an electronic device is provided, which adopts the audio service architecture of the first aspect of the present application, and further comprises a processor, which is used to call a computer program stored in a memory to realize the method of any one of the second aspect of the present application.
[0038] In a fourth aspect, a chip system is provided, which adopts the audio service architecture of the first aspect of the present application, and comprises a processor coupled with a memory, and the processor executes a computer program stored in the memory to enable the electronic device to realize the method of any one of the second aspect of the present application.
[0039] In a fifth aspect, a computer readable storage medium is provided, and the computer readable storage medium stores a computer program, which, when executed on an electronic device, causes the electronic device to implement the method of any one of the second aspect.
[0040] In a sixth aspect, a computer program product is provided, and the computer program product, when executed on an electronic device, causes the electronic device to perform the method of any one of the second aspect.
[0041] It can be understood that the beneficial effects of the third aspect to the sixth aspect described above can be referred to the related description in the first aspect and the second aspect, and will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS
[0042] Figure 1 A hardware structure schematic diagram of an electronic device provided by an embodiment of the present application is provided.
[0043] Figure 2 A calling link schematic diagram of calling an extended feature provided by an embodiment of the present application is provided.
[0044] Figure 3 A logical relationship schematic diagram of a native feature and an extended feature provided by an embodiment of the present application is provided.
[0045] Figure 4 An external interface extension schematic diagram provided by an embodiment of the present application is provided.
[0046] Figure 5 A timing diagram of calling an external interface function to access a native implementation class provided by an embodiment of the present application is provided.
[0047] Figure 6 Another external interface extension schematic diagram provided by an embodiment of the present application is provided.
[0048] Figure 7 Another timing diagram of calling an external interface function to access a native implementation class provided by an embodiment of the present application is provided.
[0049] Figure 8 An internal function extension schematic diagram provided by an embodiment of the present application is provided.
[0050] Figure 9 A timing diagram of accessing an extended implementation class provided by an embodiment of the present application is provided.
[0051] Figure 10 A schematic diagram of simultaneously extending an external interface and an internal function provided by an embodiment of the present application is provided.
[0052] Figure 11A timing diagram for accessing an internal extension implementation class by calling an extension interface is provided. DETAILED DESCRIPTION
[0053] In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular sequences of steps, techniques, etc., in order to provide a thorough understanding of the present embodiments. However, it will be apparent to those skilled in the art that the present embodiments can be practiced in other embodiments that depart from these specific details.
[0054] It should be understood that the term "comprises" when used in this specification and the appended claims specifies the presence of stated features, integers, steps, operations, elements, and / or components, but does not preclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof.
[0055] It should also be understood that, in the present embodiments, "one or more" refers to one, two, or more than two; "and / or" describes the associated objects in the association relationship, which means that there can be three kinds of relationships; for example, A and / or B can mean that A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects.
[0056] In addition, in the description of the present application and the appended claims, the terms "first", "second", "third", "fourth" and the like are only used to distinguish the description, and cannot be understood as indicating or implying relative importance.
[0057] In the present specification, the reference to "one embodiment" or "some embodiments" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Therefore, the statements "in one embodiment", "in some embodiments", "in other some embodiments", "in yet some embodiments", etc. appearing in various places in the specification are not necessarily all referring to the same embodiment, but mean "one or more but not all embodiments", unless otherwise specifically emphasized. The terms "include", "contain", "have" and their variants mean "including but not limited to", unless otherwise specifically emphasized.
[0058] An audio service architecture and an access method are provided in the embodiments of the present application, which can be applied to an electronic device. The electronic device in the embodiments of the present application can be a tablet computer, a mobile phone, a wearable device, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a personal digital assistant (PDA), and the like. The embodiments of the present application do not limit the specific type of the electronic device.
[0059] Figure 1 A structural schematic diagram of an electronic device is shown. The electronic device 100 can 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 loudspeaker 170A, a receiver 170B, a microphone 170C, a headset interface 170D, a sensor module 180, a key 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, and the like. The sensor module 180 can include a pressure sensor 180A, a gyroscope sensor 180B, a barometric 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, and the like.
[0060] It can be understood that the structure shown in the embodiments of the present application does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 can include more or fewer components than shown, or combine certain components, or split certain components, or different component arrangements. The components shown can be implemented in hardware, software, or a combination of software and hardware.
[0061] Processor 110 may include one or more processing units, such as: application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU), etc. Different processing units may be independent devices or integrated into one or more processors.
[0062] The processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache memory. This memory can store instructions or data that the processor 110 has just used or that are used repeatedly. If the processor 110 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 110, and thus improves the efficiency of the system.
[0063] Internal memory 121 can be used to store computer executable program code, including instructions. Processor 110 executes various functional applications and data processing of electronic device 100 by running the instructions stored in internal memory 121. Internal memory 121 may include a program storage area and a data storage area. The program storage area may store the operating system and at least one application program required for a function (such as image playback). Touch sensor 180K, also called a "touch panel," can be disposed on display screen 194. Touch sensor 180K and display screen 194 together form a touch screen, also called a "touch screen." Touch sensor 180K is used to detect touch operations applied to or near it. Touch sensor can transmit the detected touch operation to application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 194. In other embodiments, touch sensor 180K may also be disposed on the surface of electronic device 100, in a different location than display screen 194.
[0064] Electronic device 100 can implement audio functions, such as music playback and recording, through audio module 170, speaker 170A, receiver 170B, microphone 170C, headphone jack 170D, and application processor.
[0065] The audio module 170 is configured to convert a digital audio signal into an analog audio signal output, and to convert an analog audio input into a digital audio signal. The audio module 170 can also be configured to encode and decode an audio signal. In some embodiments, the audio module 170 can be disposed in the processor 110, or some of the functional modules of the audio module 170 can be disposed in the processor 110.
[0066] The speaker 170A, also referred to as a "loudspeaker", is configured 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.
[0067] The receiver 170B, also referred to as a "earpiece", is configured to convert an audio electrical signal into a sound signal. When the electronic device 100 receives a call or a voice message, the user can listen to the voice through the receiver 170B close to the ear.
[0068] The microphone 170C, also referred to as a "microphone", "sound transducer", is configured to convert a sound signal into an electrical signal. When making a call or sending a voice message, the user can make a sound through the mouth close to the microphone 170C, and input the sound signal into the 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, in addition to listening to voice messages, it can also realize the function of noise reduction. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C, to realize the functions of collecting sound signals, noise reduction, and identifying sound sources, and realizing directional recording functions, etc. For example, the microphone 170C can be used to collect the voice information involved in the embodiments of the present application.
[0069] The earphone interface 170D is configured to connect a wired earphone. The earphone interface 170D can be a USB interface 130, or a 3.5mm open mobile terminal platform (OMTP) standard interface, a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0070] The electronic device 100 realizes the display function through the GPU, the display screen 194, and the application processor, etc. The GPU is a microprocessor for image processing, connected to the display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 110 can include one or more GPUs, which execute program instructions to generate or change display information.
[0071] The display screen 194 is configured to display images, videos, and the like. The display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flex light-emitting diode (FLED), a Miniled, a MicroLed, a Micro-OLED, a quantum dot light emitting diode (QLED), or the like. In some embodiments, the electronic device 100 can include one or N display screens 194, where N is a positive integer greater than 1.
[0072] The camera 193 is configured to capture still images or videos. An object generates an optical image through a lens and projects the optical image to a photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, and then transmits the electrical signal to an ISP to convert the electrical signal into a digital image signal. The ISP outputs the digital image signal to a DSP for processing. The DSP converts the digital image signal into an image signal in a standard format, such as RGB, YUV, or the like. In some embodiments, the electronic device 100 can include one or N cameras 193, where N is a positive integer greater than 1. The camera 193 can be a camera module in subsequent embodiments.
[0073] The embodiments of the present application do not particularly limit the specific structure of the execution subject of the access method, as long as the execution subject can run the code of the access method according to the embodiments of the present application to communicate according to the access method provided by the embodiments of the present application. For example, the execution subject of the access method provided by the embodiments of the present application can be a functional module capable of calling and executing programs in an electronic device, or a communication device applied to an electronic device, such as a chip.
[0074] The Android Open Source Project (AOSP) contains the core components and tools of the Android system, such as the operating system kernel, application framework, system services, etc. Developers can develop based on AOSP to customize some self-developed features (or extended features) on the basis of native features.
[0075] To more clearly understand the technical architecture and access method provided by the embodiments of the present application, the concepts of class, interface, implements, and object are first described.
[0076] A class is the basis for information encapsulation in object-oriented programming (OOP) and is a user-defined reference data type.
[0077] The interface keyword can be used to declare an interface, which can include constant attributes and abstract methods (also referred to as interface functions), but does not have specific implementation methods. Therefore, an interface cannot be instantiated.
[0078] The implements keyword can be used to represent a class that can be instantiated to implement one or more interfaces. Therefore, implements needs to provide specific implementations of the abstract methods declared in the interface. Implement is an implementation class that can be instantiated.
[0079] A class does not occupy memory space until an instantiated object is created based on the class, and memory space is allocated.
[0080] As an example, an interface function method() is declared by interface:
[0081] interface interface{
[0082] Void method();
[0083] }
[0084] The implementation class that implements the interface function method() is represented by implements:
[0085] class MyClass implements Interface{
[0086] public void method(){
[0087] / / The implementation of the interface function method()
[0088] }
[0089] }
[0090] An object is an instance of a class that can be instantiated, each object has member attributes and member functions (methods) that implement the class, and can implement the behavior of the class through member attributes and member functions.
[0091] After the concepts of class, interface, implementation and object are clear, the process of calling self-researched implementation class (or self-researched object) through native implementation class (or native object) to realize the function of self-researched feature is described.
[0092] In addition, the self-researched feature in the embodiments of the present application can also be recorded as an extended feature, the self-researched interface class can also be recorded as an extended interface class, the self-researched implementation class can also be recorded as an extended implementation class, and the self-researched object can also be recorded as an extended object.
[0093] The embodiments of the present application take the following call path as an example to describe the process of calling the extended implementation class through the native implementation class. Among them, AudioFlinger is a native implementation class, HonorAudioFlinger is an extended implementation class, and the extended feature in the extended object HonorAudioFlinger can be realized by calling the extended implementation class HonorAudioFlinger through the native implementation class AudioFlinger.
[0094] Referring to Figure 2 The call path in the logical structure shown in the figure: AudioFlinger (native implementation class, used to manage the audio channel)> AudioFlingerWrapper (extended implementation class, used to encapsulate function calls into messages)> HwAudioflingerExtendT (extended implementation class, channel for passing messages)> HonorAudioFlingerDispatcher (extended implementation class, used to distribute the current message to different interfaces and functions after unpacking, thereby realizing different self-researched functions)> HonorAudioFlinger (extended implementation class, used to realize some self-researched functions).
[0095] It can be understood that the link of calling the extended implementation class through the native implementation class is long, the coupling degree between the native implementation class and the extended implementation class is too high, and the logical structure between the native implementation class and the extended implementation class is complex.
[0096] As described above, the problem causes that when AOSP is upgraded, in order to avoid conflicts between the upgraded native features and the extended features, a large amount of analysis and adaptation work needs to be done by the developer.
[0097] At the same time, with the expansion of secondary development features, the original implementation class will become a super class, and the upgrade and maintenance of AOSP and the expansion of features will not be utilized.
[0098] To solve the above problems, the embodiment of the application provides a technical architecture, which isolates and decouples the original features and the expansion features, thereby avoiding the invasive modification of AOSP, and separates the interface class and the implementation class in the expansion features, and accesses the expansion object instantiated by the expansion implementation class of the expansion features by calling the expansion interface class of the expansion features.
[0099] Reference Figure 3 The technical architecture corresponding to the audio service provided by the embodiment of the application.
[0100] As shown in (a) in the figure, Figure 3 The original features of the audio service in AOSP. The original features of the audio service include a plurality of original implementation classes (implement) and a plurality of original interface classes (interface).
[0101] The original implementation class AudioFlinger is used to manage the creation of the audio playback channel; IAfThreadCallback is the original interface class for calling the instantiated object in AudioFlinger;
[0102] The original implementation class PlaybackThread is used to execute playback in the playback channel, and IAfPlaybackThread is the original interface class for calling the instantiated object in PlaybackThread;
[0103] The original implementation class RecordThread is used to execute recording, and IAfRecordThread is the original interface class for calling the instantiated object in RecordThread.
[0104] When the related original features need to be implemented, the external module can call the interface function in the related original interface class, so as to access the related instantiated original object through the interface function in the related original interface class, and implement the function corresponding to the interface function instantiated original object.
[0105] As shown in (b) in the figure, Figure 3 The expansion features based on the secondary development of the original features of the audio service in AOSP. The expansion features of the audio service also include a plurality of expansion implementation classes (implement) and a plurality of expansion interface classes (interface). In actual application, the number of expansion implementation classes and expansion interface classes is related to the expansion features.
[0106] The extension implementation class AfCustFactoryImplent is used to build the internal class, and the extension interface class AfCustFactory is used to call the instantiated object in the AfCustFactoryImplent.
[0107] The extension implementation class HonorAudioFlinger is used to extend some new functions on the basis of the native implementation class AudioFlinger, and the extension interface class IAudioFlingerEx is used to call the instantiated object in the HonorAudioFlinger by an external module.
[0108] The extension implementation class PlaybackThreadProxy is used to extend some new playback functions on the basis of the native implementation class PlaybackThread, the extension interface class IAfPlaybackThreadEx is used to call the instantiated object in the PlaybackThreadProxy by an external module, and the extension interface class IAfPlaybackThreadCust is used to call the instantiated object in the PlaybackThreadProxy by an internal module.
[0109] The extension implementation class RecordThreadProxy is used to extend some new recording functions on the basis of the native implementation class RecordThread, and the extension interface class IAfPlaybackThreadCust is used to call the instantiated object in the RecordThreadProxy by an internal module.
[0110] Here, the external module refers to a module outside the audio service architecture, and the internal module refers to a module inside the audio service architecture, for example, the native implementation class in the feature of the audio service.
[0111] By Figure 3 It can be understood that the embodiment of the present application separates the native features and the extension features, and reduces the logical structure complexity between the native features and the extension features.
[0112] Meanwhile, the extension interface class and the extension implementation class in the extension features are separated, when the extension implementation class in the extension features needs to be called, the calling is realized through the extension interface class in the extension features, the dependence between the specific implementation classes is reduced, the coupling between these implementation classes is reduced, when the AOSP needs to be upgraded, only the interface class needs to be maintained and adapted, thereby reducing the maintenance difficulty of the AOSP.
[0113] In addition, before introducing the access method provided by the embodiment of the present application, it is necessary to explain the calling mode of the instantiated object of the implementation class provided by the embodiment of the present application.
[0114] Currently, an interface class may declare multiple interface functions. For interface classes with multiple interface functions, the switch-case approach is often used when calling one of the interface functions. This approach requires setting different messages for different interface functions. For example, message1 corresponds to calling interface function 1, message2 corresponds to calling interface function 2, message3 corresponds to calling interface function 3, and so on.
[0115] When a module needs to call interface function 1, the module sends message 1 to the interface class where interface function 1 is located to call interface function 1 and implement the corresponding function.
[0116] When a module needs to call interface function 2, the module sends message2 to the interface class where interface function 2 is located to call interface function 2 and implement the corresponding function.
[0117] When a module needs to call interface function 3, the module sends message 3 to the interface class where interface function 3 is located to call interface function 3 and implement the function corresponding to interface function 3.
[0118] ...
[0119] It's understandable that if an interface class declares dozens of interface functions, this calling method requires setting dozens of messages and their corresponding interface functions, making the development process quite complex.
[0120] In this embodiment, an interface function reference can be used to point to an instantiated object that implements the interface function. This allows calling the specific interface function within the interface class to invoke the corresponding instantiated object. Corresponding to the declaration code of the interface class and the code of the implementation class described above, an instantiated object of the implementation class can be created and its methods called within the main function.
[0121] public class Main{
[0122] public static void main(String[]args){
[0123] MyClass myObj = new MyClass(); / / Create an instance of the implementation class.
[0124] myObj.method(); / / Calls the instantiated object by invoking the specific interface function method().
[0125] }
[0126] }
[0127] It can be understood that this calling manner is simple and direct, has better readability and maintainability.
[0128] The extension manner for the native feature in the technical architecture is described in detail below.
[0129] (I) Extension of the external interface class.
[0130] Some external interface classes have been included in the native feature, such as IAfThreadCallback, IAfPlaybackThread, and IAfRecordThread shown in (a) of Figure 3 These interface classes all declare one or more interface functions, however, more interface functions can be needed in actual application to extend and open the part of the interface not opened by the native, so as to obtain more information, and the external module can implement other functions according to the information. If some interface functions are directly added in the native interface class for declaration, it can cause more invasion to the native code and is not conducive to maintenance, therefore, the embodiment of the present application can define the extension interface class in the extension code.
[0131] For example, if it is needed to add the extension interface function in the native interface class IAfPlaybackThread to call the object instantiated in PlaybackThread, the extension interface function can be added in the extension interface class IAfPlaybackThreadEx in the corresponding extension feature to implement the function corresponding to the instantiated object of the extension interface function, so that some external extension interface functions can be added without invasion and modification of the native code.
[0132] Referring to the schematic diagram for adding the external extension interface function shown in Figure 4 .
[0133] Among them, IAfPlaybackThreadEx is the external extension interface class, the added external extension interface function A (the specific name can be named according to the actual situation) and the external extension interface function B (the specific name can be named according to the actual situation) can be declared in the extension interface class, and the external module can access the corresponding instantiated object in the native implementation class PlaybackThread through the external extension interface function in the external extension interface class.
[0134] The following will be described through the following Figure 5The timing chart shows the process of accessing the object instantiated by the PlaybackThread native implementation class through calling the externally extended interface function A and the externally extended interface function B in the IAfPlaybackThreadEx.
[0135] S101, the external module calls the externally extended interface function A in the externally extended interface class IAfPlaybackThreadEX.
[0136] The extended interface function A is used to obtain the data format of the audio channel. In actual application, for example, some self-developed features may need to use the data format of the audio channel, and the native feature does not open the interface. In this case, interface function A can be added to obtain the data format of the audio channel.
[0137] The data format of the audio channel is a variable in the native instance.
[0138] S102, the externally extended interface class IAfPlaybackThreadEX sends a data format acquisition request to the instantiated object corresponding to the interface function A in the playback thread (PlaybackThread) through the interface function A.
[0139] S103, after the instantiated object corresponding to the interface function A in the playback thread (PlaybackThread) receives the data format acquisition request, the data format is returned through the interface function A in the externally extended interface class IAfPlaybackThreadEX.
[0140] S104, the external module obtains the data format returned by the interface function A in the externally extended interface class IAfPlaybackThreadEX.
[0141] Of course, in actual application, after obtaining the data format, other externally extended interface functions can be called based on the obtained data format to query other information.
[0142] As another example of the process of accessing the object instantiated by the PlaybackThread native implementation class through the externally extended interface function B.
[0143] S105, the external module calls the interface function B in the externally extended interface class IAfPlaybackThreadEX.
[0144] S106, the interface function B in the externally extended interface class IAfPlaybackThreadEX sends a channel extension query request to the instantiated object corresponding to the interface function B in the playback thread (PlaybackThread).
[0145] S107, the instance object corresponding to the interface function B in the playback thread (PlaybackThread) receives the channel extension query request, and queries whether the channel has been extended by the native interface. The query result is: extended.
[0146] S108, the playback thread returns the query result: extended, through the interface function B in the external extension interface class IAfPlaybackThreadEx.
[0147] S109, the external module obtains the query result: extended returned by the interface function B in the external extension interface class IAfPlaybackThreadEx.
[0148] In addition, in order to realize the function corresponding to the extension feature through the way of calling the extension class by the native class, the extension interface function in the extension class can also be accessed by the native class through the way of setting a friend class.
[0149] As an example, an extension class can be declared as a friend class of a native class, so that all member functions in the native class can access the private member functions in the extension class. However, this will also cause the private member functions in the extension class to be accessed at will through the native class, which will also cause the problem of poor reliability during system upgrade.
[0150] As mentioned earlier, the interface function is declared in the interface class, but the specific implementation of the interface function is not included, so the extension interface function in the extension interface class can also be inherited by the native interface class, which is equivalent to declaring the extension interface function in the extension interface class in the native interface class. Therefore, the function corresponding to the extension interface function can also be realized by calling the extension interface function inherited in the native interface class. In this way, since the interface class is completely abstract and does not contain any specific implementation of the interface function, the inheritance mode of the interface class is more reliable than the friend class mode during AOSP upgrade. Of course, the inheritance of the interface class is also more reliable than the inheritance of the implementation class.
[0151] Referring to Figure 6 Another schematic diagram for adding an external extension interface function is shown in FIG.
[0152] Among them, IAfPlaybackThreadEx is an external extension interface class, and the native interface class IAfPlaybackThread inherits the external extension interface functions A and B in the external extension interface class IAfPlaybackThreadEx. The external module can access the instantiated object corresponding to the above interface function in the native implementation class PlaybackThread through the external extension interface functions A or B inherited by the native interface class IAfPlaybackThread.
[0153] The following describes the process of accessing the instantiated object of the native implementation class PlaybackThread through calling the externally extended interface functions A and B of the externally extended interface class IAfPlaybackThreadEx inherited by the native interface class IAfPlaybackThread, by means of the timing diagram shown in the following. Figure 7
[0154] S201, the external module calls the externally extended interface function A of the externally extended interface class IAfPlaybackThreadEx inherited by the native interface class IAfPlaybackThread.
[0155] S202, the native interface class IAfPlaybackThread sends a data format acquisition request to the instantiated object corresponding to the interface function A in the playback thread (PlaybackThread) through the externally extended interface function A of the externally extended interface class IAfPlaybackThreadEx inherited by the native interface class IAfPlaybackThread.
[0156] S203, after the instantiated object corresponding to the interface function A in the playback thread (PlaybackThread) receives the data format acquisition request, the instantiated object returns the data format through the externally extended interface function A of the externally extended interface class IAfPlaybackThreadEx inherited by the native interface class IAfPlaybackThread.
[0157] S204, the external module acquires the data format returned by the externally extended interface function A.
[0158] S205, the external module calls the externally extended interface function B of the externally extended interface class IAfPlaybackThreadEx inherited by the native interface class IAfPlaybackThread.
[0159] S206, the native interface class IAfPlaybackThread sends a channel extension query request to the instantiated object corresponding to the interface function B in the playback thread (PlaybackThread) through the externally extended interface function B of the externally extended interface class IAfPlaybackThreadEx inherited by the native interface class IAfPlaybackThread.
[0160] S207, after the instantiated object corresponding to the interface function B in the playback thread (PlaybackThread) receives the channel extension query request, the instantiated object queries whether the native interface has been extended for channel extension, and the query result is that the extension has been performed.
[0161] S208, the playback thread returns the query result: extended, through the externally extended interface function B of the externally extended interface class IAfPlaybackThreadEx inherited by the native interface class IAfPlaybackThread.
[0162] S209, the external module obtains the query result: extended, returned by the externally extended interface function B.
[0163] In this way, the object instantiated by the native implementation class can also be accessed by calling the native interface class, and since the specific implementation of the interface function is not included in the interface class, the reliability during AOSP upgrade is improved.
[0164] The embodiment of the present application further provides another extension mode for native features.
[0165] (ii) Extension of internal functions.
[0166] Some functions are implemented by the native implementation class in the native features, such as Figure 3 AudioFlinger, PlaybackThread and RecordThread shown in (b), however, in actual applications, some functions may need to be extended to meet more user demands, and if the extended functions are directly added in the native code, the invasion and damage to the native code are large, and the workload of AOSP maintenance is increased, therefore, the code and logic flow of the extended features need to be separated from the native code.
[0167] Referring to Figure 8 As shown in (a), if some function instances need to be added in the native implementation class PlaybackThread, the instances of the extended functions can be added in the corresponding extended implementation class PlaybackThreadProxy; in order to realize the information transmission between the native code (native implementation class PlaybackThread) and the extended code (extended implementation class PlaybackThreadProxy), and also to ensure the isolation of the two, the internally extended interface functions also need to be declared in the corresponding internally extended interface class IAfPlaybackThreadCust.
[0168] The native interface function C in the native interface class IAfPlaybackThread in the native feature can be called to access the instantiated object corresponding to the native interface function C (which can be the addtrack() function for adding the number of playing tracks) in the native implementation class PlaybackThread, and then the instantiated object in the native implementation class PlaybackThread can be called to access the instantiated object corresponding to the in-internal extension interface function D (which can be named according to actual needs) in the in-internal extension interface class IAfPlaybackThreadEx, and then the instantiated object in the extension implementation class PlaybackThreadProxy corresponding to the in-internal extension interface function D can be accessed.
[0169] Referring to Figure 9 The process of accessing the instantiated object in the extension implementation class and implementing the extension function provided by the embodiment of the application is shown in FIG. 3.
[0170] S301, the Track receives a playing instruction.
[0171] S302, the Track calls the native interface function C in the IAfPlaybackThread.
[0172] S303, the native interface function C in the IAfPlaybackThread sends a track adding instruction to the instantiated object corresponding to the interface function C in the PlaybackThread. The instruction is used to increase the number of playing tracks.
[0173] S304, after receiving the track adding instruction, the instantiated object corresponding to the interface function C in the PlaybackThread calls the in-internal extension interface function D in the in-internal extension interface class IAfPlaybackThreadCust.
[0174] S305, the IAfPlaybackThreadCust sends the track adding instruction to the instantiated object corresponding to the interface function D in the extension implementation class PlaybackThreadProxy through the in-internal extension interface function D. The instruction is used to notify the increase of the number of playing tracks.
[0175] S306, the instantiated object corresponding to the interface function D in the extension implementation class PlaybackThreadProxy updates the number of spatial audio sound effect channels.
[0176] When a new audio track is added, the internal extension interface function is called from the native module, thereby notifying the extension function entity (which then checks whether some self-developed logic needs to be executed, for example, if the current native audio channel is a spatial audio channel, the extension function entity checks and updates the number of channels of the spatial audio effect, of course, in addition to this, other self-developed processes can also be executed, thereby realizing self-developed functions.
[0177] It can be understood that the embodiments of the present application add instances of the internal extension interface function in the extension implementation class, and at the same time, declare the corresponding internal extension interface function in the extension interface class, when it is necessary to realize the corresponding function through the function instance in the extension implementation class, the corresponding interface function in the internal extension interface class can be called by the native implementation class to access the instance of the newly added internal extension interface function in the extension implementation class. In this way, while increasing self-developed functions, the native features and self-developed features are separated, reducing the specific dependency between the native implementation class and the extension implementation class, reducing the coupling degree between the extension features and the native features, thereby improving the extensibility and maintainability of AOSP.
[0178] In addition, the above-mentioned extension interface class and extension implementation class can be divided based on the logic of the native class, for example, the native interface class is divided into AudioFinger, PlaybackThread and RecordThread according to the logic, accordingly, if each of the listed native interface classes is extended with self-developed functions, then the extension implementation class is also divided into HonorAudioFinger, PlaybackThreadPorxy and RecordThreadPorxy corresponding to the above-mentioned three native interface classes according to the logic. Similarly, the extension interface class that declares the interface functions in these extension interface classes is also divided according to the logic of the native interface class, which can be specifically referred to Figure 3 for a one-to-one correspondence relationship.
[0179] In addition, in actual application, when implementing a certain function, it may also be necessary to simultaneously utilize the extension of the above-mentioned two ways: internal extension implementation and external extension interface, etc.
[0180] Referring to Figure 10 The instance of the internal extension interface function F (the specific name can be named according to actual needs) is added in the internal extension implementation class PlaybackThreadProxy, and the instance of the internal extension interface function F can be declared in the internal extension interface class IAfPlaybackThreadCust;
[0181] The externally extended interface function E (the specific name can be named according to actual needs) is declared in the externally extended interface class IAfPlaybackThreadEx, and the instantiated object in the native implementation class PlaybackThread can be accessed by calling the externally extended interface function E.
[0182] Referring to Figure 11 the access process shown in Figure 10 .
[0183] S401, the external module calls the externally interface function E in the externally extended interface class IAfPlaybackThreadEX.
[0184] S402, the externally extended interface class IAfPlaybackThreadEX sends a query request for a Bluetooth A2DP protocol playback channel to the instantiated object of the interface function E in the playback thread through the interface function E.
[0185] Among them, A2DP protocol is Advanced Audio Distribution Profile.
[0186] S403, the instantiated object corresponding to the interface function E in the playback thread receives the query request, and calls the internally extended interface function F in the internally extended interface class IAfPlaybackThreadCust.
[0187] S404, the internally extended interface class IAfPlaybackThreadCust sends a query request for a Bluetooth A2DP protocol playback channel to the instantiated object corresponding to the interface function F in the internally extended implementation class PlaybackThreadProxy through the internally extended interface function F.
[0188] S405, the internally extended implementation class PlaybackThreadProxy queries the Bluetooth A2DP protocol playback channel through the instantiated object corresponding to the internally extended interface function F.
[0189] S406, the instantiated object corresponding to the interface function F in the internally extended implementation class PlaybackThreadProxy returns the query result to the internally extended interface function F in the internally extended interface class IAfPlaybackThreadCust.
[0190] S407, the instantiated object corresponding to the interface function E in the native implementation class PlaybackThread obtains the query result from the internally extended interface function F.
[0191] S408, the instantiated object corresponding to the interface function E in the native implementation class PlaybackThread returns the query result to the external expansion interface function E.
[0192] S409, the external module obtains the query result from the external expansion interface function E.
[0193] It can be understood that the example includes the above two ways of expansion, that is, the expansion characteristics can include the external expansion interface class and the internal expansion implementation class.
[0194] Taking PlaybackThread as an example, PlaybackThread also needs to be modified on the basis of the native, and the implementation of the expansion interface function needs to be implemented, but the specific implementation code of this interface function is concentrated together and will not be scattered everywhere in the native module; and the implementation of this interface function is very simple and will not have complex logic, because there are usually two cases: 1, open the native unopened variables or functions, that is, the first expansion in the above; 2, call the self-developed module through the internal expansion interface, and implement complex logic in the self-developed module, that is, the second expansion in the above. In the specific implementation process, only the first expansion may be used, or the second expansion may be used, of course, both expansions may also be used.
[0195] In the above embodiment, some functions in the audio service are taken as examples, and in actual application, other functions in the audio service may also be expanded, and correspondingly, the interface functions declared in the above expansion interface class may be other interface functions, and the interface function instances added in the above expansion implementation class may also be other interface function instances; similarly, the interface class where the declared interface function is located is divided according to the logic, and the implementation class where the added interface function instance is located is also divided according to the logic.
[0196] Of course, the above implementation mode can also be applied to other services in the android system, for example, a video playing service, a camera service, etc.
[0197] In addition, the instantiated object corresponding to the above native interface function is not completely consistent with the native code, and can also be a native interface function modified by specific implementation.
[0198] The focus of the embodiment of the present application is not which external expansion interface functions are expanded and the specific implementation of these external expansion interface functions, nor which internal expansion interface functions are expanded and the specific implementation of these internal expansion interfaces, nor the functions that can be implemented through these expansion interface functions. The focus of the embodiment of the present application is the way of separating and decoupling the native characteristics and the self-developed characteristics, and the calling mode, so as to reduce the invasive modification of the native characteristics and improve the maintainability of AOSP.
[0199] With reference to Figure 3 An audio service architecture is provided in embodiments of the present application, which includes an audio service native feature and an audio service extended feature.
[0200] The audio service native feature includes a native interface class and a native implementation class, the native interface class is used to declare a native interface function, and the native implementation class includes an instance of the native interface function, which is accessed through the native interface function.
[0201] The audio service extended feature includes an external extension interface class (for example, IAfPlaybackThreadEx), an internal extension interface class (for example, IAfPlaybackThreadCust), and an extension implementation class (for example, PlaybackThreadProxy), the external extension interface class is used to declare an external extension interface function, and the internal extension interface class is used to declare an internal extension interface function; the extension implementation class includes an instance of the internal extension interface function, which is accessed through the internal extension interface function; the external extension interface function is also used to access the instance of the native interface function when called.
[0202] As another embodiment of the present application, with reference to Figure 6 and Figure 7 The native interface class inherits the external extension interface function in the external extension interface class, and the instance of the native interface function is also accessed through the external extension interface function inherited by the native interface class.
[0203] An access method is provided in embodiments of the present application, which is applied to an electronic device using Figure 3 the audio service architecture, and the access method includes:
[0204] A first module calls a first external extension interface function (for example, interface function A or interface function B) in the external extension interface class to send a first access request to an instance of a first native interface function corresponding to the first external extension interface function, and the first module is a module outside the audio service architecture;
[0205] The instance of the first native interface function obtains a first processing result corresponding to the first access request based on the first access request;
[0206] The instance of the first native interface function returns the first processing result to the first module through the first extension interface function.
[0207] As another embodiment of the present application, the native interface class inherits the external extension interface function in the external extension interface class; the method further includes:
[0208] The first module calls the first outward extension interface function in the native interface class to send a second access request to an instance of a first native interface function corresponding to the first outward extension interface function, the first module being a module other than the audio service framework;
[0209] The instance of the first native interface function obtains a second processing result corresponding to the second access request based on the second access request;
[0210] The instance of the first native interface function returns the second processing result to the first module through the first outward extension interface function.
[0211] As another embodiment of the present application, the first outward extension interface function is used to obtain a data format of an audio channel, and the instance of the first native interface function is located in a PlaybackThread; the native interface class includes IAfPlaybackThread.
[0212] As another embodiment of the present application, the method further includes:
[0213] A second module (for example, Track) in the audio service framework calls a second native interface function (for example, interface function C) in the native interface class to send a third access request to an instance of a second native interface function corresponding to the second native interface function; Figure 8
[0214] The instance of the second native interface function accesses a second inward extension interface function (for example, interface function D) in the inward extension interface class based on the third access request to send a fourth access request to an instance of the second inward extension interface function, the fourth access request and the third access request being the same in request matters;
[0215] The instance of the second inward extension interface function processes the fourth access request.
[0216] As another embodiment of the present application, the native interface class includes IAfPlaybackThread, the second native interface function is addtrack(), which is used to increase the number of playing tracks, the instance of the second native interface function is located in a PlaybackThread, and the second inward extension interface function is used to notify the increase of the number of playing tracks.
[0217] As another embodiment of the present application, the method further includes:
[0218] The third module calls a third external expansion interface function (for example, interface function E) in the external expansion interface class to send a fifth access request to an instance of a third native interface function corresponding to the third external expansion interface function, the third module being a module other than the audio service architecture;
[0219] The instance of the third native interface function calls a fourth internal expansion interface function (for example, interface function F) based on the fifth access request to send a sixth access request to an instance of the fourth internal expansion interface function, the sixth access request and the fifth access request being the same in request matters;
[0220] The instance of the fourth internal expansion interface function processes the sixth access request to obtain a third processing result corresponding to the sixth access request;
[0221] The instance of the fourth internal expansion interface function sends the third processing result to the third module.
[0222] As another embodiment of the present application, the third external expansion interface function is used to query a Bluetooth A2DP playback channel, the instance of the third native interface function is located in a PlaybackThread, and the fourth internal interface function is used to query a Bluetooth A2DP playback channel.
[0223] It should be understood that the size of the serial number of each step in the above embodiments does not mean the order of execution, and the execution order of each process should be determined according to its function and inherent logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0224] The embodiments of the present application also provide a computer readable storage medium, which stores a computer program, and the computer program can implement the steps in each method embodiment of the present application when running on an electronic device.
[0225] The embodiments of the present application also provide a computer program product, which, when running on an electronic device or a wireless router, enables the electronic device to implement the steps in each method embodiment.
[0226] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the computer program for instructing the related hardware to complete all or part of the processes in the above-mentioned embodiments can be stored in a computer readable storage medium, and the computer program can implement the steps of the above-mentioned method embodiments when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms. The computer readable medium at least includes any entity or device capable of carrying the computer program code to the first device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunications signal and a software distribution medium. For example, a U disk, a mobile hard disk, a magnetic disk or an optical disk, etc. In some jurisdictions, according to legislation and patent practice, the computer readable medium can not be an electrical carrier signal and a telecommunications signal.
[0227] The embodiments of the present application also provide a chip, which includes a processor and a memory. The processor is coupled with the memory. The processor invokes a computer program stored in the memory to implement the steps of any method embodiment of the present application. The chip can be a single chip or a chip module composed of multiple chips.
[0228] In the above embodiments, the description of each embodiment has its own focus. The parts not described or recorded in detail in a certain embodiment can be referred to the relevant description of other embodiments.
[0229] Those skilled in the art can appreciate that the units and method steps of the examples described in combination with the embodiments disclosed herein can be implemented in electronic hardware or a combination of computer software and electronic hardware. Whether the functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. The skilled person can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present application.
[0230] The above embodiments are only used to illustrate the technical solutions of the present application, but not limit them. Although the present application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that the technical solutions recorded in the foregoing embodiments can be modified, or some technical features can be replaced by equivalent ones. Such modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application.
Claims
1. An audio service architecture, characterized by The method comprises: audio service native features and audio service extended features; the audio service native features comprise a native interface class and a native implementation class, the native interface class is used to declare a native interface function; the native implementation class comprises an instance of the native interface function, the instance of the native interface function is accessed through the native interface function; the audio service extended features comprise an external extension interface class, an internal extension interface class and an extension implementation class, the external extension interface class is used to declare an external extension interface function, the internal extension interface class is used to declare an internal extension interface function; the extension implementation class comprises an instance of the internal extension interface function, the instance of the internal extension interface function is accessed through the internal extension interface function; the external extension interface function is also used to access the instance of the native interface function when called.
2. The audio service architecture of claim 1, wherein, The native interface class inherits the external extension interface function in the external extension interface class, and the instance of the native interface function is also accessed through the external extension interface function inherited by the native interface class.
3. An access method, characterized by, The method is applied to an electronic device using the audio service architecture in any one of claims 1 to 2, and the method comprises: a first module calls a first external extension interface function in the external extension interface class to send a first access request to an instance of a first native interface function corresponding to the first external extension interface function, the first module being a module other than the audio service architecture; the instance of the first native interface function obtains a first processing result corresponding to the first access request based on the first access request; the instance of the first native interface function returns the first processing result to the first module through the first external extension interface function.
4. The method of claim 3, wherein, The native interface class inherits the external extension interface function in the external extension interface class; the method further comprises: the first module calls the first external extension interface function inherited in the native interface class to send a second access request to an instance of a first native interface function corresponding to the first external extension interface function, the first module being a module other than the audio service architecture; the instance of the first native interface function obtains a second processing result corresponding to the second access request based on the second access request; the instance of the first native interface function returns the second processing result to the first module through the first external extension interface function.
5. The method of claim 4, wherein, The first external extension interface function is used to obtain a data format of an audio channel, the instance of the first native interface function is located in a PlaybackThread, and the native interface class comprises IAfPlaybackThread.
6. The method according to any one of claims 3 to 5, characterized in that, The method further comprises: a second module calls a second native interface function in the native interface class to send a third access request to an instance of a second native interface function corresponding to the second native interface function; The instance of the second native interface function accesses, based on the third access request, a second internal extension interface function in the internal extension interface class to send a fourth access request to an instance of the second internal extension interface function, the fourth access request and the third access request being the same in request matter; The instance of the second internal extension interface function processes the fourth access request.
7. The method of claim 6, wherein, The native interface class includes IAfPlaybackThread, the second native interface function is used for increasing the number of playing tracks, the instance of the second native interface function is located in PlaybackThread, and the second internal extension interface function is used for notifying the increase of the number of playing tracks.
8. The method according to any one of claims 3 to 7, characterized in that, The method further includes: The third module calls a third external extension interface function in the external extension interface class to send a fifth access request to an instance of a third native interface function corresponding to the third external extension interface function, the third module being a module other than the audio service architecture; The instance of the third native interface function calls, based on the fifth access request, a fourth internal extension interface function to send a sixth access request to an instance of the fourth internal extension interface function, the sixth access request and the fifth access request being the same in request matter; The instance of the fourth internal extension interface function processes the sixth access request to obtain a third processing result corresponding to the sixth access request; The instance of the fourth internal extension interface function sends the third processing result to the third module.
9. The method of claim 8, wherein, The third external extension interface function is used for querying a Bluetooth A2DP playing channel, the instance of the third native interface function is located in PlaybackThread, and the fourth internal extension interface function is used for querying the Bluetooth A2DP playing channel.
10. An electronic device, comprising: The electronic device includes one or more processors and one or more memories; wherein the one or more memories are coupled with the one or more processors, and the one or more memories are configured to store a computer program, when the one or more processors execute the computer program, the electronic device is caused to perform the method according to any one of claims 3-9.
11. A chip system applied to an electronic device, the chip system comprising one or more processors, characterized in that, The processor is configured to call a computer instruction to cause the electronic device to perform the method according to any one of claims 3-9.
12. A computer readable storage medium comprising a computer program, characterized in that, When the computer program runs on the electronic device, the electronic device is caused to perform the method according to any one of claims 3-9.
Citation Information
Patent Citations
Frame code modifying method and device based on Android system
CN104731581A
Volume adjustment method, electronic equipment and computer readable storage medium
CN118175228A