os/mm/devsoundextensions/audiorouting/Input/AudioInputMessageHandler/src/AudioInputMessageHandler.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     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: Audio input msg handler implementation
    15 *
    16 */
    17 
    18 
    19 
    20 // INCLUDE FILES
    21 #include    "AudioInputMessageHandler.h"
    22 #include    "AudioInputMessageTypes.h"
    23 #include    "AudioInput.h"
    24 
    25 // ================= MEMBER FUNCTIONS =======================
    26 
    27 // C++ default constructor can NOT contain any code, that
    28 // might leave.
    29 //
    30 CAudioInputMessageHandler::CAudioInputMessageHandler(CAudioInput*         aAudioInput,
    31                                                      CMMFObjectContainer& aContainer) :
    32 	CMMFObject(KUidAudioInput),
    33 	iContainer(aContainer)
    34     {
    35     iAudioInput = aAudioInput;
    36     }
    37 
    38 // Two-phased constructor.
    39 EXPORT_C CAudioInputMessageHandler* CAudioInputMessageHandler::NewL(TAny*                aCustomInterface,
    40                                                            CMMFObjectContainer& aContainer)
    41     {
    42     CAudioInput* audioInput = (CAudioInput*)aCustomInterface;
    43     CAudioInputMessageHandler* self = new (ELeave) CAudioInputMessageHandler(audioInput,
    44                                                                              aContainer);
    45     
    46     return self;
    47     }
    48 
    49     
    50 // Destructor
    51 CAudioInputMessageHandler::~CAudioInputMessageHandler()
    52 	{
    53 	delete iAudioInput;
    54 	}
    55 
    56 
    57 // ---------------------------------------------------------
    58 // CAudioInput::AudioInput
    59 // ?implementation_description
    60 // (other items were commented in a header).
    61 // ---------------------------------------------------------
    62 //
    63 EXPORT_C TUid CAudioInputMessageHandler::Uid()
    64 	{
    65 	return KUidAudioInput;
    66 	}
    67 
    68 // ---------------------------------------------------------
    69 // CAudioInput::SetAudioInputL
    70 // ?implementation_description
    71 // (other items were commented in a header).
    72 // ---------------------------------------------------------
    73 //
    74 void CAudioInputMessageHandler::HandleRequest(TMMFMessage& aMessage)
    75 	{
    76 	ASSERT(aMessage.Destination().InterfaceId() == KUidAudioInput);
    77 	TRAPD(error,DoHandleRequestL(aMessage));
    78 	if(error)
    79 		{
    80 		aMessage.Complete(error);
    81 		}
    82 	}
    83 
    84 // ---------------------------------------------------------
    85 // CAudioInput::SetAudioInputL
    86 // ?implementation_description
    87 // (other items were commented in a header).
    88 // ---------------------------------------------------------
    89 //
    90 void CAudioInputMessageHandler::DoHandleRequestL(TMMFMessage& aMessage)
    91 	{
    92 	switch(aMessage.Function())
    93 		{
    94 		case EAifDelete:
    95 			{
    96 			DoDeleteL(aMessage);
    97 			break;
    98 			}
    99 		case EAifSetInputs:
   100 			{
   101 			DoSetInputsL(aMessage);
   102 			break;
   103 			}
   104 		default:
   105 			{
   106 			aMessage.Complete(KErrNotSupported);
   107 			}
   108 		}
   109 	}
   110 
   111 // ---------------------------------------------------------
   112 // CAudioInput::SetAudioInputL
   113 // ?implementation_description
   114 // (other items were commented in a header).
   115 // ---------------------------------------------------------
   116 //
   117 void CAudioInputMessageHandler::DoDeleteL(TMMFMessage& aMessage)
   118 	{
   119 	aMessage.Complete(KErrNone);
   120 	iContainer.RemoveAndDestroyMMFObject(*this);
   121 	}
   122 
   123 // ---------------------------------------------------------
   124 // CAudioInput::SetAudioInputL
   125 // ?implementation_description
   126 // (other items were commented in a header).
   127 // ---------------------------------------------------------
   128 //
   129 void CAudioInputMessageHandler::DoSetInputsL(TMMFMessage& aMessage)
   130 	{
   131 	TPckgBuf<TInt> countPckg;
   132 	aMessage.ReadData1FromClient(countPckg);
   133 	TInt count = countPckg();
   134 	
   135 	CArrayFixFlat<CAudioInput::TAudioInputPreference>* inputArray =
   136 		new(ELeave) CArrayFixFlat<CAudioInput::TAudioInputPreference>(4);
   137 	CleanupStack::PushL(inputArray);
   138 	inputArray->ResizeL(count);
   139 	
   140 	TInt length = count * inputArray->Length();
   141 	TPtr8 inputArrayPtr((TUint8*)&(*inputArray)[0],length, length);
   142 	aMessage.ReadData2FromClient(inputArrayPtr);
   143 
   144 	iAudioInput->SetAudioInputL(inputArray->Array());
   145 	CleanupStack::PopAndDestroy(inputArray);//inputArray
   146 	
   147 	aMessage.Complete(KErrNone);
   148 	}
   149 
   150 
   151 // ========================== OTHER EXPORTED FUNCTIONS =========================
   152 
   153 
   154 
   155 // End of File