• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* ------------------------------------------------------------------
2  * Copyright (C) 1998-2009 PacketVideo
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13  * express or implied.
14  * See the License for the specific language governing permissions
15  * and limitations under the License.
16  * -------------------------------------------------------------------
17  */
18 #ifndef PV_OMXDEFS_H_INCLUDED
19 #include "pv_omxdefs.h"
20 #endif
21 
22 #ifndef PV_OMX_INTERFACE_PROXY_H_INCLUDED
23 #include "pv_omx_interface_proxy.h"
24 #endif
25 
26 #ifndef PV_OMX_INTERFACE_PROXY_HANDLER_H_INCLUDED
27 #include "pv_omx_interface_proxy_handler.h"
28 #endif
29 
30 #ifndef PV_OMX_INTERFACE_PROXY_NOTIFIER_H_INCLUDED
31 #include "pv_omx_interface_proxy_notifier.h"
32 #endif
33 
34 #ifndef OSCL_MEM_H_INCLUDED
35 #include "oscl_mem.h"
36 #endif
37 
38 #ifndef OSCL_DLL_H_INCLUDED
39 #include "oscl_dll.h"
40 #endif
41 
42 #ifndef PVLOGGER_H_INCLUDED
43 #include "pvlogger.h"
44 #endif
45 
46 OSCL_DLL_ENTRY_POINT_DEFAULT()
47 
48 #if PROXY_INTERFACE
49 
50 //
51 //CPVInterfaceProxy_OMX
52 //
53 
54 _OsclBasicAllocator CPVInterfaceProxy_OMX::iDefAlloc;
55 
NewL(PVProxiedEngine_OMX & app,Oscl_DefAlloc * alloc,int32 stacksize,uint32 nreserve1,uint32 nreserve2,int32 handlerPri,int32 notifierPri)56 OSCL_EXPORT_REF CPVInterfaceProxy_OMX * CPVInterfaceProxy_OMX::NewL(
57     PVProxiedEngine_OMX& app
58     , Oscl_DefAlloc *alloc
59     , int32 stacksize
60     , uint32 nreserve1
61     , uint32 nreserve2
62     , int32 handlerPri
63     , int32 notifierPri)
64 //called under app thread context
65 {
66     // custom allocator not using TRY/LEAVE/TLS
67     _OsclBasicAllocator defallocL;
68     OsclAny *ptr = NULL;
69     if (alloc)
70     {
71         ptr = alloc->ALLOCATE(sizeof(CPVInterfaceProxy_OMX));
72         //Commented all the oscl tls statements
73         //OsclError::LeaveIfNull(ptr);
74         if (ptr == NULL)
75         {
76             return NULL;
77         }
78     }
79     else
80     {
81         ptr = defallocL.ALLOCATE(sizeof(CPVInterfaceProxy_OMX));
82     }
83     CPVInterfaceProxy_OMX *self = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxy_OMX(app, alloc, stacksize));
84     bool err;
85     //Commented OSCL_TRY to remove oscl initialization dependency
86     err = self->ConstructL(nreserve1, nreserve2, handlerPri, notifierPri);
87     if (err == false)
88     {
89         self->Delete();
90         return NULL;
91     }
92     return self;
93 }
94 
CPVInterfaceProxy_OMX(PVProxiedEngine_OMX & app,Oscl_DefAlloc * alloc,int32 stacksize)95 CPVInterfaceProxy_OMX::CPVInterfaceProxy_OMX(PVProxiedEngine_OMX& app, Oscl_DefAlloc*alloc, int32 stacksize)
96         : iPVApp(app)
97 //called under app thread context
98 {
99     iCommandIdCounter = 0;
100     iProxyIdCounter = 0;
101     iHandler = NULL;
102     iPVScheduler = NULL;
103     iNotifier = NULL;
104     iStacksize = 0x8000;
105     OSCL_UNUSED_ARG(stacksize);
106     iStopped = true;
107     iAlloc = (alloc) ? alloc : &iDefAlloc;
108     iLogger = NULL;
109     iOMXThreadCreated = false;
110 }
111 
112 //Commented all the OsclError::Leave statements to remove oscl tls dependency
113 //Changed return type of this function from void to bool
114 
ConstructL(uint32 nreserve1,uint32 nreserve2,int32 handlerPri,int32 notifierPri)115 bool CPVInterfaceProxy_OMX::ConstructL(uint32 nreserve1, uint32 nreserve2, int32 handlerPri, int32 notifierPri)
116 {
117     // Create the semaphores and critical sections
118     if (iInitSem.Create() != OsclProcStatus::SUCCESS_ERROR
119             || iExitedSem.Create() != OsclProcStatus::SUCCESS_ERROR
120             || iCounterCrit.Create() != OsclProcStatus::SUCCESS_ERROR
121             || iHandlerQueueCrit.Create() != OsclProcStatus::SUCCESS_ERROR
122             || iNotifierQueueCrit.Create() != OsclProcStatus::SUCCESS_ERROR
123             || iProxyListCrit.Create() != OsclProcStatus::SUCCESS_ERROR
124             || iThreadCreatedSem.Create() != OsclProcStatus::SUCCESS_ERROR)
125     {
126         return false;
127     }
128     //reserve space in vectors...
129     if (nreserve1 > 0)
130         iProxyList.reserve(nreserve1);
131     if (nreserve2 > 0)
132     {
133         iCommandQueue.reserve(nreserve2);
134 //      iNotificationQueue.reserve(nreserve2);
135     }
136 
137     //create handler
138     OsclAny *ptr = iAlloc->ALLOCATE(sizeof(CPVInterfaceProxyHandler_OMX));
139     if (ptr == NULL)
140     {
141         return false;
142     }
143 
144     iHandler = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxyHandler_OMX(this, handlerPri));
145 
146     //create notifier
147     ptr = iAlloc->ALLOCATE(sizeof(CPVInterfaceProxyNotifier_OMX));
148     if (ptr == NULL)
149     {
150         return false;
151     }
152 
153     iNotifier = OSCL_PLACEMENT_NEW(ptr, CPVInterfaceProxyNotifier_OMX(this, notifierPri));
154     return true;
155 }
156 
Delete()157 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::Delete()
158 //called under app thread context
159 {
160     this->~CPVInterfaceProxy_OMX();
161     iAlloc->deallocate(this);
162 }
163 
~CPVInterfaceProxy_OMX()164 CPVInterfaceProxy_OMX::~CPVInterfaceProxy_OMX()
165 //called under app thread context
166 {
167     //make sure thread was stopped.
168     StopPVThread();
169 
170     CleanupAppThreadQueues();
171 
172     //delete handler and notifier
173     if (iHandler)
174     {
175         iHandler->~CPVInterfaceProxyHandler_OMX();
176         iAlloc->deallocate(iHandler);
177     }
178     iHandler = NULL;
179     if (iNotifier)
180     {
181         iNotifier->~CPVInterfaceProxyNotifier_OMX();
182         iAlloc->deallocate(iNotifier);
183     }
184     iNotifier = NULL;
185 
186     iCounterCrit.Close();
187     iHandlerQueueCrit.Close();
188     iNotifierQueueCrit.Close();
189     iProxyListCrit.Close();
190     iThreadCreatedSem.Close();
191     iInitSem.Close();
192     iExitedSem.Close();
193 }
194 
195 //forward...
196 TOsclThreadFuncRet OSCL_THREAD_DECL pvproxythreadmain_omx(TOsclThreadFuncArg *aPtr);
197 
StartPVThread()198 OSCL_EXPORT_REF bool CPVInterfaceProxy_OMX::StartPVThread()
199 //called under app thread context
200 {
201     if (!iStopped)
202         return false;//thread already active
203 
204     //Notifier not required in omx component, Scheduler not initialized in testapp thread
205 
206     // Create the PV thread.
207     OsclProcStatus::eOsclProcError err;
208     err = iPVThread.Create((TOsclThreadFuncPtr)pvproxythreadmain_omx,
209                            iStacksize,
210                            (TOsclThreadFuncArg)this,
211                            Start_on_creation,
212                            true);
213 
214 
215     if (err == OSCL_ERR_NONE)
216     {
217         // the iThreadCreated semaphore blocks the app thread until the new thread initializes oscl etc.
218         // we use it before checking the flag "iOMXThreadCreated"
219         // In case of either success or error the new thread signals this semaphore
220         if (iThreadCreatedSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
221         {
222             iNotifier->RemoveFromScheduler();
223             return false;
224         }
225         // check if the thread was created OK
226         if (!iOMXThreadCreated)
227         {
228             //error cleanup
229             iNotifier->RemoveFromScheduler();
230             return false;
231         }
232 
233         iStopped = false;
234         //Wait for PV thread to initialize its scheduler.
235         if (iInitSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
236         {
237             //Commented to remove oscl tls dependency
238             return false;
239         }
240         return true;
241     }
242     else
243     {
244         //error cleanup
245         iNotifier->RemoveFromScheduler();
246         return false;
247     }
248 }
249 
StopPVThread()250 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::StopPVThread()
251 //called under app thread context.
252 {
253     //if called under the PV thread, we'll get deadlock..
254     //so don't allow it.
255     if (iPVThreadContext.IsSameThreadContext())
256     {   //Commented to remove oscl tls dependency (OsclError::Panic)
257         return;
258     }
259 
260     if (iStopped)
261     {
262         return ;
263     }
264 
265     //deque notifier AO
266     iNotifierQueueCrit.Lock();
267     if (iNotifier && iNotifier->IsAdded())
268     {
269         iNotifier->RemoveFromScheduler();
270     }
271 
272     iNotifierQueueCrit.Unlock();
273 
274     //Stop the scheduler loop.
275     if (iPVScheduler)
276     {
277         iPVScheduler->StopScheduler();
278     }
279 
280     //Wait for PV thread to finish up, then it's safe
281     //to delete the remaining stuff.
282     if (iExitedSem.Wait() != OsclProcStatus::SUCCESS_ERROR)
283     {   //Commented to remove oscl tls dependency (OsclError::Panic)
284         return;
285     }
286 
287     //let the destructor know it's exited.
288     iStopped = true;
289 
290     //The thread will exit on its own, but go ahead and
291     //forcibly terminate it now to make sure it's cleaned
292     //up by the time this call returns.
293     iPVThread.Terminate(0);
294 }
295 
DeliverNotifications(int32 aTargetCount,int32 & aNoticesPending)296 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::DeliverNotifications(int32 aTargetCount, int32& aNoticesPending)
297 //deliver notifications off the queue, from the app thread size
298 {
299     //make sure this isn't called under PV thread...
300     if (iPVThreadContext.IsSameThreadContext())
301         OsclError::Leave(OsclErrThreadContextIncorrect);
302 
303     for (int32 count = 0; count < aTargetCount;)
304     {
305         //get next notification or cleanup message.
306         iNotifierQueueCrit.Lock();
307         //CPVProxyMsg notice(0,0,NULL);
308         //Added, increased one more parameter in the call
309         CPVProxyMsg_OMX notice(0, 0, 0, NULL);
310         if (iNotificationQueue.size() > 0)
311         {
312             notice = iNotificationQueue[0];
313             iNotificationQueue.erase(&iNotificationQueue[0]);
314         }
315         iNotifierQueueCrit.Unlock();
316 
317         if (notice.iMsg)
318         {
319             count++;
320             CPVProxyInterface_OMX *ext = FindInterface(notice.iProxyId);
321             if (ext)
322                 ext->iClient->HandleNotification(notice.iMsgId, notice.iMsg);
323             else
324             {   //since messages are cleaned up when interfaces
325                 //get unregistered, we should not get here.
326                 OSCL_ASSERT(NULL != ext);//debug error.
327             }
328         }
329         else
330             break;//no more messages.
331     }
332     //return number of notices left after trying to process
333     //the desired number.
334     aNoticesPending = iNotificationQueue.size();
335 }
336 
CleanupAppThreadQueues()337 void CPVInterfaceProxy_OMX::CleanupAppThreadQueues()
338 //cleanup memory allocated in App thread.
339 {
340     //un-sent commands...
341     iHandlerQueueCrit.Lock();
342     while (!iCommandQueue.empty())
343     {
344         CPVProxyMsg_OMX *msg = &iCommandQueue[0];
345         CPVProxyInterface_OMX *proxy = FindInterface(msg->iProxyId);
346         if (proxy)
347             proxy->iClient->CleanupCommand(msg->iMsgId, msg->iMsg);
348         iCommandQueue.erase(msg);
349     }
350     iCommandQueue.clear();
351     iCommandQueue.destroy();
352     iHandlerQueueCrit.Unlock();
353 
354     //proxy list...
355     iProxyListCrit.Lock();
356     iProxyList.clear();
357     iProxyList.destroy();
358     iProxyListCrit.Unlock();
359 }
360 
CleanupPVThreadQueues()361 void CPVInterfaceProxy_OMX::CleanupPVThreadQueues()
362 //cleanup memory allocated in PV thread.
363 {
364     //un-sent notifications
365     iNotifierQueueCrit.Lock();
366     while (!iNotificationQueue.empty())
367     {
368         CPVProxyMsg_OMX *msg = &iNotificationQueue[0];
369         CPVProxyInterface_OMX *proxy = FindInterface(msg->iProxyId);
370         if (proxy)
371             proxy->iServer->CleanupNotification(msg->iMsgId, msg->iMsg);
372         iNotificationQueue.erase(msg);
373     }
374     iNotificationQueue.clear();
375     iNotificationQueue.destroy();
376     iNotifierQueueCrit.Unlock();
377 }
378 
CancelCommand(TPVProxyId aProxyId,TPVProxyMsgId aMsgId)379 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::CancelCommand(TPVProxyId aProxyId, TPVProxyMsgId aMsgId)
380 {
381     CleanupCommands(FindInterface(aProxyId), false, aMsgId);
382 }
383 
CancelAllCommands(TPVProxyId aProxyId)384 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::CancelAllCommands(TPVProxyId aProxyId)
385 {
386     CleanupCommands(FindInterface(aProxyId), true);
387 }
388 
CleanupCommands(CPVProxyInterface_OMX * aExt,bool aAll,TPVProxyMsgId aMsgId)389 void CPVInterfaceProxy_OMX::CleanupCommands(CPVProxyInterface_OMX *aExt, bool aAll, TPVProxyMsgId aMsgId)
390 {
391     if (!aExt)
392         return ;
393     iHandlerQueueCrit.Lock();
394     for (uint32 i = 0; i < iCommandQueue.size(); i++)
395     {
396         CPVProxyMsg_OMX *msg = &iCommandQueue[i];
397         if (msg->iProxyId == aExt->iProxyId
398                 && (aAll || msg->iMsgId == aMsgId))
399         {
400             aExt->iClient->CleanupCommand(msg->iMsgId, msg->iMsg);
401             iCommandQueue.erase(msg);
402             i--;//move back one since vecter gets scrunched.
403             if (!aAll)
404             {
405                 iHandlerQueueCrit.Unlock();
406                 return ;
407             }
408         }
409     }
410     iHandlerQueueCrit.Unlock();
411 }
412 
CancelNotification(TPVProxyId aProxyId,TPVProxyMsgId aMsgId)413 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::CancelNotification(TPVProxyId aProxyId, TPVProxyMsgId aMsgId)
414 {
415     CleanupNotifications(FindInterface(aProxyId), false, aMsgId);
416 }
417 
CancelAllNotifications(TPVProxyId aProxyId)418 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::CancelAllNotifications(TPVProxyId aProxyId)
419 {
420     CleanupNotifications(FindInterface(aProxyId), true);
421 }
422 
CleanupNotifications(CPVProxyInterface_OMX * aExt,bool aAll,TPVProxyMsgId aMsgId)423 void CPVInterfaceProxy_OMX::CleanupNotifications(CPVProxyInterface_OMX *aExt, bool aAll, TPVProxyMsgId aMsgId)
424 {
425     if (!aExt)
426         return ;
427     iNotifierQueueCrit.Lock();
428     for (uint i = 0; i < iNotificationQueue.size(); i++)
429     {
430         CPVProxyMsg_OMX *msg = &iNotificationQueue[i];
431         if (msg->iProxyId == aExt->iProxyId
432                 && (aAll || msg->iMsgId == aMsgId))
433         {
434             aExt->iServer->CleanupNotification(msg->iMsgId, msg->iMsg);
435             iNotificationQueue.erase(msg);
436             i--;//move back one since vector gets scrunched.
437             if (!aAll)
438             {
439                 iNotifierQueueCrit.Unlock();
440                 return ;
441             }
442         }
443     }
444     iNotifierQueueCrit.Unlock();
445 }
446 
CleanupInterfaceMessages(CPVProxyInterface_OMX * aExt)447 void CPVInterfaceProxy_OMX::CleanupInterfaceMessages(CPVProxyInterface_OMX *aExt)
448 //cleanup all extension messages for a particular interface.
449 {
450     CleanupCommands(aExt, true);
451     CleanupNotifications(aExt, true);
452 }
453 
RegisterProxiedInterface(PVProxiedInterfaceServer_OMX & server_proxy,PVProxiedInterfaceClient_OMX & client_proxy)454 OSCL_EXPORT_REF TPVProxyId CPVInterfaceProxy_OMX::RegisterProxiedInterface(
455     PVProxiedInterfaceServer_OMX& server_proxy,
456     PVProxiedInterfaceClient_OMX& client_proxy)
457 //Proxy extensions call this to register themselves.
458 {
459     TPVProxyId id = ++iProxyIdCounter;
460     iProxyListCrit.Lock();
461     CPVProxyInterface_OMX proxy(id, &server_proxy, &client_proxy);
462     int32 err;
463     OSCL_TRY(err, iProxyList.push_back(proxy););
464     iProxyListCrit.Unlock();
465     OsclError::LeaveIfError(err);
466     return id;
467 }
468 
UnregisterProxiedInterface(TPVProxyId aProxyId)469 OSCL_EXPORT_REF void CPVInterfaceProxy_OMX::UnregisterProxiedInterface(TPVProxyId aProxyId)
470 //Proxy extensions call this to unregister themselves.
471 {
472     iProxyListCrit.Lock();
473     CPVProxyInterface_OMX *ext = FindInterface(aProxyId, true);
474     if (ext)
475     {
476         //cleanup unprocessed messages and remove.
477         CleanupInterfaceMessages(ext);
478         iProxyList.erase(ext);
479     }
480     iProxyListCrit.Unlock();
481 }
482 
SendCommand(TPVProxyId aProxyId,TPVCommandId cmdid,OsclAny * aCmd)483 OSCL_EXPORT_REF TPVProxyMsgId CPVInterfaceProxy_OMX::SendCommand(TPVProxyId aProxyId, TPVCommandId cmdid, OsclAny *aCmd)
484 //Proxy extensions call this to send commands from app side
485 //to PV side.
486 {
487     bool status;
488     iCounterCrit.Lock();
489     TPVProxyMsgId id = ++iCommandIdCounter;
490     iCounterCrit.Unlock();
491     iHandlerQueueCrit.Lock();
492     //Changed the function arguments to pass command id
493     CPVProxyMsg_OMX msg(aProxyId, id, cmdid, aCmd);
494 
495     status = iCommandQueue.push_back(msg);
496 
497     //if the queue was empty, signal the AO.
498     if (iCommandQueue.size() == 1)
499     {
500         iHandler->PendComplete(OSCL_REQUEST_ERR_NONE);
501     }
502 
503     iHandlerQueueCrit.Unlock();
504     //propagate any allocation failure...
505     if (status == false)
506     {
507         return false;
508     }
509     return id;
510 }
511 
SendNotification(TPVProxyId aProxyId,OsclAny * aResp)512 OSCL_EXPORT_REF TPVProxyMsgId CPVInterfaceProxy_OMX::SendNotification(TPVProxyId aProxyId, OsclAny *aResp)
513 //Proxy extensions call this to send notifications from PV
514 //side to app side.
515 {
516     int32 err = OSCL_ERR_NONE;
517     iCounterCrit.Lock();
518     TPVProxyMsgId id = ++iCommandIdCounter;
519     iCounterCrit.Unlock();
520     iNotifierQueueCrit.Lock();
521     CPVProxyMsg_OMX msg(aProxyId, id, 0, aResp);
522     OSCL_TRY(err, iNotificationQueue.push_back(msg););
523     //if the queue was empty and the notifier is scheduled,
524     //signal it.
525     if (iNotifier
526             && iNotifier->IsAdded()
527             && iNotificationQueue.size() == 1)
528         iNotifier->PendComplete(OSCL_REQUEST_ERR_NONE);
529     iNotifierQueueCrit.Unlock();
530     //propagate any allocation failure...
531     OsclError::LeaveIfError(err);
532     return id;
533 }
534 
FindInterface(TPVProxyId aId,bool locked)535 CPVProxyInterface_OMX * CPVInterfaceProxy_OMX::FindInterface(TPVProxyId aId, bool locked)
536 //lookup a registered proxy interface
537 {
538     if (!locked)
539         iProxyListCrit.Lock();
540     for (uint32 i = 0; i < iProxyList.size(); i++)
541     {
542         if (iProxyList[i].iProxyId == aId)
543         {
544             if (!locked)
545                 iProxyListCrit.Unlock();
546             return &iProxyList[i];
547         }
548     }
549     if (!locked)
550         iProxyListCrit.Unlock();
551     return NULL;
552 }
553 
InThread()554 void CPVInterfaceProxy_OMX::InThread()
555 //this is the guts of the proxy thread routine.
556 //it's a separate routine since it needs to be
557 //run under a trap handler in order to avoid any
558 //Cbase 66 panic from the cleanup stack.
559 {
560     volatile int32 errTerm = OsclErrNone;
561     volatile int32 errSched = OsclErrNone;
562 
563     //create & install scheduler
564     OsclScheduler::Init("PVProxy");
565     iPVScheduler = OsclExecScheduler::Current();
566 
567     iPVThreadContext.EnterThreadContext();
568 
569     //add handler to scheduler
570     iHandler->AddToScheduler();
571     iHandler->PendForExec();
572 
573     //App thread logon...
574     int32 err;
575     OSCL_TRY(err, iPVApp.PVThreadLogon(*this););
576     if (err != OsclErrNone)
577         errTerm = err;
578 
579     iOMXThreadCreated = true;
580     // now it's safe to signal the thread create sema
581     iThreadCreatedSem.Signal();
582 
583     //Start scheduler.  This call blocks until scheduler is
584     //either stopped or exits due to an error.
585     OSCL_TRY(err, iPVScheduler->StartScheduler(&iInitSem););
586     if (err != OsclErrNone)
587         errSched = err;
588 
589     //Cleanup un-processed data.
590     CleanupPVThreadQueues();
591 
592     //App thread logoff...
593     OSCL_TRY(err, iPVApp.PVThreadLogoff(*this););
594     if (err != OSCL_ERR_NONE)
595         errTerm = err;
596 
597     //Deque the handler AO
598     iHandlerQueueCrit.Lock();
599     iHandler->RemoveFromScheduler();
600     iHandlerQueueCrit.Unlock();
601 
602     iPVThreadContext.ExitThreadContext();
603 
604     //Uninstall scheduler
605     OsclScheduler::Cleanup();
606     iPVScheduler = NULL;
607     iOMXThreadCreated = false;
608 
609     //Generate panics if any leaves happened.
610     OSCL_ASSERT(errTerm == OsclErrNone);//EPVProxyPanicEngineLeave
611     OSCL_ASSERT(errSched == OsclErrNone);//EPVProxyPanicSchedulerLeave
612 }
613 
614 ////////////////////////////////
615 // OS-specific Thread routines
616 ////////////////////////////////
617 
618 
619 #include "oscl_mem_audit.h"
620 
pvproxythreadmain_omx(TOsclThreadFuncArg * aPtr)621 TOsclThreadFuncRet OSCL_THREAD_DECL pvproxythreadmain_omx(TOsclThreadFuncArg *aPtr)
622 //PV Thread main routine
623 {
624 
625     CPVInterfaceProxy_OMX *proxy = (CPVInterfaceProxy_OMX *) aPtr;
626 
627     //Init OSCL and create logger.
628     int error = OsclBase::Init();
629     if (error)
630     {
631         proxy->iThreadCreatedSem.Signal(); // signal to let the app thread run
632         return 0;
633     }
634     error = OsclErrorTrap::Init();
635     if (error)
636     {
637         proxy->iThreadCreatedSem.Signal(); // signal to let the app thread run
638         return 0;
639     }
640     OsclMem::Init();
641     PVLogger::Init();
642 
643 #if defined( OSCL_SET_THREAD_NAME)
644     OSCL_SET_THREAD_NAME("OMX proxy");
645 #endif
646 
647     setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_AUDIO);
648     //Call the proxied app routine to create its logger appenders.
649     //proxy->iPVApp.CreateLoggerAppenders();
650     //proxy->iLogger=PVLogger::GetLoggerObject("");
651 
652     PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, proxy->iLogger, PVLOGMSG_NOTICE, (0, "PVPROXY:Proxy Thread 0x%x Entry...", OsclExecScheduler::GetId()));
653 
654 
655     int32 leave;
656     OSCL_TRY(leave, proxy->InThread(););
657 
658     if (leave != OsclErrNone)
659     {
660         PVLOGGER_LOGMSG(PVLOGMSG_INST_REL, proxy->iLogger, PVLOGMSG_ERR, (0, "PVPROXY:Proxy Thread 0x%x Exit: Leave Reason %d", OsclExecScheduler::GetId(), leave));
661     }
662     else
663     {
664         PVLOGGER_LOGMSG(PVLOGMSG_INST_HLDBG, proxy->iLogger, PVLOGMSG_NOTICE, (0, "PVPROXY:Proxy Thread 0x%x Exit: Normal", OsclExecScheduler::GetId()));
665     }
666 
667     proxy->iThreadCreatedSem.Signal(); // signal to let the app thread run just in case
668 
669     //Cleanup logger.
670     PVLogger::Cleanup();
671 
672     OsclMem::Cleanup();
673     proxy->iLogger = NULL;
674     OsclErrorTrap::Cleanup();
675     OsclBase::Cleanup();
676 
677     //Signal & Exit
678     proxy->iExitedSem.Signal();
679 
680     return 0;
681 }
682 #endif // PROXY_INTERFACE
683 
684 
685 
686 
687 
688 
689 
690 
691