17 |
17 |
18 #ifndef TMSCSDEVSOUND_H |
18 #ifndef TMSCSDEVSOUND_H |
19 #define TMSCSDEVSOUND_H |
19 #define TMSCSDEVSOUND_H |
20 |
20 |
21 #include <sounddevice.h> |
21 #include <sounddevice.h> |
|
22 #include "tmstimer.h" |
22 |
23 |
23 namespace TMS { |
24 namespace TMS { |
24 |
25 |
25 class TMSCSPDevSoundObserver; |
26 // FORWARD DECLARATIONS |
|
27 class TMSTimer; |
|
28 class TMSCSDevSoundObserver; |
26 |
29 |
27 /** |
30 /** |
28 * Wrapper for CMMFDevSound |
31 * Wrapper for CMMFDevSound |
29 * |
32 * |
30 */ |
33 */ |
31 NONSHARABLE_CLASS(TMSCSPDevSound) : public CBase, |
34 NONSHARABLE_CLASS(TMSCSDevSound) : public CBase, |
32 public MDevSoundObserver |
35 public MDevSoundObserver, |
|
36 public TMSTimerObserver |
33 { |
37 { |
34 public: |
38 public: |
35 |
39 |
36 /** |
40 /** |
37 * Destructor. |
41 * Destructor. |
38 */ |
42 */ |
39 virtual ~TMSCSPDevSound(); |
43 virtual ~TMSCSDevSound(); |
40 |
44 |
41 /** |
45 /** |
42 * Activates the dev sound stream. TMSCSPDevSoundObserver methods are called |
46 * Activates the DevSound stream. |
43 * when activation goes ok or fails. If the stream is already active or |
47 * Stream activation status is indicated by TMSCSDevSoundObserver callback |
44 * activating then nothing is done. |
48 * methods. If the stream is already active or being activated, call to |
|
49 * this will result in no action. |
45 */ |
50 */ |
46 virtual void Activate(); |
51 virtual void Activate(const gint retrytime); |
47 |
52 |
48 /** |
53 /** |
49 * Deactivates the devsound stream. If stream is not active or |
54 * Deactivates an active DevSound stream. |
50 * activation is not ongoing then nothing is done. |
|
51 */ |
55 */ |
52 virtual void Deactivate(); |
56 virtual void Deactivate(gboolean reset = TRUE); |
53 |
57 |
54 /** |
58 /* |
55 * Indicates that activation is ongoing, |
59 * Returns DevSound instance associated with the stream. |
56 * but the result of the activation is still unknown. |
|
57 * @return ETrue - activation ongoing, EFalse - activation not ongoing. |
|
58 */ |
60 */ |
59 TBool IsActivationOngoing() const; |
|
60 |
|
61 /** |
|
62 * Determines wether the devsound stream is active or not. |
|
63 * @return ETrue - Stream is active, EFalse - Stream not active. |
|
64 */ |
|
65 TBool IsActive() const; |
|
66 |
|
67 CMMFDevSound& DevSound(); |
61 CMMFDevSound& DevSound(); |
68 |
|
69 // from base class MDevSoundObserver |
|
70 |
62 |
71 /** |
63 /** |
72 * From MDevSoundObserver |
64 * From MDevSoundObserver |
73 * Empty implementation |
65 * Indicates DevSound initialization status. |
74 */ |
66 */ |
75 void InitializeComplete(TInt aError); |
67 void InitializeComplete(TInt aError); |
76 |
68 |
77 /** |
69 /** |
78 * From MDevSoundObserver |
70 * From MDevSoundObserver |
79 * Empty implementation |
71 * Empty implementation |
80 */ |
72 */ |
81 void BufferToBeFilled(CMMFBuffer* aBuffer); |
73 void BufferToBeFilled(CMMFBuffer* /*aBuffer*/) {} |
82 |
74 |
83 /** |
75 /** |
84 * From MDevSoundObserver |
76 * From MDevSoundObserver |
85 * Empty implementation |
77 * Empty implementation |
86 */ |
78 */ |
87 void PlayError(TInt aError); |
79 void PlayError(TInt /*aError*/) {} |
88 |
80 |
89 /** |
81 /** |
90 * From MDevSoundObserver |
82 * From MDevSoundObserver |
91 * Empty implementation |
83 * Empty implementation |
92 */ |
84 */ |
93 void ToneFinished(TInt aError); |
85 void ToneFinished(TInt /*aError*/) {} |
94 |
86 |
95 /** |
87 /** |
96 * From MDevSoundObserver |
88 * From MDevSoundObserver |
97 * Empty implementation |
89 * Empty implementation |
98 */ |
90 */ |
99 void BufferToBeEmptied(CMMFBuffer* aBuffer); |
91 void BufferToBeEmptied(CMMFBuffer* /*aBuffer*/) {} |
100 |
92 |
101 /** |
93 /** |
102 * From MDevSoundObserver |
94 * From MDevSoundObserver |
103 * Empty implementation |
95 * Empty implementation |
104 */ |
96 */ |
105 void RecordError(TInt aError); |
97 void RecordError(TInt /*aError*/) {} |
106 |
98 |
107 /** |
99 /** |
108 * From MDevSoundObserver |
100 * From MDevSoundObserver |
109 * Empty implementation |
101 * Empty implementation |
110 */ |
102 */ |
111 void ConvertError(TInt aError); |
103 void ConvertError(TInt /*aError*/) {} |
112 |
104 |
113 /** |
105 /** |
114 * From MDevSoundObserver |
106 * From MDevSoundObserver |
115 * Empty implementation |
107 * Empty implementation |
116 */ |
108 */ |
117 void DeviceMessage(TUid aMessageType, const TDesC8& aMsg); |
109 void DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/) {} |
|
110 |
|
111 /* |
|
112 * From TMSTimerObserver. |
|
113 * Called upon timer timeout event. |
|
114 */ |
|
115 void TimerEvent(); |
118 |
116 |
119 protected: |
117 protected: |
120 |
118 |
121 TMSCSPDevSound(TMSCSPDevSoundObserver& aObserver); |
119 TMSCSDevSound(TMSCSDevSoundObserver& observer); |
122 |
120 void ConstructL(const TMSStreamType strmtype, const gint retrytime); |
123 void ConstructL(TMMFState aMode, gint aAudioPreference, |
121 void InitializeL(); |
124 gint aAudioPriority); |
122 void NotifyEvent(gint error); |
|
123 void StartTimer(); |
|
124 void CancelTimer(); |
125 |
125 |
126 private: |
126 private: |
127 |
127 |
128 /** |
128 /** |
129 * Derived class has to activate the stream here. |
129 * Derived class has to activate the stream here. |
130 */ |
130 */ |
131 virtual void DoActivateL() = 0; |
131 virtual void DoActivateL() = 0; |
132 |
132 |
133 protected: |
133 protected: |
134 |
134 |
135 TUint iStreamType; |
135 /** |
|
136 * Indication of DevSound activated state. TRUE == stream activated. |
|
137 * Derived class has to update this. |
|
138 */ |
|
139 gboolean iActive; |
136 |
140 |
137 /** |
141 /** |
138 * Indication if device is activated. Derived class has to update this. |
142 * Indication of an ongoing DevSound activation. |
|
143 * Derived class has to update this. |
139 */ |
144 */ |
140 TBool iActive; |
145 gboolean iActivationOngoing; |
141 |
146 |
142 /** |
147 /** |
143 * Indication if activation is ongoing. |
148 * Devsound instance associated with the stream. |
144 * Derived class has to update this. |
|
145 */ |
|
146 TBool iActivationOngoing; |
|
147 |
|
148 /** |
|
149 * Devsound instance |
|
150 * Own. |
|
151 */ |
149 */ |
152 CMMFDevSound* iDevSound; |
150 CMMFDevSound* iDevSound; |
153 |
151 |
154 /** |
152 /** |
155 * Observer for successfull activation. |
153 * An observer subscribing to TMSCSDevSound notifications. |
156 * Not own. |
|
157 */ |
154 */ |
158 TMSCSPDevSoundObserver& iObserver; |
155 TMSCSDevSoundObserver& iObserver; |
159 |
156 |
|
157 TMSStreamType iStreamType; |
|
158 gint iPreference; |
|
159 gint iPriority; |
|
160 TMMFState iMode; |
|
161 |
|
162 /* |
|
163 * For retry timer |
|
164 */ |
|
165 gint iInitRetryTime; |
|
166 gint iStartRetryTime; |
|
167 TMSTimer* iTimer; |
|
168 gint iTimeout; |
160 }; |
169 }; |
161 |
170 |
162 } //namespace TMS |
171 } //namespace TMS |
163 |
172 |
164 #endif // TMSCSDEVSOUND_H |
173 #endif // TMSCSDEVSOUND_H |