profilesservices/RingingTone3DPlugin/src/CRingingTone3DPlugin.cpp
branchRCL_3
changeset 24 8ee96d21d9bf
parent 23 8bda91a87a00
child 25 7e0eff37aedb
equal deleted inserted replaced
23:8bda91a87a00 24:8ee96d21d9bf
     1 /*
       
     2 * Copyright (c) 2005 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:  Plug-In that implements C3DRingingToneInterface.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CRingingTone3DPlugin.h"
       
    21 #include "tdaudioconstants.h"
       
    22 #include "RingingTone3DPluginDebug.h"
       
    23 
       
    24 #include <EnvironmentalReverbUtility.h>       // CEnvironmentalReverbUtility
       
    25 #include <SourceDopplerBase.h>                // CSourceDoppler
       
    26 #include <SourceLocationBase.h>               // CSourceLocation
       
    27 #include <ListenerLocationBase.h>             // CListenerLocation
       
    28 
       
    29 #ifndef SPP_NSS_3D_RINGING_TONE_STW_DISABLED
       
    30 #include <StereoWideningBase.h>               // CStereoWidening
       
    31 #endif
       
    32 
       
    33 
       
    34 #include <MProfileEngine.h>
       
    35 #include <MProfile.h>
       
    36 #include <MProfileTones.h>
       
    37 #include <MProfileExtraSettings.h>
       
    38 #include <MProfile3DToneSettings.h>
       
    39 #include <MProfileName.h>
       
    40 #include <ProfileInternal.hrh> // for TProfile3DToneEffect and TProfile3DToneEcho
       
    41 
       
    42 
       
    43 // CONSTANTS
       
    44 const TUint32 KDopplerFactor = 100;
       
    45 
       
    46 
       
    47 
       
    48 
       
    49 // ============================ MEMBER FUNCTIONS ===============================
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CRingingTone3DPlugin::NewL
       
    53 // Two-phased constructor.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 CRingingTone3DPlugin* CRingingTone3DPlugin::NewL( TAny* aParameter )
       
    57     {
       
    58     // aParameter comes from REComSession::CreateImplementationL
       
    59     // (TAny *aConstructionParameters)
       
    60     
       
    61     CRingingTone3DPlugin* self = new ( ELeave ) CRingingTone3DPlugin();
       
    62     CleanupStack::PushL( self );
       
    63     self->ConstructL( aParameter );
       
    64     CleanupStack::Pop();
       
    65     
       
    66     return self;
       
    67     }
       
    68 
       
    69 // Destructor
       
    70 CRingingTone3DPlugin::~CRingingTone3DPlugin()
       
    71     {
       
    72     
       
    73     // Stop() may leave because of CDrmPlayerUtility error
       
    74     // (CMMFDrmAudioPlayerUtility::IsValidCustomCommandDestination
       
    75     // uses CleanupClosePushL).
       
    76     TRAP_IGNORE( Stop() );
       
    77     
       
    78     delete iTimer;
       
    79     delete iParser;
       
    80     }
       
    81     
       
    82     
       
    83 // -----------------------------------------------------------------------------
       
    84 // CRingingTone3DPlugin::Stop
       
    85 // Stop the playback.
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 void CRingingTone3DPlugin::Stop()
       
    89     {
       
    90     FLOG( _L("CRingingTone3DPlugin::Stop START") );
       
    91     
       
    92     // Stop the playback and timer.
       
    93     if ( iTimer )
       
    94         {
       
    95         iTimer->Cancel();    
       
    96         }
       
    97     
       
    98     StopRingingTone();
       
    99 
       
   100     delete iReverbEffect;
       
   101     iReverbEffect = NULL;
       
   102     
       
   103     delete iDopplerEffect;
       
   104     iDopplerEffect = NULL;
       
   105     
       
   106     delete iListener;
       
   107     iListener = NULL;
       
   108     
       
   109     delete iSource;
       
   110     iSource = NULL;
       
   111     
       
   112 #ifdef __STEREO_WIDENING_EFFECT_UI     
       
   113     delete iStereoWidening;
       
   114     iStereoWidening = NULL;
       
   115 #endif    
       
   116     
       
   117     FLOG( _L("CRingingTone3DPlugin::Stop END") );
       
   118     }
       
   119 
       
   120 
       
   121 // -----------------------------------------------------------------------------
       
   122 // CRingingTone3DPlugin::CRingingTone3DPlugin
       
   123 // C++ default constructor can NOT contain any code, that
       
   124 // might leave.
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 CRingingTone3DPlugin::CRingingTone3DPlugin()
       
   128     {
       
   129     iPlaying = EFalse;
       
   130     iPlayerType = KErrNotFound;
       
   131     iProfileId = KErrNotFound;
       
   132  
       
   133     iProfile3DToneEffect = KErrNotFound;
       
   134     iProfile3DToneEcho = KErrNotFound;
       
   135     iRingingTone = KNullDesC;
       
   136     }
       
   137 
       
   138 
       
   139 // -----------------------------------------------------------------------------
       
   140 // CRingingTone3DPlugin::ConstructL
       
   141 // Symbian 2nd phase constructor can leave.
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 void CRingingTone3DPlugin::ConstructL( TAny* aParameter )
       
   145     {
       
   146     FLOG( _L("CRingingTone3DPlugin::ConstructL START") );
       
   147 
       
   148     iTimer = C3DAudioTimeOutTimer::NewL( EPriorityHigh, this );
       
   149     iParser = C3DAudioXMLParser::NewL();
       
   150 
       
   151     FLOG( _L("CRingingTone3DPlugin::ConstructL END") ); 
       
   152     }
       
   153 
       
   154 
       
   155 // -----------------------------------------------------------------------------
       
   156 // CRingingTone3DPlugin::Init
       
   157 // 
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 void CRingingTone3DPlugin::Init( CMdaAudioPlayerUtility* aSamplePlayer )
       
   161     {
       
   162     FLOG( _L("CRingingTone3DPlugin::InitL START") );
       
   163     
       
   164     __ASSERT_ALWAYS( aSamplePlayer, Panic(KErrArgument) );
       
   165     
       
   166     iAudioPlayerUtility = aSamplePlayer;
       
   167     iPlayerType = EMdaAudioPlayerUtility;
       
   168   
       
   169 #ifdef _DEBUG			                
       
   170     FlogPlayer( iPlayerType );
       
   171 #endif        
       
   172     
       
   173     FLOG( _L("CRingingTone3DPlugin::InitL END") );
       
   174     }
       
   175     
       
   176     
       
   177 // -----------------------------------------------------------------------------
       
   178 // CRingingTone3DPlugin::Init
       
   179 // 
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 void CRingingTone3DPlugin::Init( CMdaAudioToneUtility* aSamplePlayer )
       
   183     {
       
   184     FLOG( _L("CRingingTone3DPlugin::InitL START") );
       
   185     
       
   186     __ASSERT_ALWAYS( aSamplePlayer, Panic(KErrArgument) );
       
   187     
       
   188     iAudioToneUtility = aSamplePlayer;
       
   189     iPlayerType = EMdaAudioToneUtility;
       
   190 
       
   191 #ifdef _DEBUG			                
       
   192     FlogPlayer( iPlayerType );
       
   193 #endif        
       
   194     
       
   195     FLOG( _L("CRingingTone3DPlugin::InitL END") );
       
   196     }
       
   197 
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // CRingingTone3DPlugin::Init
       
   201 // 
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 void CRingingTone3DPlugin::Init( CDrmPlayerUtility* aSamplePlayer )
       
   205     {
       
   206     //FLOG( _L("CRingingTone3DPlugin::InitL START") );
       
   207     
       
   208     __ASSERT_ALWAYS( aSamplePlayer, Panic(KErrArgument) );
       
   209     
       
   210     iDrmPlayerUtility = aSamplePlayer;
       
   211     iPlayerType = EDrmPlayerUtility;
       
   212 
       
   213 #ifdef _DEBUG			                
       
   214     FlogPlayer( iPlayerType );
       
   215 #endif        
       
   216     
       
   217     //FLOG( _L("CRingingTone3DPlugin::InitL END") );
       
   218     }
       
   219 
       
   220 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   221 // -----------------------------------------------------------------------------
       
   222 // CRingingTone3DPlugin::Init
       
   223 // 
       
   224 // -----------------------------------------------------------------------------
       
   225 //
       
   226 void CRingingTone3DPlugin::Init( CVideoPlayerUtility* aSamplePlayer )
       
   227     {
       
   228     FLOG( _L("CRingingTone3DPlugin::InitL START") );
       
   229     
       
   230     __ASSERT_ALWAYS( aSamplePlayer, Panic(KErrArgument) );
       
   231     
       
   232     iVideoPlayerUtility = aSamplePlayer;
       
   233     iPlayerType = EVideoPlayerUtility;
       
   234 
       
   235 #ifdef _DEBUG			                
       
   236     FlogPlayer( iPlayerType );
       
   237 #endif        
       
   238     
       
   239     FLOG( _L("CRingingTone3DPlugin::InitL END") );
       
   240     }
       
   241 #endif
       
   242 
       
   243 // -----------------------------------------------------------------------------
       
   244 // CRingingTone3DPlugin::SetAttr (from C3DRingingToneInterface.h)
       
   245 // 
       
   246 // -----------------------------------------------------------------------------
       
   247 //
       
   248 TInt CRingingTone3DPlugin::SetAttr( T3DRingingToneInterfaceAttr aAttributeKey,
       
   249                                     TInt aValue )
       
   250     {
       
   251     switch (aAttributeKey)
       
   252         {
       
   253         case E3DRTIAttrProfileId:
       
   254             {
       
   255             iProfileId = aValue;
       
   256             break;
       
   257             }
       
   258         case E3DRTIAttr3DEffect:
       
   259             {
       
   260             iProfile3DToneEffect = aValue;
       
   261             break;
       
   262             }
       
   263         case E3DRTIAttr3DEcho:
       
   264             {
       
   265             iProfile3DToneEcho = aValue;
       
   266             break;
       
   267             }
       
   268         default:
       
   269             {
       
   270             break;
       
   271             }
       
   272         }
       
   273         
       
   274     return KErrNone;
       
   275     }
       
   276 
       
   277 
       
   278 // -----------------------------------------------------------------------------
       
   279 // CRingingTone3DPlugin::SetAttr  (from C3DRingingToneInterface.h)
       
   280 // 
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 TInt CRingingTone3DPlugin::SetAttr( T3DRingingToneInterfaceAttr aAttributeKey,
       
   284                                     const TDesC& aValue )
       
   285     {
       
   286     switch (aAttributeKey)
       
   287         {
       
   288         case E3DRTIAttr3DRingingTone:
       
   289             {
       
   290             if ( aValue.Length() < iRingingTone.MaxLength() )
       
   291                 {
       
   292                 iRingingTone = aValue;    
       
   293                 }
       
   294             break;
       
   295             }
       
   296         default:
       
   297             {
       
   298             break;
       
   299             }
       
   300         }
       
   301         
       
   302     return KErrNone;
       
   303     }
       
   304 
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CRingingTone3DPlugin::SetAttr  (from C3DRingingToneInterface.h)
       
   308 // 
       
   309 // -----------------------------------------------------------------------------
       
   310 //
       
   311 TInt CRingingTone3DPlugin::SetAttr( TInt aAttributeKey, TAny* aValue )
       
   312     {
       
   313     switch (aAttributeKey)
       
   314         {
       
   315         case E3DRTIAttrAudioPlayerUtility:
       
   316             {
       
   317             Init( ( CMdaAudioPlayerUtility* )aValue );
       
   318             break;
       
   319             }
       
   320         case E3DRTIAttrAudioToneUtility:
       
   321             {
       
   322             Init( ( CMdaAudioToneUtility* )aValue );
       
   323             break;
       
   324             }
       
   325         case E3DRTIAttrDrmPlayerUtility:
       
   326             {
       
   327             Init( ( CDrmPlayerUtility* )aValue );
       
   328             break;
       
   329             }
       
   330 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   331         case E3DRTIAttrVideoPlayerUtility:
       
   332             {
       
   333             Init( ( CVideoPlayerUtility* )aValue );
       
   334             break;
       
   335             }
       
   336 #endif
       
   337         default:
       
   338             {
       
   339             break;
       
   340             }
       
   341         }
       
   342         
       
   343     return KErrNone;    
       
   344     }
       
   345 
       
   346 
       
   347 // -----------------------------------------------------------------------------
       
   348 // CRingingTone3DPlugin::PlayL
       
   349 // Start the playback, initialize first in case there has been changes.
       
   350 // -----------------------------------------------------------------------------
       
   351 //
       
   352 void CRingingTone3DPlugin::PlayL()
       
   353     {
       
   354     TInt err = KErrNone;
       
   355     
       
   356     TRAP( err, DoPlayL() );
       
   357     
       
   358     if ( err != KErrNone )
       
   359         {
       
   360         // 3D play failed - play normal ringing tone
       
   361         UnInitialize();
       
   362         PlayRingingTone();
       
   363         }
       
   364     }
       
   365 
       
   366 
       
   367 // -----------------------------------------------------------------------------
       
   368 // CRingingTone3DPlugin::DoPlayL
       
   369 //
       
   370 // Start the playback, initialize first in case there has been changes.
       
   371 // -----------------------------------------------------------------------------
       
   372 //
       
   373 void CRingingTone3DPlugin::DoPlayL()
       
   374     {
       
   375     FLOG( _L("CRingingTone3DPlugin::DoPlayL START") );
       
   376     
       
   377     __ASSERT_ALWAYS( iPlayerType != KErrNotFound, Panic(KErrNotReady) );
       
   378     
       
   379     TInt err = KErrNone;
       
   380 
       
   381     if ( iTimer )
       
   382         {
       
   383         iTimer->Cancel();    
       
   384         }
       
   385     else
       
   386         {
       
   387         User::Leave( KErrNoMemory );  // ConstructL has failed
       
   388         }
       
   389     
       
   390     TRAP( err, InitializeL() );  // Initialize the plug-in
       
   391 
       
   392     if ( err != KErrNone )
       
   393         {
       
   394         FLOG( _L("### CRingingTone3DPlugin::InitializeL failed (%d) ###"), err);
       
   395         User::Leave(err);
       
   396         }
       
   397         
       
   398     if ( iProfile3DToneEffect == EProfile3DEffectOff )
       
   399         {
       
   400         PlayRingingTone();  // play normal ringing tone
       
   401         
       
   402         FLOG( _L("CRingingTone3DPlugin::DoPlayL END") );
       
   403         return;
       
   404         }
       
   405   
       
   406 
       
   407 #ifdef __STEREO_WIDENING_EFFECT_UI
       
   408     if ( iStereoWidening )
       
   409         {
       
   410         if ( !iStereoWidening->IsEnabled() )
       
   411             {
       
   412             FLOG( _L("### CStereoWidening not enabled ###") );
       
   413             
       
   414             TRAP( err, iStereoWidening->EnableL() );
       
   415             if ( err != KErrNone )
       
   416                 {
       
   417                 FLOG( _L("### CStereoWidening::EnableL failed (%d) ###"), err);
       
   418                 User::Leave( err );    
       
   419                 }
       
   420             }
       
   421 
       
   422         // play normal ringing tone with stereowidening
       
   423         PlayRingingTone();  
       
   424         
       
   425         FLOG( _L("CRingingTone3DPlugin::DoPlayL END") );
       
   426         return;
       
   427         }
       
   428 #endif
       
   429 
       
   430 
       
   431     iCurrentUpdate = KErrNotFound;
       
   432 
       
   433     SetNext3DPatternPositionL();
       
   434         
       
   435     PlayRingingTone();  // Start playing 3D ringing tone.
       
   436     
       
   437     FLOG( _L("CRingingTone3DPlugin::DoPlayL END") );      
       
   438     }
       
   439 
       
   440     
       
   441 // -----------------------------------------------------------------------------
       
   442 // CRingingTone3DPlugin::TimerExpiredL
       
   443 // Callback method for timer expiration.
       
   444 // Used to update the location and doppler-effects.
       
   445 // -----------------------------------------------------------------------------
       
   446 //
       
   447 void CRingingTone3DPlugin::TimerExpiredL()
       
   448     {
       
   449     //FLOG( _L("CRingingTone3DPlugin::TimerExpiredL START") );
       
   450     
       
   451     if ( iCurrentUpdate % 10 == 0 )
       
   452         {
       
   453         FLOG( _L("CRingingTone3DPlugin::TimerExpiredL called (count = %d)"), iCurrentUpdate);
       
   454         }
       
   455 
       
   456     SetNext3DPatternPositionL();
       
   457         
       
   458     //FLOG( _L("CRingingTone3DPlugin::TimerExpiredL END") );
       
   459     }
       
   460 
       
   461 
       
   462 
       
   463 // -----------------------------------------------------------------------------
       
   464 // CRingingTone3DPlugin::SetNext3DPatternPositionL
       
   465 //
       
   466 // Used to update the location and doppler-effects.
       
   467 // -----------------------------------------------------------------------------
       
   468 //
       
   469 void CRingingTone3DPlugin::SetNext3DPatternPositionL()
       
   470     {
       
   471     //FLOG( _L("CRingingTone3DPlugin::SetNext3DPatternPositionL START") );
       
   472     
       
   473     TInt err = KErrNone;
       
   474     
       
   475     if ( !iSource || !iListener )
       
   476         {
       
   477         FLOG( _L("### CSourceLocation or CListenerLocation or C3DAudioPattern is NULL ###") );
       
   478         User::Leave( KErrDied );
       
   479         }
       
   480     
       
   481     if ( iCurrentUpdate == KErrNotFound )
       
   482         {
       
   483         iCurrentUpdate = 0;  // first position
       
   484         }
       
   485     else
       
   486         {
       
   487         iCurrentUpdate++;  // next position
       
   488         }
       
   489     
       
   490     // iCurrentUpdate out of bounds. Start from the beginning.
       
   491     if ( iCurrentUpdate >= iParser->CountL() )
       
   492         {
       
   493         iCurrentUpdate = 0;
       
   494         }
       
   495  
       
   496 
       
   497     //
       
   498     // update doppler-effect
       
   499     //
       
   500     if ( iDoppler  && iDopplerEffect )
       
   501         {
       
   502         // Current doppler-velocity.
       
   503         T3DVelocity velocity = iParser->VelocityL( iCurrentUpdate );
       
   504         
       
   505         // Update the velocity and apply.
       
   506         TRAP( err, iDopplerEffect->SetCartesianVelocityL( ( TInt32& )velocity.iXVector, 
       
   507                                                           ( TInt32& )velocity.iYVector, 
       
   508                                                           ( TInt32& )velocity.iZVector ) );
       
   509         if ( err != KErrNone )
       
   510             {
       
   511             FLOG( _L("### CSourceDoppler::SetCartesianVelocityL failed (%d) ###"), err);
       
   512             User::Leave( err );
       
   513             }                                                            
       
   514 
       
   515         if ( !iDopplerEffect->IsEnabled() )
       
   516             {
       
   517             FLOG( _L("### CSourceDoppler not enabled ###") );
       
   518             
       
   519             TRAP( err, iDopplerEffect->EnableL() );
       
   520 
       
   521             if ( err != KErrNone )
       
   522                 {
       
   523                 FLOG( _L("### CSourceDoppler::EnableL failed (%d) ###"), err);
       
   524                 User::Leave( err );
       
   525                 }
       
   526             }
       
   527         
       
   528         TRAP( err, iDopplerEffect->ApplyL() );
       
   529         if ( err != KErrNone )
       
   530             {
       
   531             FLOG( _L("### CSourceDoppler::ApplyL failed (%d) ###"), err);
       
   532             User::Leave( err );
       
   533             }
       
   534             
       
   535 #ifdef _DEBUG			                
       
   536         //FlogVelocityL( velocity, iCurrentUpdate );
       
   537 #endif        
       
   538         
       
   539         }
       
   540         
       
   541         
       
   542     //
       
   543     // set new 3D pattern position
       
   544     //
       
   545     T3DPosition position = iParser->PositionL( iCurrentUpdate );
       
   546     
       
   547     TRAP( err, iSource->SetLocationCartesianL( ( TInt32& )position.iX, 
       
   548                                                ( TInt32& )position.iY, 
       
   549                                                ( TInt32& )position.iZ ) );
       
   550     if ( err != KErrNone )
       
   551         {
       
   552         FLOG( _L("### CSourceLocation::SetLocationCartesianL failed (%d) ###"), err);
       
   553         User::Leave( err );
       
   554         }
       
   555         
       
   556     if ( !iSource->IsEnabled() )
       
   557         {
       
   558         FLOG( _L("### CSourceLocation not enabled ###") );
       
   559 
       
   560         TRAP( err, iSource->EnableL() );
       
   561         if ( err != KErrNone )
       
   562             {
       
   563             FLOG( _L("### CSourceLocation::EnableL failed (%d) ###"), err);
       
   564             User::Leave( err );
       
   565             }          
       
   566         }
       
   567     
       
   568     TRAP( err, iSource->ApplyL() );    
       
   569     if ( err != KErrNone )
       
   570         {
       
   571         FLOG( _L("### CSourceLocation::ApplyL failed (%d) ###"), err);
       
   572         User::Leave( err );
       
   573         }          
       
   574       
       
   575 
       
   576 #ifdef _DEBUG			                
       
   577     //FlogPositionL( position, iCurrentUpdate );
       
   578 #endif        
       
   579 
       
   580       
       
   581     //
       
   582     // if reverb is created and not enabled try to enable it.
       
   583     //
       
   584     if ( iReverbEffect )
       
   585         {
       
   586         TBool enabled = iReverbEffect->EnvironmentalReverb().IsEnabled();
       
   587         if ( !enabled )
       
   588             {
       
   589             FLOG( _L("### CEnvironmentalReverb not enabled ###") );
       
   590 
       
   591             TRAP( err, iReverbEffect->EnvironmentalReverb().EnableL() );
       
   592             if ( err != KErrNone )
       
   593                 {
       
   594                 FLOG( _L("### CEnvironmentalReverb::EnableL failed (%d) ###"), err);
       
   595                 User::Leave( err );
       
   596                 }          
       
   597             }
       
   598         }
       
   599   
       
   600   
       
   601     //
       
   602     // if listener location is created and not enabled try to enable it
       
   603     //
       
   604     if ( !iListener->IsEnabled() )
       
   605         {
       
   606         FLOG( _L("### CListnerLocation not enabled ###") );
       
   607         
       
   608         TRAP( err, iListener->EnableL() );
       
   609         if ( err != KErrNone )
       
   610             {
       
   611             FLOG( _L("### CListnerLocation::EnableL failed (%d) ###"), err);
       
   612             User::Leave( err );
       
   613             }
       
   614         }        
       
   615 
       
   616 
       
   617     // Get the update time and calculate it according to velocity set.
       
   618     TInt dTime = iParser->TimeL( iCurrentUpdate ) * 1000;
       
   619     
       
   620     CalculateDTime( dTime );
       
   621     
       
   622 #ifdef _DEBUG			                
       
   623     //FlogTimeL( dTime, iCurrentUpdate );
       
   624 #endif        
       
   625 
       
   626     // Start the timer if pattern changes.
       
   627     if ( dTime != 0 )
       
   628         {
       
   629         iTimer->After( dTime );    
       
   630         }
       
   631         
       
   632     //FLOG( _L("CRingingTone3DPlugin::SetNext3DPatternPositionL END") );
       
   633     }
       
   634 
       
   635 
       
   636 // -----------------------------------------------------------------------------
       
   637 // CRingingTone3DPlugin::CalculateDTime
       
   638 // Calculate the time spent in current update, depending on the velocity set.
       
   639 // -----------------------------------------------------------------------------
       
   640 void CRingingTone3DPlugin::CalculateDTime( TInt& aTime )
       
   641     {
       
   642     // Velocity is set to zero, so no movement will appear.    
       
   643     if ( iVelocity == 0 )
       
   644         {
       
   645         aTime = 0;
       
   646         }
       
   647     // Velocity is under five (default), so the updates take more time.
       
   648     else if ( iVelocity < KMotionPatternDefaultVelocity )
       
   649         {
       
   650         aTime = aTime + ( ( aTime / 5 ) * ( KMotionPatternDefaultVelocity - iVelocity ) );
       
   651         }
       
   652     // Velocity is over five (default), so the updates take less time.
       
   653     else if ( iVelocity > KMotionPatternDefaultVelocity )
       
   654         {
       
   655         aTime = aTime - ( ( aTime / 6 ) * ( iVelocity - KMotionPatternDefaultVelocity ) );
       
   656         }
       
   657     }
       
   658 
       
   659 
       
   660 // -----------------------------------------------------------------------------
       
   661 // CRingingTone3DPlugin::InitializeL()
       
   662 // Initialize the plugin to current settings.
       
   663 // -----------------------------------------------------------------------------
       
   664 //    
       
   665 void CRingingTone3DPlugin::UnInitialize()
       
   666     {
       
   667     if ( iReverbEffect )
       
   668         {
       
   669         TRAP_IGNORE( iReverbEffect->DisableEnvironmentalReverbL() );
       
   670         }
       
   671     if ( iListener )
       
   672         {
       
   673         TRAP_IGNORE( iListener->DisableL() );
       
   674         }
       
   675     if ( iSource )
       
   676         {
       
   677         TRAP_IGNORE( iSource->DisableL() );
       
   678         }
       
   679         
       
   680     if ( iDopplerEffect )
       
   681         {
       
   682         TRAP_IGNORE( iDopplerEffect->DisableL() );
       
   683         }
       
   684     }
       
   685 
       
   686 
       
   687 // -----------------------------------------------------------------------------
       
   688 // CRingingTone3DPlugin::InitializeL()
       
   689 // Initialize the plugin to current settings.
       
   690 // -----------------------------------------------------------------------------
       
   691 //
       
   692 void CRingingTone3DPlugin::InitializeL()
       
   693     {
       
   694     FLOG( _L("CRingingTone3DPlugin::InitializeL START") );
       
   695     
       
   696     if ( iProfile3DToneEffect == KErrNotFound || iProfile3DToneEcho == KErrNotFound )
       
   697         {
       
   698         // profile 3D settings not available - get them from active profile 
       
   699         ReadActiveProfileL();
       
   700         }
       
   701  
       
   702     // if ringing tone has been set (SetAttr), check its validity
       
   703     if ( !CheckRingingTone() ) 
       
   704         {
       
   705         FLOG( _L("### invalid 3D ringing tone ###") );
       
   706         FLOG( _L("CRingingTone3DPlugin::InitializeL END") );
       
   707         User::Leave(KErrNotFound);
       
   708         }
       
   709 
       
   710     if ( iProfile3DToneEffect == EProfile3DEffectOff )
       
   711         {
       
   712         FLOG( _L("3D ringing tones not enabled") );
       
   713         FLOG( _L("CRingingTone3DPlugin::InitializeL END") );
       
   714         return;
       
   715         }
       
   716 
       
   717 #ifdef _DEBUG
       
   718     Check3DPatternL(iProfile3DToneEffect);
       
   719     Check3DEchoL(iProfile3DToneEcho);
       
   720 #endif    
       
   721         
       
   722 
       
   723 #ifdef __STEREO_WIDENING_EFFECT_UI
       
   724     if ( iProfile3DToneEffect == EProfile3DEffectStereoWidening )        
       
   725         {
       
   726         const TInt KStereoWideningLevel = 50;
       
   727         
       
   728         if ( !iStereoWidening )
       
   729             {
       
   730             iStereoWidening = StereoWideningL();    
       
   731             }
       
   732                  
       
   733         iStereoWidening->SetStereoWideningLevelL( KStereoWideningLevel );
       
   734         iStereoWidening->EnableL();
       
   735         
       
   736         FLOG( _L("CStereoWidening used as 3D effect") );
       
   737         FLOG( _L("CRingingTone3DPlugin::InitializeL END") );
       
   738         return;
       
   739         }
       
   740 #endif
       
   741 
       
   742     //
       
   743     // parse 3D pattern
       
   744     //
       
   745     TInt err = KErrNone;
       
   746     TRAP( err ,iParser->ParseL( iProfile3DToneEffect ) );
       
   747     if ( err != KErrNone )
       
   748         {
       
   749         FLOG( _L("### C3DAudioXMLParser::ParseL failed (err=%d, pattern=%d) ###"), err, iProfile3DToneEffect);
       
   750         User::Leave( err );
       
   751         }
       
   752       
       
   753     
       
   754 #ifdef _DEBUG                         
       
   755     C3DAudioXMLParser::FlogPubSubL( iProfile3DToneEcho );
       
   756 #endif
       
   757 
       
   758     iVelocity = iParser->Attribute( C3DAudioXMLParser::EKeyVelocity );
       
   759     iDoppler = iParser->Attribute( C3DAudioXMLParser::EKeyDopplerUsed );
       
   760     
       
   761     if ( iProfile3DToneEcho != EProfile3DEchoOff )
       
   762         {
       
   763         TInt err = KErrNone;
       
   764         
       
   765         if ( !iReverbEffect ) 
       
   766             {
       
   767             TRAP( err, iReverbEffect = EnvironmentalReverbUtilityL());
       
   768             if ( err != KErrNone )
       
   769                 {
       
   770                 FLOG( _L("### CEnvironmentalReverbUtility::NewL failed (%d) ###"), err);
       
   771                 User::Leave(err);    
       
   772                 }
       
   773             }
       
   774 
       
   775         // Apply the preset. This also enables reverb effect.
       
   776         TRAP( err, iReverbEffect->ApplyPresetL( iProfile3DToneEcho ) );
       
   777         if ( err != KErrNone )
       
   778             {
       
   779             FLOG( _L("### CEnvironmentalReverbUtility::ApplyPresetL failed (%d) ###"), err);
       
   780             User::Leave(err);    
       
   781             }
       
   782         }
       
   783                
       
   784                 
       
   785     // SourceLocation and ListenerLocation are not created.
       
   786     if ( !iSource ) 
       
   787         {
       
   788         iSource = SourceLocationL();
       
   789         }
       
   790            
       
   791     if ( !iListener ) 
       
   792         {
       
   793         iListener = ListenerLocationL();
       
   794         }
       
   795 
       
   796     // Veriable to set the location.
       
   797     TInt32 zeroInt = 0;
       
   798                          
       
   799     // Set both locations to (0, 0, 0) and enable them.
       
   800     iListener->SetLocationCartesianL( zeroInt, zeroInt, zeroInt );
       
   801     iListener->EnableL();
       
   802                 
       
   803     iSource->SetLocationCartesianL( zeroInt, zeroInt, zeroInt );
       
   804     iSource->EnableL();
       
   805 
       
   806     // Doppler is enabled
       
   807     if ( iDoppler )
       
   808         {
       
   809         // The effect is not created
       
   810         if ( !iDopplerEffect ) 
       
   811             {
       
   812             iDopplerEffect = SourceDopplerL();
       
   813             }
       
   814                     
       
   815         TInt maxFactor = iDopplerEffect->FactorMax();
       
   816         if ( KDopplerFactor > maxFactor )
       
   817             {
       
   818             iDopplerEffect->SetFactorL( maxFactor );
       
   819             FLOG( _L("### CSourceDoppler::SetFactorL: max factor (%d) overflow ###"), maxFactor );  
       
   820             }
       
   821         else
       
   822             {
       
   823             // Set doppler factor.
       
   824             iDopplerEffect->SetFactorL( KDopplerFactor );
       
   825             }
       
   826                   
       
   827         // Enable the effect.                
       
   828         iDopplerEffect->EnableL();
       
   829         }
       
   830     
       
   831 
       
   832     FLOG( _L("CRingingTone3DPlugin::InitializeL END") );
       
   833     }
       
   834 
       
   835 
       
   836 
       
   837 // -----------------------------------------------------------------------------
       
   838 // CRingingTone3DPlugin::EnvironmentalReverbUtilityL()
       
   839 //
       
   840 // -----------------------------------------------------------------------------
       
   841 //    
       
   842 CEnvironmentalReverbUtility* CRingingTone3DPlugin::EnvironmentalReverbUtilityL()
       
   843     {
       
   844     CEnvironmentalReverbUtility* ret = NULL;
       
   845     
       
   846     switch ( iPlayerType )
       
   847         {
       
   848         case EMdaAudioPlayerUtility:
       
   849             {
       
   850             ret = CEnvironmentalReverbUtility::NewL( *iAudioPlayerUtility );
       
   851             break;
       
   852             }
       
   853         case EMdaAudioToneUtility:
       
   854             {
       
   855             ret = CEnvironmentalReverbUtility::NewL( *iAudioToneUtility );
       
   856             break;
       
   857             }
       
   858         case EDrmPlayerUtility:
       
   859             {
       
   860             ret = CEnvironmentalReverbUtility::NewL( *iDrmPlayerUtility );
       
   861             break;
       
   862             }
       
   863 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   864         case EVideoPlayerUtility:
       
   865             {
       
   866             ret = CEnvironmentalReverbUtility::NewL( *iVideoPlayerUtility );
       
   867             break;
       
   868             }
       
   869 #endif
       
   870         default:
       
   871             {
       
   872             Panic(KErrArgument);
       
   873             break;
       
   874             }
       
   875         }
       
   876         
       
   877     return ret;
       
   878     }
       
   879 
       
   880 
       
   881 // -----------------------------------------------------------------------------
       
   882 // CRingingTone3DPlugin::SourceLocationL()
       
   883 //
       
   884 // -----------------------------------------------------------------------------
       
   885 //    
       
   886 CSourceLocation* CRingingTone3DPlugin::SourceLocationL()
       
   887     {
       
   888     CSourceLocation* ret = NULL;
       
   889     
       
   890     switch ( iPlayerType )
       
   891         {
       
   892         case EMdaAudioPlayerUtility:
       
   893             {
       
   894             ret = CSourceLocation::NewL( *iAudioPlayerUtility );
       
   895             break;
       
   896             }
       
   897         case EMdaAudioToneUtility:
       
   898             {
       
   899             ret = CSourceLocation::NewL( *iAudioToneUtility );
       
   900             break;
       
   901             }
       
   902         case EDrmPlayerUtility:
       
   903             {
       
   904             ret = CSourceLocation::NewL( *iDrmPlayerUtility );
       
   905             break;
       
   906             }
       
   907 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   908         case EVideoPlayerUtility:
       
   909             {
       
   910             ret = CSourceLocation::NewL( *iVideoPlayerUtility );
       
   911             break;
       
   912             }
       
   913 #endif
       
   914         default:
       
   915             {
       
   916             Panic(KErrArgument);
       
   917             break;
       
   918             }
       
   919         }
       
   920         
       
   921     return ret;
       
   922     }
       
   923 
       
   924 
       
   925 // -----------------------------------------------------------------------------
       
   926 // CRingingTone3DPlugin::ListenerLocationL()
       
   927 //
       
   928 // -----------------------------------------------------------------------------
       
   929 //    
       
   930 CListenerLocation* CRingingTone3DPlugin::ListenerLocationL()
       
   931     {
       
   932     CListenerLocation* ret = NULL;
       
   933     
       
   934     switch ( iPlayerType )
       
   935         {
       
   936         case EMdaAudioPlayerUtility:
       
   937             {
       
   938             ret = CListenerLocation::NewL( *iAudioPlayerUtility );
       
   939             break;
       
   940             }
       
   941         case EMdaAudioToneUtility:
       
   942             {
       
   943             ret = CListenerLocation::NewL( *iAudioToneUtility );
       
   944             break;
       
   945             }
       
   946         case EDrmPlayerUtility:
       
   947             {
       
   948             ret = CListenerLocation::NewL( *iDrmPlayerUtility );
       
   949             break;
       
   950             }
       
   951 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   952         case EVideoPlayerUtility:
       
   953             {
       
   954             ret = CListenerLocation::NewL( *iVideoPlayerUtility );
       
   955             break;
       
   956             }
       
   957 #endif
       
   958         default:
       
   959             {
       
   960             Panic(KErrArgument);
       
   961             break;
       
   962             }
       
   963         }
       
   964         
       
   965     return ret;
       
   966     }
       
   967 
       
   968 
       
   969 
       
   970 // -----------------------------------------------------------------------------
       
   971 // CRingingTone3DPlugin::SourceDopplerL()
       
   972 //
       
   973 // -----------------------------------------------------------------------------
       
   974 //    
       
   975 CSourceDoppler* CRingingTone3DPlugin::SourceDopplerL()
       
   976     {
       
   977     CSourceDoppler* ret = NULL;
       
   978     
       
   979     switch ( iPlayerType )
       
   980         {
       
   981         case EMdaAudioPlayerUtility:
       
   982             {
       
   983             ret = CSourceDoppler::NewL( *iAudioPlayerUtility );
       
   984             break;
       
   985             }
       
   986         case EMdaAudioToneUtility:
       
   987             {
       
   988             ret = CSourceDoppler::NewL( *iAudioToneUtility );
       
   989             break;
       
   990             }
       
   991         case EDrmPlayerUtility:
       
   992             {
       
   993             ret = CSourceDoppler::NewL( *iDrmPlayerUtility );
       
   994             break;
       
   995             }
       
   996 #ifdef RD_VIDEO_AS_RINGING_TONE
       
   997         case EVideoPlayerUtility:
       
   998             {
       
   999             ret = CSourceDoppler::NewL( *iVideoPlayerUtility );
       
  1000             break;
       
  1001             }
       
  1002 #endif
       
  1003         default:
       
  1004             {
       
  1005             Panic(KErrArgument);
       
  1006             break;
       
  1007             }
       
  1008         }
       
  1009         
       
  1010     return ret;
       
  1011     }
       
  1012 
       
  1013 
       
  1014 
       
  1015 #ifdef __STEREO_WIDENING_EFFECT_UI
       
  1016 // -----------------------------------------------------------------------------
       
  1017 // CRingingTone3DPlugin::StereoWideningL()
       
  1018 //
       
  1019 // -----------------------------------------------------------------------------
       
  1020 //    
       
  1021 CStereoWidening* CRingingTone3DPlugin::StereoWideningL()
       
  1022     {
       
  1023     CStereoWidening* ret = NULL;
       
  1024     
       
  1025     switch ( iPlayerType )
       
  1026         {
       
  1027         case EMdaAudioPlayerUtility:
       
  1028             {
       
  1029             ret = CStereoWidening::NewL( *iAudioPlayerUtility );
       
  1030             break;
       
  1031             }
       
  1032         case EMdaAudioToneUtility:
       
  1033             {
       
  1034             ret = CStereoWidening::NewL( *iAudioToneUtility );
       
  1035             break;
       
  1036             }
       
  1037         case EDrmPlayerUtility:
       
  1038             {
       
  1039             ret = CStereoWidening::NewL( *iDrmPlayerUtility );
       
  1040             break;
       
  1041             }
       
  1042         case EVideoPlayerUtility:
       
  1043             {
       
  1044             ret = CStereoWidening::NewL( *iVideoPlayerUtility );
       
  1045             break;
       
  1046             }
       
  1047         default:
       
  1048             {
       
  1049             Panic(KErrArgument);
       
  1050             break;
       
  1051             }
       
  1052         }
       
  1053         
       
  1054     return ret;
       
  1055     }
       
  1056 #endif
       
  1057 
       
  1058 
       
  1059 // -----------------------------------------------------------------------------
       
  1060 // CRingingTone3DPlugin::PlayRingingTone()
       
  1061 //
       
  1062 // -----------------------------------------------------------------------------
       
  1063 //    
       
  1064 void CRingingTone3DPlugin::PlayRingingTone()
       
  1065     {
       
  1066     if ( iPlaying )
       
  1067         {
       
  1068         return;
       
  1069         }
       
  1070     iPlaying = ETrue;
       
  1071     
       
  1072     switch ( iPlayerType )
       
  1073         {
       
  1074         case EMdaAudioPlayerUtility:
       
  1075             {
       
  1076             iAudioPlayerUtility->Play();
       
  1077             break;
       
  1078             }
       
  1079         case EMdaAudioToneUtility:
       
  1080             {
       
  1081             iAudioToneUtility->Play();
       
  1082             break;
       
  1083             }
       
  1084         case EDrmPlayerUtility:
       
  1085             {
       
  1086             iDrmPlayerUtility->Play();
       
  1087             break;
       
  1088             }
       
  1089 #ifdef RD_VIDEO_AS_RINGING_TONE
       
  1090         case EVideoPlayerUtility:
       
  1091             {
       
  1092             iVideoPlayerUtility->Play();
       
  1093             break;
       
  1094             }
       
  1095 #endif
       
  1096         default:
       
  1097             {
       
  1098             break;
       
  1099             }
       
  1100         }
       
  1101     }
       
  1102 
       
  1103 
       
  1104 // -----------------------------------------------------------------------------
       
  1105 // CRingingTone3DPlugin::StopRingingTone()
       
  1106 //
       
  1107 // -----------------------------------------------------------------------------
       
  1108 //    
       
  1109 void CRingingTone3DPlugin::StopRingingTone()
       
  1110     {
       
  1111     if ( !iPlaying )
       
  1112         {
       
  1113         return;
       
  1114         }
       
  1115     iPlaying = EFalse;
       
  1116         
       
  1117     switch ( iPlayerType )
       
  1118         {
       
  1119         case EMdaAudioPlayerUtility:
       
  1120             {
       
  1121             iAudioPlayerUtility->Stop();
       
  1122             break;
       
  1123             }
       
  1124         case EMdaAudioToneUtility:
       
  1125             {
       
  1126             iAudioToneUtility->CancelPlay();
       
  1127             break;
       
  1128             }
       
  1129         case EDrmPlayerUtility:
       
  1130             {
       
  1131             iDrmPlayerUtility->Stop();
       
  1132             break;
       
  1133             }
       
  1134 #ifdef RD_VIDEO_AS_RINGING_TONE
       
  1135         case EVideoPlayerUtility:
       
  1136             {
       
  1137             iVideoPlayerUtility->Stop();
       
  1138             break;
       
  1139             }
       
  1140 #endif
       
  1141         default:
       
  1142             {
       
  1143             Panic(KErrArgument);
       
  1144             break;
       
  1145             }
       
  1146         }
       
  1147         
       
  1148     FLOG( _L("CRingingTone3DPlugin::StopRingingTone: ringing stopped") );
       
  1149     }
       
  1150 
       
  1151 
       
  1152 // -----------------------------------------------------------------------------
       
  1153 // CRingingTone3DPlugin::Panic()
       
  1154 //
       
  1155 // -----------------------------------------------------------------------------
       
  1156 //    
       
  1157 void CRingingTone3DPlugin::Panic(TInt aReason)
       
  1158     {
       
  1159 	_LIT(KPanicCategory,"RingingTone3DAudioPlugin");
       
  1160 	
       
  1161 	User::Panic(KPanicCategory, aReason); 
       
  1162     }
       
  1163 
       
  1164 
       
  1165 // -----------------------------------------------------------------------------
       
  1166 // CRingingTone3DPlugin::ReadActiveProfileL()
       
  1167 // -----------------------------------------------------------------------------
       
  1168 //    
       
  1169 void CRingingTone3DPlugin::ReadActiveProfileL()
       
  1170     {
       
  1171     MProfileEngine* profileEngine = CreateProfileEngineL();
       
  1172     CleanupReleasePushL( *profileEngine );
       
  1173     
       
  1174     MProfile* activeProfile  = profileEngine->ActiveProfileL();
       
  1175     CleanupReleasePushL( *activeProfile );
       
  1176         
       
  1177 #ifdef _DEBUG        
       
  1178     FlogProfileL(activeProfile);
       
  1179 #endif        
       
  1180 
       
  1181     //const MProfileTones& profileTones = activeProfile->ProfileTones();
       
  1182     //iRingingTone = profileTones.RingingTone1();
       
  1183       
       
  1184     const MProfileExtraSettings& extra = activeProfile->ProfileExtraSettings();
       
  1185     const MProfile3DToneSettings& threeD = extra.Profile3DToneSettings();
       
  1186     
       
  1187     iProfile3DToneEffect = threeD.Effect();
       
  1188     iProfile3DToneEcho = threeD.Echo();
       
  1189    
       
  1190     CleanupStack::PopAndDestroy(activeProfile); 
       
  1191     CleanupStack::PopAndDestroy( profileEngine );
       
  1192     }
       
  1193 
       
  1194 
       
  1195 // -----------------------------------------------------------------------------
       
  1196 // CRingingTone3DPlugin::CheckRingingTone()
       
  1197 // -----------------------------------------------------------------------------
       
  1198 //    
       
  1199 TBool CRingingTone3DPlugin::CheckRingingTone()
       
  1200     {
       
  1201     if ( iRingingTone.Length() == 0 )
       
  1202         {
       
  1203         return ETrue; // nothing to check
       
  1204         }
       
  1205         
       
  1206     TParsePtr fileParser( iRingingTone );
       
  1207     TPtrC extPtr = fileParser.Ext();
       
  1208     
       
  1209     // Ringing tone is valid for 3D-playback, i.e not a .rng-tone or "No ringing tone".
       
  1210     // Or the user has set the RingingToneInUse flag to EFalse in CR.
       
  1211     if ( extPtr.Compare( KRngType ) == 0 || iRingingTone.Compare( KNoToneFileName ) == 0 ) 
       
  1212         {
       
  1213         return EFalse;
       
  1214         }
       
  1215         
       
  1216     return ETrue;
       
  1217     }
       
  1218 
       
  1219 
       
  1220 
       
  1221 #ifdef _DEBUG
       
  1222 
       
  1223 // -----------------------------------------------------------------------------
       
  1224 // CRingingTone3DPlugin::Check3DPatternL()
       
  1225 //
       
  1226 // -----------------------------------------------------------------------------
       
  1227 //    
       
  1228 void CRingingTone3DPlugin::Check3DPatternL(TInt aPattern)
       
  1229     {
       
  1230     
       
  1231     if ( aPattern != EProfile3DEffectOff && aPattern != EProfile3DEffectCircle &&
       
  1232          aPattern != EProfile3DEffectFlyby && aPattern != EProfile3DEffectZigZag &&
       
  1233          aPattern != EProfile3DEffectRandomWalk && aPattern != EProfile3DEffectChaos &&
       
  1234          aPattern != EProfile3DEffectStereoWidening )
       
  1235         {
       
  1236         User::Leave(KErrArgument);
       
  1237         }
       
  1238     }
       
  1239 
       
  1240 // -----------------------------------------------------------------------------
       
  1241 // CRingingTone3DPlugin::Check3DEchoL()
       
  1242 //
       
  1243 // -----------------------------------------------------------------------------
       
  1244 //    
       
  1245 void CRingingTone3DPlugin::Check3DEchoL(TInt aEcho)
       
  1246     {
       
  1247     
       
  1248     if ( aEcho != EProfile3DEchoOff && aEcho != EProfile3DEchoLivingRoom &&
       
  1249          aEcho != EProfile3DEchoCave && aEcho != EProfile3DEchoStoneCorridor &&
       
  1250          aEcho != EProfile3DEchoForest && aEcho != EProfile3DEchoSewerPipe &&
       
  1251          aEcho != EProfile3DEchoUnderwater )
       
  1252         {
       
  1253         User::Leave(KErrArgument);
       
  1254         }
       
  1255     }
       
  1256 
       
  1257 
       
  1258 // -----------------------------------------------------------------------------
       
  1259 // CRingingTone3DPlugin::FlogRepository()
       
  1260 //
       
  1261 // -----------------------------------------------------------------------------
       
  1262 //    
       
  1263 void CRingingTone3DPlugin::FlogRepositoryL(CRepository* aRepository, TInt aEcho)
       
  1264     {
       
  1265     FLOG( _L("------ start repository data ------") );
       
  1266     
       
  1267     TInt num = 0;
       
  1268     TBuf<128> buf;
       
  1269     
       
  1270     User::LeaveIfError( aRepository->Get( E3DAudioRepositoryPattern, num ) );
       
  1271     C3DAudioXMLParser::GetPatternString(buf, num);
       
  1272     FLOG( _L("pattern: %S (%d)"), &buf, num );
       
  1273     
       
  1274     User::LeaveIfError( aRepository->Get( E3DAudioRepositoryReverb, num ) );
       
  1275     C3DAudioXMLParser::GetEchoString(buf, num);
       
  1276     
       
  1277     C3DAudioXMLParser::GetEchoString(buf, aEcho);
       
  1278     FLOG( _L("echo: %S (%d)"), &buf, aEcho );
       
  1279  
       
  1280     User::LeaveIfError( aRepository->Get( E3DAudioRepositoryVelocity, num ) );
       
  1281     FLOG( _L("velocity: %d"), num );
       
  1282     
       
  1283     User::LeaveIfError( aRepository->Get( E3DAudioRepositoryDoppler, num ) );
       
  1284     FLOG( _L("doppler: %d"), num );
       
  1285     
       
  1286     User::LeaveIfError( aRepository->Get( E3DAudioRepositoryBlockCount, num ) );
       
  1287     FLOG( _L("block count: %d"), num );
       
  1288     
       
  1289     FLOG( _L("------ end repository data ------") );
       
  1290     }
       
  1291 
       
  1292 
       
  1293 // -----------------------------------------------------------------------------
       
  1294 // CRingingTone3DPlugin::FlogProfile()
       
  1295 //
       
  1296 // -----------------------------------------------------------------------------
       
  1297 //    
       
  1298 void CRingingTone3DPlugin::FlogProfileL(MProfile* aProfile)
       
  1299     {
       
  1300     FLOG( _L("------ start profile data ------") );
       
  1301     
       
  1302     TInt num = 0;
       
  1303     TBuf<128> buf;
       
  1304     
       
  1305     const MProfileName& name = aProfile->ProfileName();
       
  1306     buf = name.Name();
       
  1307     FLOG( _L("profile name: %S"), &buf );
       
  1308     
       
  1309     const MProfileTones& profileTones = aProfile->ProfileTones();
       
  1310     TFileName ringingTone = profileTones.RingingTone1();
       
  1311     FLOG( _L("ringing tone: %S"), &ringingTone );
       
  1312   
       
  1313     const MProfileExtraSettings& extra = aProfile->ProfileExtraSettings();
       
  1314     const MProfile3DToneSettings& threeD = extra.Profile3DToneSettings();
       
  1315     
       
  1316     num = threeD.Effect();
       
  1317     C3DAudioXMLParser::GetPatternString(buf, num);
       
  1318     FLOG( _L("pattern: %S (%d)"), &buf, num );
       
  1319     
       
  1320     num = threeD.Echo();
       
  1321     C3DAudioXMLParser::GetEchoString(buf, num);
       
  1322     FLOG( _L("echo: %S (%d)"), &buf, num );
       
  1323 
       
  1324     
       
  1325     FLOG( _L("------ end profile data ------") );
       
  1326     }
       
  1327 
       
  1328 
       
  1329 // -----------------------------------------------------------------------------
       
  1330 // CRingingTone3DPlugin::FlogPlayer()
       
  1331 //
       
  1332 // -----------------------------------------------------------------------------
       
  1333 //    
       
  1334 void CRingingTone3DPlugin::FlogPlayer(TInt aPlayer)
       
  1335     {
       
  1336     TBuf<128> buf;
       
  1337     
       
  1338   	switch ( aPlayer )
       
  1339 		{
       
  1340 		case EMdaAudioPlayerUtility:
       
  1341 			buf = _L("EMdaAudioPlayerUtility");
       
  1342 			break;
       
  1343 		case EMdaAudioToneUtility:
       
  1344 			buf = _L("EMdaAudioToneUtility");
       
  1345 			break;
       
  1346 		case EDrmPlayerUtility:
       
  1347 			buf = _L("EDrmPlayerUtility");
       
  1348 			break;
       
  1349 		case EVideoPlayerUtility:
       
  1350 			buf = _L("EVideoPlayerUtility");
       
  1351 			break;
       
  1352 			
       
  1353 		default:
       
  1354 			buf = _L("### unknown player ###");
       
  1355 			break;
       
  1356 		}
       
  1357 
       
  1358     
       
  1359     FLOG( _L("player type: %S"), &buf );
       
  1360     }
       
  1361 
       
  1362 
       
  1363 // -----------------------------------------------------------------------------
       
  1364 // CRingingTone3DPlugin::FlogPositionL()
       
  1365 //
       
  1366 // -----------------------------------------------------------------------------
       
  1367 //    
       
  1368 void CRingingTone3DPlugin::FlogPositionL(T3DPosition& aPosition, TInt aIndex)
       
  1369     {
       
  1370     TBuf<128> buf;
       
  1371     TInt x = aPosition.iX;
       
  1372     TInt y = aPosition.iY;
       
  1373     TInt z = aPosition.iZ;
       
  1374     
       
  1375     buf.Format(_L("%d:  position x=%d y=%d z=%d"), aIndex, x,y,z);
       
  1376     FLOG(buf);
       
  1377     }
       
  1378 
       
  1379 
       
  1380 // -----------------------------------------------------------------------------
       
  1381 // CRingingTone3DPlugin::FlogVelocityL()
       
  1382 //
       
  1383 // -----------------------------------------------------------------------------
       
  1384 //    
       
  1385 void CRingingTone3DPlugin::FlogVelocityL(T3DVelocity& aVelocity, TInt aIndex)
       
  1386     {
       
  1387     TBuf<128> buf;
       
  1388     
       
  1389     TInt x = aVelocity.iXVector;
       
  1390     TInt y = aVelocity.iYVector;
       
  1391     TInt z = aVelocity.iZVector;
       
  1392     
       
  1393     buf.Format(_L("%d:  velocity x=%d y=%d z=%d"), aIndex, x,y,z);
       
  1394     FLOG(buf);
       
  1395     }
       
  1396 
       
  1397 // -----------------------------------------------------------------------------
       
  1398 // CRingingTone3DPlugin::FlogTimeL()
       
  1399 //
       
  1400 // -----------------------------------------------------------------------------
       
  1401 //    
       
  1402 void CRingingTone3DPlugin::FlogTimeL(TInt aTime, TInt aIndex)
       
  1403     {
       
  1404     TBuf<128> buf;
       
  1405   
       
  1406     buf.Format(_L("%d:  time = %d"), aIndex, aTime);
       
  1407     FLOG(buf);
       
  1408     }
       
  1409 
       
  1410 #endif   // _DEBUG
       
  1411 
       
  1412 
       
  1413 
       
  1414 
       
  1415 
       
  1416 
       
  1417 //  End of File