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