|
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 "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: Telephony Multimedia Service |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <AudioPreference.h> |
|
19 #include "csdownlink.h" |
|
20 #include "mcspdevsoundobserver.h" |
|
21 |
|
22 using namespace TMS; |
|
23 |
|
24 const gint KDefaultVolume = 4; |
|
25 const gint KDefaultMaxVolume = 10; |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // Static constructor |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CSDownlink* CSDownlink::NewL(MCSPDevSoundObserver& aObserver) |
|
32 { |
|
33 CSDownlink* self = new (ELeave) CSDownlink(aObserver); |
|
34 CleanupStack::PushL(self); |
|
35 self->ConstructL(); |
|
36 CleanupStack::Pop(self); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // Destructor. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CSDownlink::~CSDownlink() |
|
45 { |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // Sets volume |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 void CSDownlink::SetVolume(gint aVolume) |
|
53 { |
|
54 if (iDevSound) |
|
55 { |
|
56 gint maxVolume(iDevSound->MaxVolume()); |
|
57 maxVolume = (maxVolume > 0) ? maxVolume : KDefaultMaxVolume; |
|
58 gint scaledVolume = (aVolume * maxVolume) / KDefaultMaxVolume; |
|
59 iDevSound->SetVolume(scaledVolume); |
|
60 } |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // Gives volume |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 gint CSDownlink::Volume() |
|
68 { |
|
69 gint vol = 0; |
|
70 if (iDevSound) |
|
71 { |
|
72 vol = iDevSound->Volume(); |
|
73 } |
|
74 return vol; |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // Gives max volume |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 gint CSDownlink::MaxVolume() |
|
82 { |
|
83 gint vol = 0; |
|
84 if (iDevSound) |
|
85 { |
|
86 vol = iDevSound->MaxVolume(); |
|
87 } |
|
88 return vol; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // From class MDevSoundObserver |
|
93 // Downlink stream has been activated successfully. |
|
94 // ----------------------------------------------------------------------------- |
|
95 // |
|
96 void CSDownlink::BufferToBeFilled(CMMFBuffer* /*aBuffer*/) |
|
97 { |
|
98 //CSPLOGSTRING( CSPINT, "CSDownlink:: activated" ); |
|
99 // We dont react to devsound messages unless we are activating. |
|
100 if (IsActivationOngoing()) |
|
101 { |
|
102 iActive = ETrue; |
|
103 iActivationOngoing = EFalse; |
|
104 iObserver.DownlinkActivatedSuccessfully(); |
|
105 } |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // From class MDevSoundObserver |
|
110 // Downlink stream activation failed |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CSDownlink::PlayError(TInt aError) |
|
114 { |
|
115 //CSPLOGSTRING( CSPINT, "CSDownlink::PlayError" ); |
|
116 |
|
117 // We dont react to devsound messages unless we are activating. |
|
118 if (IsActivationOngoing()) |
|
119 { |
|
120 //CSPLOGSTRING( CSPINT, "CSDownlink::PlayError activation failed" ); |
|
121 if (aError == KErrAccessDenied) |
|
122 { |
|
123 iActivationOngoing = EFalse; |
|
124 iObserver.DownlinkActivationFailed(); |
|
125 } |
|
126 } |
|
127 } |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // From class CSPDevsound |
|
131 // Tries to activate Downlink stream. |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CSDownlink::DoActivateL() |
|
135 { |
|
136 if (iDevSound) |
|
137 { |
|
138 iDevSound->PlayInitL(); |
|
139 } |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // Constructor |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 CSDownlink::CSDownlink(MCSPDevSoundObserver& aObserver) : |
|
147 CSPDevSound(aObserver) |
|
148 { |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // Second phase constructor |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CSDownlink::ConstructL() |
|
156 { |
|
157 CSPDevSound::ConstructL(EMMFStatePlaying, KAudioPrefCSCallDownlink, |
|
158 KAudioPriorityCSCallDownlink); |
|
159 |
|
160 if (iDevSound) |
|
161 { |
|
162 iDevSound->SetVolume(KDefaultVolume); |
|
163 } |
|
164 } |
|
165 |
|
166 // End of File |