本文整理汇总了C++中OsEvent::getEventData方法的典型用法代码示例。如果您正苦于以下问题:C++ OsEvent::getEventData方法的具体用法?C++ OsEvent::getEventData怎么用?C++ OsEvent::getEventData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OsEvent
的用法示例。
在下文中一共展示了OsEvent::getEventData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: realize
// Realizes the player by initiating a connection to the target, allocates
// buffers, etc.
OsStatus MpStreamPlayer::realize(UtlBoolean bBlock /* = TRUE */)
{
OsStatus status = OS_FAILED ;
OsEvent eventHandle ;
intptr_t eventData ;
// Only proceed if we have a flow graph and the player is unrealized.
if (getState() == PlayerUnrealized)
{
// Create an mpQueueEvent object to signal state changes in from
// the MpStreamFeeder
mpQueueEvent = new OsQueuedEvent(*getMessageQueue(), 0);
// Realize the stream
if (mSourceType == SourceUrl)
{
if (mpMsgQ != NULL)
{
MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_URL, mTarget, NULL,
&eventHandle, mpQueueEvent, mFlags, (intptr_t) new Url(mUrl)) ;
status = mpMsgQ->send(msg) ;
}
}
else if (mSourceType == SourceBuffer)
{
if (mpMsgQ != NULL)
{
MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_BUFFER, mTarget, NULL,
&eventHandle, mpQueueEvent, mFlags, (intptr_t) mpBuffer) ;
status = mpMsgQ->send(msg) ;
}
}
if (status == OS_SUCCESS)
{
// Wait for a response
status = eventHandle.wait(OsTime(MAX_REALIZE_WAIT, 0)) ;
if (status == OS_SUCCESS)
{
if (eventHandle.getEventData(eventData) == OS_SUCCESS)
{
mHandle = (StreamHandle) eventData ;
if (mHandle != 0)
mbRealized = TRUE ;
}
else
{
mHandle = NULL ;
}
}
else
{
mHandle = NULL ;
}
}
}
if (mHandle == 0)
{
mState = PlayerDestroyed ;
status = OS_FAILED ;
mSemStateChange.release() ;
}
if (status == OS_SUCCESS)
{
// Start Server task if successfull
if (start() == TRUE)
{
// Block while waiting for prefetch (if requested)
if (bBlock)
{
while (getState() == PlayerUnrealized)
{
mSemStateChange.acquire();
}
}
else
{
// Wait for task to startup
while (!isStarted())
{
OsTask::yield() ;
}
}
}
else
{
syslog(FAC_STREAMING, PRI_CRIT, "Failed to create thread for MpStreamPlayer") ;
// Unable to create thread; attempt to clean up
status = OS_FAILED ;
MpStreamMsg msgStop(MpStreamMsg::STREAM_STOP, mTarget, mHandle);
mpMsgQ->send(msgStop) ;
MpStreamMsg msgDestroy(MpStreamMsg::STREAM_DESTROY, mTarget, mHandle);
mpMsgQ->send(msgDestroy) ;
//.........这里部分代码省略.........
示例2: testThreadedEvent
void testThreadedEvent()
{
// Seed the random number generator
srand(OsDateTime::getSecsSinceEpoch());
int numTries = 100;
int* rightResults = new int[numTries];
int* leftResults = new int[numTries];
// Create the Right thread. This context will be the
// Left thread.
RightEventThread rightThread(rightResults, numTries);
rightThread.start();
int index;
for(index = 0; index < numTries; index++)
{
OsEvent* event = new OsEvent(index);
OsRpcMsg eventMsg(OsMsg::USER_START,0,*event);
rightThread.postMessage(eventMsg);
int waitTimeMsec = (rand() % 3) * 110;
OsTime time(0, waitTimeMsec * 1000);
event->wait(time);
OsStatus eventStat = event->signal(index);
if(eventStat == OS_ALREADY_SIGNALED)
{
// We (Left) lost the other side is done
int eventData;
event->getEventData(eventData);
CPPUNIT_ASSERT(eventData == index);
// This/Left side deletes the event
delete event;
event = NULL;
leftResults[index] = TRUE;
}
else
{
// The other/Right side lost
// Do nothing
leftResults[index] = FALSE;
//osPrintf("Left: %d\n", eventStat);
}
}
OsTask::delay(1000);
int leftDeletes = 0;
int rightDeletes = 0;
for(index = 0; index < numTries; index++)
{
if(leftResults[index] == TRUE)
{
leftDeletes++;
}
if(rightResults[index] == TRUE)
{
rightDeletes++;
}
if(rightResults[index] == leftResults[index])
{
//osPrintf("Left deleted: %d Right deleted: %d\n",
// leftDeletes, rightDeletes);
//osPrintf("[%d]: Both sides %s\n", index,
// rightResults[index] ? "Deleted" : "Did not delete");
}
CPPUNIT_ASSERT(rightResults[index] != leftResults[index]);
}
//osPrintf("Left deleted: %d Right deleted: %d\n",
// leftDeletes, rightDeletes);
CPPUNIT_ASSERT(leftDeletes + rightDeletes == numTries);
}
示例3: realize
// Realizes the player by initiating a connection to the target, allocates
// buffers, etc.
OsStatus MpStreamPlaylistPlayer::realize(UtlBoolean bBlock)
{
OsStatus status = OS_FAILED;
PlayListEntry* e;
if (mAggregateState == PlayerFailed)
{
OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize failure, mAggregateState == PlayerFailed");
return status;
}
// Start prefetching all of the elements
UtlSListIterator playListDbIterator(*mPlayListDb) ;
while((e = (PlayListEntry*)playListDbIterator()))
{
// OsSysLog::add(FAC_MP, PRI_DEBUG, "MpStreamPlaylistPlayer::realize entry[%d] state %d", e->index, e->state);
if (e->state == PlayerUnrealized)
{
OsEvent eventHandle;
// Realize the stream
if (e->sourceType == SourceUrl)
{
MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_URL,
mTarget,
NULL,
&eventHandle,
e->pQueuedEvent,
e->flags,
(intptr_t) new Url(e->url));
status = mpMsgQ->send(msg);
if (status != OS_SUCCESS)
{
setEntryState(e, PlayerFailed);
e->handle = NULL;
OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize failed on send of MpStreamMsg::STREAM_REALIZE_URL message");
}
}
else if (e->sourceType == SourceBuffer)
{
MpStreamMsg msg(MpStreamMsg::STREAM_REALIZE_BUFFER,
mTarget,
NULL,
&eventHandle,
e->pQueuedEvent,
e->flags,
(intptr_t) e->pBuffer);
status = mpMsgQ->send(msg);
if (status != OS_SUCCESS)
{
setEntryState(e, PlayerFailed);
e->handle = NULL;
delete e->pBuffer;
e->pBuffer = NULL;
OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize failed on send of MpStreamMsg::STREAM_REALIZE_BUFFER message");
}
}
if (status == OS_SUCCESS)
{
// Wait for a response
intptr_t eventData;
status = eventHandle.wait(mRealizeTimeout);
if (status == OS_SUCCESS)
status = eventHandle.getEventData(eventData);
if (status == OS_SUCCESS)
{
e->handle = (StreamHandle) eventData;
}
else
{
setEntryState(e, PlayerFailed);
e->handle = NULL;
if (e->sourceType == SourceBuffer)
{
delete e->pBuffer;
e->pBuffer = NULL;
}
OsSysLog::add(FAC_MP, PRI_ERR, "MpStreamPlaylistPlayer::realize STREAM_REALIZE_ request failed");
}
}
}
}
// Block if requested
playListDbIterator.reset();
if ((status == OS_SUCCESS) && bBlock)
{
while((e = (PlayListEntry*)playListDbIterator()) != NULL &&
(mAggregateState != PlayerFailed))
{
while (e->state == PlayerUnrealized)
{
status = mSemStateChange.acquire(mRealizeTimeout);
if (status == OS_WAIT_TIMEOUT)
{
setEntryState(e, PlayerFailed);
//.........这里部分代码省略.........