os/mm/mdfdevvideoextensions/nga_mdf_postprocessor/src/NGAPostProcSessionManager.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     8 *
     9 * Initial Contributors:
    10 * Nokia Corporation - initial contribution.
    11 *
    12 * Contributors:
    13 *
    14 * Description:
    15 *
    16 */
    17 
    18 
    19 #include <e32base.h>
    20 #include <graphics/surfaceupdateclient.h> //RSurfaceUpdateSession
    21 #include <graphics/surfacemanager.h> //RSurfaceManager
    22 #include <graphics/suerror.h> //KAllScreens
    23  
    24 #include "NGAPostProcSessionManager.h" 
    25 #include "NGAPostProcSessionManagerObserver.h"
    26 #include "MdfRDebug.h"
    27 #include "NGAPostProcNotifier.h"
    28 
    29 // --- Constants ---
    30 const TInt KMessageSlots      = 4; 
    31 
    32 //**************************************************
    33 
    34 CNGAPostProcSessionManager* CNGAPostProcSessionManager::NewL() 
    35 { 
    36    PP_DEBUG(_L("CNGAPostProcSessionManager:NewL() ++"));
    37 
    38     CNGAPostProcSessionManager* self = new (ELeave) CNGAPostProcSessionManager; 
    39     CleanupStack::PushL(self);
    40     self->ConstructL(); 
    41     CleanupStack::Pop();
    42 
    43    PP_DEBUG(_L("CNGAPostProcSessionManager:NewL() --"));
    44     return self; 
    45 }
    46 
    47 CNGAPostProcSessionManager::CNGAPostProcSessionManager() 
    48 :iSurfaceUpdateSession(NULL),
    49  iObserver(NULL)
    50  
    51 {
    52 }
    53 
    54 void CNGAPostProcSessionManager::ConstructL() 
    55 { 
    56    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:ConstructL() ++"), this);
    57     
    58     iSurfaceUpdateSession = new (ELeave) RSurfaceUpdateSession();
    59     User::LeaveIfError(iSurfaceUpdateSession->Connect(KMessageSlots));
    60     
    61    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:ConstructL() --"), this);
    62 }
    63 
    64 CNGAPostProcSessionManager::~CNGAPostProcSessionManager()
    65 {
    66    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:~() ++"), this);
    67     if(iSurfaceUpdateSession)
    68     {
    69     	iSurfaceUpdateSession->Close();
    70     	delete iSurfaceUpdateSession;
    71     	iSurfaceUpdateSession = NULL;
    72 	}
    73 	while (iAOList.Count()>0)
    74     {
    75         CNGAPostProcNotifier* notifier = iAOList[0];
    76         iAOList.Remove(0);
    77         delete notifier;
    78     }
    79     
    80 	iAOList.Reset();
    81     iAOList.Close();
    82     
    83    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:~() --"), this);
    84 }
    85 
    86 void CNGAPostProcSessionManager::PostPicture(const TSurfaceId& aSurfaceId,
    87 								TInt aBufId, TInt aNumOfBuf, TBool aNotifyRequired) 
    88 { 
    89    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:PostPicture() ++"), this);
    90    TInt err = KErrNone;
    91 	if(aNotifyRequired)
    92 	{
    93 	    CNGAPostProcNotifier* iNotifier;
    94 	    if ( iAOList.Count() <= aNumOfBuf )
    95 		{
    96 			TRAP(err, iNotifier = CNGAPostProcNotifier::NewL(*this));
    97 	    	if (err != KErrNone)
    98 	    	{
    99 	    	   PP_DEBUG(_L("CNGAPostProcHwDevice[%x]:Initialize -- failed to create CNGAPostProcNotifier %d."), this, err);
   100 	    	   return;
   101 	    	}
   102 		}
   103 		else
   104 		{
   105 		for(TInt j=0; j < iAOList.Count(); j++)
   106 			{
   107 				iNotifier = iAOList[j];
   108 				if(!iNotifier->IsActive())
   109 				{
   110 					iAOList.Remove(j);
   111 					iAOList.Compress();
   112 					break;
   113 				}
   114 			}
   115 		}
   116 		iNotifier->SetBufferId(aBufId);
   117 		iNotifier->Activate();
   118 		iSurfaceUpdateSession->NotifyWhenAvailable(iNotifier->iStatus);
   119 		iAOList.Append(iNotifier);
   120 	}
   121 	iSurfaceUpdateSession->SubmitUpdate(KAllScreens, aSurfaceId, aBufId);
   122 
   123    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:PostPicture() -- "), this);
   124 }
   125 
   126 void CNGAPostProcSessionManager::CancelUpdate() 
   127 { 
   128    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:SetClockSource() ++"), this);
   129 	iSurfaceUpdateSession->CancelAllUpdateNotifications();
   130    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:SetClockSource() --"), this);
   131 }
   132 
   133 void CNGAPostProcSessionManager::HandleBufferRelease(TInt aBufId, TInt aStatus) 
   134 { 
   135    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:HandleBufferRelease() ++"), this);
   136     if(iObserver)
   137     {
   138 		iObserver->BufferAvailable(aBufId, aStatus);
   139 	}
   140    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:HandleBufferRelease() --"), this);
   141 }
   142 
   143 void CNGAPostProcSessionManager::SetObserver(MNGAPostProcSessionManagerObserver& aObserver) 
   144 { 
   145    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:SetClockSource() ++"), this);
   146 	iObserver = &aObserver;
   147    PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:SetClockSource() --"), this);
   148 }
   149