audio DevicesFactory

audio DevicesFactory

 

xref: /hardware/interfaces/audio/common/all-versions/default/service/service.cpp

int main(int /* argc */, char* /* argv */ []) {
    android::ProcessState::initWithDriver("/dev/vndbinder");
    // start a threadpool for vndbinder interactions
    android::ProcessState::self()->startThreadPool();
    configureRpcThreadpool(16, true /*callerWillJoin*/);

    bool fail = registerPassthroughServiceImplementation<audio::V4_0::IDevicesFactory>() != OK &&
                registerPassthroughServiceImplementation<audio::V2_0::IDevicesFactory>() != OK; LOG_ALWAYS_FATAL_IF(fail, "Could not register audio core API 2.0 nor 4.0"); fail = registerPassthroughServiceImplementation<audio::effect::V4_0::IEffectsFactory>() != OK && registerPassthroughServiceImplementation<audio::effect::V2_0::IEffectsFactory>() != OK, LOG_ALWAYS_FATAL_IF(fail, "Could not register audio effect API 2.0 nor 4.0"); fail = registerPassthroughServiceImplementation<soundtrigger::V2_1::ISoundTriggerHw>() != OK && registerPassthroughServiceImplementation<soundtrigger::V2_0::ISoundTriggerHw>() != OK, ALOGW_IF(fail, "Could not register soundtrigger API 2.0 nor 2.1"); fail = registerPassthroughServiceImplementation<bluetooth::a2dp::V1_0::IBluetoothAudioOffload>() != OK; ALOGW_IF(fail, "Could not register Bluetooth audio offload 1.0"); joinRpcThreadpool(); }

 

registerPassthroughServiceImplementation()

xref: /system/libhidl/transport/include/hidl/LegacySupport.h

template<class Interface>
__attribute__((warn_unused_result))
status_t registerPassthroughServiceImplementation(
        std::string name = "default") {
    sp<Interface> service = Interface::getService(name, true /* getStub */);

    if (service == nullptr) {
        ALOGE("Could not get passthrough implementation for %s/%s.",
            Interface::descriptor, name.c_str());
        return EXIT_FAILURE; } LOG_FATAL_IF(service->isRemote(), "Implementation of %s/%s is remote!", Interface::descriptor, name.c_str()); status_t status = service->registerAsService(name); if (status == OK) { ALOGI("Registration complete for %s/%s.", Interface::descriptor, name.c_str()); } else { ALOGE("Could not register service %s/%s (%d).", Interface::descriptor, name.c_str(), status); } return status; }

Interface :: getService getStub above parameters () is true, the so getRawServiceInternal () in ServiceManagement.cpp in, will go directly to the following pm = getPassthroughServiceManager (); pm-> get ()
it will perform PassthroughServiceManager :: get (), this function also ServiceManagement.cpp years. This function library to open so as to IDevicesFactory for example, will go to open [email protected]. After this call will be open so where HIDL_FETCH_IDevicesFactory (), and this function will DevicesFactory a new object, as follows:
Hardware \ in the interfaces \ Audio \ Core \ All-versions \ default \ the include \ Core \ All-versions \ default \ DevicesFactory.impl .h
IDevicesFactory* HIDL_FETCH_IDevicesFactory(const char* /* name */) {

return new DevicesFactory();

}

 DevicesFactory inherited IDevicesFactory (class / .intermediates at soong)

Continue PassthroughServiceManager :: get (), this function will next call RegisterReference (actualFqName, name), this is IDevicesFactory actualFqName in DevicesFactoryAll.cpp where :: descriptor, it is [email protected] :: IDevicesFactory

 

So getRawServiceInternal () return a DevicesFactory object back getServiceInternal (), because DevicesFactory inherited IDevicesFactory, and IDevicesFactory :: isRemote () returns false, it will perform the following IType :: castFrom (base), this function is directly return parent, that is, return base parameter, which is DevicesFactory object.

 

Then return to registerPassthroughServiceImplementation (), and then perform service-> registerAsService (), that is performed IDevicesFactory :: registerAsService ()

 

The above will go to open [email protected], so that in the search path:

xref: /system/libhidl/base/include/hidl/HidlInternal.h

#define HAL_LIBRARY_PATH_SYSTEM_64BIT "/system/lib64/hw/"
#define HAL_LIBRARY_PATH_VNDK_SP_64BIT_FOR_VERSION "/system/lib64/vndk-sp%s/hw/"
#define HAL_LIBRARY_PATH_VENDOR_64BIT "/vendor/lib64/hw/"
#define HAL_LIBRARY_PATH_ODM_64BIT    "/odm/lib64/hw/"
#define HAL_LIBRARY_PATH_SYSTEM_32BIT "/system/lib/hw/"
#define HAL_LIBRARY_PATH_VNDK_SP_32BIT_FOR_VERSION "/system/lib/vndk-sp%s/hw/"
#define HAL_LIBRARY_PATH_VENDOR_32BIT "/vendor/lib/hw/"
#define HAL_LIBRARY_PATH_ODM_32BIT    "/odm/lib/hw/"

#if defined(__LP64__)
#define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_64BIT
#define HAL_LIBRARY_PATH_VNDK_SP_FOR_VERSION HAL_LIBRARY_PATH_VNDK_SP_64BIT_FOR_VERSION
#define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_64BIT
#define HAL_LIBRARY_PATH_ODM    HAL_LIBRARY_PATH_ODM_64BIT
#else
#define HAL_LIBRARY_PATH_SYSTEM HAL_LIBRARY_PATH_SYSTEM_32BIT
#define HAL_LIBRARY_PATH_VNDK_SP_FOR_VERSION HAL_LIBRARY_PATH_VNDK_SP_32BIT_FOR_VERSION
#define HAL_LIBRARY_PATH_VENDOR HAL_LIBRARY_PATH_VENDOR_32BIT
#define HAL_LIBRARY_PATH_ODM    HAL_LIBRARY_PATH_ODM_32BIT
#endif

 

 

That is what this [email protected] makefile to build it do? as follows:

cc_library_shared {
    name: "[email protected]",
    relative_install_path: "hw",
    proprietary: true,
    vendor: true,
    srcs: [
        "Conversions.cpp",
        "Device.cpp",
        "DevicesFactory.cpp",
        "ParametersUtil.cpp",
        "PrimaryDevice.cpp",
        "Stream.cpp",
        "StreamIn.cpp",
        "StreamOut.cpp",
    ],

    cflags: [
        "-DAUDIO_HAL_VERSION_4_0",
    ],

    defaults: ["hidl_defaults"],

    export_include_dirs: ["include"],

    shared_libs: [
        "libbase",
        "libcutils",
        "libfmq",
        "libhardware",
        "libhidlbase",
        "libhidltransport",
        "liblog",
        "libutils",
        "[email protected]",
        "[email protected]",
        "[email protected]",
        "android.hardware.audio.common-util",
    ],

    header_libs: [
        "android.hardware.audio.common.util@all-versions",
        "android.hardware.audio.core@all-versions-impl",
        "libaudioclient_headers",
        "libaudio_system_headers",
        "libhardware_headers",
        "libmedia_headers",
    ],

    whole_static_libs: [
        "libmedia_helper",
    ],

}

 

Guess you like

Origin www.cnblogs.com/aspirs/p/11605154.html