uiacceltk/hitchcock/ServerCore/Src/alfstreamerbridge.cpp
changeset 19 f5bac0badc7e
parent 14 83d2d132aa58
child 21 6ce30188c5bf
equal deleted inserted replaced
14:83d2d132aa58 19:f5bac0badc7e
    19 
    19 
    20 #include <e32debug.h>
    20 #include <e32debug.h>
    21 #include <coemain.h>
    21 #include <coemain.h>
    22 #include "alfstreamerbridge.h"
    22 #include "alfstreamerbridge.h"
    23 #include "alfstreamerserver.h"
    23 #include "alfstreamerserver.h"
       
    24 #include "alfbridge.h"
    24 #include "alflogger.h"
    25 #include "alflogger.h"
    25 
    26 
    26 #ifdef ALF_DEBUG_TRACK_DRAWING
    27 #ifdef ALF_DEBUG_TRACK_DRAWING
    27 #include "alfcommanddebug.h"
    28 #include "alfcommanddebug.h"
    28 #endif
    29 #endif
    29 
    30 
    30 
    31 
    31 // #define EGL_TALKS_TO_WINDOW_SERVER
    32 // From MMP macro nowadays
       
    33 //#define ALF_DRAW_FRAME_BEFORE_END_CALLBACK    
    32 
    34 
    33 // ---------------------------------------------------------------------------
    35 // ---------------------------------------------------------------------------
    34 // constructor
    36 // constructor
    35 // 
    37 // 
    36 // ---------------------------------------------------------------------------
    38 // ---------------------------------------------------------------------------
    81     iDataBuf.SetLength(0);
    83     iDataBuf.SetLength(0);
    82     iStreamerServer = NULL;
    84     iStreamerServer = NULL;
    83 #ifdef ALF_DEBUG_TRACK_DRAWING
    85 #ifdef ALF_DEBUG_TRACK_DRAWING
    84     iCommandDebugger = CAlfCommandDebug::NewL();
    86     iCommandDebugger = CAlfCommandDebug::NewL();
    85 #endif
    87 #endif
    86     CHuiEnv::Static()->iSwapObserver = this;
       
    87     }
    88     }
    88 
    89 
    89 // ---------------------------------------------------------------------------
    90 // ---------------------------------------------------------------------------
    90 // destructor
    91 // destructor
    91 // 
    92 // 
    92 // ---------------------------------------------------------------------------
    93 // ---------------------------------------------------------------------------
    93 // 
    94 // 
    94 CAlfStreamerBridge::~CAlfStreamerBridge()
    95 CAlfStreamerBridge::~CAlfStreamerBridge()
    95     {
    96     {
    96     CHuiEnv::Static()->iSwapObserver = 0;
       
    97     iDataBuf.Close();
    97     iDataBuf.Close();
    98     iQueueSema.Close();
    98     iQueueSema.Close();
    99 #ifdef ALF_DEBUG_TRACK_DRAWING
    99 #ifdef ALF_DEBUG_TRACK_DRAWING
   100     delete iCommandDebugger;
   100     delete iCommandDebugger;
   101 #endif
   101 #endif
   171 // 
   171 // 
   172 // ---------------------------------------------------------------------------
   172 // ---------------------------------------------------------------------------
   173 // 
   173 // 
   174 TInt CAlfStreamerBridge::AddData( TAlfDecoderServerBindings aOp,TInt aI1,TInt aI2 ,TAny* aPtr )
   174 TInt CAlfStreamerBridge::AddData( TAlfDecoderServerBindings aOp,TInt aI1,TInt aI2 ,TAny* aPtr )
   175     {
   175     {
   176     if (iSwapActive && aOp == EAlfRequestCommitBatch)
       
   177         {
       
   178         __ALFLOGSTRING("CAlfStreamerBridge::AddData() just release window server");    
       
   179         iBatchObserver->BridgerCallback(KRELEASEWINDOWSERVER,KRELEASEDBEFOREQUEUE);
       
   180         return KErrNone;
       
   181         }
       
   182     
       
   183     TInt err = KErrNotFound;
   176     TInt err = KErrNotFound;
   184         {    
   177         {    
   185 #ifdef ALF_DEBUG_TRACK_DRAWING    
   178 #ifdef ALF_DEBUG_TRACK_DRAWING    
   186         iCommandDebugger->SetDescription( aOp, R_ALF_BRIDGE_COMMAND_DESCRIPTION_ARRAY );
   179         iCommandDebugger->SetDescription( aOp, R_ALF_BRIDGE_COMMAND_DESCRIPTION_ARRAY );
   187         __ALFLOGSTRING2("CAlfStreamerBridge::AddData op %S, iQueue.Length = %d", &iCommandDebugger->Text(), iQueue.Count());
   180         __ALFLOGSTRING2("CAlfStreamerBridge::AddData op %S, iQueue.Length = %d", &iCommandDebugger->Text(), iQueue.Count());
   188     #else
   181 #else
   189         __ALFLOGSTRING2("CAlfStreamerBridge::AddData op %d, iQueue.Length = %d", aOp, iQueue.Count());    
   182         __ALFLOGSTRING2("CAlfStreamerBridge::AddData op %d, iQueue.Length = %d", aOp, iQueue.Count());    
   190     #endif
   183 #endif
   191         err = KErrNone;
   184         err = KErrNone;
   192         for(TInt i = 0; i < iMessages.Count(); i++ )
   185         for(TInt i = 0; i < iMessages.Count(); i++ )
   193             {
   186             {
   194             if (iMessages[i].IsEmpty())
   187             if (iMessages[i].IsEmpty())
   195                 {
   188                 {
   225     {
   218     {
   226     TAlfBridgerData data;
   219     TAlfBridgerData data;
   227     ASSERT(aIndex <= iMessages.Count()-1);
   220     ASSERT(aIndex <= iMessages.Count()-1);
   228     data = iMessages[aIndex];
   221     data = iMessages[aIndex];
   229     return data;    
   222     return data;    
   230     }
       
   231 
       
   232 void CAlfStreamerBridge::PrepareSwap()
       
   233     {
       
   234 #ifdef EGL_TALKS_TO_WINDOW_SERVER
       
   235     __ALFLOGSTRING("CAlfStreamerBridge:: Prepare swap, flush the queue");    
       
   236     iSwapActive = ETrue;
       
   237     if (iStatus.Int() >=0 && iMessages.Count() > iStatus.Int() )
       
   238         {
       
   239         Cancel(); // remove from scheduler
       
   240         RunL(); // run manually (and activate)
       
   241         }
       
   242     __ALFLOGSTRING("CAlfStreamerBridge:: Prepare swap, the queue emptied");    
       
   243 #endif //#ifdef EGL_TALKS_TO_WINDOW_SERVER
       
   244     }
       
   245 
       
   246 void CAlfStreamerBridge::SwapComplete()
       
   247     {
       
   248 #ifdef EGL_TALKS_TO_WINDOW_SERVER
       
   249     __ALFLOGSTRING("CAlfStreamerBridge:: Swap buffers complete");    
       
   250     iSwapActive = EFalse;
       
   251 #endif // #ifdef EGL_TALKS_TO_WINDOW_SERVER
       
   252 
       
   253     }
       
   254 	
       
   255 #ifdef EGL_TALKS_TO_WINDOW_SERVER
       
   256 void CAlfStreamerBridge::ReleaseWindowServer(TBool aRelease)
       
   257     {
       
   258     __ALFLOGSTRING1("CAlfStreamerBridge::ReleaseWindowServer: %d",aRelease);    
       
   259     if (aRelease)
       
   260         {
       
   261         iMakeCurrentActive = ETrue;    
       
   262         if (iBatchObserver && !iSwapActive)    
       
   263             {
       
   264             iBatchObserver->BridgerCallback(KRELEASEWINDOWSERVER);
       
   265             }
       
   266         }
       
   267     else
       
   268         {
       
   269         iMakeCurrentActive = EFalse;
       
   270         }                
       
   271 #else
       
   272 void CAlfStreamerBridge::ReleaseWindowServer(TBool)
       
   273 	{
       
   274 #endif
       
   275     }
       
   276 
       
   277 void CAlfStreamerBridge::SetWgIdArray(TInt* aArray)
       
   278     {
       
   279     iWgArray = aArray;
       
   280     }
   223     }
   281 
   224 
   282 EXPORT_C TUid CAlfStreamerBridge::FindAppUidForWgId(TInt /*aWgId*/)
   225 EXPORT_C TUid CAlfStreamerBridge::FindAppUidForWgId(TInt /*aWgId*/)
   283     {
   226     {
   284     __ASSERT_DEBUG(EFalse, User::Leave(KErrNotSupported));
   227     __ASSERT_DEBUG(EFalse, User::Leave(KErrNotSupported));
   306 #else
   249 #else
   307     __ALFLOGSTRING1("CAlfStreamerBridge::RunL: First op %d", operation);
   250     __ALFLOGSTRING1("CAlfStreamerBridge::RunL: First op %d", operation);
   308 #endif
   251 #endif
   309     switch ( operation )
   252     switch ( operation )
   310         {
   253         {
   311         // Just call back to Alf decoder thread
       
   312         case EAlfRequestCommitBatch:
   254         case EAlfRequestCommitBatch:
       
   255 #ifdef ALF_DRAW_FRAME_BEFORE_END_CALLBACK    
       
   256             {
       
   257             CAlfBridge* bridge = dynamic_cast<CAlfBridge*>(iObserver);
       
   258             if (bridge)
       
   259                 {
       
   260                 bridge->iHuiEnv->RefreshCallBack((TAny*)bridge->iHuiEnv);
       
   261                 }
       
   262             } // fall through
       
   263 #endif
   313         case EAlfRequestCommandReadNotification:
   264         case EAlfRequestCommandReadNotification:
   314         case EAlfReleaseTemporaryChunk:
   265         case EAlfReleaseTemporaryChunk:
   315             {
   266             {
   316             if (iBatchObserver)
   267             if (iBatchObserver)
   317                 {
   268                 {
   322             }
   273             }
   323         default:
   274         default:
   324             {
   275             {
   325             // Handle command
   276             // Handle command
   326             __ALFLOGSTRING("CAlfStreamerBridge:: calling observer callback");
   277             __ALFLOGSTRING("CAlfStreamerBridge:: calling observer callback");
       
   278             __ASSERT_ALWAYS(iObserver, User::Invariant());
   327             iObserver->HandleCallback(iStatus.Int());
   279             iObserver->HandleCallback(iStatus.Int());
   328             
   280             
   329             // For "getters" also call back to Alf decoder thread
   281             // For "getters" also call back to Alf decoder thread
   330             if ((operation > EAlfDSGetCommandsStart) && (operation < EAlfDSGetCommandsEnd))
   282             if ((operation > EAlfDSGetCommandsStart) && (operation < EAlfDSGetCommandsEnd))
   331             	{
   283             	{
   351     __ALFLOGSTRING1("CAlfStreamerBridge:: Queue op %d", operation2 );
   303     __ALFLOGSTRING1("CAlfStreamerBridge:: Queue op %d", operation2 );
   352 #endif
   304 #endif
   353     switch ( operation2 )
   305     switch ( operation2 )
   354             {
   306             {
   355             case EAlfRequestCommitBatch:
   307             case EAlfRequestCommitBatch:
       
   308 #ifdef ALF_DRAW_FRAME_BEFORE_END_CALLBACK    
       
   309             {
       
   310             CAlfBridge* bridge = dynamic_cast<CAlfBridge*>(iObserver);
       
   311             if (bridge)
       
   312                 {
       
   313                 bridge->iHuiEnv->RefreshCallBack((TAny*)bridge->iHuiEnv);
       
   314                 }
       
   315             } // fall through
       
   316 #endif
   356             case EAlfRequestCommandReadNotification:
   317             case EAlfRequestCommandReadNotification:
   357             case EAlfReleaseTemporaryChunk:
   318             case EAlfReleaseTemporaryChunk:
   358                 {
   319                 {
   359                 if (iBatchObserver)
   320                 if (iBatchObserver)
   360                     {
   321                     {
   366                 }
   327                 }
   367             default:
   328             default:
   368                 {
   329                 {
   369 	            // Handle command
   330 	            // Handle command
   370                 __ALFLOGSTRING("CAlfStreamerBridge:: calling observer callback");
   331                 __ALFLOGSTRING("CAlfStreamerBridge:: calling observer callback");
       
   332                 __ASSERT_ALWAYS(iObserver, User::Invariant());
   371 	            iObserver->HandleCallback(iQueue[0]);
   333 	            iObserver->HandleCallback(iQueue[0]);
   372 	            
   334 	            
   373 	            // For "getters" also call back to Alf decoder thread
   335 	            // For "getters" also call back to Alf decoder thread
   374 	            if ((operation2 > EAlfDSGetCommandsStart) && (operation2 < EAlfDSGetCommandsEnd))
   336 	            if ((operation2 > EAlfDSGetCommandsStart) && (operation2 < EAlfDSGetCommandsEnd))
   375 	            	{
   337 	            	{
   414 // 
   376 // 
   415 void CAlfStreamerBridge::StartNewBlock()
   377 void CAlfStreamerBridge::StartNewBlock()
   416     {
   378     {
   417     // Queue marker. Basically we could use one new member to assert that there can
   379     // Queue marker. Basically we could use one new member to assert that there can
   418     // be only one marker
   380     // be only one marker
   419     __ALFLOGSTRING1("CAlfStreamerBridge:: Request command read notification, swap active: %d", iSwapActive );    
   381     //__ALFLOGSTRING1("CAlfStreamerBridge:: Request command read notification, swap active: %d", iSwapActive );    
   420    if ( iSwapActive || iMakeCurrentActive )
       
   421         {
       
   422         __ALFLOGSTRING("CAlfStreamerBridge::StartNewBlock() just release window server");    
       
   423         iBatchObserver->BridgerCallback(KRELEASEWINDOWSERVER,KRELEASEDBEFOREQUEUE);
       
   424         return;
       
   425         }
       
   426     AddData(EAlfRequestCommitBatch,0,0,0);
   382     AddData(EAlfRequestCommitBatch,0,0,0);
   427     }
   383     }
   428 
   384 
   429 // ---------------------------------------------------------------------------
   385 // ---------------------------------------------------------------------------
   430 // RequestCommandReadNotification
   386 // RequestCommandReadNotification
   501 // 
   457 // 
   502 const TAny* CAlfStreamerBridge::GetEffectsDataL( TInt aIndex )
   458 const TAny* CAlfStreamerBridge::GetEffectsDataL( TInt aIndex )
   503     {
   459     {
   504     return GetVarDataL(aIndex);
   460     return GetVarDataL(aIndex);
   505     }
   461     }
   506 
       
   507 // ---------------------------------------------------------------------------
       
   508 // SetStreamerServer
       
   509 // ---------------------------------------------------------------------------
       
   510 // 
       
   511 void CAlfStreamerBridge::SetStreamerServer( CAlfStreamerServer& aStreamerServer )
       
   512     {
       
   513     iStreamerServer = &aStreamerServer;   
       
   514     }
       
   515 
       
   516 // ---------------------------------------------------------------------------
       
   517 // StreamerServer
       
   518 // ---------------------------------------------------------------------------
       
   519 // 
       
   520 CAlfStreamerServer* CAlfStreamerBridge::StreamerServer()
       
   521     {
       
   522     return iStreamerServer;
       
   523     }