os/mm/mdfdevvideoextensions/nga_mdf_postprocessor_shai/src/NGAPostProcSessionManager.cpp
Update contrib.
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
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".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
20 #include <graphics/surfaceupdateclient.h> //RSurfaceUpdateSession
21 #include <graphics/surfacemanager.h> //RSurfaceManager
22 #include <graphics/suerror.h> //KAllScreens
24 #include "NGAPostProcSessionManager.h"
25 #include "NGAPostProcSessionManagerObserver.h"
26 #include "MdfRDebug.h"
27 #include "NGAPostProcNotifier.h"
30 const TInt KMessageSlots = 4;
32 //**************************************************
34 CNGAPostProcSessionManager* CNGAPostProcSessionManager::NewL()
36 PP_DEBUG(_L("CNGAPostProcSessionManager:NewL() ++"));
38 CNGAPostProcSessionManager* self = new (ELeave) CNGAPostProcSessionManager;
39 CleanupStack::PushL(self);
43 PP_DEBUG(_L("CNGAPostProcSessionManager:NewL() --"));
47 CNGAPostProcSessionManager::CNGAPostProcSessionManager()
48 :iSurfaceUpdateSession(NULL),
54 void CNGAPostProcSessionManager::ConstructL()
56 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:ConstructL() ++"), this);
58 iSurfaceUpdateSession = new (ELeave) RSurfaceUpdateSession();
59 User::LeaveIfError(iSurfaceUpdateSession->Connect(KMessageSlots));
61 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:ConstructL() --"), this);
64 void CNGAPostProcSessionManager::CreateNotifierL(TInt aNumSurfaceBuffers)
66 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:CreateNotifierL() ++"), this);
68 CNGAPostProcNotifier* notifier;
69 for(TInt index = 0; index < aNumSurfaceBuffers; ++index)
71 notifier = CNGAPostProcNotifier::NewL(*this);
72 CleanupStack::PushL(notifier);
74 iAOList.AppendL(notifier);
78 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:CreateNotifierL() --"), this);
81 CNGAPostProcSessionManager::~CNGAPostProcSessionManager()
83 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:~() ++"), this);
84 //Its safer to destry notifiers before surfaceupdatesession object since notifiers
85 //guarantee synchronous cancellation.
86 iAOList.ResetAndDestroy();
88 if(iSurfaceUpdateSession)
91 iSurfaceUpdateSession->Close();
92 delete iSurfaceUpdateSession;
93 iSurfaceUpdateSession = NULL;
97 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:~() --"), this);
100 TInt CNGAPostProcSessionManager::PostPicture(const TSurfaceId& aSurfaceId,
101 TInt aBufId, TBool aNotifyRequired)
103 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:PostPicture() ++"), this);
107 CNGAPostProcNotifier* notifier = NULL;
108 for(TInt j=0; j < iAOList.Count(); j++)
110 //notifier = iAOList[j];
111 if(!iAOList[j]->IsActive())
113 notifier = iAOList[j];
115 //iAOList.Compress(); //why this is required? may create fragmentation.
126 notifier->SetBufferId(aBufId);
127 notifier->Activate();
128 iSurfaceUpdateSession->NotifyWhenAvailable(notifier->iStatus);
129 iAOList.Append(notifier);
133 err = iSurfaceUpdateSession->SubmitUpdate(KAllScreens, aSurfaceId, aBufId);
135 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:PostPicture() -- err = %d"), this, err);
139 void CNGAPostProcSessionManager::CancelUpdate()
141 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:CancelUpdate() ++"), this);
142 iSurfaceUpdateSession->CancelAllUpdateNotifications();
143 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:CancelUpdate() --"), this);
146 void CNGAPostProcSessionManager::CancelNotifiers()
149 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:CancelNotifiers() ++"), this);
150 TInt notifierCount = iAOList.Count();
151 for (TInt i = notifierCount - 1; i >= 0; --i) //reverse loop since the active notifier is appended to the list
153 if (iAOList[i]->IsActive())
155 iAOList[i]->Cancel();
165 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:CancelNotifiers() --"), this);
171 void CNGAPostProcSessionManager::HandleBufferRelease(TInt aBufId, TInt aStatus)
173 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:HandleBufferRelease() ++"), this);
176 iObserver->BufferAvailable(aBufId, aStatus);
178 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:HandleBufferRelease() --"), this);
181 void CNGAPostProcSessionManager::SetObserver(MNGAPostProcSessionManagerObserver& aObserver)
183 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:SetClockSource() ++"), this);
184 iObserver = &aObserver;
185 PP_DEBUG(_L("CNGAPostProcSessionManager[%x]:SetClockSource() --"), this);