|
1 /* |
|
2 * Copyright (c) 2005 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: Manipulates the virtual location of the spectator. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <logger.h> |
|
22 #include "cammsspectatorlocationcontrol.h" |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CAMMSSpectatorLocationControl::NewLC |
|
29 // Two-phased constructor. |
|
30 // ----------------------------------------------------------------------------- |
|
31 CAMMSSpectatorLocationControl* CAMMSSpectatorLocationControl::NewLC( |
|
32 CMMAPlayer* aPlayer) |
|
33 { |
|
34 CAMMSSpectatorLocationControl* self = new(ELeave) |
|
35 CAMMSSpectatorLocationControl(aPlayer); |
|
36 |
|
37 CleanupStack::PushL(self); |
|
38 |
|
39 return self; |
|
40 } |
|
41 |
|
42 // Destructor |
|
43 CAMMSSpectatorLocationControl::~CAMMSSpectatorLocationControl() |
|
44 { |
|
45 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSSpectatorLocationControl::~CAMMSSpectatorLocationControl"); |
|
46 |
|
47 // Perform DeallocateControl, if the state change has not yet performed it. |
|
48 DeallocateControl(); |
|
49 delete(CAudioEffect*)iLocationEffect; |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CAMMSSpectatorLocationControl::PrepareControlL |
|
54 // Function which is called after the correct state is set in Player. |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 void CAMMSSpectatorLocationControl::PrepareControlL() |
|
58 { |
|
59 // Perform the action only for the first time, skip if called afterwards |
|
60 if (!iLocationEffect) |
|
61 { |
|
62 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSSpectatorLocationControl::PrepareControlL"); |
|
63 |
|
64 CCustomCommandUtility* customCommandUtility = |
|
65 CreateCustomCommandUtilityL(); |
|
66 |
|
67 // Set the base class location effect as CListenerLocation |
|
68 // Effect API takes the ownership of customCommandUtility. |
|
69 iLocationEffect = CListenerLocation::NewL(customCommandUtility); |
|
70 |
|
71 // Enable the Effect API Control |
|
72 iLocationEffect->EnableL(); |
|
73 } |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CAMMSSpectatorLocationControl::DeallocateControl |
|
78 // Function which is called after the correct state is set in Player. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CAMMSSpectatorLocationControl::DeallocateControl() |
|
82 { |
|
83 if (iLocationEffect) |
|
84 { |
|
85 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSSpectatorLocationControl::DeallocateControl"); |
|
86 |
|
87 // Disable the Effect API Control |
|
88 TRAPD(err, iLocationEffect->DisableL()); |
|
89 if (err != KErrNone) |
|
90 { |
|
91 // The only even theoritically possible error code here would be |
|
92 // KErrAccessDenied which is a result from Effect API calling ApplyL |
|
93 // method without having update rights, but since the Effect |
|
94 // is already created, that situation can be discarded here. |
|
95 } |
|
96 |
|
97 // Delete the Effect API class. |
|
98 // The class that is derived from CLocation is casted here to the |
|
99 // base class CAudioEffect, since CLocation has the destructor |
|
100 // defined as protected, but the derived class and the base class |
|
101 // have it defined as public. |
|
102 delete(CAudioEffect*)iLocationEffect; |
|
103 iLocationEffect = NULL; |
|
104 } |
|
105 } |
|
106 |
|
107 const TDesC& CAMMSSpectatorLocationControl::ClassName() const |
|
108 { |
|
109 return KAMMSSpectatorLocationControl; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CAMMSSpectatorLocationControl::CAMMSSpectatorLocationControl |
|
114 // C++ default constructor can NOT contain any code, that |
|
115 // might leave. |
|
116 // ----------------------------------------------------------------------------- |
|
117 CAMMSSpectatorLocationControl::CAMMSSpectatorLocationControl( |
|
118 CMMAPlayer* aPlayer) |
|
119 : CAMMSLocationControl(aPlayer) |
|
120 { |
|
121 } |
|
122 |
|
123 |
|
124 // End of File |