phoneengine/audiohandling/src/cpeaudiodtmftoneplayer.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 23 Jun 2010 18:12:20 +0300
changeset 45 6b911d05207e
parent 37 ba76fc04e6c2
child 51 f39ed5e045e0
child 76 cfea66083b62
permissions -rw-r--r--
Revision: 201023 Kit: 2010125
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     1
/*
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     2
* Copyright (c) 2002-2007 Nokia Corporation and/or its subsidiary(-ies). 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     3
* All rights reserved.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     4
* This component and the accompanying materials are made available
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     6
* which accompanies this distribution, and is available
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     8
*
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
     9
* Initial Contributors:
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    11
*
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    12
* Contributors:
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    13
*
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    14
* Description:  This module contains the implementation of CPEAudioDtmfTonePlayer class 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    15
*                member functions
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    16
*
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    17
*/
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    18
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    19
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    20
// INCLUDE FILES
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    21
#include    "cpeaudiodtmftoneplayer.h"
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    22
#include    "pepanic.pan"
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    23
#include    <utility.h>
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    24
#include    <mdaaudiotoneplayer.h>
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    25
#include    <talogger.h>
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    26
#include    <AudioPreference.h>
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    27
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    28
// EXTERNAL DATA STRUCTURES
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    29
// None
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    30
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    31
// EXTERNAL FUNCTION PROTOTYPES  
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    32
// None
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    33
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    34
// CONSTANTS
45
6b911d05207e Revision: 201023
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents: 37
diff changeset
    35
const TInt KDtmfPauseAfterTone = 45000;
37
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    36
const TInt KDtmfToneZero = 0;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    37
const TInt KBufSize = 10;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    38
_LIT( KPhoneTone_Asterisk, "*+w" );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    39
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    40
const TInt KMaxVolumeLevel = 10;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    41
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    42
// MACROS
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    43
// None
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    44
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    45
// LOCAL CONSTANTS AND MACROS
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    46
// None
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    47
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    48
// MODULE DATA STRUCTURES
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    49
// None
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    50
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    51
// LOCAL FUNCTION PROTOTYPES
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    52
// None
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    53
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    54
// FORWARD DECLARATIONS
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    55
// None. 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    56
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    57
// ==================== LOCAL FUNCTIONS =====================================
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    58
// None
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    59
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    60
// ================= MEMBER FUNCTIONS =======================================
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    61
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    62
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    63
// CPEAudioDtmfTonePlayer::NewL
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    64
// Two-phased constructor.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    65
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    66
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    67
CPEAudioDtmfTonePlayer* CPEAudioDtmfTonePlayer::NewL()
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    68
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    69
    CPEAudioDtmfTonePlayer* self = 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    70
        new ( ELeave ) CPEAudioDtmfTonePlayer;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    71
    
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    72
    CleanupStack::PushL( self );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    73
    self->ConstructL();
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    74
    CleanupStack::Pop( self );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    75
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    76
    return self;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    77
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    78
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    79
//Destructor
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    80
CPEAudioDtmfTonePlayer::~CPEAudioDtmfTonePlayer()
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    81
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    82
    TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::~CPEAudioDtmfTonePlayer");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    83
    Cancel();
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    84
    delete iDTMFPlayer;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    85
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    86
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    87
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    88
// CPEAudioDtmfTonePlayer::CPEAudioDtmfTonePlayer
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    89
// C++ default constructor can NOT contain any code, that
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    90
// might leave.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    91
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    92
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    93
CPEAudioDtmfTonePlayer::CPEAudioDtmfTonePlayer()
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    94
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    95
    TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::CPEAudioDtmfTonePlayer");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    96
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    97
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    98
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
    99
// CPEAudioDtmfTonePlayer::ConstructL
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   100
// Symbian 2nd phase constructor can leave.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   101
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   102
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   103
void CPEAudioDtmfTonePlayer::ConstructL()
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   104
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   105
    TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::ConstructL start");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   106
    TMMFPrioritySettings dtmfClickPlayerPrioritySettings;  
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   107
    iDTMFPlayer = CMMFDevSound::NewL();
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   108
    
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   109
    iDTMFPlayer->InitializeL( *this, EMMFStateTonePlaying );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   110
    
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   111
    TEFLOGSTRING( KTAOBJECT, "AUD CPEAudioDtmfTonePlayer::ConstructL completed");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   112
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   113
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   114
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   115
// CPEAudioDtmfTonePlayer::SetVolume
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   116
// Sets the volume level that is used when the dtmf tone is played.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   117
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   118
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   119
void CPEAudioDtmfTonePlayer::SetVolume( 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   120
        TInt aVolume  //Volume to be set
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   121
        )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   122
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   123
    TInt vol = ConvertVolume( aVolume );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   124
        
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   125
    if ( vol != iVolume )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   126
        {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   127
        iVolume = vol;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   128
        iDTMFPlayer->SetVolume( iVolume );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   129
        TEFLOGSTRING2( KTAINT, "AUD CPEAudioDtmfTonePlayer::SetVolume, iVolume = %d", 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   130
            iVolume );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   131
        }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   132
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   133
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   134
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   135
// CPEAudioDtmfTonePlayer::PlayDtmfTone
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   136
// Searches the given DTMF tone from iToneArray and calls PlayCurrentTone -member function.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   137
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   138
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   139
void CPEAudioDtmfTonePlayer::PlayDtmfTone( 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   140
        TChar aTone )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   141
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   142
    TEFLOGSTRING( KTAINT, "AUD CPEAudioDtmfTonePlayer::PlayDtmfTone");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   143
    Cancel();
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   144
    Normalize( aTone ); 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   145
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   146
    // DTMF signalling.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   147
    if ( iDTMFPlayer )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   148
        {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   149
        TBuf<KBufSize> key; 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   150
        key.Append( aTone );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   151
        TEFLOGSTRING( KTAREQOUT, "AUD CPEAudioDtmfTonePlayer::PlayDtmfTone > CMMFDevSound::PlayDTMFStringL");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   152
        TRAP_IGNORE( iDTMFPlayer->PlayDTMFStringL( key ) ); 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   153
        }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   154
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   155
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   156
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   157
// CPEAudioDtmfTonePlayer::Cancel
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   158
// Cancels the currently playing tone.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   159
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   160
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   161
void CPEAudioDtmfTonePlayer::Cancel()
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   162
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   163
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::Cancel");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   164
    iDTMFPlayer->Stop();
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   165
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   166
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   167
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   168
// CPEAudioDtmfTonePlayer::Normalize
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   169
// Lowers case for chars and if its '*','+', or 'w' sets it to asterisk char ('*').
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   170
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   171
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   172
void CPEAudioDtmfTonePlayer::Normalize( 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   173
        TChar& aTone )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   174
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   175
    TEFLOGSTRING( KTAINT, "AUD CPEAudioDtmfTonePlayer::Normalize");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   176
    aTone.LowerCase();
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   177
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   178
    TPtrC ast( KPhoneTone_Asterisk );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   179
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   180
    if ( ast.Locate( aTone ) != KErrNotFound )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   181
        {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   182
        aTone = ast[ 0 ];
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   183
        TEFLOGSTRING( KTAINT, "AUD CPEAudioDtmfTonePlayer::Normalize");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   184
        }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   185
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   186
    
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   187
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   188
// CPEAudioDtmfTonePlayer::InitializeComplete
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   189
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   190
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   191
 void CPEAudioDtmfTonePlayer::InitializeComplete(  
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   192
    TInt aError )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   193
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   194
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::InitializeComplete");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   195
    __ASSERT_DEBUG( aError == KErrNone , Panic( EPEPanicAudioInitializeError ) );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   196
      
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   197
    if( aError == KErrNone)
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   198
        {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   199
        TMMFPrioritySettings dtmfClickPlayerSettings;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   200
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   201
        dtmfClickPlayerSettings.iPref = 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   202
                  ( TMdaPriorityPreference ) KAudioPrefKeyDownDTMF;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   203
        dtmfClickPlayerSettings.iPriority = KAudioPriorityDtmfKeyPress; 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   204
        dtmfClickPlayerSettings.iState = EMMFStateTonePlaying; 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   205
      
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   206
        iDTMFPlayer->SetPrioritySettings( dtmfClickPlayerSettings );         
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   207
      
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   208
        TTimeIntervalMicroSeconds32 length( KMdaInfiniteDurationDTMFToneOnLength );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   209
        TTimeIntervalMicroSeconds32 pause( KDtmfPauseAfterTone );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   210
        TTimeIntervalMicroSeconds32 zero( KDtmfToneZero );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   211
      
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   212
        iDTMFPlayer->SetDTMFLengths( length, pause, zero  );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   213
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   214
        iDTMFPlayer->SetToneRepeats( 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   215
                            KMdaAudioToneRepeatForever, 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   216
                            TTimeIntervalMicroSeconds( KDtmfToneZero ) );              
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   217
        // Must initialize volume to dtmf player. Otherwise it will be
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   218
        // 5 by default in audio SW.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   219
        iDTMFPlayer->SetVolume( iVolume );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   220
        }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   221
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   222
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   223
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   224
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   225
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   226
// CPEAudioDtmfTonePlayer::ToneFinished
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   227
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   228
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   229
void CPEAudioDtmfTonePlayer::ToneFinished( 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   230
    TInt /*aError*/ )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   231
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   232
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::ToneFinished");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   233
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   234
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   235
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   236
// CPEAudioDtmfTonePlayer::BufferToBeFilled
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   237
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   238
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   239
void CPEAudioDtmfTonePlayer::BufferToBeFilled( CMMFBuffer* /*aBuffer*/ )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   240
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   241
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::BufferToBeFilled");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   242
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   243
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   244
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   245
// CPEAudioDtmfTonePlayer::PlayError
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   246
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   247
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   248
void CPEAudioDtmfTonePlayer::PlayError( TInt /*aError*/ )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   249
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   250
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::PlayError");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   251
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   252
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   253
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   254
// CPEAudioDtmfTonePlayer::BufferToBeEmptied
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   255
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   256
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   257
void CPEAudioDtmfTonePlayer::BufferToBeEmptied( CMMFBuffer* /*aBuffer*/ )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   258
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   259
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::BufferToBeEmptied");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   260
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   261
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   262
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   263
// CPEAudioDtmfTonePlayer::RecordError
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   264
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   265
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   266
void CPEAudioDtmfTonePlayer::RecordError( TInt /*aError*/ )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   267
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   268
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::RecordError");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   269
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   270
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   271
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   272
// CPEAudioDtmfTonePlayer::ConvertError
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   273
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   274
//
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   275
void CPEAudioDtmfTonePlayer::ConvertError( TInt /*aError*/ )  
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   276
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   277
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::ConvertError");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   278
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   279
    
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   280
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   281
// CPEAudioDtmfTonePlayer::DeviceMessage
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   282
// ---------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   283
//  
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   284
void CPEAudioDtmfTonePlayer::DeviceMessage( TUid /*aMessageType*/, 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   285
                                         const TDesC8& /*aMsg*/ )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   286
    {
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   287
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::DeviceMessage");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   288
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   289
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   290
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   291
// CPEAudioDtmfTonePlayer::ConvertVolume
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   292
// -----------------------------------------------------------------------------
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   293
//  
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   294
TInt CPEAudioDtmfTonePlayer::ConvertVolume( TInt aVolume )
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   295
    { 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   296
    TEFLOGSTRING( KTAREQEND, "AUD CPEAudioDtmfTonePlayer::ConvertVolume");
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   297
    TInt result = iDTMFPlayer->MaxVolume() * aVolume / KMaxVolumeLevel;    
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   298
    
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   299
    TEFLOGSTRING3( KTAREQEND, 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   300
            "AUD CPEAudioDtmfTonePlayer::ConvertVolume, result = %d, maxVol=%d", 
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   301
            result, iDTMFPlayer->MaxVolume() );
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   302
    return result;
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   303
    }
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   304
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   305
// ================= OTHER EXPORTED FUNCTIONS ==============
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   306
// None.
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   307
ba76fc04e6c2 Revert last code drop.
Pat Downey <patd@symbian.org>
parents:
diff changeset
   308
//  End of File