devsoundextensions/effects/RoomLevel/RoomLevelEffect/Src/RoomLevelBase.cpp
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     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:   Implementation of the RoomLevel effect class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #ifdef _DEBUG
       
    24 #include <e32svr.h>
       
    25 #endif
       
    26 
       
    27 #include "RoomLevelProxy.h"
       
    28 
       
    29 #include <RoomLevelBase.h>
       
    30 #include <CustomInterfaceUtility.h>
       
    31 #include <DrmAudioSamplePlayer.h>
       
    32 #include <mdaaudioinputstream.h>
       
    33 #include <mdaaudiooutputstream.h>
       
    34 #include <mdaaudiotoneplayer.h>
       
    35 #include <mmf/server/sounddevice.h>
       
    36 #include <videoplayer.h>
       
    37 
       
    38 #ifdef _DEBUG
       
    39 #define DEBPRN0         RDebug::Printf( "%s", __PRETTY_FUNCTION__);
       
    40 #define DEBPRN1(str)    RDebug::Printf( "%s %s", __PRETTY_FUNCTION__, str );
       
    41 #else
       
    42 #define DEBPRN0
       
    43 #define DEBPRN1(str)
       
    44 #endif
       
    45 
       
    46 // ============================ MEMBER FUNCTIONS ===============================
       
    47 
       
    48 // -----------------------------------------------------------------------------
       
    49 // CRoomLevel::CRoomLevel
       
    50 // C++ default constructor can NOT contain any code, that
       
    51 // might leave.
       
    52 // -----------------------------------------------------------------------------
       
    53 //
       
    54 EXPORT_C CRoomLevel::CRoomLevel()
       
    55     : 	iRoomLevelData(),
       
    56     	iDataPckgTo(iRoomLevelData)
       
    57     {
       
    58 
       
    59     }
       
    60 
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // CRoomLevel::~CRoomLevel
       
    64 // Destructor
       
    65 // -----------------------------------------------------------------------------
       
    66 //
       
    67 //
       
    68 EXPORT_C CRoomLevel::~CRoomLevel()
       
    69     {
       
    70 
       
    71     }
       
    72 
       
    73 
       
    74 // -----------------------------------------------------------------------------
       
    75 // CRoomLevel::NewL
       
    76 // Static function for creating an instance of the RoomLevel object.
       
    77 // -----------------------------------------------------------------------------
       
    78 //
       
    79 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
    80 	CMdaAudioConvertUtility& aUtility, CEnvironmentalReverb& aReverb )
       
    81 	{
       
    82 
       
    83     DEBPRN0;
       
    84    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
    85     CleanupStack::PushL(customInterface);
       
    86 
       
    87 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
       
    88 
       
    89 	if ( !roomLevelProxy )
       
    90 		{
       
    91 		DEBPRN1("No Adaptation Support - leaving");
       
    92 		User::Leave(KErrNotSupported);
       
    93 		}
       
    94 
       
    95 	CleanupStack::Pop(customInterface);
       
    96 
       
    97     roomLevelProxy->iClientReverb = &aReverb;
       
    98     roomLevelProxy->AttachReverb(aReverb);
       
    99 
       
   100     return roomLevelProxy;
       
   101 
       
   102 	}
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CRoomLevel::NewL
       
   106 // Static function for creating an instance of the RoomLevel object.
       
   107 // -----------------------------------------------------------------------------
       
   108 //
       
   109 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   110 	CMdaAudioInputStream& aUtility, CEnvironmentalReverb& aReverb )
       
   111 	{
       
   112 
       
   113     DEBPRN0;
       
   114     CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
       
   115 
       
   116 	if (roomLevelProxy == NULL)
       
   117 		{
       
   118         DEBPRN1("No Adaptation Support - leaving");
       
   119     	User::Leave(KErrNotSupported);
       
   120 		}
       
   121 
       
   122 	roomLevelProxy->iClientReverb = &aReverb;
       
   123     roomLevelProxy->AttachReverb(aReverb);
       
   124 
       
   125     return roomLevelProxy;
       
   126 	}
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CRoomLevel::NewL
       
   130 // Static function for creating an instance of the RoomLevel object.
       
   131 // -----------------------------------------------------------------------------
       
   132 //
       
   133 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   134 	CMdaAudioOutputStream& aUtility, CEnvironmentalReverb& aReverb )
       
   135 	{
       
   136 
       
   137     DEBPRN0;
       
   138     CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
       
   139 
       
   140 	if (roomLevelProxy == NULL)
       
   141 		{
       
   142         DEBPRN1("No Adaptation Support - leaving");
       
   143     	User::Leave(KErrNotSupported);
       
   144 		}
       
   145 
       
   146 	roomLevelProxy->iClientReverb = &aReverb;
       
   147     roomLevelProxy->AttachReverb(aReverb);
       
   148 
       
   149     return roomLevelProxy;
       
   150 	}
       
   151 
       
   152 // -----------------------------------------------------------------------------
       
   153 // CRoomLevel::NewL
       
   154 // Static function for creating an instance of the RoomLevel object.
       
   155 // -----------------------------------------------------------------------------
       
   156 //
       
   157 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   158 	CMdaAudioPlayerUtility& aUtility, CEnvironmentalReverb& aReverb )
       
   159 	{
       
   160 
       
   161     DEBPRN0;
       
   162    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   163     CleanupStack::PushL(customInterface);
       
   164 
       
   165 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
       
   166 
       
   167 	if ( !roomLevelProxy )
       
   168 		{
       
   169 		DEBPRN1("No Adaptation Support - leaving");
       
   170 		User::Leave(KErrNotSupported);
       
   171 		}
       
   172 
       
   173 	CleanupStack::Pop(customInterface);
       
   174 
       
   175 
       
   176     roomLevelProxy->iClientReverb = &aReverb;
       
   177     roomLevelProxy->AttachReverb(aReverb);
       
   178 
       
   179     return roomLevelProxy;
       
   180 	}
       
   181 
       
   182 // -----------------------------------------------------------------------------
       
   183 // CRoomLevel::NewL
       
   184 // Static function for creating an instance of the RoomLevel object.
       
   185 // -----------------------------------------------------------------------------
       
   186 //
       
   187 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   188 	CMdaAudioRecorderUtility& aUtility,
       
   189 	TBool aRecordStream, CEnvironmentalReverb& aReverb )
       
   190 	{
       
   191 
       
   192     DEBPRN0;
       
   193    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility, aRecordStream);
       
   194     CleanupStack::PushL(customInterface);
       
   195 
       
   196 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
       
   197 
       
   198 	if ( !roomLevelProxy )
       
   199 		{
       
   200 		DEBPRN1("No Adaptation Support - leaving");
       
   201 		User::Leave(KErrNotSupported);
       
   202 		}
       
   203 
       
   204 	CleanupStack::Pop(customInterface);
       
   205 
       
   206     roomLevelProxy->iClientReverb = &aReverb;
       
   207     roomLevelProxy->AttachReverb(aReverb);
       
   208 
       
   209     return roomLevelProxy;
       
   210 	}
       
   211 
       
   212 // -----------------------------------------------------------------------------
       
   213 // CRoomLevel::NewL
       
   214 // Static function for creating an instance of the RoomLevel object.
       
   215 // -----------------------------------------------------------------------------
       
   216 //
       
   217 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   218 	CMdaAudioToneUtility& aUtility, CEnvironmentalReverb& aReverb )
       
   219 	{
       
   220 
       
   221 	DEBPRN0;
       
   222     CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aUtility.CustomInterface(KUidRoomLevelEffect);
       
   223 
       
   224 	if (roomLevelProxy == NULL)
       
   225 		{
       
   226         DEBPRN1("No Adaptation Support - leaving");
       
   227     	User::Leave(KErrNotSupported);
       
   228 		}
       
   229 
       
   230 	roomLevelProxy->iClientReverb = &aReverb;
       
   231     roomLevelProxy->AttachReverb(aReverb);
       
   232 
       
   233     return roomLevelProxy;
       
   234 	}
       
   235 
       
   236 // -----------------------------------------------------------------------------
       
   237 // CAudioEqualizer::NewL
       
   238 // Static function for creating an instance of the RoomLevel object.
       
   239 // -----------------------------------------------------------------------------
       
   240 //
       
   241 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   242 	CMMFDevSound& aDevSound, CEnvironmentalReverb& aReverb )
       
   243 	{
       
   244 
       
   245 	DEBPRN0;
       
   246     CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aDevSound.CustomInterface(KUidRoomLevelEffect);
       
   247 
       
   248 	if (roomLevelProxy == NULL)
       
   249 		{
       
   250         DEBPRN1("No Adaptation Support - leaving");
       
   251     	User::Leave(KErrNotSupported);
       
   252 		}
       
   253 
       
   254 	roomLevelProxy->iClientReverb = &aReverb;
       
   255     roomLevelProxy->AttachReverb(aReverb);
       
   256 
       
   257     return roomLevelProxy;
       
   258 	}
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CRoomLevel::NewL
       
   262 // Static function for creating an instance of the RoomLevel object.
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   266 	CCustomCommandUtility* aUtility, CEnvironmentalReverb& aReverb )
       
   267 	{
       
   268 
       
   269     DEBPRN0;
       
   270    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   271     CleanupStack::PushL(customInterface);
       
   272 
       
   273 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
       
   274 
       
   275 	if ( !roomLevelProxy )
       
   276 		{
       
   277 		DEBPRN1("No Adaptation Support - leaving");
       
   278 		User::Leave(KErrNotSupported);
       
   279 		}
       
   280 
       
   281  	CleanupStack::Pop(customInterface);
       
   282 
       
   283     roomLevelProxy->iClientReverb = &aReverb;
       
   284     roomLevelProxy->AttachReverb(aReverb);
       
   285 
       
   286     return roomLevelProxy;
       
   287 	}
       
   288 
       
   289 // -----------------------------------------------------------------------------
       
   290 // CRoomLevel::NewL
       
   291 // Static function for creating an instance of the RoomLevel object.
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   295 	MCustomInterface& aCustomInterface, CEnvironmentalReverb& aReverb )
       
   296 	{
       
   297 
       
   298     DEBPRN0;
       
   299 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)aCustomInterface.CustomInterface(KUidRoomLevelEffect);
       
   300 	if ( !roomLevelProxy )
       
   301 		{
       
   302 		DEBPRN1("No Adaptation Support - leaving");
       
   303 		User::Leave(KErrNotSupported);
       
   304 		}
       
   305 
       
   306     roomLevelProxy->iClientReverb = &aReverb;
       
   307 
       
   308     roomLevelProxy->AttachReverb(aReverb);
       
   309 
       
   310     return roomLevelProxy;
       
   311 	}
       
   312 
       
   313 // -----------------------------------------------------------------------------
       
   314 // CRoomLevel::NewL
       
   315 // Static function for creating an instance of the RoomLevel object.
       
   316 // -----------------------------------------------------------------------------
       
   317 //
       
   318 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   319     CMidiClientUtility& aUtility, CEnvironmentalReverb& aReverb)
       
   320 	{
       
   321 
       
   322     DEBPRN0;
       
   323    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   324     CleanupStack::PushL(customInterface);
       
   325 
       
   326 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
       
   327 
       
   328 	if ( !roomLevelProxy )
       
   329 		{
       
   330 		DEBPRN1("No Adaptation Support - leaving");
       
   331 		User::Leave(KErrNotSupported);
       
   332 		}
       
   333 
       
   334 	CleanupStack::Pop(customInterface);
       
   335 
       
   336     roomLevelProxy->iClientReverb = &aReverb;
       
   337 
       
   338     roomLevelProxy->AttachReverb(aReverb);
       
   339 
       
   340     return roomLevelProxy;
       
   341 	}
       
   342 
       
   343 // -----------------------------------------------------------------------------
       
   344 // CRoomLevel::NewL
       
   345 // Static function for creating an instance of the RoomLevel object.
       
   346 // -----------------------------------------------------------------------------
       
   347 //
       
   348 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   349     CDrmPlayerUtility& aUtility, CEnvironmentalReverb& aReverb)
       
   350 	{
       
   351 
       
   352     DEBPRN0;
       
   353    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   354     CleanupStack::PushL(customInterface);
       
   355 
       
   356 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
       
   357 
       
   358 	if ( !roomLevelProxy )
       
   359 		{
       
   360 		DEBPRN1("No Adaptation Support - leaving");
       
   361 		User::Leave(KErrNotSupported);
       
   362 		}
       
   363 
       
   364 	CleanupStack::Pop(customInterface);
       
   365 
       
   366     roomLevelProxy->iClientReverb = &aReverb;
       
   367 
       
   368     roomLevelProxy->AttachReverb(aReverb);
       
   369 
       
   370     return roomLevelProxy;
       
   371 	}
       
   372 
       
   373 // -----------------------------------------------------------------------------
       
   374 // CRoomLevel::NewL
       
   375 // Static function for creating an instance of the RoomLevel object.
       
   376 // -----------------------------------------------------------------------------
       
   377 //
       
   378 EXPORT_C CRoomLevel* CRoomLevel::NewL(
       
   379     CVideoPlayerUtility& aUtility, CEnvironmentalReverb& aReverb)
       
   380 	{
       
   381 
       
   382     DEBPRN0;
       
   383    	CCustomInterfaceUtility* customInterface = CCustomInterfaceUtility::NewL(aUtility);
       
   384     CleanupStack::PushL(customInterface);
       
   385 
       
   386 	CRoomLevelProxy* roomLevelProxy = (CRoomLevelProxy*)customInterface->CustomInterface(KUidRoomLevelEffect);
       
   387 
       
   388 	if ( !roomLevelProxy )
       
   389 		{
       
   390 		DEBPRN1("No Adaptation Support - leaving");
       
   391 		User::Leave(KErrNotSupported);
       
   392 		}
       
   393 
       
   394 	CleanupStack::Pop(customInterface);
       
   395 
       
   396     roomLevelProxy->iClientReverb = &aReverb;
       
   397 
       
   398     roomLevelProxy->AttachReverb(aReverb);
       
   399 
       
   400     return roomLevelProxy;
       
   401 	}
       
   402 
       
   403 // -----------------------------------------------------------------------------
       
   404 // CRoomLevel::RoomLevel
       
   405 // -----------------------------------------------------------------------------
       
   406 //
       
   407 EXPORT_C TInt32 CRoomLevel::Level() const
       
   408 	{
       
   409 	return iRoomLevelData.iStreamRoomLevel;
       
   410 	}
       
   411 
       
   412 // -----------------------------------------------------------------------------
       
   413 // CRoomLevel::RoomLevelLevelRange
       
   414 // -----------------------------------------------------------------------------
       
   415 //
       
   416 EXPORT_C void CRoomLevel::LevelRange(
       
   417 	TInt32& aMin,
       
   418 	TInt32& aMax)
       
   419 	{
       
   420 
       
   421 	aMin = iRoomLevelData.iStreamMinRoomLevel;
       
   422 	aMax = iRoomLevelData.iStreamMaxRoomLevel;
       
   423 	}
       
   424 
       
   425 
       
   426 // -----------------------------------------------------------------------------
       
   427 // CRoomLevel::SetRoomLevelL
       
   428 // -----------------------------------------------------------------------------
       
   429 //
       
   430 EXPORT_C void CRoomLevel::SetRoomLevelL(
       
   431 	TInt32 aRoomLevel )
       
   432 	{
       
   433 	if ( (aRoomLevel >= iRoomLevelData.iStreamMinRoomLevel) && (aRoomLevel <= iRoomLevelData.iStreamMaxRoomLevel) )
       
   434 		{
       
   435 		iRoomLevelData.iStreamRoomLevel = aRoomLevel;
       
   436 		}
       
   437 	else
       
   438 		{
       
   439 		User::Leave(KErrArgument);
       
   440 		}
       
   441 	}
       
   442 
       
   443 
       
   444 // -----------------------------------------------------------------------------
       
   445 // CRoomLevel::Uid
       
   446 // -----------------------------------------------------------------------------
       
   447 //
       
   448 EXPORT_C TUid CRoomLevel::Uid() const
       
   449 	{
       
   450 	return KUidRoomLevelEffect;
       
   451 	}
       
   452 
       
   453 
       
   454 // -----------------------------------------------------------------------------
       
   455 // CRoomLevel::DoEffectData
       
   456 // -----------------------------------------------------------------------------
       
   457 //
       
   458 EXPORT_C const TDesC8& CRoomLevel::DoEffectData()
       
   459 	{
       
   460     DEBPRN0;
       
   461 	iDataPckgTo = iRoomLevelData;
       
   462 	return iDataPckgTo;
       
   463 	}
       
   464 
       
   465 // -----------------------------------------------------------------------------
       
   466 // CRoomLevel::SetEffectData
       
   467 // -----------------------------------------------------------------------------
       
   468 //
       
   469 EXPORT_C void CRoomLevel::SetEffectData(
       
   470 	const TDesC8& aEffectDataBuffer )
       
   471 	{
       
   472     DEBPRN0;
       
   473 	TEfRoomLevelDataPckg dataPckg;
       
   474 	dataPckg.Copy(aEffectDataBuffer);
       
   475 	iRoomLevelData = dataPckg();
       
   476 	iEnabled = iRoomLevelData.iEnabled;
       
   477 	iEnforced = iRoomLevelData.iEnforced;
       
   478 	iHaveUpdateRights = iRoomLevelData.iHaveUpdateRights;
       
   479 	}
       
   480 
       
   481 
       
   482 // ========================== OTHER EXPORTED FUNCTIONS =========================
       
   483 
       
   484