devsound/a3fcharacterisationtest/src/char_a3f_devsound_toneclient.cpp
changeset 24 2672ba96448e
equal deleted inserted replaced
21:1c0a769d0cc5 24:2672ba96448e
       
     1 // Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // char_a3f_devsound_testclient.h
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "char_a3f_devsound_toneclient.h"
       
    19 
       
    20 CA3FDevSoundToneClient::CA3FDevSoundToneClient(MA3FDevsoundToneClientObserver &aObserver)
       
    21 	: 	iDevSound(NULL), 
       
    22 		iObserver(aObserver), 
       
    23 		iDTMFString(KNullDesC)
       
    24 	{
       
    25 	}
       
    26 
       
    27 CA3FDevSoundToneClient::~CA3FDevSoundToneClient()
       
    28 	{
       
    29 	delete iDevSound;
       
    30 	}
       
    31 
       
    32 CA3FDevSoundToneClient* CA3FDevSoundToneClient::NewL(MA3FDevsoundToneClientObserver &aObserver)
       
    33 	{
       
    34 	CA3FDevSoundToneClient* self = new (ELeave) CA3FDevSoundToneClient(aObserver);
       
    35 	CleanupStack::PushL(self);
       
    36 	self->ConstructL();
       
    37 	CleanupStack::Pop(self);
       
    38 	return self;
       
    39 	}
       
    40 
       
    41 void CA3FDevSoundToneClient::ConstructL()
       
    42 	{   
       
    43 	iDevSound = CMMFDevSound::NewL();
       
    44 	iDevSound->SetVolume(iDevSound->MaxVolume());
       
    45 	}
       
    46 
       
    47 void CA3FDevSoundToneClient::SetPriority(TInt priority)
       
    48 	{   
       
    49 	TMMFPrioritySettings settings;
       
    50 	settings.iPriority = priority;
       
    51 	settings.iPref = EMdaPriorityPreferenceTime;
       
    52 	iDevSound->SetPrioritySettings(settings);
       
    53 	}
       
    54 
       
    55 TInt CA3FDevSoundToneClient::InitTonePlay(TInt aFrequency,TInt aDuration)
       
    56 	{
       
    57 	iFrequency = aFrequency;
       
    58 	iDuration = aDuration;
       
    59 	TRAPD(err, iDevSound->InitializeL(*this,EMMFStateTonePlaying));
       
    60 	return err;
       
    61 	}
       
    62 
       
    63 TInt CA3FDevSoundToneClient::InitDualTonePlay(TInt aFrequency, TInt aFrequencyTwo,  TInt aDuration)
       
    64 	{
       
    65 	iFrequency = aFrequency;
       
    66 	iFrequencyTwo = aFrequencyTwo;
       
    67 	iDuration = aDuration;
       
    68 	TRAPD(err, iDevSound->InitializeL(*this,EMMFStateTonePlaying));
       
    69 	return err;
       
    70 	}
       
    71 
       
    72 TInt CA3FDevSoundToneClient::InitDTMFStringPlay(const TDesC &aDTMFString)
       
    73 	{
       
    74 	iDTMFString = aDTMFString;
       
    75 	TRAPD(err, iDevSound->InitializeL(*this,EMMFStateTonePlaying));
       
    76 	return err;
       
    77 	}
       
    78 
       
    79 TInt CA3FDevSoundToneClient::InitToneSequencePlay()
       
    80 	{
       
    81 	TRAPD(err, iDevSound->InitializeL(*this,EMMFStateTonePlaying));
       
    82 	return err;
       
    83 	}
       
    84 
       
    85 void CA3FDevSoundToneClient::InitializeComplete(TInt aError)
       
    86 	{
       
    87 	iObserver.ClientInitializeCompleteCallback(aError);
       
    88 	}
       
    89 TInt CA3FDevSoundToneClient::PlayTone()
       
    90 	{
       
    91 	TRAPD(err, iDevSound->PlayToneL(iFrequency,iDuration));
       
    92 	return err;
       
    93 	}
       
    94 TInt CA3FDevSoundToneClient::PlayDualTone()
       
    95 	{
       
    96 	TRAPD(err, iDevSound->PlayDualToneL(iFrequency,iFrequencyTwo,iDuration));
       
    97 	return err;
       
    98 	}
       
    99 TInt CA3FDevSoundToneClient::PlayDTMFString()
       
   100 	{
       
   101 	TRAPD(err, iDevSound->PlayDTMFStringL(iDTMFString));
       
   102 	return err;
       
   103 	}
       
   104 TInt CA3FDevSoundToneClient::PlayToneSequence()
       
   105 	{
       
   106 	TUint8* tablePointer = const_cast<TUint8*>( &(KFixedSequenceTestSequenceDataX[0] ) ); 
       
   107 	TPtrC8 KFixedSequenceData(tablePointer, sizeof(KFixedSequenceTestSequenceDataX));
       
   108 	TRAPD(err, iDevSound->PlayToneSequenceL(KFixedSequenceData));
       
   109 	return err;
       
   110 	}
       
   111 void CA3FDevSoundToneClient::ToneFinished(TInt aError)
       
   112 	{
       
   113 	iObserver.ClientToneFinishedCallback(aError);
       
   114 	}
       
   115 
       
   116 void CA3FDevSoundToneClient::BufferToBeFilled(CMMFBuffer*/*aBuffer*/)
       
   117 	{
       
   118 	__ASSERT_ALWAYS(0, Panic(_L("CA3FDevSoundToneClient"), EInvalidCallbackCall));
       
   119 	}
       
   120 
       
   121 void CA3FDevSoundToneClient::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
       
   122 	{
       
   123 	__ASSERT_ALWAYS(0, Panic(_L("CA3FDevSoundToneClient"), EInvalidCallbackCall));
       
   124 	}
       
   125 
       
   126 void CA3FDevSoundToneClient::PlayError(TInt /*aError*/)
       
   127 	{
       
   128 	__ASSERT_ALWAYS(0, Panic(_L("CA3FDevSoundToneClient"), EInvalidCallbackCall));
       
   129 	}
       
   130 
       
   131 void CA3FDevSoundToneClient::RecordError(TInt /*aError*/)
       
   132 	{
       
   133 	__ASSERT_ALWAYS(0, Panic(_L("CA3FDevSoundToneClient"), EInvalidCallbackCall));
       
   134 	}
       
   135 
       
   136 void CA3FDevSoundToneClient::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
       
   137 	{
       
   138 	__ASSERT_ALWAYS(0, Panic(_L("CA3FDevSoundToneClient"), EInvalidCallbackCall));
       
   139 	}
       
   140 
       
   141 void CA3FDevSoundToneClient::ConvertError(TInt /*aError*/)
       
   142 	{
       
   143 	__ASSERT_ALWAYS(0, Panic(_L("CA3FDevSoundToneClient"), EInvalidCallbackCall));
       
   144 	}
       
   145