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