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