os/mm/devsound/a3fdevsound/src/mmfdevsoundproxy/mmfdevsoundcallbackhandler.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 * Copyright (c) 2006-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:
    15 *
    16 */
    17 
    18 
    19 
    20 #ifndef MMFDEVSOUNDCALLBACKHANDLER_H
    21 #define MMFDEVSOUNDCALLBACKHANDLER_H
    22 
    23 //  INCLUDES
    24 #include <e32base.h>
    25 #include <e32msgqueue.h>
    26 #include "mmfaudioclientserver.h"
    27 
    28 // CLASS DECLARATION
    29 class RMMFDevSoundProxy;
    30 class MDevSoundObserver;
    31 
    32 /**
    33 *  Utility class to handle Play Error callback from DevSound server.
    34 *
    35 *  @lib MMFDevSound.dll
    36 *  @since 
    37 */
    38 class CMsgQueueHandler : public CActive
    39 	{
    40 public:  // Constructors and destructor
    41 
    42 	/**
    43 	* Constructs, and returns a pointer to, a new
    44 	* CMMFPlayErrorHandler object.
    45 	* Leaves on failure..
    46 	* @param RMMFDevSoundProxy* aDevSoundProxy A handle to DevSoundProxy to
    47 	*        subcribe for event notification from server.
    48 	* @param MDevSoundObserver& aDevSoundObserver A reference to
    49 	*        MDevSoundObserver to which the events will be forwarded to.
    50 	* @param aDevSoundCIObserver Observer which will receive Custom Interface events
    51 	* @return CMMFPlayErrorHandler* A pointer to newly created object.
    52 	*/
    53 	static CMsgQueueHandler* NewL(RMMFDevSoundProxy* aDevSoundProxy,
    54 								MDevSoundObserver& aDevSoundObserver,
    55 								RMsgQueue<TMMFDevSoundQueueItem>* aMsgQueue,
    56 								MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver);
    57 	/**
    58 	* Destructor.
    59 	*/
    60 	~CMsgQueueHandler();
    61 
    62 	/**
    63 	* Subscribes for Play Error event from DevSound server.
    64 	* @since 
    65 	* @return void
    66 	*/
    67 	void ReceiveEvents();
    68 
    69 	/**
    70 	* Called by DevSound server when Play Error event occurs.
    71 	* Leaves on failure.
    72 	* @since 
    73 	* @return void
    74 	*/
    75 	void RunL();
    76 
    77 	/**
    78 	* Called by CActive object framework if RunL leaves.
    79 	* @since 
    80 	* @param TInt aError Reason for leave
    81 	* @return TInt KErrNone if error is handled succesfully, else
    82 	* corresponding error codel
    83 	*/
    84 	TInt RunError(TInt aError);
    85 
    86 	/**
    87 	* Called by CActive object framework when client cancels active object.
    88 	* @since 
    89 	* @return void
    90 	*/
    91 	void DoCancel();
    92 	/**
    93 	* Called as part of Stop() process to recover any buffers etc
    94 	*/
    95 	void Finish();
    96 
    97 private:
    98 	/**
    99 	* C++ default constructor.
   100 	*/
   101 	CMsgQueueHandler(RMMFDevSoundProxy* aDevSoundProxy,
   102 					MDevSoundObserver& aDevSoundObserver,
   103 					RMsgQueue<TMMFDevSoundQueueItem>* aMsgQueue,
   104 					MMMFDevSoundCustomInterfaceObserver& aDevSoundCIObserver);
   105 	/**
   106 	* By default Symbian 2nd phase constructor is private.
   107 	*/
   108 	void ConstructL();
   109 
   110 	/*
   111 	* Handles initialization completion event.
   112 	*/
   113 	void DoInitComplete();
   114 
   115 	/*
   116 	* Handles play completion or cancel event.
   117 	*/
   118 	void DoPlayErrorComplete();
   119 
   120 	/*
   121 	* Handles record completion or cancel event.
   122 	*/
   123 	void DoRecordErrorComplete();
   124 
   125 	/*
   126 	* Handles CMMFDevSound object's data request event to supply
   127 	* CMMFDevSound with the buffer that it needs to play.
   128 	*/
   129 	void DoBTBFCompleteL();
   130 
   131 	/*
   132 	* Handles CMMFDevSound object's data request event to supply
   133 	* CMMFDevSound with the buffer that it needs to record.
   134 	*/
   135 	void DoBTBECompleteL();
   136 
   137 	/*
   138 	* Handles tone play completion event.
   139 	*/
   140 	void DoToneFinishedComplete();
   141 
   142 	/*
   143 	* Sends DevSound server event completion notification to the client.
   144 	*/
   145 	void DoSendEventToClientComplete();
   146 	
   147 	/* Handles CMMFDevSound object's data request event to supply 
   148 	* CMMFDevSound with the last buffer that it needs to record.
   149 	*/
   150 	void DoPausedRecordComplete();
   151 	
   152 	/*
   153 	* Allocates local data buffer and links it with the global chunk.
   154 	* @param aHandle Handle to a global chunk or 0 if chunk already exists.
   155 	*/
   156 	void AssignDataBufferToChunkL(TInt aHandle);
   157 	/*
   158 	* Update existing data buffer with latest buffer info from server
   159 	* but using existing chunk
   160 	*/
   161 	void UpdateDataBufferL();
   162 	
   163 	static TInt AsyncQueueFinishCallback(TAny* aPtr);
   164 	void DoAsyncQueueFinishCallback();
   165 
   166 private:
   167 	
   168 	RMMFDevSoundProxy* iDevSoundProxy;
   169 	MDevSoundObserver& iDevSoundObserver;
   170 	TMMFDevSoundProxyHwBufPckg iSetPckg;
   171 
   172 	TMMFEventPckg iEventPckg;
   173 
   174 	RMsgQueue<TMMFDevSoundQueueItem>* iMsgQueue;
   175 	TMMFDevSoundQueueItem   iCurrentItem;
   176 	RChunk iChunk;
   177 	TPtr8 iChunkDataPtr;
   178 	CMMFPtrBuffer* iDataBuffer;
   179 	CMMFDataBuffer* iEmptyBuffer;
   180 	MMMFDevSoundCustomInterfaceObserver& iDevSoundCIObserver;
   181 	CAsyncCallBack*				iAsyncQueueFinish;
   182 	};
   183 
   184 #endif      // MMFDEVSOUNDCALLBACKHANDLER_H
   185 
   186 // End of File