baseport/syborg/soundsc/variant_sound.cpp
author Martin Trojer <martin.trojer@nokia.com>
Wed, 21 Oct 2009 10:29:21 +0100
changeset 15 5fca9e46c6fa
permissions -rwxr-xr-x
Merged patch from Johnathan White (@accenture) Added sound support and estart Updated framebuffer (support landscape and portrait mode) Fixes in pointer, keyboard and hostfs
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     1
/*
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     3
* All rights reserved.
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     5
* under the terms of the License "Eclipse Public License v1.0"
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     8
*
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
     9
* Initial Contributors:
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    11
*
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    12
* Contributors:
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    13
*
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    14
* Description:
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    15
*
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    16
*/
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    17
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    18
#include "variant_sound.h"
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    19
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    20
_LIT(KSoundScPddName, "SoundSc.Syborg");
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    21
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    22
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    23
DECLARE_STANDARD_PDD()
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    24
	{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    25
	return new DDriverSyborgSoundScPddFactory;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    26
	}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    27
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    28
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    29
DDriverSyborgSoundScPddFactory::DDriverSyborgSoundScPddFactory()
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    30
	{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    31
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    32
	iUnitsMask = ((1 << KSoundScTxUnit0) | (1 << KSoundScRxUnit0));
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    33
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    34
	iVersion = RSoundSc::VersionRequired();
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    35
	}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    36
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    37
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    38
TInt DDriverSyborgSoundScPddFactory::Install()
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    39
	{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    40
	_LIT(KAudioDFC, "AUDIO DFC");
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    41
	// Get a pointer to the the McBSP's DFC Queue so that handling of both McBSP callbacks and requests
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    42
	// made to the LDD from user mode can be processed in the same thread, to avoid the use of semaphores
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    43
	TInt r = Kern::DfcQCreate(iDfcQ, 26, &KAudioDFC);
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    44
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    45
	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::PDD install");
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    46
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    47
	if(r==KErrNone)
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    48
		{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    49
		// All PDD factories must have a unique name
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    50
		TInt r = SetName(&KSoundScPddName);
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    51
		}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    52
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    53
	return r;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    54
	}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    55
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    56
void DDriverSyborgSoundScPddFactory::GetCaps(TDes8& /*aDes*/) const
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    57
	{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    58
	}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    59
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    60
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    61
TInt DDriverSyborgSoundScPddFactory::Validate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    62
	{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    63
	// Check that the version requested is less than or equal to the version of this PDD
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    64
	if (!Kern::QueryVersionSupported(RSoundSc::VersionRequired(), aVer))
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    65
		{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    66
		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Validate KErrNotSup1");
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    67
		return KErrNotSupported;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    68
		}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    69
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    70
	// Check the unit number specifies either playback or recording
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    71
	if ((aUnit != KSoundScTxUnit0) && (aUnit != KSoundScRxUnit0))
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    72
		{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    73
		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Validate KErrNotSup2");
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    74
		return KErrNotSupported;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    75
		}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    76
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    77
	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Validate KErrNone");
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    78
	return KErrNone;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    79
	}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    80
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    81
TInt DDriverSyborgSoundScPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    82
	{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    83
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    84
	DSoundScPdd* pD = NULL;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    85
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    86
	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::PDD create aUnit %d TxUnitId %d", aUnit, KSoundScTxUnit0);
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    87
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    88
	// Assume failure
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    89
	TInt r = KErrNoMemory;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    90
	aChannel = NULL;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    91
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    92
				
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    93
	DDriverSyborgSoundScPdd* pTxD = new DDriverSyborgSoundScPdd;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    94
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    95
	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::TxPdd %d", pTxD);
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    96
		
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    97
	if (pTxD)
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    98
		{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
    99
		pD = pTxD;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   100
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   101
		// Save a pointer to the factory so that it is accessible by the PDD and call the PDD's
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   102
		// second stage constructor
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   103
		pTxD->iPhysicalDevice = this;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   104
			
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   105
		pTxD->iUnitType = aUnit; // Either KSoundScTxUnit0 or KSoundScRxUnit0 (play or record)
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   106
			
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   107
		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::TxPdd2 %d", pTxD);
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   108
			
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   109
		r = pTxD->DoCreate();
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   110
			
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   111
		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Create ret %d", r);
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   112
			
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   113
		}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   114
	
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   115
	// If everything succeeded, save a pointer to the PDD.  This should only be done if DoCreate() succeeded,
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   116
	// as some LDDs have been known to access this pointer even if Create() returns an error!
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   117
	if (r == KErrNone)
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   118
		{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   119
		aChannel = pD;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   120
		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::TxPdd set AChannel %d", aChannel);
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   121
		}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   122
	else
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   123
		{
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   124
		delete pD;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   125
		}
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   126
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   127
	return r;
5fca9e46c6fa Merged patch from Johnathan White (@accenture)
Martin Trojer <martin.trojer@nokia.com>
parents:
diff changeset
   128
	}