opensl es 提供了三种类型:分别是 SL_PROFILES_PHONE(手机);SL_PROFILES_MUSIC(音乐); SL_PROFILES_GAME (游戏)。
如果你使用的手机的开发商使用了OpenSL ES 的话,会有一个类似于上面的sl配置。如果是手机的话,一般会是SL_PROFILES_PHONE 在android较低的版本下也就意味着某些Opensl es 的功能不可用。
下面是查询代码:
1 SLObjectItf _engineObject; 2 SLresult result; 3 result = slCreateEngine(&_engineObject, 0, NULL, 0, NULL, NULL); 4 assert(SL_RESULT_SUCCESS == result); 5 6 result = (*_engineObject)->Realize(_engineObject, SL_BOOLEAN_FALSE); 7 assert(SL_RESULT_SUCCESS == result); 8 9 SLEngineCapabilitiesItf capabilities; 10 SLuint16 profilesSupported; 11 result = (*_engineObject)->GetInterface(_engineObject, SL_IID_ENGINECAPABILITIES, &capabilities); 12 assert(SL_RESULT_SUCCESS == result); 13 result = (*capabilities)->QuerySupportedProfiles (capabilities, &profilesSupported); 14 assert(SL_RESULT_SUCCESS == result); 15 16 if (profilesSupported & SL_PROFILES_PHONE) 17 { 18 //手机 19 LOGI("SL_PROFILES_PHONE"); 20 } 21 if (profilesSupported & SL_PROFILES_MUSIC) 22 { 23 //音乐 24 LOGI("SL_PROFILES_MUSIC"); 25 } 26 if (profilesSupported & SL_PROFILES_GAME) 27 { 28 //游戏 29 LOGI("SL_PROFILES_GAME"); 30 }
备注:可能有些设备获取不了引擎功能接口 SLEngineCapabilitiesItf;