os/mm/devsound/devsoundpluginsupport/src/CustomInterfaces/g729decoderconfigci.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <ecom/implementationproxy.h>
sl@0
    17
#include <ecom/implementationproxy.h>
sl@0
    18
#include <ecom/ecom.h>
sl@0
    19
#include <s32mem.h>
sl@0
    20
sl@0
    21
#include "g729decoderconfigci.h"
sl@0
    22
sl@0
    23
sl@0
    24
// MUX //
sl@0
    25
sl@0
    26
TInt CMMFG729DecoderIntfcMux::OpenInterface(TUid /*aInterfaceId*/)
sl@0
    27
	{
sl@0
    28
	// attempt to open the interface link with the
sl@0
    29
	// remote slave device
sl@0
    30
	iRemoteHandle = -1;
sl@0
    31
	TUid slaveId = {KMmfUidCustomInterfaceG729DecoderIntfcDeMux};
sl@0
    32
sl@0
    33
	TInt handle = iUtility->OpenSlave(slaveId, KNullDesC8);
sl@0
    34
	if (handle >= 0)
sl@0
    35
		{
sl@0
    36
		iRemoteHandle = handle;
sl@0
    37
		}
sl@0
    38
sl@0
    39
	return iRemoteHandle;
sl@0
    40
	}
sl@0
    41
sl@0
    42
sl@0
    43
void CMMFG729DecoderIntfcMux::Release()
sl@0
    44
	{
sl@0
    45
	// close the slave device if it exists
sl@0
    46
	if (iRemoteHandle > 0)
sl@0
    47
		{
sl@0
    48
		// we assume the slave is closed correctly
sl@0
    49
		iUtility->CloseSlave(iRemoteHandle);
sl@0
    50
		}
sl@0
    51
sl@0
    52
	TUid key = iKey;
sl@0
    53
	delete this;
sl@0
    54
sl@0
    55
	// tell ECom to destroy us
sl@0
    56
	REComSession::DestroyedImplementation(key);
sl@0
    57
	}
sl@0
    58
sl@0
    59
sl@0
    60
void CMMFG729DecoderIntfcMux::PassDestructorKey(TUid aDestructorKey)
sl@0
    61
	{
sl@0
    62
	// store the destructor key
sl@0
    63
	iKey = aDestructorKey;
sl@0
    64
	}
sl@0
    65
sl@0
    66
sl@0
    67
void CMMFG729DecoderIntfcMux::CompleteConstructL(MMMFDevSoundCustomInterfaceMuxUtility* aCustomUtility)
sl@0
    68
	{
sl@0
    69
	// store a pointer to the utility
sl@0
    70
	iUtility = aCustomUtility;
sl@0
    71
	}
sl@0
    72
sl@0
    73
sl@0
    74
MMMFDevSoundCustomInterfaceMuxPlugin* CMMFG729DecoderIntfcMux::NewL()
sl@0
    75
	{
sl@0
    76
	CMMFG729DecoderIntfcMux* self = new (ELeave) CMMFG729DecoderIntfcMux;
sl@0
    77
	return self;
sl@0
    78
	}
sl@0
    79
sl@0
    80
sl@0
    81
TAny* CMMFG729DecoderIntfcMux::CustomInterface(TUid /*aInterfaceId*/)
sl@0
    82
	{
sl@0
    83
	MG729DecoderIntfc* interface = this;
sl@0
    84
	return interface;
sl@0
    85
	}
sl@0
    86
sl@0
    87
sl@0
    88
CMMFG729DecoderIntfcMux::CMMFG729DecoderIntfcMux() :
sl@0
    89
	iRemoteHandle(-1)
sl@0
    90
	{
sl@0
    91
	}
sl@0
    92
sl@0
    93
sl@0
    94
CMMFG729DecoderIntfcMux::~CMMFG729DecoderIntfcMux()
sl@0
    95
	{
sl@0
    96
	}
sl@0
    97
sl@0
    98
sl@0
    99
// from MG729DecoderIntfc
sl@0
   100
TInt CMMFG729DecoderIntfcMux::BadLsfNextBuffer()
sl@0
   101
	{
sl@0
   102
	TInt result = KErrBadHandle;
sl@0
   103
sl@0
   104
	if (iRemoteHandle > 0)
sl@0
   105
		{
sl@0
   106
		// any return code other than zero is an error
sl@0
   107
		result = iUtility->SendSlaveSyncCommand(iRemoteHandle,
sl@0
   108
												EMMFDevSoundCIG729DecoderIntfcBadLsfNextBuffer,
sl@0
   109
												KNullDesC8);
sl@0
   110
		}
sl@0
   111
sl@0
   112
	return result;
sl@0
   113
	}
sl@0
   114
sl@0
   115
sl@0
   116
sl@0
   117
// DEMUX //	
sl@0
   118
sl@0
   119
TInt CMMFG729DecoderIntfcDeMux::OpenInterface(TUid /*aInterfaceId*/)
sl@0
   120
	{
sl@0
   121
	return KErrNone;
sl@0
   122
	}
sl@0
   123
sl@0
   124
sl@0
   125
void CMMFG729DecoderIntfcDeMux::Release()
sl@0
   126
	{
sl@0
   127
	TUid key = iKey;
sl@0
   128
sl@0
   129
	delete this;
sl@0
   130
sl@0
   131
	// tell ECom to destroy us
sl@0
   132
	REComSession::DestroyedImplementation(key);
sl@0
   133
	}
sl@0
   134
sl@0
   135
sl@0
   136
void CMMFG729DecoderIntfcDeMux::PassDestructorKey(TUid aDestructorKey)
sl@0
   137
	{
sl@0
   138
	// store the destructor key
sl@0
   139
	iKey = aDestructorKey;
sl@0
   140
	}
sl@0
   141
sl@0
   142
sl@0
   143
void CMMFG729DecoderIntfcDeMux::SetInterfaceTarget(MMMFDevSoundCustomInterfaceTarget* aTarget)
sl@0
   144
	{
sl@0
   145
	iTarget = aTarget;
sl@0
   146
	}
sl@0
   147
sl@0
   148
sl@0
   149
void CMMFG729DecoderIntfcDeMux::CompleteConstructL(MMMFDevSoundCustomInterfaceDeMuxUtility* aCustomUtility)
sl@0
   150
	{
sl@0
   151
	// store a pointer to the utility
sl@0
   152
	iUtility = aCustomUtility;
sl@0
   153
	}
sl@0
   154
sl@0
   155
sl@0
   156
void CMMFG729DecoderIntfcDeMux::RefreshL()
sl@0
   157
	{
sl@0
   158
	// refetch the G729 decoder intfc custom interface if we already have a target
sl@0
   159
	if (iTarget)
sl@0
   160
		{
sl@0
   161
		iInterfaceG729DecoderIntfc = static_cast <MG729DecoderIntfc*> (iTarget->CustomInterface(KUidG729DecoderIntfc));
sl@0
   162
sl@0
   163
		if (!iInterfaceG729DecoderIntfc)
sl@0
   164
			{
sl@0
   165
			iInterfaceG729DecoderIntfc = NULL;
sl@0
   166
			User::Leave(KErrNotSupported);
sl@0
   167
			}
sl@0
   168
		}
sl@0
   169
	}
sl@0
   170
sl@0
   171
sl@0
   172
MMMFDevSoundCustomInterfaceDeMuxPlugin* CMMFG729DecoderIntfcDeMux::NewL()
sl@0
   173
	{
sl@0
   174
	CMMFG729DecoderIntfcDeMux* self = new (ELeave) CMMFG729DecoderIntfcDeMux;
sl@0
   175
	return self;
sl@0
   176
	}
sl@0
   177
sl@0
   178
sl@0
   179
CMMFG729DecoderIntfcDeMux::CMMFG729DecoderIntfcDeMux()
sl@0
   180
	{
sl@0
   181
	}
sl@0
   182
sl@0
   183
sl@0
   184
CMMFG729DecoderIntfcDeMux::~CMMFG729DecoderIntfcDeMux()
sl@0
   185
	{
sl@0
   186
	}
sl@0
   187
sl@0
   188
sl@0
   189
TInt CMMFG729DecoderIntfcDeMux::DoOpenSlaveL(TUid /*aInterface*/, const TDesC8& /*aPackageBuf*/)
sl@0
   190
	{
sl@0
   191
	// fetch the G729 decoder intfc Hw Device custom interface
sl@0
   192
	iInterfaceG729DecoderIntfc = static_cast<MG729DecoderIntfc*> (iTarget->CustomInterface(KUidG729DecoderIntfc));
sl@0
   193
sl@0
   194
	if (!iInterfaceG729DecoderIntfc)
sl@0
   195
		{
sl@0
   196
		iInterfaceG729DecoderIntfc = NULL;
sl@0
   197
		User::Leave(KErrNotSupported);
sl@0
   198
		}
sl@0
   199
sl@0
   200
	return KErrNone;
sl@0
   201
	}
sl@0
   202
sl@0
   203
sl@0
   204
void CMMFG729DecoderIntfcDeMux::DoCloseSlaveL(TInt /*aHandle*/)
sl@0
   205
	{
sl@0
   206
	// nothing to do
sl@0
   207
	}
sl@0
   208
sl@0
   209
sl@0
   210
// original RMessage is supplied so that remote demux plugin can extract necessary details
sl@0
   211
// using DeMux utility
sl@0
   212
TInt CMMFG729DecoderIntfcDeMux::DoSendSlaveSyncCommandL(const RMmfIpcMessage& aMessage)
sl@0
   213
	{
sl@0
   214
	TMMFDevSoundCIMessageData data;
sl@0
   215
	TInt result = KErrGeneral;
sl@0
   216
sl@0
   217
	// decode message
sl@0
   218
	iUtility->GetSyncMessageDataL(aMessage, data);
sl@0
   219
sl@0
   220
	switch (data.iCommand)
sl@0
   221
		{
sl@0
   222
		case EMMFDevSoundCIG729DecoderIntfcBadLsfNextBuffer:
sl@0
   223
			{
sl@0
   224
			result = DoBadLsfNextBufferL();
sl@0
   225
			break;
sl@0
   226
			}
sl@0
   227
		default:
sl@0
   228
			{
sl@0
   229
			User::Leave(KErrNotSupported);
sl@0
   230
			}
sl@0
   231
		}
sl@0
   232
sl@0
   233
	return result;
sl@0
   234
	}
sl@0
   235
sl@0
   236
sl@0
   237
TInt CMMFG729DecoderIntfcDeMux::DoSendSlaveSyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
sl@0
   238
	{
sl@0
   239
	return KErrNone;
sl@0
   240
	}
sl@0
   241
sl@0
   242
sl@0
   243
void CMMFG729DecoderIntfcDeMux::DoSendSlaveAsyncCommandL(const RMmfIpcMessage& /*aMessage*/)
sl@0
   244
	{
sl@0
   245
	// not used in this interface
sl@0
   246
	}
sl@0
   247
sl@0
   248
sl@0
   249
void CMMFG729DecoderIntfcDeMux::DoSendSlaveAsyncCommandResultL(const RMmfIpcMessage& /*aMessage*/)
sl@0
   250
	{
sl@0
   251
	// not used in this interface
sl@0
   252
	}
sl@0
   253
sl@0
   254
sl@0
   255
TInt CMMFG729DecoderIntfcDeMux::DoBadLsfNextBufferL()
sl@0
   256
	{
sl@0
   257
	TInt result = KErrNotFound;
sl@0
   258
sl@0
   259
	if (iInterfaceG729DecoderIntfc)
sl@0
   260
		{
sl@0
   261
		result = iInterfaceG729DecoderIntfc->BadLsfNextBuffer();
sl@0
   262
		}
sl@0
   263
sl@0
   264
	return result;
sl@0
   265
	}
sl@0
   266
sl@0
   267
sl@0
   268
//
sl@0
   269
// ImplementationTable
sl@0
   270
//
sl@0
   271
sl@0
   272
const TImplementationProxy ImplementationTable[] = 
sl@0
   273
	{
sl@0
   274
	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceG729DecoderIntfcMux,	CMMFG729DecoderIntfcMux::NewL),
sl@0
   275
	IMPLEMENTATION_PROXY_ENTRY(KMmfUidCustomInterfaceG729DecoderIntfcDeMux,	CMMFG729DecoderIntfcDeMux::NewL),
sl@0
   276
	};
sl@0
   277
sl@0
   278
//
sl@0
   279
// ImplementationGroupProxy
sl@0
   280
//
sl@0
   281
EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
sl@0
   282
	{
sl@0
   283
	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
sl@0
   284
sl@0
   285
	return ImplementationTable;
sl@0
   286
	}