void OMXMaster::addPlugin(OMXPluginBase *plugin) { Mutex::Autolock autoLock(mLock); mPlugins.push_back(plugin); OMX_U32 index = 0; char name[128]; OMX_ERRORTYPE err; while ((err = plugin->enumerateComponents( name, sizeof(name), index++)) == OMX_ErrorNone) { String8 name8(name); if (mPluginByComponentName.indexOfKey(name8) >= 0) { LOGE("A component of name '%s' already exists, ignoring this one.", name8.string()); continue; } mPluginByComponentName.add(name8, plugin); } //Temporary fix to be able to use overlay with s/w codecs #ifndef OMX_FIX CHECK_EQ(err, OMX_ErrorNoMore); #endif }
void NVOMXMaster::addPlugin(OMXPluginBase *plugin) { Mutex::Autolock autoLock(mLock); mPlugins.push_back(plugin); OMX_U32 index = 0; char name[128]; OMX_ERRORTYPE err; while ((err = plugin->enumerateComponents( name, sizeof(name), index++)) == OMX_ErrorNone) { String8 name8(name); if (mPluginByComponentName.indexOfKey(name8) >= 0) { ALOGE("A component of name '%s' already exists, ignoring this one.", name8.string()); continue; } mPluginByComponentName.add(name8, plugin); } if (err != OMX_ErrorNoMore) { ALOGE("OMX plugin failed w/ error 0x%08x after registering %d " "components", err, mPluginByComponentName.size()); } }
static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jclass clazz, jstring name, jint mode) { if (name == NULL) { jniThrowNullPointerException(env, NULL); return NULL; } const jchar* str = env->GetStringCritical(name, 0); if (str == NULL) { // Whatever, whatever. jniThrowException(env, "java/lang/IllegalStateException", NULL); return NULL; } String8 name8((const char16_t*)str, env->GetStringLength(name)); env->ReleaseStringCritical(name, str); int flags=0; switch (mode&0x30000000) { case 0: case 0x10000000: flags = O_RDONLY; break; case 0x20000000: flags = O_WRONLY; break; case 0x30000000: flags = O_RDWR; break; } if (mode&0x08000000) flags |= O_CREAT; if (mode&0x04000000) flags |= O_TRUNC; if (mode&0x02000000) flags |= O_APPEND; int realMode = S_IRWXU|S_IRWXG; if (mode&0x00000001) realMode |= S_IROTH; if (mode&0x00000002) realMode |= S_IWOTH; int fd = open(name8.string(), flags, realMode); if (fd < 0) { jniThrowException(env, "java/io/FileNotFoundException", strerror(errno)); return NULL; } jobject object = jniCreateFileDescriptor(env, fd); if (object == NULL) { close(fd); } return object; }
static jobject android_os_Parcel_openFileDescriptor(JNIEnv* env, jclass clazz, jstring name, jint mode) { if (name == NULL) { jniThrowNullPointerException(env, NULL); return NULL; } ScopedUtfChars name8(env, name); if (name8.c_str() == NULL) { return NULL; } int flags=0; switch (mode&0x30000000) { case 0: case 0x10000000: flags = O_RDONLY; break; case 0x20000000: flags = O_WRONLY; break; case 0x30000000: flags = O_RDWR; break; } if (mode&0x08000000) flags |= O_CREAT; if (mode&0x04000000) flags |= O_TRUNC; if (mode&0x02000000) flags |= O_APPEND; int realMode = S_IRWXU|S_IRWXG; if (mode&0x00000001) realMode |= S_IROTH; if (mode&0x00000002) realMode |= S_IWOTH; int fd = open(name8.c_str(), flags, realMode); if (fd < 0) { jniThrowException(env, "java/io/FileNotFoundException", strerror(errno)); return NULL; } jobject object = jniCreateFileDescriptor(env, fd); if (object == NULL) { close(fd); } return object; }
TInt CBellagioOpenMaxSymbianLoader::GetInfoIndex(OMX_STRING componentName) { TInt index = 0; TInt count = 0; TInt length = 0; count = componentInfos.Count(); if (count < 1) { return -1; } /* Turn the name into Symbian descriptor */ length = strlen(componentName); TPtrC8 name8(reinterpret_cast<const TUint8 *>(componentName), length); TBuf<256> name16; CnvUtfConverter::ConvertToUnicodeFromUtf8(name16, name8); /* Search all the components for the correct one */ for (index = 0; index < count; index++) { if (name16.Compare((componentInfos[index])->DisplayName()) == 0) { break; // stop the loop } } if (index == count) { return -1; } return index; }
/* * Enumerates and returns all IPv4 interfaces */ static netif *enumIPvXInterfaces(JNIEnv *env, netif *ifs, TUint family) { TPckgBuf<TSoInetInterfaceInfo> info; TSoInetInterfaceInfo &i = info(); RSocket r; _LIT(proto, "ip"); TInt err = r.Open(sserv, proto); if (err != KErrNone) { JNU_ThrowByName(env , JNU_JAVANETPKG "SocketException", "Socket creation failed"); return ifs; } /* * Iterate through each interface */ int idx = 1; err = r.SetOpt(KSoInetEnumInterfaces, KSolInetIfCtrl, 1); while ((err = r.GetOpt(KSoInetNextInterface, KSolInetIfCtrl, info)) == KErrNone) { #ifdef _UNICODE TName n = i.iName; TUint8 n8[0x20]; TPtr8 name8(n8, sizeof n8); TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8(name8, n); fprintf(stderr, "Interface proto %s status %x\n", name8.PtrZ(), i.iState); { TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8(name8, i.iTag); fprintf(stderr, "tag %s\n", name8.PtrZ()); } const char *if_name = (const char *)name8.PtrZ(); #else const char *if_name = (const char *)i.iTag.PtrZ(); #endif if (i.iState == EIfUp) { TInetAddr ia = i.iAddress; fprintf(stderr, "Address %x\n", ia.Address()); } if (i.iAddress.Family() == family) { TInetAddr ia = i.iAddress; /* * Add to the list */ ifs = addif(env, ifs, if_name, idx, KAfInet, ia); /* * If an exception occurred then free the list */ if ((*env)->ExceptionOccurred(env)) { freeif(ifs); ifs = NULL; goto done; } } ++idx; } { TPckgBuf<TSoInetIfQuery> q1; TSoInetIfQuery &q = q1(); TInt inum = 1; q.iIndex = inum; while ((err = r.GetOpt(KSoInetIfQueryByIndex, KSolInetIfQuery, q1)) == KErrNone) { fprintf(stderr, "Interface %d up %d\n", inum, q.iIsUp); #ifdef _UNICODE TUint8 n8[0x20]; TPtr8 name8(n8, sizeof n8); TInt err = CnvUtfConverter::ConvertFromUnicodeToUtf8(name8, q.iName); fprintf(stderr, "Interface %d name %s\n", inum, name8.PtrZ()); #endif fprintf(stderr, "src addr %x\n", q.iSrcAddr.Address()); fprintf(stderr, "dst addr %x\n", q.iDstAddr.Address()); q.iIndex = ++inum; } } done: r.Close(); return ifs; }