38 GSource *source = g_main_current_source();
41 callbackId = g_source_get_id(source);
50 mAsyncTuneEnabled(false),mEventPriority(G_PRIORITY_DEFAULT_IDLE),mMutexVar(PTHREAD_MUTEX_INITIALIZER),
51 mPlayerState(
eSTATE_IDLE),mEventWorkerDataQue(),mPendingAsyncEvents()
53 for (
int i = 0; i < AAMP_MAX_NUM_EVENTS; i++)
69 for (
int i = 0; i < AAMP_MAX_NUM_EVENTS; i++)
88 while(!mEventWorkerDataQue.empty())
91 mEventWorkerDataQue.pop();
94 if (mPendingAsyncEvents.size() > 0)
96 AAMPLOG_WARN(
"mPendingAsyncEvents.size - %lu", mPendingAsyncEvents.size());
97 for (AsyncEventListIter it = mPendingAsyncEvents.begin(); it != mPendingAsyncEvents.end(); it++)
99 if ((it->first != 0) && (it->second))
101 AAMPLOG_WARN(
"remove id - %d", (
int) it->first);
102 g_source_remove(it->first);
106 mPendingAsyncEvents.clear();
109 for (
int i = 0; i < AAMP_MAX_NUM_EVENTS; i++)
113 #ifdef EVENT_DEBUGGING
114 for (
int i = 0; i < AAMP_MAX_NUM_EVENTS; i++)
116 AAMPLOG_WARN(
"EventType[%d]->[%d]",i,
mEventStats[i]);
127 if(eventListener != NULL)
133 AAMPLOG_ERR(
"Null eventlistner. Failed to register");
142 if(eventListener != NULL)
148 AAMPLOG_ERR(
"Null eventlistner. Failed to deregister");
157 if ((eventListener != NULL) && (eventType >=
AAMP_EVENT_ALL_EVENTS) && (eventType < AAMP_MAX_NUM_EVENTS))
162 AAMPLOG_INFO(
"EventType:%d, Listener %p new %p", eventType, eventListener, pListener);
172 AAMPLOG_ERR(
"EventType %d registered out of range",eventType);
182 if ((eventListener != NULL) && (eventType >=
AAMP_EVENT_ALL_EVENTS) && (eventType < AAMP_MAX_NUM_EVENTS))
186 while (*ppLast != NULL)
191 *ppLast = pListener->
pNext;
193 AAMPLOG_INFO(
"Eventtype:%d %p delete %p", eventType, eventListener, pListener);
197 ppLast = &(pListener->
pNext);
325 AAMPEventPtr eventData=NULL;
327 if(mEventWorkerDataQue.size())
329 eventData = (AAMPEventPtr)mEventWorkerDataQue.front();
330 mEventWorkerDataQue.pop();
349 AAMPLOG_INFO(
"Sending event %d to AsyncQ", eventType);
350 mEventWorkerDataQue.push(eventData);
372 #ifdef EVENT_DEBUGGING
373 long long startTime = NOW_STEADY_TS_MS;
388 AAMPLOG_INFO(
"(type=%d)", eventType);
392 AAMPLOG_WARN(
"(type=%d)(state=%d)", eventType, std::dynamic_pointer_cast<StateChangedEvent>(eventData)->getState());
399 while (pListener != NULL)
405 pListener = pListener->
pNext;
408 while (pListener != NULL)
414 pListener = pListener->
pNext;
420 while (pList != NULL)
427 pList = pCurrent->
pNext;
428 SAFE_DELETE(pCurrent);
430 #ifdef EVENT_DEBUGGING
431 AAMPLOG_WARN(
"TimeTaken for Event %d SyncEvent [%d]",eventType, (NOW_STEADY_TS_MS - startTime));
442 AsyncEventListIter itr = mPendingAsyncEvents.find(
id);
443 if(itr != mPendingAsyncEvents.end())
445 AAMPLOG_TRACE(
"id:%d in mPendingAsyncEvents, erasing it. State:%d",
id,itr->second);
446 assert (itr->second);
447 mPendingAsyncEvents.erase(itr);
451 AAMPLOG_TRACE(
"id:%d not in mPendingAsyncEvents, insert and mark as not pending",
id);
452 mPendingAsyncEvents[id] =
false;
463 AsyncEventListIter itr = mPendingAsyncEvents.find(
id);
464 if(itr != mPendingAsyncEvents.end())
466 AAMPLOG_TRACE(
"id:%d already in mPendingAsyncEvents and completed, erase it State:%d",
id,itr->second);
467 assert (!itr->second);
468 mPendingAsyncEvents.erase(itr);
472 mPendingAsyncEvents[id] =
true;
473 AAMPLOG_TRACE(
"id:%d in mPendingAsyncEvents, added to list",
id);