Android 对属性“”的未定义引用

Android 对属性“”的未定义引用,android,android-ndk,Android,Android Ndk,我的目标是进行微调以找到合适的线程优先级 我关注的线程位于/hardware/my_company/codec/openmax_il下/ 我修改了2个文件 Android.mk 将“$(顶部)/system/core/include”添加到本地_C_include列表中,如下所示 LOCAL_C_INCLUDES:= \ blur blur blur $(TOP)/hardware/my_company/camera/v4l2_camerahal \ $(TOP)/sy

我的目标是进行微调以找到合适的线程优先级

我关注的线程位于/hardware/my_company/codec/openmax_il下/

我修改了2个文件

  • Android.mk

    将“$(顶部)/system/core/include”添加到本地_C_include列表中,如下所示

    LOCAL_C_INCLUDES:= \
    
        blur blur blur
        $(TOP)/hardware/my_company/camera/v4l2_camerahal \
        $(TOP)/system/core/include
    
  • 在我的源文件中

    #include <cutils/properties.h>
    
    int componentInit(blur blur blur)
    {
       int ret = 0;
    
       blur blur blur
    
       // To find proper thread priority
       char value[92];
       property_get("omx.video_enc.priority", value, "0");
       setVideoEncoderPriority(atoi(value));
    
       return ret;
    }
    
    如果有人能帮上忙,那对我就好了。:)


    谢谢

    听起来您想使用
    \uu系统\u属性\u get()
    ,这是在
    中定义的。从该标题:

    /* Look up a system property by name, copying its value and a
    ** \0 terminator to the provided pointer.  The total bytes
    ** copied will be no greater than PROP_VALUE_MAX.  Returns
    ** the string length of the value.  A property that is not
    ** defined is identical to a property with a length 0 value.
    */
    int __system_property_get(const char *name, char *value);
    
    此签名并不完全是您想要使用的,因为在未定义属性的情况下,您有一个默认值。由于
    \uuuu system\u property\u get()
    在未定义属性的情况下返回0,因此您可以自己轻松地进行补充

    下面是我如何在自己的本机代码中解决这个问题的,它对我来说很好(尽管它缺少缓冲区溢出检查,这是一个更好的解决方案):

    #包括
    int android_属性_get(常量字符*键、字符*值、常量字符*默认值)
    {
    int iReturn=\uuuuuu系统\uu属性\uu获取(键,值);
    如果(!iReturn)strcpy(值,默认值);
    返回i返回;
    }
    
    您必须添加到源文件中

    #include <cutils/properties.h>
    
    您需要添加:

     #include <cutil/properties.h>
    
    #include <cutils/properties.h>
    
    LOCAL_STATIC_LIBRARIES := libcutils libc
    
     #include <cutil/properties.h>
    
    LOCAL_WHOLE_STATIC_LIBRARIES := libcutils`