mpxplugins/viewplugins/views/equalizerview/inc/mpxequalizerhelper.h
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     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:  Helper class for managing equalizer utility instances.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef C_MPXEQUALIZERHELPER_H
       
    21 #define C_MPXEQUALIZERHELPER_H
       
    22 
       
    23 
       
    24 //  INCLUDES
       
    25 #include <EqualizerPresetsDialog.h>
       
    26 #include <mdaaudiosampleplayer.h>
       
    27 #include <mpxplaybackobserver.h>
       
    28 
       
    29 #include "mpxequalizerview.h"
       
    30 
       
    31 
       
    32 // FORWARD DECLARATIONS
       
    33 class MMPXPlaybackUtility;
       
    34 class CAudioEqualizerUtility;
       
    35 class CEqualizerPresetsDialog;
       
    36 
       
    37 
       
    38 // CLASS DECLARATION
       
    39 
       
    40 /**
       
    41  *  Helper class for managing equalizer utility instances.
       
    42  *
       
    43  *  @lib mpxplaybackview.lib
       
    44  *  @since S60 v3.0
       
    45  */
       
    46 NONSHARABLE_CLASS( CMPXEqualizerHelper ) : public CMPXEqualizerView,
       
    47                                            public MMPXPlaybackObserver,
       
    48                                            public MEqualizerPresetActivationObserver,
       
    49                                            public MMdaAudioPlayerCallback
       
    50     {
       
    51 public:
       
    52 
       
    53     /**
       
    54      * Two-phased constructor.
       
    55      *
       
    56      * @since 3.0
       
    57      * @return Pointer to newly created object.
       
    58      */
       
    59     static CMPXEqualizerHelper* NewL();
       
    60 
       
    61     /**
       
    62      * Destructor.
       
    63      */
       
    64     virtual ~CMPXEqualizerHelper();
       
    65 
       
    66 private:
       
    67 
       
    68     /**
       
    69      * C++ default constructor.
       
    70      */
       
    71     CMPXEqualizerHelper();
       
    72     
       
    73     /**
       
    74      * By default Symbian 2nd phase constructor is private.
       
    75      */
       
    76     void ConstructL();
       
    77 
       
    78     /**
       
    79      * Initialize audio equalizer utility for current active playing track.
       
    80      */
       
    81     void InitializeEqualizerUtilityL();
       
    82 
       
    83     /**
       
    84      * Release audio equalizer utility.
       
    85      */
       
    86     void ReleaseEqualizerUtility();
       
    87 
       
    88     /**
       
    89      * Get current preset ID.
       
    90      *
       
    91      * @param aPresetId On return, Current preset ID.
       
    92      * @return Index to the preset array if found.
       
    93      *         KErrNotFound if not found.
       
    94      */
       
    95     TInt GetPresetId( TInt& aPresetId );
       
    96 
       
    97     /**
       
    98      * Initialize secondary audio equalizer utility
       
    99      * for situations when the engine cannot provide one.
       
   100      */
       
   101     void InitializeBackupEqualizerUtilityL();
       
   102 
       
   103     /**
       
   104      * Create secondary audio equalizer utility
       
   105      * based on latest preset settings.
       
   106      */
       
   107     void CreateBackupEqualizerUtility();
       
   108 
       
   109     /**
       
   110      * Setup active equalizer utility for equalizer dialog.
       
   111      */
       
   112     void SetupActiveEqualizerUtility();
       
   113 
       
   114     /**
       
   115      * Launch equalizer dialog.
       
   116      */
       
   117     void DoLaunchEqualizerDialogL();
       
   118 
       
   119     /**
       
   120      *  Handle playback message
       
   121      *
       
   122      *  @param aMessage playback message
       
   123      */
       
   124     void DoHandlePlaybackMessageL( 
       
   125         const CMPXMessage& aMessage );
       
   126 
       
   127     /**
       
   128      *  Handle playback state changed.
       
   129      *
       
   130      *  @param aState New Playback state
       
   131      */
       
   132     void DoHandleStateChangedL(
       
   133         TMPXPlaybackState aState );
       
   134 
       
   135 // from base class CMPXEqualizerView
       
   136 
       
   137     /**
       
   138      * From CMPXEqualizerView
       
   139      * Launch equalizer dialog.
       
   140      *
       
   141      * @since 3.0
       
   142      */
       
   143     void LaunchEqualizerL();
       
   144 
       
   145 // from base class MMPXPlaybackObserver
       
   146 
       
   147     /**
       
   148      * From MMPXPlaybackObserver
       
   149      * Handle playback message
       
   150      * 
       
   151      * @param aMessage playback message
       
   152      * @param aErr system error code.
       
   153      */
       
   154     void HandlePlaybackMessage( CMPXMessage* aMessage, TInt aError );
       
   155     
       
   156 // from base class MEqualizerPresetActivationObserver
       
   157 
       
   158     /**
       
   159      * From MEqualizerPresetActivationObserver
       
   160      * Handle preset id activation from Equalizer dialog.
       
   161      * 
       
   162      * @param aActivatedPreset Current activated preset id.
       
   163      */
       
   164     void HandlePresetActivation( TInt aActivatedPreset );
       
   165 
       
   166 // from base class MMdaAudioPlayerCallback
       
   167 
       
   168     /**
       
   169      * From MMdaAudioPlayerCallback.
       
   170      * Callback when an attempt to open and initialise an audio sample 
       
   171      * has completed.
       
   172      *
       
   173      * @param aError The status of the audio sample after initialisation.
       
   174      * @param aDuration The duration of the audio sample.
       
   175      */
       
   176     void MapcInitComplete(
       
   177         TInt aError,
       
   178         const TTimeIntervalMicroSeconds& aDuration );
       
   179 
       
   180     /**
       
   181      * From MMdaAudioPlayerCallback.
       
   182      * Callback when an attempt to playback an audio sample has completed.
       
   183      *
       
   184      * @param aError The status of playback.
       
   185      */
       
   186     void MapcPlayComplete( TInt aError );
       
   187 
       
   188 private:    // Data
       
   189 
       
   190     // Pointer to the equalizer utility we use. 
       
   191     // This is either the equalizer utility provided by Music
       
   192     // Player Engine or iBackupEqualizerUtility.
       
   193     CAudioEqualizerUtility* iEqualizerUtility;          // not owned
       
   194 
       
   195     // Play utility used to open the 'null sound' file and
       
   196     // create iBackupEqualizerUtility
       
   197     CMdaAudioPlayerUtility* iPlayUtility;               // owned
       
   198 
       
   199     // Equalizer utility for the active playback utility
       
   200     CAudioEqualizerUtility* iAudioEqualizerUtility;     // owned
       
   201 
       
   202     // Backup equalizer utility instance used when the equalizer custom
       
   203     // interface cannot be created by using the active play utility
       
   204     CAudioEqualizerUtility* iBackupEqualizerUtility;   // owned
       
   205 
       
   206     // Current playback utility
       
   207     MMPXPlaybackUtility* iPlaybackUtility;  // not own, but need to close
       
   208 
       
   209     CEqualizerPresetsDialog* iEqDialog;     // not own
       
   210 
       
   211     // Should be launch equalizer dialog on open complete callback
       
   212     TBool iLaunchEqualizerOnOpenComplete;
       
   213 
       
   214     // iPlayUtility->OpenL() has been called but not yet completed
       
   215     TBool iOpenInProgress;
       
   216     
       
   217     // Used to syncronize backup equalizer creation and dialog launching
       
   218     CActiveSchedulerWait* iWait;
       
   219     };
       
   220 
       
   221 #endif  // C_MPXEQUALIZERHELPER_H
       
   222 
       
   223 // End of File