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 <glib.h> |
|
20 #include <S60FourCC.h> |
19 #include <S60FourCC.h> |
|
20 #include "tmsutility.h" |
21 #include "tmscsdevsound.h" |
21 #include "tmscsdevsound.h" |
22 #include "tmscsdevsoundobserver.h" |
22 #include "tmscsdevsoundobserver.h" |
23 |
23 |
24 using namespace TMS; |
24 using namespace TMS; |
25 |
25 |
26 // ----------------------------------------------------------------------------- |
26 // ----------------------------------------------------------------------------- |
27 // TMSCSPDevSound |
27 // TMSCSPDevSound |
28 // ----------------------------------------------------------------------------- |
28 // ----------------------------------------------------------------------------- |
29 // |
29 // |
30 TMSCSPDevSound::TMSCSPDevSound(TMSCSPDevSoundObserver& aObserver) : |
30 TMSCSDevSound::TMSCSDevSound(TMSCSDevSoundObserver& observer) : |
31 iObserver(aObserver) |
31 iObserver(observer) |
32 { |
32 { |
33 } |
33 } |
34 |
34 |
35 // ----------------------------------------------------------------------------- |
35 // ----------------------------------------------------------------------------- |
36 // ConstructL |
36 // ConstructL |
37 // ----------------------------------------------------------------------------- |
37 // ----------------------------------------------------------------------------- |
38 // |
38 // |
39 void TMSCSPDevSound::ConstructL(TMMFState aMode, gint aAudioPreference, |
39 void TMSCSDevSound::ConstructL(const TMSStreamType strmtype) |
40 gint aAudioPriority) |
|
41 { |
40 { |
|
41 TRACE_PRN_FN_ENT; |
|
42 iStreamType = strmtype; |
|
43 |
|
44 if (strmtype == TMS_STREAM_UPLINK) |
|
45 { |
|
46 iMode = EMMFStateRecording; |
|
47 iPriority = KAudioPriorityCSCallUplink; |
|
48 iPreference = KAudioPrefCSCallUplink; |
|
49 } |
|
50 else if (strmtype == TMS_STREAM_DOWNLINK) |
|
51 { |
|
52 iMode = EMMFStatePlaying; |
|
53 iPriority = KAudioPriorityCSCallDownlink; |
|
54 iPreference = KAudioPrefCSCallDownlink; |
|
55 } |
|
56 InitializeL(); |
|
57 TRACE_PRN_FN_EXT; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // InitializeL |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void TMSCSDevSound::InitializeL() |
|
65 { |
|
66 TRACE_PRN_FN_ENT; |
42 TMMFPrioritySettings audioPriority; |
67 TMMFPrioritySettings audioPriority; |
43 TFourCC modemFourCC; |
68 TFourCC modemFourCC; |
44 modemFourCC.Set(KS60FourCCCodeModem); |
69 modemFourCC.Set(KS60FourCCCodeModem); |
|
70 |
|
71 delete iDevSound; |
|
72 iDevSound = NULL; |
45 iDevSound = CMMFDevSound::NewL(); |
73 iDevSound = CMMFDevSound::NewL(); |
46 if (iDevSound) |
74 if (iDevSound) |
47 { |
75 { |
48 #ifndef __WINSCW__ |
76 #ifndef __WINSCW__ |
49 iDevSound->InitializeL(*this, modemFourCC, aMode); |
77 iDevSound->InitializeL(*this, modemFourCC, iMode); |
50 #else //For testing TMS in WINSCW |
78 #else |
51 iDevSound->InitializeL(*this, KMMFFourCCCodePCM16, aMode); |
79 //For testing TMS in WINSCW |
|
80 iDevSound->InitializeL(*this, KMMFFourCCCodePCM16, iMode); |
52 #endif |
81 #endif |
53 iStreamType = aAudioPreference; |
82 audioPriority.iPriority = iPriority; |
54 audioPriority.iPriority = aAudioPriority; |
83 audioPriority.iPref = iPreference; |
55 audioPriority.iPref = aAudioPreference; |
84 audioPriority.iState = iMode; |
56 audioPriority.iState = aMode; |
|
57 iDevSound->SetPrioritySettings(audioPriority); |
85 iDevSound->SetPrioritySettings(audioPriority); |
58 } |
86 } |
|
87 TRACE_PRN_FN_EXT; |
59 } |
88 } |
60 |
89 |
61 // ----------------------------------------------------------------------------- |
90 // ----------------------------------------------------------------------------- |
62 // From class MDevSoundObserver |
91 // From class MDevSoundObserver |
63 // Not implemented |
92 // Not implemented |
64 // ----------------------------------------------------------------------------- |
93 // ----------------------------------------------------------------------------- |
65 // |
94 // |
66 TMSCSPDevSound::~TMSCSPDevSound() |
95 TMSCSDevSound::~TMSCSDevSound() |
67 { |
96 { |
68 delete iDevSound; |
97 delete iDevSound; |
69 } |
98 } |
70 |
99 |
71 // ----------------------------------------------------------------------------- |
100 // ----------------------------------------------------------------------------- |
72 // Tries to activate the audio stream if not active or activating |
101 // Tries to activate the audio stream if not already active or activating |
73 // ----------------------------------------------------------------------------- |
102 // ----------------------------------------------------------------------------- |
74 // |
103 // |
75 void TMSCSPDevSound::Activate() |
104 void TMSCSDevSound::Activate() |
76 { |
105 { |
77 if (!IsActive() && !IsActivationOngoing()) |
106 if (!iActive && !iActivationOngoing) |
78 { |
107 { |
79 iActivationOngoing = ETrue; |
108 iActivationOngoing = ETrue; |
80 TRAP_IGNORE(DoActivateL()); |
109 TRAP_IGNORE(DoActivateL()); |
81 } |
110 } |
82 } |
111 } |
83 |
112 |
84 // ----------------------------------------------------------------------------- |
113 // ----------------------------------------------------------------------------- |
85 // Deactivates the audio device. |
114 // Deactivates the audio device. |
86 // ----------------------------------------------------------------------------- |
115 // ----------------------------------------------------------------------------- |
87 // |
116 // |
88 void TMSCSPDevSound::Deactivate() |
117 void TMSCSDevSound::Deactivate() |
89 { |
118 { |
90 if (iDevSound && (IsActive() || IsActivationOngoing())) |
119 if (iDevSound && (iActive || iActivationOngoing)) |
91 { |
120 { |
92 iDevSound->Stop(); |
121 iDevSound->Stop(); |
93 iActive = EFalse; |
122 iActive = EFalse; |
94 iActivationOngoing = EFalse; |
123 iActivationOngoing = EFalse; |
95 } |
124 } |
96 } |
125 } |
97 |
126 |
98 // ----------------------------------------------------------------------------- |
127 // ----------------------------------------------------------------------------- |
99 // ActivationOngoing |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TBool TMSCSPDevSound::IsActivationOngoing() const |
|
103 { |
|
104 return iActivationOngoing; |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // IsActive |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 TBool TMSCSPDevSound::IsActive() const |
|
112 { |
|
113 return iActive; |
|
114 } |
|
115 |
|
116 // ----------------------------------------------------------------------------- |
|
117 // DevSound |
128 // DevSound |
118 // ----------------------------------------------------------------------------- |
129 // ----------------------------------------------------------------------------- |
119 // |
130 // |
120 CMMFDevSound& TMSCSPDevSound::DevSound() |
131 CMMFDevSound& TMSCSDevSound::DevSound() |
121 { |
132 { |
122 return *iDevSound; |
133 return *iDevSound; |
123 } |
134 } |
124 |
135 |
125 // ----------------------------------------------------------------------------- |
136 // ----------------------------------------------------------------------------- |
126 // From class MDevSoundObserver |
137 // From class MDevSoundObserver |
127 // Not implemented |
|
128 // ----------------------------------------------------------------------------- |
138 // ----------------------------------------------------------------------------- |
129 // |
139 // |
130 void TMSCSPDevSound::InitializeComplete(TInt aError) |
140 void TMSCSDevSound::InitializeComplete(TInt aError) |
131 { |
141 { |
132 if (iStreamType == KAudioPrefCSCallDownlink) |
142 TRACE_PRN_FN_ENT; |
|
143 if (aError == TMS_RESULT_SUCCESS) |
133 { |
144 { |
134 iObserver.DownlinkInitCompleted(aError); |
145 NotifyEvent(aError); |
135 } |
146 } |
136 else |
147 TRACE_PRN_FN_EXT; |
|
148 } |
|
149 |
|
150 // ----------------------------------------------------------------------------- |
|
151 // TMSCSDevSound::NotifyEvent |
|
152 // ----------------------------------------------------------------------------- |
|
153 // |
|
154 void TMSCSDevSound::NotifyEvent(gint error) |
|
155 { |
|
156 if (iStreamType == TMS_STREAM_DOWNLINK) |
137 { |
157 { |
138 iObserver.UplinkInitCompleted(aError); |
158 iObserver.DownlinkInitCompleted(error); |
|
159 } |
|
160 else if (iStreamType == TMS_STREAM_UPLINK) |
|
161 { |
|
162 iObserver.UplinkInitCompleted(error); |
139 } |
163 } |
140 } |
164 } |
141 |
165 |
142 // ----------------------------------------------------------------------------- |
|
143 // From class MDevSoundObserver |
|
144 // Not implemented |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 void TMSCSPDevSound::BufferToBeFilled(CMMFBuffer* /*aBuffer*/) |
|
148 { |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // From class MDevSoundObserver |
|
153 // Not implemented |
|
154 // ----------------------------------------------------------------------------- |
|
155 // |
|
156 void TMSCSPDevSound::PlayError(TInt /*aError*/) |
|
157 { |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // From class MDevSoundObserver |
|
162 // Not implemented |
|
163 // ----------------------------------------------------------------------------- |
|
164 // |
|
165 void TMSCSPDevSound::ToneFinished(TInt /*aError*/) |
|
166 { |
|
167 } |
|
168 |
|
169 // ----------------------------------------------------------------------------- |
|
170 // From class MDevSoundObserver |
|
171 // Not implemented |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 void TMSCSPDevSound::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) |
|
175 { |
|
176 } |
|
177 |
|
178 // ----------------------------------------------------------------------------- |
|
179 // From class MDevSoundObserver |
|
180 // Not implemented |
|
181 // ----------------------------------------------------------------------------- |
|
182 // |
|
183 void TMSCSPDevSound::RecordError(TInt /*aError*/) |
|
184 { |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // From class MDevSoundObserver |
|
189 // Not implemented |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void TMSCSPDevSound::ConvertError(TInt /*aError*/) |
|
193 { |
|
194 } |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // From class MDevSoundObserver |
|
198 // Not implemented |
|
199 // ----------------------------------------------------------------------------- |
|
200 // |
|
201 void TMSCSPDevSound::DeviceMessage(TUid /*aMessageType*/, |
|
202 const TDesC8& /*aMsg*/) |
|
203 { |
|
204 } |
|
205 |
|
206 // End of File |
166 // End of File |