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 19 #ifndef PV_INTERFACE_PROXY_H_INCLUDED 20 #include "pv_interface_proxy.h" 21 #endif 22 23 #ifndef PV_INTERFACE_PROXY_HANDLER_H_INCLUDED 24 #include "pv_interface_proxy_handler.h" 25 #endif 26 27 void CPVInterfaceProxyHandler::Run() 28 { 29 if (Status() != OSCL_REQUEST_ERR_NONE) 30 return; 31 32 CPVProxyMsg command(0, 0, NULL); 33 34 //Enter critical section... 35 iProxy->iHandlerQueueCrit.Lock(); 36 37 //check command queue... 38 if (iProxy->iCommandQueue.size() > 0) 39 { 40 command = iProxy->iCommandQueue[0]; 41 iProxy->iCommandQueue.erase(&iProxy->iCommandQueue[0]); 42 } 43 44 PendForExec(); 45 46 //if there's another message queued, 47 //go ahead and signal request complete. 48 if (iProxy->iCommandQueue.size() > 0) 49 PendComplete(OSCL_REQUEST_ERR_NONE); 50 51 //Leave critical section... 52 iProxy->iHandlerQueueCrit.Unlock(); 53 54 //Process command 55 if (command.iMsg) 56 { 57 //call proxy server message handler 58 CPVProxyInterface *proxy = iProxy->FindInterface(command.iProxyId); 59 if (proxy) 60 proxy->iServer->HandleCommand(command.iMsgId, command.iMsg); 61 else 62 OSCL_ASSERT(0);//debug error. 63 } 64 65 } 66 67