安卓音效AudioEffect源码剖析2——音效库接口

本文深入探讨了Android音效库的audio_effect_library_t结构体,包括其在不同Android版本的变化,以及effect_handle_t接口的定义。重点讲解了如何定制音效库的接口,并强调了在导出符号时的注意事项。
摘要由CSDN通过智能技术生成

1、库的导出符号表——audio_effect_library_t

audio_effect_library_t的定义在hardware/libhardware/include/hardware/audio_effect.h中。

这个结构体在Android4.3+时有发生变化,query_num_effects()和query_effect()被删除。

如果希望做库兼容性,需要检测EFFECT_LIBRARY_API_VERSION,当其为

#ifEFFECT_API_VERSION_MAJOR(EFFECT_LIBRARY_API_VERSION) > 2时query_num_effects()和query_effect()不复存在。

typedef struct audio_effect_library_s {
    // tag must be initialized to AUDIO_EFFECT_LIBRARY_TAG
    uint32_t tag;
    // Version of the effect library API : 0xMMMMmmmm MMMM: Major, mmmm: minor
    uint32_t version;
    // Name of this library
    const char *name;
    // Author/owner/implementor of the library
    const char *implementor;

    
    //
    //    Function:        query_num_effects
    //
    //    Description:    Returns the number of different effects exposed by the
    //          library. Each effect must have a unique effect uuid (see
    //          effect_descriptor_t). This function together with EffectQueryEffect()
    //          is used to enumerate all effects present in the library.
    //
    //    Input/Output:
    //          pNumEffects:    address where the number of effects should be returned.
    //
    //    Output:
    //        returned value:    0          successful operation.
    //                          -ENODEV     library failed to initialize
    //                          -EINVAL     invalid pNumEffects
    //        *pNumEffects:     updated with number of effects in library
    //
    
    int32_t (*query_num_effects)(uint32_t *pNumEffects);

    
    //
    //    Function:        query_effect
    //
    //    Description:    Returns the descriptor of the effect engine which index is
    //          given as argument.
    //          See effect_descriptor_t for details on effect descriptors.
    //          This function together with EffectQueryNumberEffects() is used to enumerate all
    //          effects present in the library. The enumeration sequence is:
    //              EffectQueryNumberEffects(&num_effects);
    //              for (i = 0; i < num_effects; i++)
    //                  EffectQueryEffect(i,...);
    //
    //    Input/Output:
    //          index:          index of the effect
    //          pDescriptor:    address where to return the effect descriptor.
    //
    //    Output:
    //        returned value:    0          successful operation.
    //                          -ENODEV     library failed to initialize
    //                          -EINVAL     invalid pDescriptor or index
    //                          -ENOSYS     effect list has changed since last execution of
    //                                      EffectQueryNumberEffects()
    //                          -ENOENT     no more effect available
    //        *pDescriptor:     updated with the effect descriptor.
    /
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值