mpviewplugins/mpsettingsviewplugin/src/mpmpxasframeworkwrapper_p.cpp
changeset 20 82baf59ce8dd
equal deleted inserted replaced
19:4e84c994a771 20:82baf59ce8dd
       
     1 /*
       
     2 * Copyright (c) 2009 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: Framework wraper for Audio Settings - Private.
       
    15 *
       
    16 */
       
    17 
       
    18 #include <mpxplaybackutility.h>
       
    19 
       
    20 #include "mpmpxasframeworkwrapper_p.h"
       
    21 #include "mpxaudioeffectengine.h"
       
    22 #include "mpcommondefs.h"
       
    23 #include "mptrace.h"
       
    24 
       
    25 
       
    26 /*!
       
    27     \class MpMpxAsFrameworkWrapperPrivate
       
    28     \brief Wrapper for mpx framework utilities - private implementation.
       
    29 
       
    30     This is a private implementation of the mpx framework wrapper utilties interface.
       
    31 */
       
    32 
       
    33 /*!
       
    34  \internal
       
    35  */
       
    36 MpMpxAsFrameworkWrapperPrivate::MpMpxAsFrameworkWrapperPrivate()
       
    37     :iPlaybackUtility( 0 ),
       
    38      iAudioEffectProperties( new CMPXAudioEffectProperties() )
       
    39 {
       
    40     
       
    41 }
       
    42 
       
    43 /*!
       
    44  \internal
       
    45  */
       
    46 MpMpxAsFrameworkWrapperPrivate::~MpMpxAsFrameworkWrapperPrivate()
       
    47 {
       
    48     if( iPlaybackUtility )
       
    49         {
       
    50         iPlaybackUtility->Close();
       
    51         }
       
    52     delete iAudioEffectProperties;
       
    53 }
       
    54 
       
    55 /*!
       
    56  \internal
       
    57  */
       
    58 
       
    59 void MpMpxAsFrameworkWrapperPrivate::init()
       
    60 {
       
    61     TRAPD( err, doInitL() );
       
    62     if ( err != KErrNone ) 
       
    63         {
       
    64         TX_LOG_ARGS( "Error: " << err << "; should never get here." );
       
    65         }
       
    66 }
       
    67 
       
    68 /*!
       
    69  \internal
       
    70  */
       
    71 void MpMpxAsFrameworkWrapperPrivate::setBalance( int balance )
       
    72 {
       
    73     TRAPD( err, doSetBalanceL( balance ) );
       
    74     if ( err != KErrNone ) 
       
    75         {
       
    76         TX_LOG_ARGS( "Error: " << err << "; should never get here." );
       
    77         }
       
    78 }
       
    79 
       
    80 /*!
       
    81  \internal
       
    82  */
       
    83 void MpMpxAsFrameworkWrapperPrivate::setLoudness( bool mode )
       
    84 {
       
    85     TRAPD( err, doSetLoudnessL( mode ) );
       
    86     if ( err != KErrNone ) 
       
    87         {
       
    88         TX_LOG_ARGS( "Error: " << err << "; should never get here." );
       
    89         }
       
    90 }
       
    91 
       
    92 /*!
       
    93  \internal
       
    94  */
       
    95 int MpMpxAsFrameworkWrapperPrivate::balance()
       
    96 {
       
    97     int ret = 0;
       
    98     TRAPD( err, ret = balanceL() );
       
    99     if ( err != KErrNone ) 
       
   100         {
       
   101         TX_LOG_ARGS( "Error: " << err << "; should never get here." );
       
   102         return 0;
       
   103         }   
       
   104     return ret;
       
   105 }
       
   106 
       
   107 /*!
       
   108  \internal
       
   109  */
       
   110 bool MpMpxAsFrameworkWrapperPrivate::loudness()
       
   111 {
       
   112     bool ret = true;
       
   113     TRAPD( err, ret = loudnessL() );
       
   114     if ( err != KErrNone ) 
       
   115         {
       
   116         TX_LOG_ARGS( "Error: " << err << "; should never get here." );
       
   117         return false;
       
   118         }   
       
   119     return ret;
       
   120 }
       
   121 
       
   122 /*!
       
   123  \internal
       
   124  */
       
   125 void MpMpxAsFrameworkWrapperPrivate::doInitL()
       
   126 {
       
   127     TRAPD( err, iAudioEffectProperties->LoadFromFileL() );
       
   128     if( KErrNone != err )
       
   129         {
       
   130         iAudioEffectProperties->Reset();
       
   131         User::Leave( err );
       
   132         }
       
   133 }
       
   134 
       
   135 /*!
       
   136  \internal
       
   137  */
       
   138 void MpMpxAsFrameworkWrapperPrivate::doSetBalanceL( int balance )
       
   139 {
       
   140     iAudioEffectProperties->SetBalance( balance );
       
   141     iAudioEffectProperties->SaveToFileL();
       
   142     if ( !iPlaybackUtility ) 
       
   143         {
       
   144         iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid( MpCommon::KMusicPlayerUid ) ) ;
       
   145         }
       
   146    iPlaybackUtility ->SetL( EPbPropertyBalance, balance );
       
   147    
       
   148 }
       
   149 
       
   150 /*!
       
   151  \internal
       
   152  */
       
   153 void MpMpxAsFrameworkWrapperPrivate::doSetLoudnessL( bool mode )
       
   154 {
       
   155     if( loudnessL() != mode )  //do not set same value twice
       
   156         {
       
   157         iAudioEffectProperties->SetLoudness( mode );
       
   158         iAudioEffectProperties->SaveToFileL();
       
   159         if ( !iPlaybackUtility ) 
       
   160             {
       
   161             iPlaybackUtility = MMPXPlaybackUtility::UtilityL( TUid::Uid( MpCommon::KMusicPlayerUid ) ) ;
       
   162             }
       
   163         iPlaybackUtility->CommandL( EPbApplyEffect, KAudioEffectsID );
       
   164         }
       
   165 }
       
   166 
       
   167 /*!
       
   168  \internal
       
   169  */
       
   170 int MpMpxAsFrameworkWrapperPrivate::balanceL()
       
   171 {
       
   172     return iAudioEffectProperties->Balance();
       
   173 }
       
   174 
       
   175 /*!
       
   176  \internal
       
   177  */
       
   178 bool MpMpxAsFrameworkWrapperPrivate::loudnessL()
       
   179 {
       
   180     return iAudioEffectProperties->Loudness();
       
   181 }
       
   182 
       
   183 
       
   184 
       
   185