1 /* |
|
2 * Copyright (c) 2010 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 "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: TMS AudioEffect. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <glib.h> |
|
19 #include <tms.h> |
|
20 #include <tmsfactory.h> |
|
21 #include <tmsglobalvoleffect.h> |
|
22 #include <tmsglobalgaineffect.h> |
|
23 #include "cpeaudioeffect.h" |
|
24 #include "pepanic.pan" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 // --------------------------------------------------------------------------- |
|
29 // Static constructor |
|
30 // --------------------------------------------------------------------------- |
|
31 // |
|
32 CPEAudioEffect* CPEAudioEffect::NewL(TMSEffectObserver& aObserver) |
|
33 { |
|
34 CPEAudioEffect* self = CPEAudioEffect::NewLC(aObserver); |
|
35 CleanupStack::Pop(self); |
|
36 return self; |
|
37 } |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // Static constructor |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 CPEAudioEffect* CPEAudioEffect::NewLC(TMSEffectObserver& aObserver) |
|
44 { |
|
45 CPEAudioEffect* self = new (ELeave) CPEAudioEffect(); |
|
46 CleanupStack::PushL(self); |
|
47 self->ConstructL(aObserver); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CPEAudioEffect::CPEAudioEffect |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CPEAudioEffect::CPEAudioEffect() |
|
56 { |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // Second phase constructor |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 void CPEAudioEffect::ConstructL(TMSEffectObserver& aObserver) |
|
64 { |
|
65 TMSVer* v = NULL; |
|
66 TInt err(KErrNotFound); |
|
67 TMSFactory::CreateFactory(iFactory, *v); |
|
68 if (iFactory) |
|
69 { |
|
70 err = iFactory->CreateEffect(TMS_EFFECT_GLOBAL_GAIN, iGlobalGain); |
|
71 err |= iFactory->CreateEffect(TMS_EFFECT_GLOBAL_VOL, iGlobalVol); |
|
72 } |
|
73 if (err) |
|
74 { |
|
75 User::Leave(KErrNotFound); |
|
76 } |
|
77 err = static_cast<TMSGlobalVolEffect*>(iGlobalVol)->AddObserver(aObserver, |
|
78 NULL); |
|
79 User::LeaveIfError(err); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Destructor |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 CPEAudioEffect::~CPEAudioEffect() |
|
87 { |
|
88 iFactory->DeleteEffect(iGlobalGain); |
|
89 iFactory->DeleteEffect(iGlobalVol); |
|
90 delete iFactory; |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CPEAudioEffect::SetMuteState(TBool aMute) |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 TInt CPEAudioEffect::SetMuteState(TBool aMute) |
|
98 { |
|
99 __ASSERT_DEBUG(iGlobalGain, Panic(EPEPanicBadHandle)); |
|
100 guint value(0); |
|
101 TInt err(KErrNotFound); |
|
102 if (aMute) |
|
103 { |
|
104 err = static_cast<TMSGlobalGainEffect*>(iGlobalGain)->SetLevel(0); |
|
105 } |
|
106 else |
|
107 { |
|
108 err = static_cast<TMSGlobalGainEffect*>(iGlobalGain)->GetMaxLevel( |
|
109 value); |
|
110 if (err == TMS_RESULT_SUCCESS) |
|
111 { |
|
112 err = static_cast<TMSGlobalGainEffect*>(iGlobalGain)->SetLevel( |
|
113 value); |
|
114 } |
|
115 } |
|
116 return err; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------------------------- |
|
120 // CPEAudioEffect::SetUnmuted |
|
121 // --------------------------------------------------------------------------- |
|
122 // |
|
123 TBool CPEAudioEffect::MuteState() const |
|
124 { |
|
125 __ASSERT_DEBUG(iGlobalGain, Panic(EPEPanicBadHandle)); |
|
126 guint value; |
|
127 static_cast<TMSGlobalGainEffect*>(iGlobalGain)->GetLevel(value); |
|
128 return (value == 0) ? ETrue : EFalse; |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------------------------- |
|
132 // CPEAudioEffect::SetVolume |
|
133 // --------------------------------------------------------------------------- |
|
134 // |
|
135 void CPEAudioEffect::SetVolume(TInt aVolume) |
|
136 { |
|
137 __ASSERT_DEBUG(iGlobalVol, Panic(EPEPanicBadHandle)); |
|
138 static_cast<TMSGlobalVolEffect*>(iGlobalVol)->SetLevel(aVolume); |
|
139 } |
|
140 |
|
141 // --------------------------------------------------------------------------- |
|
142 // CPEAudioEffect::Volume |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 TInt CPEAudioEffect::Volume() const |
|
146 { |
|
147 __ASSERT_DEBUG(iGlobalVol, Panic(EPEPanicBadHandle)); |
|
148 guint value(0); |
|
149 static_cast<TMSGlobalVolEffect*>(iGlobalVol)->GetLevel(value); |
|
150 return value; |
|
151 } |
|
152 |
|
153 // End of File |
|