startupservices/startupanimation/sanimmmfplugin/src/sanimmmfplugin.cpp
changeset 0 2e3d3ce01487
equal deleted inserted replaced
-1:000000000000 0:2e3d3ce01487
       
     1 /*
       
     2 * Copyright (c) 2007 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 CSAnimMmfPlugin class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include <AudioPreference.h>
       
    20 
       
    21 #include "sanimmmfplugin.h"
       
    22 #include "assert.h"
       
    23 #include "trace.h"
       
    24 
       
    25 // ======== MEMBER FUNCTIONS ========
       
    26 
       
    27 // ---------------------------------------------------------------------------
       
    28 // CSAnimMmfPlugin::NewL
       
    29 //
       
    30 // ---------------------------------------------------------------------------
       
    31 //
       
    32 CSAnimMmfPlugin* CSAnimMmfPlugin::NewL()
       
    33     {
       
    34     FUNC_LOG;
       
    35 
       
    36     CSAnimMmfPlugin* self = new( ELeave ) CSAnimMmfPlugin();
       
    37     return self;
       
    38     }
       
    39 
       
    40 
       
    41 // ---------------------------------------------------------------------------
       
    42 // CSAnimMmfPlugin::~CSAnimMmfPlugin
       
    43 //
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 CSAnimMmfPlugin::~CSAnimMmfPlugin()
       
    47     {
       
    48     FUNC_LOG;
       
    49 
       
    50     if ( iAudioPlayer )
       
    51         {
       
    52         iAudioPlayer->Close();
       
    53         }
       
    54     delete iAudioPlayer;
       
    55     }
       
    56 
       
    57 
       
    58 // ---------------------------------------------------------------------------
       
    59 // CSAnimMmfPlugin::Load
       
    60 //
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 void CSAnimMmfPlugin::Load(
       
    64     RFs& /*aFs*/,
       
    65     const TDesC& aFileName,
       
    66     TRequestStatus& aStatus )
       
    67     {
       
    68     FUNC_LOG;
       
    69     INFO_1( "File name: %S", &aFileName );
       
    70 
       
    71     SetClientRequest( aStatus );
       
    72 
       
    73     if ( iAudioPlayer )
       
    74         {
       
    75         iAudioPlayer->Close();
       
    76         delete iAudioPlayer;
       
    77         iAudioPlayer = NULL;
       
    78         }
       
    79 
       
    80     TRAPD( errorCode, iAudioPlayer = CMdaAudioPlayerUtility::NewFilePlayerL(
       
    81         aFileName,
       
    82         *this,
       
    83         KAudioPriorityPhonePower,
       
    84         TMdaPriorityPreference( KAudioPrefDefaultTone ) ) );
       
    85     ERROR( errorCode, "Failed to load tone file" );
       
    86     if ( errorCode != KErrNone )
       
    87         {
       
    88         CompleteClientRequest( errorCode );
       
    89         }
       
    90     }
       
    91 
       
    92 
       
    93 // ---------------------------------------------------------------------------
       
    94 // CSAnimMmfPlugin::Start
       
    95 //
       
    96 // ---------------------------------------------------------------------------
       
    97 //
       
    98 void CSAnimMmfPlugin::Start( TRequestStatus& aStatus )
       
    99     {
       
   100     FUNC_LOG;
       
   101     ASSERT_TRACE( iAudioPlayer, SAnimPanic::ENotInitialized );
       
   102 
       
   103     SetClientRequest( aStatus );
       
   104 
       
   105     INFO_2( "Volume: %d, volume ramp: %Ld", iVolume, iVolumeRamp.Int64() );
       
   106 
       
   107     iAudioPlayer->SetVolume( iVolume );
       
   108     iAudioPlayer->SetVolumeRamp( iVolumeRamp );
       
   109     iAudioPlayer->Play();
       
   110     }
       
   111 
       
   112 
       
   113 // ---------------------------------------------------------------------------
       
   114 // CSAnimMmfPlugin::Cancel
       
   115 //
       
   116 // ---------------------------------------------------------------------------
       
   117 //
       
   118 void CSAnimMmfPlugin::Cancel()
       
   119     {
       
   120     FUNC_LOG;
       
   121 
       
   122     CompleteClientRequest( KErrCancel );
       
   123     if ( iAudioPlayer )
       
   124         {
       
   125         iAudioPlayer->Close();
       
   126         }
       
   127     }
       
   128 
       
   129 
       
   130 // ---------------------------------------------------------------------------
       
   131 // CSAnimMmfPlugin::MapcInitComplete
       
   132 //
       
   133 // ---------------------------------------------------------------------------
       
   134 //
       
   135 void CSAnimMmfPlugin::MapcInitComplete(
       
   136     TInt aError,
       
   137 	const TTimeIntervalMicroSeconds& /*aDuration*/ )
       
   138 	{
       
   139     FUNC_LOG;
       
   140     ERROR( aError, "Audio init failed" );
       
   141 
       
   142     CompleteClientRequest( aError );
       
   143 	}
       
   144 
       
   145 
       
   146 // ---------------------------------------------------------------------------
       
   147 // CSAnimMmfPlugin::MapcPlayComplete
       
   148 //
       
   149 // ---------------------------------------------------------------------------
       
   150 //
       
   151 void CSAnimMmfPlugin::MapcPlayComplete( TInt aError )
       
   152     {
       
   153     FUNC_LOG;
       
   154     ERROR( aError, "Audio play failed" );
       
   155 
       
   156     CompleteClientRequest( aError );
       
   157     }
       
   158 
       
   159 
       
   160 // ---------------------------------------------------------------------------
       
   161 // CSAnimMmfPlugin::CSAnimMmfPlugin
       
   162 //
       
   163 // ---------------------------------------------------------------------------
       
   164 //
       
   165 CSAnimMmfPlugin::CSAnimMmfPlugin() : iAudioPlayer( NULL )
       
   166     {
       
   167     FUNC_LOG;
       
   168     }