本文整理汇总了C++中OsclMemAllocator类的典型用法代码示例。如果您正苦于以下问题:C++ OsclMemAllocator类的具体用法?C++ OsclMemAllocator怎么用?C++ OsclMemAllocator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了OsclMemAllocator类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AndroidAudioMIO
/*
/ Packet Video Audio MIO component
/
/ This implementation routes audio to AudioFlinger. Audio buffers are
/ enqueued in a message queue to a separate audio output thread. Once
/ the buffers have been successfully written, they are returned through
/ another message queue to the MIO and from there back to the engine.
/ This separation is necessary because most of the PV API is not
/ thread-safe.
*/
OSCL_EXPORT_REF AndroidAudioOutput::AndroidAudioOutput() :
AndroidAudioMIO("AndroidAudioOutput"),
iAudioThreadCreated(false),
iExitAudioThread(false),
iActiveTiming(NULL)
{
iClockTimeOfWriting_ns = 0;
iInputFrameSizeInBytes = 0;
// semaphore used to communicate between this mio and the audio output thread
iAudioThreadSem = new OsclSemaphore();
iAudioThreadSem->Create(0);
iAudioThreadTermSem = new OsclSemaphore();
iAudioThreadTermSem->Create(0);
// locks to access the queues by this mio and by the audio output thread
iOSSRequestQueueLock.Create();
iOSSRequestQueue.reserve(iWriteResponseQueue.capacity());
// create active timing object
OsclMemAllocator alloc;
OsclAny*ptr=alloc.allocate(sizeof(AndroidAudioMIOActiveTimingSupport));
if (ptr) {
iActiveTiming=new(ptr)AndroidAudioMIOActiveTimingSupport(kMaxClockDriftInMsecs, kMaxClockCorrection);
iActiveTiming->setThreadSemaphore(iAudioThreadSem);
}
}
示例2: CPVInterfaceProxy
OSCL_EXPORT_REF CPVInterfaceProxy * CPVInterfaceProxy::NewL(
PVProxiedEngine& app
, Oscl_DefAlloc *alloc
, int32 stacksize
, uint32 nreserve1
, uint32 nreserve2
, int32 handlerPri
, int32 notifierPri)
//called under app thread context
{
OsclMemAllocator defallocL;
OsclAny *ptr = NULL;
if (alloc)
{
ptr = alloc->ALLOCATE(sizeof(CPVInterfaceProxy));
OsclError::LeaveIfNull(ptr);
}
else
{
ptr = defallocL.ALLOCATE(sizeof(CPVInterfaceProxy));
}
CPVInterfaceProxy *self = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxy(app, alloc, stacksize));
int32 err;
err = self->CPVIConstructL(nreserve1, nreserve2, handlerPri, notifierPri);
if (err != OSCL_ERR_NONE)
{
self->Delete();
return NULL;
}
return self;
}
示例3:
bool
PVMFOMXEncPort::pvmiSetPortFormatSpecificInfoSync(OsclRefCounterMemFrag& aMemFrag)
{
if ((iConnectedPort) &&
(iTag == PVMF_OMX_ENC_NODE_PORT_TYPE_OUTPUT))
{
OsclAny* temp = NULL;
iConnectedPort->QueryInterface(PVMI_CAPABILITY_AND_CONFIG_PVUUID, temp);
PvmiCapabilityAndConfig *config = (PvmiCapabilityAndConfig*) temp;
/*
* Create PvmiKvp for capability settings
*/
if ((config) && (aMemFrag.getMemFragSize() > 0))
{
OsclMemAllocator alloc;
PvmiKvp kvp;
kvp.key = NULL;
kvp.length = oscl_strlen(PVMF_FORMAT_SPECIFIC_INFO_KEY) + 1; // +1 for \0
kvp.key = (PvmiKeyType)alloc.ALLOCATE(kvp.length);
if (kvp.key == NULL)
{
return false;
}
oscl_strncpy(kvp.key, PVMF_FORMAT_SPECIFIC_INFO_KEY, kvp.length);
kvp.value.key_specific_value = (OsclAny*)(aMemFrag.getMemFragPtr());
kvp.capacity = aMemFrag.getMemFragSize();
kvp.length = aMemFrag.getMemFragSize();
PvmiKvp* retKvp = NULL; // for return value
int32 err;
OSCL_TRY(err, config->setParametersSync(NULL, &kvp, 1, retKvp););
示例4: new
bool
PVMFSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync(const char* aFormatValType,
PvmiKvp*& aKvp)
{
/*
* Create PvmiKvp for capability settings
*/
aKvp = NULL;
OsclMemAllocator alloc;
uint32 strLen = oscl_strlen(aFormatValType) + 1;
uint8* ptr = (uint8*)alloc.allocate(sizeof(PvmiKvp) + strLen);
if (!ptr)
{
PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSocketPort::pvmiGetPortInPlaceDataProcessingInfoSync: Error - No memory. Cannot allocate PvmiKvp"));
return false;
}
aKvp = new(ptr) PvmiKvp;
ptr += sizeof(PvmiKvp);
aKvp->key = (PvmiKeyType)ptr;
oscl_strncpy(aKvp->key, aFormatValType, strLen);
aKvp->length = aKvp->capacity = strLen;
#if SNODE_ENABLE_UDP_MULTI_PACKET
if (iTag == PVMF_SOCKET_NODE_PORT_TYPE_SOURCE)
aKvp->value.bool_value = false;//for the multiple UDP recv feature
else
#endif
aKvp->value.bool_value = true;
return true;
}
示例5: LOGV
OSCL_EXPORT_REF AndroidAudioStream::~AndroidAudioStream()
{
LOGV("destructor");
// cleanup active timing object
if (iActiveTiming) {
iActiveTiming->~AndroidAudioMIOActiveTimingSupport();
OsclMemAllocator alloc;
alloc.deallocate(iActiveTiming);
}
}
示例6: destruct_and_dealloc
virtual void destruct_and_dealloc(OsclAny* ptr)
{
uint8* tmp_ptr = (uint8*) ptr;
uint aligned_refcnt_size =
oscl_mem_aligned_size(sizeof(OsclRefCounterSA<MediaCmdCleanupSA>));
tmp_ptr += aligned_refcnt_size;
PVMFMediaCmd* mcmd_ptr = reinterpret_cast<PVMFMediaCmd*>(tmp_ptr);
mcmd_ptr->~PVMFMediaCmd();
OsclMemAllocator alloc;
alloc.deallocate(ptr);
}
示例7: AndroidAudioMIO
/*
/ Packet Video Audio MIO component
/
/ This implementation routes audio to a stream interface
*/
OSCL_EXPORT_REF AndroidAudioStream::AndroidAudioStream() :
AndroidAudioMIO("AndroidAudioStream"),
iActiveTiming(NULL), mClockUpdated(false)
{
// create active timing object
LOGV("constructor");
OsclMemAllocator alloc;
OsclAny*ptr=alloc.allocate(sizeof(AndroidAudioMIOActiveTimingSupport));
if (ptr) {
iActiveTiming = new(ptr)AndroidAudioMIOActiveTimingSupport(0, 0);
}
}
示例8: Delete
OSCL_EXPORT_REF void CPVInterfaceProxy::Delete()
//called under app thread context
{
Oscl_DefAlloc *alloc = this->iAlloc;
bool default_alloc = (this->iAlloc == &this->iDefAlloc);
this->~CPVInterfaceProxy();
if (default_alloc)
{
OsclMemAllocator defalloc;
defalloc.deallocate(this);
}
else
{
alloc->deallocate(this);
}
}
示例9: OSCL_UNUSED_ARG
PVMFStatus PVMFSocketPort::releaseParameters(PvmiMIOSession aSession,
PvmiKvp* aParameters,
int num_elements)
{
OSCL_UNUSED_ARG(aSession);
PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_INFO, (0, "PVMFSocketPort::releaseParameters: aSession=0x%x, aParameters=0x%x, num_elements=%d",
aSession, aParameters, num_elements));
if ((num_elements != 1) ||
(pv_mime_strcmp(aParameters->key, PVMI_PORT_CONFIG_INPLACE_DATA_PROCESSING_VALUE) != 0))
{
PVLOGGER_LOGMSG(PVLOGMSG_INST_MLDBG, iLogger, PVLOGMSG_ERR, (0, "PVMFSocketPort::releaseParameters: Error - Not a PvmiKvp created by this port"));
return PVMFFailure;
}
OsclMemAllocator alloc;
alloc.deallocate((OsclAny*)(aParameters));
return PVMFSuccess;
}
示例10: oscl_UnicodeToUTF8
////// INetURI implementation
////////////////////////////////////////////////////////////////////////////////////
bool INetURI::setURI(OSCL_wString &aUri, const bool aRedirectURI)
{
if (aUri.get_size() == 0) return false;
OsclMemAllocator alloc;
char *buf = (char*)alloc.allocate(aUri.get_size() + 1);
if (!buf) return false;
uint32 size = oscl_UnicodeToUTF8(aUri.get_cstr(), aUri.get_size(), buf, aUri.get_size() + 1);
if (size == 0)
{
alloc.deallocate(buf);
return false;
}
iURI = OSCL_HeapString<OsclMemAllocator> (buf, size);
alloc.deallocate(buf);
// clear iHost
iHostName.set(NULL, 0);
iRedirectURI = aRedirectURI;
return true;
}
开发者ID:Katarzynasrom,项目名称:patch-hosting-for-android-x86-support,代码行数:22,代码来源:pvmf_protocol_engine_common.cpp
示例11: oscl_memset
///////////////////////////////////Create a function to decode the StreamMuxConfig
// note this function should ideally also get a reference to an object that holds the values
// for the streammuxconfig... these are alse needed in the mediaInfo class (to pass to
// the parser constructor) and can be gotten here. for now just get the audiospecificconfig
OSCL_EXPORT_REF uint8 * PV_LATM_Parser::ParseStreamMuxConfig(uint8* decoderSpecificConfig, int32 * size)
{
uint32 SMC_SUCCESS = 0;
uint32 SMC_INVALID_MUX_VERSION = 1;
uint32 SMC_INVALID_NUM_PROGRAM = 2;
uint32 SMC_INVALID_NUM_LAYER = 4;
uint32 SMC_INVALID_OBJECT_TYPE = 8;
uint32 SMC_USED_RESERVED_SAMPLING_FREQ = 16;
uint32 samplingFreqTable[] =
{
96000, 88200, 64000, 48000, 44100,
32000, 24000, 22050, 16000, 12000,
11025, 8000, 7350
};
if (*size == 0)
{
// means there is nothing to parse
return NULL;
}
// size should be the length of the decoderSpecificConfig.. the AudioSpecificConfing cant
// be larger than that, so just allocate that number of bytes
// we wont know until we've parsed it how big it is.
OsclMemAllocator alloc;
uint8* ASCPtr = (uint8*)(alloc.allocate(sizeof(uint8) * (*size)));
if (ASCPtr == NULL)
{
// memory allocation problem?
*size = 0;
return NULL;
}
oscl_memset(ASCPtr, 0, *size);
OsclExclusivePtrA<uint8, OsclMemAllocator> ascAutoPtr;
ascAutoPtr.set(ASCPtr);
//streamMuxConfig * sMC;
sMC = (streamMuxConfig *) oscl_calloc(1, sizeof(streamMuxConfig));
if (sMC == NULL)
{ // unlikely: calloc failure
return NULL;
}
sMC->parseResult = SMC_SUCCESS; // set default result
uint32 bitPos = 0;
uint32 ASCPos = 0;
int32 temp;
int32 numProgram = 0;
int32 prog, lay;
int32 numLayer;
int32 count;
int32 dependsOnCoreCoder;
// audio mux version
sMC->audioMuxVersion = BufferReadBits(decoderSpecificConfig, &bitPos, 1);
if (sMC->audioMuxVersion == 0)
{
// should not be anything other than 0!!
// all streams same time framing
sMC->allStreamsSameTimeFraming = BufferReadBits(decoderSpecificConfig, &bitPos, 1);
/*
* numSubFrames -- how many payloadmux() are multiplexed
*/
sMC->numSubFrames = BufferReadBits(decoderSpecificConfig, &bitPos, 6);
/*
* numPrograms -- how many programs are multiplexed
*/
numProgram = BufferReadBits(decoderSpecificConfig, &bitPos, 4);
if (numProgram != 0)
{
sMC->parseResult |= SMC_INVALID_NUM_PROGRAM;
//numProgram = 0;
// really should exit
*size = 0;
return NULL;
}
// loop through programs -- happens only once now
for (prog = 0; prog <= numProgram; prog++)
{
// can only be one numProgram (RFC3016)
numLayer = BufferReadBits(decoderSpecificConfig, &bitPos, 3);
/*
* Number of scalable layers, only one is indicated in rfc3016
*/
if (numLayer != 0)
//.........这里部分代码省略.........