mpserviceplugins/inc/mpxaudioeffectproperties.inl
changeset 19 4e84c994a771
equal deleted inserted replaced
5:2a40e88564c8 19:4e84c994a771
       
     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:  Inline implementation of audio effect properties
       
    15 *
       
    16 */
       
    17 
       
    18 #include  <s32file.h>
       
    19 #include  <s32std.h>
       
    20 #include <f32file.h>
       
    21 #include <mpxlog.h>
       
    22 
       
    23 _LIT( KMPXAudioEffectFileName, "c:\\system\\data\\mpxaudioeffect.dat" );
       
    24 
       
    25 // -----------------------------------------------------------------------------
       
    26 // Destructor
       
    27 // -----------------------------------------------------------------------------
       
    28 //
       
    29 inline CMPXAudioEffectProperties::~CMPXAudioEffectProperties()
       
    30     {
       
    31     //iDesValues.DeleteAll();
       
    32     }
       
    33 
       
    34 
       
    35 // -----------------------------------------------------------------------------
       
    36 // Return balance
       
    37 // -----------------------------------------------------------------------------
       
    38 //
       
    39 inline TInt CMPXAudioEffectProperties::Balance() const
       
    40     {
       
    41     return Value(EIntBalance);
       
    42     }
       
    43 
       
    44 // -----------------------------------------------------------------------------
       
    45 // Set balance
       
    46 // -----------------------------------------------------------------------------
       
    47 //
       
    48 inline void CMPXAudioEffectProperties::SetBalance(TInt aBalance)
       
    49     {
       
    50     SetValue(EIntBalance, aBalance);
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // Reverb value
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 inline TInt CMPXAudioEffectProperties::Reverb() const
       
    58     {
       
    59     return Value(EIntReverb);
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // Set reverb
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 inline void CMPXAudioEffectProperties::SetReverb(TInt aReverb)
       
    67     {
       
    68     SetValue(EIntReverb, aReverb);
       
    69     }
       
    70 
       
    71 // -----------------------------------------------------------------------------
       
    72 // Stereo value
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 inline TBool CMPXAudioEffectProperties::Stereo() const
       
    76     {
       
    77     return Value(EIntStereo);
       
    78     }
       
    79 
       
    80 // -----------------------------------------------------------------------------
       
    81 // Set bass boost
       
    82 // -----------------------------------------------------------------------------
       
    83 //
       
    84 inline void CMPXAudioEffectProperties::SetStereo(TBool aStereo)
       
    85     {
       
    86     SetValue(EIntStereo, aStereo);
       
    87     }
       
    88 
       
    89 // -----------------------------------------------------------------------------
       
    90 // Bass boost value
       
    91 // -----------------------------------------------------------------------------
       
    92 //
       
    93 inline TBool CMPXAudioEffectProperties::BassBoost() const
       
    94     {
       
    95     return Value(EIntBassBoost);
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // Set bass boost
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 inline void CMPXAudioEffectProperties::SetBassBoost(TBool aBassBoost)
       
   103     {
       
   104     SetValue(EIntBassBoost, aBassBoost);
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // Bass boost value
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 inline TBool CMPXAudioEffectProperties::Loudness() const
       
   112     {
       
   113     return Value(EIntLoudness);
       
   114     }
       
   115 
       
   116 // -----------------------------------------------------------------------------
       
   117 // Set loudness
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 inline void CMPXAudioEffectProperties::SetLoudness(TBool aLoudness)
       
   121     {
       
   122     SetValue(EIntLoudness, aLoudness);
       
   123     }
       
   124     
       
   125 // -----------------------------------------------------------------------------
       
   126 // Externalize properties
       
   127 // -----------------------------------------------------------------------------
       
   128 //
       
   129 inline void CMPXAudioEffectProperties::ExternalizeL(RWriteStream& aStream) const
       
   130     {
       
   131     MPX_DEBUG1("CMPXAudioEffectProperties::ExternalizeL <---");
       
   132     for (TInt i=0;i<EIntNumItems;++i)
       
   133         {
       
   134         aStream.WriteInt32L(iIntValues[i]);
       
   135         MPX_DEBUG2("CMPXAudioEffectProperties::ExternalizeL  -- %i", iIntValues[i]);
       
   136         }
       
   137 
       
   138     //for (TInt ii=0;ii<EDesNumItems;++ii)
       
   139     //    {
       
   140     //    aStream.WriteInt32L(Value(static_cast<TDesProperty>(ii)).Length());
       
   141     //    aStream << Value(static_cast<TDesProperty>(ii));
       
   142     //    }
       
   143     MPX_DEBUG1("CMPXAudioEffectProperties::ExternalizeL --->");
       
   144     }
       
   145 
       
   146 // -----------------------------------------------------------------------------
       
   147 // Internalize properties
       
   148 // -----------------------------------------------------------------------------
       
   149 //
       
   150 inline void CMPXAudioEffectProperties::InternalizeL(RReadStream& aStream)
       
   151     {
       
   152     MPX_DEBUG1("CMPXAudioEffectProperties::InternalizeL <---");
       
   153     for (TInt i=0;i<EIntNumItems;++i)
       
   154         {
       
   155         iIntValues[i]=aStream.ReadInt32L();
       
   156         MPX_DEBUG2("CMPXAudioEffectProperties::InternalizeL  -- %i", iIntValues[i]);
       
   157         }
       
   158     //for (TInt ii=0;ii<EDesNumItems;++ii)
       
   159     //    {
       
   160     //    delete iDesValues[ii];
       
   161     //    iDesValues[ii] = NULL;
       
   162     //    iDesValues[ii] = HBufC::NewL(aStream,aStream.ReadInt32L());
       
   163     //    }
       
   164     MPX_DEBUG1("CMPXAudioEffectProperties::InternalizeL --->");
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // Get value of a descriptor property
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 inline const TDesC& CMPXAudioEffectProperties::Value(TDesProperty /*aProperty*/) const
       
   172     {
       
   173     //return iDesValues[aProperty] ? 
       
   174     //       static_cast<const TDesC&>(*iDesValues[aProperty]) : KNullDesC;
       
   175     return KNullDesC;
       
   176     }
       
   177 
       
   178 // -----------------------------------------------------------------------------
       
   179 // Get value of an integer property
       
   180 // -----------------------------------------------------------------------------
       
   181 //
       
   182 inline TInt CMPXAudioEffectProperties::Value(TIntProperty aProperty) const
       
   183     {
       
   184     return iIntValues[aProperty];
       
   185     }
       
   186     
       
   187 // -----------------------------------------------------------------------------
       
   188 // Set value of a descriptor property
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 inline void CMPXAudioEffectProperties::SetValue(TDesProperty /*aProperty*/,
       
   192                                           const TDesC& /*aValue*/)
       
   193     {
       
   194     //delete iDesValues[aProperty];
       
   195     //iDesValues[aProperty]=aValue.Alloc();
       
   196     }
       
   197     
       
   198 // -----------------------------------------------------------------------------
       
   199 // Set value of an integer property
       
   200 // -----------------------------------------------------------------------------
       
   201 //
       
   202 inline void CMPXAudioEffectProperties::SetValue(TIntProperty aProperty,TInt aValue)
       
   203     {
       
   204     iIntValues[aProperty]=aValue;
       
   205     }
       
   206 
       
   207 // -----------------------------------------------------------------------------
       
   208 // Reset all values to 0 or NULL
       
   209 // -----------------------------------------------------------------------------
       
   210 //
       
   211 inline void CMPXAudioEffectProperties::Reset()
       
   212     {
       
   213     MPX_DEBUG1("CMPXAudioEffectProperties::Reset");
       
   214     for (TInt i=0;i<EIntNumItems;++i)
       
   215         {
       
   216         iIntValues[i] =0;
       
   217         }
       
   218     //for (TInt ii=0;ii<EDesNumItems;++ii)
       
   219     //    {
       
   220     //    delete iDesValues[ii];
       
   221     //    iDesValues[ii]=NULL;
       
   222     //    }
       
   223     }
       
   224    
       
   225 // -----------------------------------------------------------------------------
       
   226 // Save to file
       
   227 // -----------------------------------------------------------------------------
       
   228 // 
       
   229 inline void CMPXAudioEffectProperties::SaveToFileL() const
       
   230     {
       
   231     MPX_DEBUG1("CMPXAudioEffectProperties::SaveToFileL <---");
       
   232     RFs fs;
       
   233     User::LeaveIfError( fs.Connect() );
       
   234     CleanupClosePushL(fs);
       
   235     fs.MkDirAll( KMPXAudioEffectFileName  );
       
   236     TParse parsedName;
       
   237     fs.Parse( KMPXAudioEffectFileName, parsedName );
       
   238     CFileStore* store = CDirectFileStore::ReplaceLC(fs, 
       
   239                                                     parsedName.FullName(), 
       
   240                                                     EFileWrite);
       
   241     store->SetTypeL( KDirectFileStoreLayoutUid );
       
   242     RStoreWriteStream stream;
       
   243     TStreamId id = stream.CreateLC( *store );
       
   244     this->ExternalizeL(stream);
       
   245     stream.CommitL();
       
   246     CleanupStack::PopAndDestroy();
       
   247     store->SetRootL( id );
       
   248     store->CommitL();
       
   249     CleanupStack::PopAndDestroy();
       
   250     CleanupStack::PopAndDestroy(&fs);
       
   251     MPX_DEBUG1("CMPXAudioEffectProperties::SaveToFileL --->");
       
   252     }
       
   253 
       
   254 // -----------------------------------------------------------------------------
       
   255 // Load from file
       
   256 // -----------------------------------------------------------------------------
       
   257 //  
       
   258 inline void CMPXAudioEffectProperties::LoadFromFileL()
       
   259     {
       
   260     MPX_DEBUG1("CMPXAudioEffectProperties::LoadFromFileL <---");
       
   261     RFs fs;
       
   262     User::LeaveIfError( fs.Connect() );
       
   263     CleanupClosePushL(fs);
       
   264     fs.MkDirAll( KMPXAudioEffectFileName );
       
   265     TParse parsedName;
       
   266 
       
   267     fs.Parse( KMPXAudioEffectFileName, parsedName );
       
   268     CFileStore* store = CDirectFileStore::OpenLC(fs, 
       
   269                                                  parsedName.FullName(), 
       
   270                                                  EFileRead );
       
   271     RStoreReadStream stream;
       
   272     stream.OpenLC( *store, store->Root() );
       
   273     this->InternalizeL(stream);
       
   274     CleanupStack::PopAndDestroy(); //store
       
   275     CleanupStack::PopAndDestroy(); //stream
       
   276     CleanupStack::PopAndDestroy(&fs);
       
   277     MPX_DEBUG1("CMPXAudioEffectProperties::LoadFromFileL --->");
       
   278     }
       
   279