baseport/syborg/soundsc/variant_sound.cpp
changeset 16 73107a0bc259
child 45 01c1ffcc4fca
equal deleted inserted replaced
12:5c4b0c1fa5f8 16:73107a0bc259
       
     1 /*
       
     2 * Copyright (c) 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 the License "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 #include "variant_sound.h"
       
    19 
       
    20 _LIT(KSoundScPddName, "SoundSc.Syborg");
       
    21 
       
    22 
       
    23 DECLARE_STANDARD_PDD()
       
    24 	{
       
    25 	return new DDriverSyborgSoundScPddFactory;
       
    26 	}
       
    27 
       
    28 
       
    29 DDriverSyborgSoundScPddFactory::DDriverSyborgSoundScPddFactory()
       
    30 	{
       
    31 
       
    32 	iUnitsMask = ((1 << KSoundScTxUnit0) | (1 << KSoundScRxUnit0));
       
    33 
       
    34 	iVersion = RSoundSc::VersionRequired();
       
    35 	}
       
    36 
       
    37 
       
    38 TInt DDriverSyborgSoundScPddFactory::Install()
       
    39 	{
       
    40 	_LIT(KAudioDFC, "AUDIO DFC");
       
    41 	// Get a pointer to the the McBSP's DFC Queue so that handling of both McBSP callbacks and requests
       
    42 	// made to the LDD from user mode can be processed in the same thread, to avoid the use of semaphores
       
    43 	TInt r = Kern::DfcQCreate(iDfcQ, 26, &KAudioDFC);
       
    44 
       
    45 	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::PDD install");
       
    46 
       
    47 	if(r==KErrNone)
       
    48 		{
       
    49 		// All PDD factories must have a unique name
       
    50 		TInt r = SetName(&KSoundScPddName);
       
    51 		}
       
    52 
       
    53 	return r;
       
    54 	}
       
    55 
       
    56 void DDriverSyborgSoundScPddFactory::GetCaps(TDes8& /*aDes*/) const
       
    57 	{
       
    58 	}
       
    59 
       
    60 
       
    61 TInt DDriverSyborgSoundScPddFactory::Validate(TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& aVer)
       
    62 	{
       
    63 	// Check that the version requested is less than or equal to the version of this PDD
       
    64 	if (!Kern::QueryVersionSupported(RSoundSc::VersionRequired(), aVer))
       
    65 		{
       
    66 		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Validate KErrNotSup1");
       
    67 		return KErrNotSupported;
       
    68 		}
       
    69 
       
    70 	// Check the unit number specifies either playback or recording
       
    71 	if ((aUnit != KSoundScTxUnit0) && (aUnit != KSoundScRxUnit0))
       
    72 		{
       
    73 		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Validate KErrNotSup2");
       
    74 		return KErrNotSupported;
       
    75 		}
       
    76 
       
    77 	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Validate KErrNone");
       
    78 	return KErrNone;
       
    79 	}
       
    80 
       
    81 TInt DDriverSyborgSoundScPddFactory::Create(DBase*& aChannel, TInt aUnit, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
       
    82 	{
       
    83 
       
    84 	DSoundScPdd* pD = NULL;
       
    85 
       
    86 	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::PDD create aUnit %d TxUnitId %d", aUnit, KSoundScTxUnit0);
       
    87 
       
    88 	// Assume failure
       
    89 	TInt r = KErrNoMemory;
       
    90 	aChannel = NULL;
       
    91 
       
    92 				
       
    93 	DDriverSyborgSoundScPdd* pTxD = new DDriverSyborgSoundScPdd;
       
    94 
       
    95 	SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::TxPdd %d", pTxD);
       
    96 		
       
    97 	if (pTxD)
       
    98 		{
       
    99 		pD = pTxD;
       
   100 
       
   101 		// Save a pointer to the factory so that it is accessible by the PDD and call the PDD's
       
   102 		// second stage constructor
       
   103 		pTxD->iPhysicalDevice = this;
       
   104 			
       
   105 		pTxD->iUnitType = aUnit; // Either KSoundScTxUnit0 or KSoundScRxUnit0 (play or record)
       
   106 			
       
   107 		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::TxPdd2 %d", pTxD);
       
   108 			
       
   109 		r = pTxD->DoCreate();
       
   110 			
       
   111 		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::Create ret %d", r);
       
   112 			
       
   113 		}
       
   114 	
       
   115 	// If everything succeeded, save a pointer to the PDD.  This should only be done if DoCreate() succeeded,
       
   116 	// as some LDDs have been known to access this pointer even if Create() returns an error!
       
   117 	if (r == KErrNone)
       
   118 		{
       
   119 		aChannel = pD;
       
   120 		SYBORG_SOUND_DEBUG("DDriverSyborgSoundScPddFactory::TxPdd set AChannel %d", aChannel);
       
   121 		}
       
   122 	else
       
   123 		{
       
   124 		delete pD;
       
   125 		}
       
   126 
       
   127 	return r;
       
   128 	}