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