|
1 /* |
|
2 * Copyright (c) 2006 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: Audio output proxy implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "AudioOutput.h" |
|
22 #include "AudioOutputProxyAO.h" |
|
23 #include "AudioOutputProxy.h" |
|
24 #include "AudioOutputMessageTypes.h" |
|
25 #include <CustomCommandUtility.h> |
|
26 #include "CustomInterfaceUtility.h" |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 // ================= MEMBER FUNCTIONS ======================= |
|
32 |
|
33 // C++ default constructor can NOT contain any code, that |
|
34 // might leave. |
|
35 // |
|
36 CAudioOutputProxy::CAudioOutputProxy(TMMFMessageDestinationPckg aMessageHandler, |
|
37 MCustomCommand& aCustomCommand, |
|
38 CCustomInterfaceUtility* aCustomInterfaceUtility) : |
|
39 iCustomCommand(&aCustomCommand), |
|
40 iMessageHandler(aMessageHandler), |
|
41 iCustomInterfaceUtility(aCustomInterfaceUtility) |
|
42 { |
|
43 iOutput = ENoPreference; |
|
44 iDefaultOutput = ENoPreference; |
|
45 iSecureOutput = EFalse; |
|
46 iRegistered = EFalse; |
|
47 } |
|
48 |
|
49 // Two-phased constructor. |
|
50 EXPORT_C CAudioOutputProxy* CAudioOutputProxy::NewL(TMMFMessageDestinationPckg aMessageHandler, |
|
51 MCustomCommand& aCustomCommand, |
|
52 CCustomInterfaceUtility* aCustomInterfaceUtility) |
|
53 { |
|
54 CAudioOutputProxy* self = new(ELeave) CAudioOutputProxy(aMessageHandler,aCustomCommand,aCustomInterfaceUtility); |
|
55 self->ConstructL(); |
|
56 return self; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CAudioOutputProxy::ConstructL |
|
61 // Symbian 2nd phase constructor can leave. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 void CAudioOutputProxy::ConstructL() |
|
65 { |
|
66 } |
|
67 |
|
68 // Destructor |
|
69 CAudioOutputProxy::~CAudioOutputProxy() |
|
70 { |
|
71 if (iRegistered != EFalse) |
|
72 { |
|
73 if(iObserver) |
|
74 UnregisterObserver(*iObserver); |
|
75 } |
|
76 |
|
77 if (iCustomCommand) |
|
78 { |
|
79 iCustomCommand->CustomCommandSync(iMessageHandler, EAofDelete, KNullDesC8, KNullDesC8); |
|
80 } |
|
81 |
|
82 if(iAsyncSender) |
|
83 { |
|
84 delete iAsyncSender; |
|
85 iAsyncSender = NULL; |
|
86 } |
|
87 |
|
88 if(iCustomInterfaceUtility) |
|
89 { |
|
90 iCustomInterfaceUtility->RemoveCustomInterface(iMessageHandler); |
|
91 delete iCustomInterfaceUtility; |
|
92 iCustomInterfaceUtility = NULL; |
|
93 } |
|
94 } |
|
95 |
|
96 // --------------------------------------------------------- |
|
97 // CAudioOutput::Uid |
|
98 // ?implementation_description |
|
99 // (other items were commented in a header). |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C const TUid CAudioOutputProxy::Uid() |
|
103 { |
|
104 return KUidAudioOutput; |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------- |
|
108 // CAudioOutput::AudioOutput |
|
109 // ?implementation_description |
|
110 // (other items were commented in a header). |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 CAudioOutput::TAudioOutputPreference CAudioOutputProxy::AudioOutput() |
|
114 { |
|
115 |
|
116 TPckgBuf<TAudioOutputPreference> outPutPckg; |
|
117 TInt error = iCustomCommand->CustomCommandSync(iMessageHandler, (TInt)EAofGetAudioOutput, KNullDesC8, KNullDesC8, outPutPckg); |
|
118 |
|
119 if (KErrNone == error) |
|
120 iOutput = outPutPckg(); |
|
121 else |
|
122 iOutput = ENoPreference; |
|
123 |
|
124 return iOutput; |
|
125 } |
|
126 // --------------------------------------------------------- |
|
127 // CAudioOutput::DefaultAudioOutput |
|
128 // ?implementation_description |
|
129 // (other items were commented in a header). |
|
130 // --------------------------------------------------------- |
|
131 // |
|
132 CAudioOutput::TAudioOutputPreference CAudioOutputProxy::DefaultAudioOutput() |
|
133 { |
|
134 return iDefaultOutput; |
|
135 } |
|
136 // --------------------------------------------------------- |
|
137 // CAudioOutput::RegisterObserverL |
|
138 // ?implementation_description |
|
139 // (other items were commented in a header). |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CAudioOutputProxy::RegisterObserverL(MAudioOutputObserver& aObserver) |
|
143 { |
|
144 if(iRegistered) |
|
145 { |
|
146 iObserver = &aObserver; |
|
147 iAsyncSender->SetObserver(aObserver); |
|
148 } |
|
149 else |
|
150 { |
|
151 iRegistered = ETrue; |
|
152 iObserver = &aObserver; |
|
153 delete iAsyncSender; |
|
154 iAsyncSender = NULL; |
|
155 |
|
156 iAsyncSender = CAudioOutputProxyAO::NewL(this,aObserver,iCustomCommand); |
|
157 iAsyncSender->SetRegisterFlag(ETrue); |
|
158 iAsyncSender->SendAsyncMessage(iMessageHandler,EAofRegisterObserver); |
|
159 } |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------- |
|
163 // CAudioOutput::SecureOutput |
|
164 // ?implementation_description |
|
165 // (other items were commented in a header). |
|
166 // --------------------------------------------------------- |
|
167 // |
|
168 TBool CAudioOutputProxy::SecureOutput() |
|
169 { |
|
170 return iSecureOutput; |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------- |
|
174 // CAudioOutput::SetAudioOutputL |
|
175 // ?implementation_description |
|
176 // (other items were commented in a header). |
|
177 // --------------------------------------------------------- |
|
178 // |
|
179 void CAudioOutputProxy::SetAudioOutputL(TAudioOutputPreference aAudioOutput) |
|
180 { |
|
181 iOutput = aAudioOutput; |
|
182 TPckgC<TAudioOutputPreference> outputPckg(aAudioOutput); |
|
183 iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetAudioOutput, outputPckg, KNullDesC8); |
|
184 } |
|
185 // --------------------------------------------------------- |
|
186 // CAudioOutput::SetAudioOutputL |
|
187 // ?implementation_description |
|
188 // (other items were commented in a header). |
|
189 // --------------------------------------------------------- |
|
190 // |
|
191 void CAudioOutputProxy::SetSecureOutputL(TBool aSecureOutput) |
|
192 { |
|
193 iSecureOutput = aSecureOutput; |
|
194 TPckgC<TBool> outputPckg(aSecureOutput); |
|
195 TInt err = KErrNone; |
|
196 //ou1cimx1#454515 CAudioOutputConfigurator::SetSecureOutputL() is deprecated |
|
197 err = iCustomCommand->CustomCommandSync(iMessageHandler, EAofSetSecureOutput, outputPckg, KNullDesC8); |
|
198 if(err != KErrNone) |
|
199 { |
|
200 User::Leave(err); |
|
201 } |
|
202 |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------- |
|
206 // CAudioOutput::RegisterObserverL |
|
207 // ?implementation_description |
|
208 // (other items were commented in a header). |
|
209 // --------------------------------------------------------- |
|
210 // |
|
211 void CAudioOutputProxy::UnregisterObserver(MAudioOutputObserver& aObserver) |
|
212 { |
|
213 iRegistered = EFalse; |
|
214 if (iObserver == &aObserver) |
|
215 { |
|
216 if (iAsyncSender) |
|
217 { |
|
218 iAsyncSender->SetRegisterFlag(EFalse); |
|
219 iCustomCommand->CustomCommandSync(iMessageHandler, EAofUnregisterObserver, KNullDesC8, KNullDesC8); |
|
220 iObserver = NULL; |
|
221 } |
|
222 } |
|
223 } |
|
224 |
|
225 |
|
226 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
227 |
|
228 |
|
229 |
|
230 // End of File |