|
1 /* |
|
2 * Copyright (c) 2007 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 |
|
19 // INCLUDES |
|
20 #include "SystemInfoBeep.h" |
|
21 |
|
22 // ----------------------------------------------------------------------------- |
|
23 // CSystemInfoBeep::NewL |
|
24 // Two-phased constructor. |
|
25 // ----------------------------------------------------------------------------- |
|
26 CSystemInfoBeep* CSystemInfoBeep::NewL() |
|
27 { |
|
28 CSystemInfoBeep* self = new (ELeave) CSystemInfoBeep(); |
|
29 CleanupStack::PushL( self ); |
|
30 self->ConstructL(); |
|
31 CleanupStack::Pop(); |
|
32 return self; |
|
33 }; |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CSystemInfoBeep::CSystemInfoBeep |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 CSystemInfoBeep::CSystemInfoBeep() |
|
41 : iState( EBeepIdle ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // CSystemInfoBeep::ConstructL |
|
47 // Symbian 2nd phase constructor can leave. |
|
48 // ----------------------------------------------------------------------------- |
|
49 void CSystemInfoBeep::ConstructL() |
|
50 { |
|
51 iToneUtil = CMdaAudioToneUtility::NewL( *this ); |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CSystemInfoBeep::~CSystemInfoBeep |
|
56 // Destructor |
|
57 // ----------------------------------------------------------------------------- |
|
58 CSystemInfoBeep::~CSystemInfoBeep() |
|
59 { |
|
60 delete iToneUtil; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // CSystemInfoBeep::Play |
|
65 // ----------------------------------------------------------------------------- |
|
66 void CSystemInfoBeep::Play( TInt aFrequency, TTimeIntervalMicroSeconds aDuration ) |
|
67 { |
|
68 if ( iState == EBeepPreparing ) |
|
69 { |
|
70 iToneUtil->CancelPrepare(); |
|
71 } |
|
72 else if ( iState == EBeepPlaying ) |
|
73 { |
|
74 iToneUtil->CancelPlay(); |
|
75 } |
|
76 iState = EBeepPreparing; |
|
77 iToneUtil->PrepareToPlayTone( aFrequency, aDuration ); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CSystemInfoBeep::MatoPrepareComplete |
|
82 // ----------------------------------------------------------------------------- |
|
83 void CSystemInfoBeep::MatoPrepareComplete( TInt aError ) |
|
84 { |
|
85 if ( aError == KErrNone ) |
|
86 { |
|
87 iState = EBeepPlaying; |
|
88 iToneUtil->Play(); |
|
89 } |
|
90 else |
|
91 { |
|
92 iState = EBeepIdle; |
|
93 } |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CSystemInfoBeep::MatoPlayComplete |
|
98 // ----------------------------------------------------------------------------- |
|
99 void CSystemInfoBeep::MatoPlayComplete( TInt /*aError*/ ) |
|
100 { |
|
101 iState = EBeepIdle; |
|
102 } |