audiostubs/devsoundextensions_stubs/mmfdevsoundadaptation_stub/src/MmfHwDeviceStub.h
changeset 0 0ce1b5ce9557
equal deleted inserted replaced
-1:000000000000 0:0ce1b5ce9557
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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: Audio Stubs -
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef MMFHWDEVSTUB_H
       
    21 #define MMFHWDEVSTUB_H
       
    22 
       
    23 //  INCLUDES
       
    24 #include <e32base.h>
       
    25 #include <mmfhwdevice.h>
       
    26 
       
    27 // CLASS DECLARATION
       
    28 
       
    29 /**
       
    30 *  This class provides an stub interface for CMMFHwDevice - intended
       
    31 *  to provide non audio rendering support for MMFDevSoundAdaptation Stub
       
    32 *
       
    33 *  @lib MmfDevSoundAdaptation_Stub.lib
       
    34 *  @since Series 60 3.0
       
    35 */
       
    36 class CMMFHwDeviceStub : public CActive
       
    37     {
       
    38     public:
       
    39 
       
    40         /**
       
    41         * Constructs, and returns a pointer to, a new CMMFHwDeviceStub object.
       
    42         * Leaves on failure..
       
    43         * @since Series 60 3.0
       
    44         * @return CMMFHwDeviceStub* A pointer to newly created object.
       
    45         */
       
    46         static CMMFHwDeviceStub* NewL();
       
    47 
       
    48         /**
       
    49         * Destructor.
       
    50         */
       
    51         ~CMMFHwDeviceStub();
       
    52 
       
    53     public:
       
    54         // Methods from CMMFHwDevice
       
    55 
       
    56         /**
       
    57         * Starts playback/record based on aFuncCmd.
       
    58         * @since Series 60 3.0
       
    59         * @param TDeviceFunc aFuncCmd A function indicating decode or encode
       
    60         * @param TDeviceFlow aFlowCmd Flow command, not used here
       
    61         * @return TInt Error code. KErrNone if success.
       
    62         */
       
    63         TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd);
       
    64 
       
    65         /**
       
    66         * Stops current operation.
       
    67         * @since Series 60 3.0
       
    68         * @return TInt Error code. KErrNone if success.
       
    69         */
       
    70         TInt Stop();
       
    71 
       
    72         /**
       
    73         * Pauses current operation.
       
    74         * @since Series 60 3.0
       
    75         * @return TInt Error code. KErrNone if success.
       
    76         */
       
    77         TInt Pause();
       
    78 
       
    79         /**
       
    80         * Initializes CMMFHwDevice.
       
    81         * @since Series 60 3.0
       
    82         * @param THwDeviceInitParams& aDevInfo A reference to device init
       
    83         *        params.
       
    84         * @return TInt Error code. KErrNone if success.
       
    85         */
       
    86         TInt Init(THwDeviceInitParams& aDevInfo);
       
    87 
       
    88         /**
       
    89         * Returns a pointer to CustomInterface.
       
    90         * @since Series 60 3.0
       
    91         * @param TUid aInterfaceId A uid that uniquely identifies the custom
       
    92         *        interface definition.
       
    93         * @return TAny* NULL if no custom interface found, else object
       
    94         *        implementing custom interface
       
    95         */
       
    96         TAny* CustomInterface(TUid aInterfaceId);
       
    97 
       
    98         /**
       
    99         * Called by client when data is available during playback.
       
   100         * @since Series 60 3.0
       
   101         * @param CMMFBuffer& aFillBufferPtr A pointer to buffer that was sent
       
   102         *        to client during callback FillThisHwBuffer()
       
   103         * @return TInt Error code. KErrNone if success.
       
   104         */
       
   105         TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr);
       
   106 
       
   107         /**
       
   108         * Called by client when data is available during recording.
       
   109         * @since Series 60 3.0
       
   110         * @param CMMFBuffer& aFillBufferPtr A pointer to buffer that was sent
       
   111         *        to client during callback EmptyThisHwBuffer()
       
   112         * @return TInt Error code. KErrNone if success.
       
   113         */
       
   114         TInt ThisHwBufferEmptied(CMMFBuffer& aEmptyBufferPtr);
       
   115 
       
   116         /**
       
   117         * Configures CMMFHwDevice.
       
   118         * @since Series 60 3.0
       
   119         * @param TTaskConfig& aConfig A reference to configuration objec.
       
   120         * @return TInt Error code. KErrNone if success.
       
   121         */
       
   122         TInt SetConfig(TTaskConfig& aConfig);
       
   123 
       
   124         /**
       
   125         * Stops and deletes codec.
       
   126         * @since Series 60 3.0
       
   127         * @return TInt Error code. KErrNone if success.
       
   128         */
       
   129         TInt StopAndDeleteCodec();
       
   130 
       
   131         /**
       
   132         * Deletes codec.
       
   133         * @since Series 60 3.0
       
   134         * @return TInt Error code. KErrNone if success.
       
   135         */
       
   136         TInt DeleteCodec();
       
   137 
       
   138     public:// From CActive
       
   139 
       
   140         /**
       
   141         * Called by CActive object framework when local timer times out.
       
   142         * @since Series 60 3.0
       
   143         * @return void
       
   144         */
       
   145         virtual void RunL();
       
   146 
       
   147         /**
       
   148         * Called by CActive object framework when client cancels active object.
       
   149         * @since Series 60 3.0
       
   150         * @return void
       
   151         */
       
   152         virtual void DoCancel();
       
   153 
       
   154         /**
       
   155         * Called by CActive object framework when RunL leaves.
       
   156         * @since Series 60 3.0
       
   157         * @param TInt aError Error code.
       
   158         * @return KErrNone
       
   159         */
       
   160         virtual TInt Error(TInt aError);
       
   161 
       
   162     private:
       
   163 
       
   164         /**
       
   165         * C++ default constructor.
       
   166         */
       
   167         CMMFHwDeviceStub();
       
   168 
       
   169         /**
       
   170         * By default Symbian 2nd phase constructor is private.
       
   171         */
       
   172         void ConstructL();
       
   173 
       
   174         /**
       
   175         * Initialize play buffer.
       
   176         * Leaves on failure.
       
   177         * @since Series 60 3.0
       
   178         * @return void
       
   179         */
       
   180         void InitializePlayBufferL();
       
   181 
       
   182         /**
       
   183         * Initialize record buffer
       
   184         * Leaves on failure.
       
   185         * @since Series 60 3.0
       
   186         * @return void
       
   187         */
       
   188         void InitializeRecdBufferL();
       
   189 
       
   190         /**
       
   191         * Read data from the input file to the buffer
       
   192         * @since Series 60 3.0
       
   193         * @return void
       
   194         */
       
   195         void SetActiveRecdBufferL();
       
   196 
       
   197         void SetActivePlayBufferL();
       
   198 
       
   199     private:
       
   200         // Pointer reference to HwDevice observer.
       
   201         MMMFHwDeviceObserver*       iObserver;
       
   202 
       
   203         // States this object can be at any time.
       
   204         enum THwDeviceStubState
       
   205             {
       
   206             EHWDeviceIdle,
       
   207             EHWDevicePlay,
       
   208             EHWDeviceRecord
       
   209             };
       
   210         // HwDevice state
       
   211         THwDeviceStubState          iHwDeviceState;
       
   212         // Local timer object
       
   213         RTimer                      iTimer;
       
   214         // Buffers used for playback
       
   215         CMMFDataBuffer              *iPlayBuffer1;
       
   216         CMMFDataBuffer              *iPlayBuffer2;
       
   217         CMMFDataBuffer              *iCurPlayBuffer;
       
   218         // Buffers used for recording
       
   219         CMMFDataBuffer              *iRecdBuffer1;
       
   220         CMMFDataBuffer              *iRecdBuffer2;
       
   221         CMMFDataBuffer              *iCurRecdBuffer;
       
   222         // ETrue if last buffer is received, else EFalse
       
   223         TBool                       iLastBufferReceived;
       
   224         // Count
       
   225         TInt                        iCount;
       
   226         // Index to the position within input file
       
   227         TInt                        iPosition;
       
   228 };
       
   229 
       
   230 #endif      // MMFHWDEVSTUB_H
       
   231 
       
   232 // End of File