// This header file is automatically generated at build-time
// *** OFFICIAL RELEASE INFO -- Will not auto update
-#define PV2WAY_ENGINE_SDKINFO_LABEL "1338044"
+#define PV2WAY_ENGINE_SDKINFO_LABEL "1338246"
#define PV2WAY_ENGINE_SDKINFO_DATE 0x20100323
#endif //PV_2WAY_SDKINFO_H_INCLUDED
// This header file is automatically generated at build-time
// *** OFFICIAL RELEASE INFO -- Will not auto update
-#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1338044"
+#define PVAUTHOR_ENGINE_SDKINFO_LABEL "1338246"
#define PVAUTHOR_ENGINE_SDKINFO_DATE 0x20100323
#endif //PV_AUTHOR_SDKINFO_H_INCLUDED
// This header file is automatically generated at build-time
// *** OFFICIAL RELEASE INFO -- Will not auto update
-#define PVPLAYER_ENGINE_SDKINFO_LABEL "1338044"
+#define PVPLAYER_ENGINE_SDKINFO_LABEL "1338246"
#define PVPLAYER_ENGINE_SDKINFO_DATE 0x20100323
#endif //PV_PLAYER_SDKINFO_H_INCLUDED
/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
+ * Copyright (C) 1998-2010 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
if (error)
return error;
}
-#if (OSCL_HAS_SINGLETON_SUPPORT)
- {
- _OsclBasicAllocator alloc;
- int32 error;
- OsclSingletonRegistry::initialize(alloc, error);
- //exit on error
- if (error)
- return error;
- }
-#endif
return 0;
}
OSCL_EXPORT_REF int32 OsclBase::Cleanup()
{
int32 result = 0;
-#if (OSCL_HAS_SINGLETON_SUPPORT)
- {
- _OsclBasicAllocator alloc;
- int32 error;
- OsclSingletonRegistry::cleanup(alloc, error);
- //continue if error
- if (error)
- result = error;
- }
-#endif
{
_OsclBasicAllocator alloc;
int32 error;
/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
+ * Copyright (C) 1998-2010 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "oscl_lock_base.h"
#include "oscl_base_alloc.h"
-
-OsclSingletonRegistry::SingletonTable* OsclSingletonRegistry::iSingletonTable = NULL;
-
-
-OSCL_EXPORT_REF void OsclSingletonRegistry::initialize(Oscl_DefAlloc &alloc, int32 &aError)
-{
- aError = 0;
- //Allocate the registry on the first init call
- //Note: there's some chance of thread contention here, since
- //thread lock isn't available until after this step.
- if (!iSingletonTable)
- {
- OsclAny* table = alloc.allocate(sizeof(SingletonTable));
- if (table)
- iSingletonTable = new(table) SingletonTable();
- else
- {
- aError = EPVErrorBaseOutOfMemory;
- return;
- }
- }
-
- //increment the ref count on each init.
- iSingletonTable->iTableLock.Lock();
- iSingletonTable->iRefCount++;
- iSingletonTable->iTableLock.Unlock();
-}
-
-OSCL_EXPORT_REF void OsclSingletonRegistry::cleanup(Oscl_DefAlloc &alloc, int32 &aError)
-{
- aError = 0;
- if (!iSingletonTable)
- {
- aError = EPVErrorBaseNotInstalled;//no table!
- return;
- }
-
- //decrement the ref count and cleanup when it reaches zero.
- iSingletonTable->iTableLock.Lock();
- iSingletonTable->iRefCount--;
- if (iSingletonTable->iRefCount == 0)
- {
- //cleanup
- iSingletonTable->iTableLock.Unlock();
- iSingletonTable->~SingletonTable();
- alloc.deallocate(iSingletonTable);
- iSingletonTable = NULL;
- }
- else
- {
- iSingletonTable->iTableLock.Unlock();
- }
-}
+// static object instantiation, alive with application
+OsclSingletonRegistry::SingletonTable OsclSingletonRegistry::sSingletonTable;
OSCL_EXPORT_REF OsclAny* OsclSingletonRegistry::getInstance(uint32 ID, int32 &aError)
{
OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST);
aError = 0;
- if (!iSingletonTable)
- {
- aError = EPVErrorBaseNotInstalled;//no table!
- return NULL;
- }
-
- iSingletonTable->iSingletonLocks[ID].Lock();
- OsclAny* value = iSingletonTable->iSingletons[ID];
- iSingletonTable->iSingletonLocks[ID].Unlock();
-
+ sSingletonTable.iSingletonLocks[ID].Lock();
+ OsclAny* value = sSingletonTable.iSingletons[ID];
+ sSingletonTable.iSingletonLocks[ID].Unlock();
return value;
}
OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST);
aError = 0;
- if (!iSingletonTable)
- {
- aError = EPVErrorBaseNotInstalled;//no table!
- return;
- }
-
- iSingletonTable->iSingletonLocks[ID].Lock();
- iSingletonTable->iSingletons[ID] = ptr;
- iSingletonTable->iSingletonLocks[ID].Unlock();
+ sSingletonTable.iSingletonLocks[ID].Lock();
+ sSingletonTable.iSingletons[ID] = ptr;
+ sSingletonTable.iSingletonLocks[ID].Unlock();
}
OSCL_EXPORT_REF OsclAny* OsclSingletonRegistry::lockAndGetInstance(uint32 ID, int32 &aError)
OSCL_ASSERT(ID < OSCL_SINGLETON_ID_LAST);
aError = 0;
-
- if (!iSingletonTable)
- {
- aError = EPVErrorBaseNotInstalled;//no table!
- return NULL;
- }
-
- iSingletonTable->iSingletonLocks[ID].Lock();
- OsclAny* value = iSingletonTable->iSingletons[ID];
- //leave it locked.
+ sSingletonTable.iSingletonLocks[ID].Lock();
+ OsclAny* value = sSingletonTable.iSingletons[ID];
+ //leave this table entry locked
return value;
}
aError = 0;
- if (!iSingletonTable)
- {
- aError = EPVErrorBaseNotInstalled;//no table!
- return;
- }
-
//assume it's already locked.
-
- iSingletonTable->iSingletons[ID] = ptr;
- iSingletonTable->iSingletonLocks[ID].Unlock();
+ sSingletonTable.iSingletons[ID] = ptr;
+ sSingletonTable.iSingletonLocks[ID].Unlock();
}
#endif //OSCL_HAS_SINGLETON_SUPPORT
typedef registry_type* registry_pointer_type;
private:
- OSCL_IMPORT_REF static void initialize(Oscl_DefAlloc &alloc, int32 &error);
- OSCL_IMPORT_REF static void cleanup(Oscl_DefAlloc &alloc, int32 &error);
friend class OsclBase;
private:
class SingletonTable
{
public:
- SingletonTable(): iRefCount(0)
+ SingletonTable()
{
for (uint32 i = 0; i < OSCL_SINGLETON_ID_LAST; i++)
iSingletons[i] = NULL;
}
- _OsclBasicLock iTableLock;
- uint32 iRefCount;
OsclAny* iSingletons[OSCL_SINGLETON_ID_LAST];
_OsclBasicLock iSingletonLocks[OSCL_SINGLETON_ID_LAST];
};
//The singleton table is a global variable.
- static SingletonTable* iSingletonTable;
+ static SingletonTable sSingletonTable;
};
template < class T, uint32 ID, class Registry = OsclSingletonRegistry > class OsclSingleton
/* ------------------------------------------------------------------
- * Copyright (C) 1998-2009 PacketVideo
+ * Copyright (C) 1998-2010 PacketVideo
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#endif //OSCL_TLS_IS_KEYED
-
+_OsclBasicLock OsclTLSRegistry::sLock; // static object instanciated, alive with application
OSCL_EXPORT_REF void OsclTLSRegistry::initialize(Oscl_DefAlloc &alloc, int32 &aError)
{
TOsclTlsKey* pkey = NULL;
aError = 0;
+ sLock.Lock();
#if ( OSCL_TLS_IS_KEYED)
//Allocate the table on the first init call.
if (!table)
{
aError = EPVErrorBaseOutOfMemory;
+ sLock.Unlock();
return;
}
{
aError = EPVErrorBaseOutOfMemory;
alloc.deallocate(table);
+ sLock.Unlock();
return;
}
aError = EPVErrorBaseSystemCallFailed;
alloc.deallocate(pkey);
alloc.deallocate(table);
+ sLock.Unlock();
return;
}
iTlsKey = new(table) TlsKey();
- iTlsKey->iLock.Lock();
iTlsKey->iRefCnt++;
iTlsKey->iOsclTlsKey = pkey;
- iTlsKey->iLock.Unlock();
}
else
{
- iTlsKey->iLock.Lock();
iTlsKey->iRefCnt++;
pkey = iTlsKey->iOsclTlsKey;
- iTlsKey->iLock.Unlock();
}
#endif
if (registry == 0)
{
aError = EPVErrorBaseOutOfMemory;
+ sLock.Unlock();
return;
}
// save it away
TLSStorageOps::save_registry(pkey, registry, aError);
+ sLock.Unlock();
}
OSCL_EXPORT_REF void OsclTLSRegistry::cleanup(Oscl_DefAlloc &alloc, int32 &aError)
{
TOsclTlsKey* pkey = NULL;
aError = 0;
+ sLock.Lock();
#if (OSCL_TLS_IS_KEYED)
if (!iTlsKey)
{
aError = EPVErrorBaseNotInstalled;//No key!
+ sLock.Unlock();
return;
}
pkey = iTlsKey->iOsclTlsKey;
if (!OSCL_TLS_REGISTRY_VALID(registry))
{
aError = EPVErrorBaseNotInstalled;//No registry!
+ sLock.Unlock();
return;
}
alloc.deallocate(registry);
TLSStorageOps::save_registry(pkey, NULL, aError);
if (aError)
+ {
+ sLock.Unlock();
return;
+ }
#if (OSCL_TLS_IS_KEYED)
//Remove Tls key
-
- iTlsKey->iLock.Lock();
iTlsKey->iRefCnt--;
if (iTlsKey->iRefCnt == 0)
{
//Deallocate key.
OSCL_TLS_KEY_DELETE_FUNC(*pkey);
alloc.deallocate(pkey);
- iTlsKey->iLock.Unlock();
iTlsKey->~TlsKey();
alloc.deallocate(iTlsKey);
iTlsKey = NULL;
}
- else
- {
- iTlsKey->iLock.Unlock();
- }
#endif
+
+ sLock.Unlock();
}
OSCL_EXPORT_REF OsclAny* OsclTLSRegistry::getInstance(uint32 ID, int32 &aError)
TOsclTlsKey* pkey = NULL;
+ sLock.Lock();
#if (OSCL_TLS_IS_KEYED)
if (!iTlsKey)
{
aError = EPVErrorBaseNotInstalled;//No table!
+ sLock.Unlock();
return NULL;
}
pkey = iTlsKey->iOsclTlsKey;
if (!OSCL_TLS_REGISTRY_VALID(registry))
{
aError = EPVErrorBaseNotInstalled;//No registry!
+ sLock.Unlock();
return NULL;
}
+ registry_type id = registry[ID];
+ sLock.Unlock();
- return registry[ID];
+ return id;
}
OSCL_EXPORT_REF void OsclTLSRegistry::registerInstance(OsclAny* ptr, uint32 ID, int32 &aError)
aError = 0;
TOsclTlsKey *pkey = NULL;
+ sLock.Lock();
#if (OSCL_TLS_IS_KEYED)
if (!iTlsKey)
{
aError = EPVErrorBaseNotInstalled;//No table!
+ sLock.Unlock();
return ;
}
pkey = iTlsKey->iOsclTlsKey;
if (!OSCL_TLS_REGISTRY_VALID(registry))
{
aError = EPVErrorBaseNotInstalled;//no registry!
+ sLock.Unlock();
return;
}
registry[ID] = ptr;
-
+ sLock.Unlock();
}
{}
typedef OsclAny* registry_type;
typedef registry_type* registry_pointer_type;
+ static _OsclBasicLock sLock; // _osclbaselock declaration with TLS registry and key
#if ( OSCL_TLS_IS_KEYED)
class TlsKey
public:
TlsKey(): iRefCnt(0), iOsclTlsKey(NULL)
{}
- _OsclBasicLock iLock;
uint32 iRefCnt;
TOsclTlsKey *iOsclTlsKey;
};