1 /* |
|
2 * Copyright (c) 2009 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 audio output mode. |
|
15 * |
|
16 */ |
|
17 #ifndef CAMMSAUDIOOUTPUTCONTROL_H |
|
18 #define CAMMSAUDIOOUTPUTCONTROL_H |
|
19 |
|
20 // INCLUDES |
|
21 #include "cammscontrol.h" |
|
22 #include <cmmamidiplayer.h> |
|
23 #include <mmmaplayerstatelistener.h> |
|
24 // for audio routing control |
|
25 #include <AudioOutput.h> |
|
26 |
|
27 // for audio routing observers |
|
28 #include <MAudioOutputObserver.h> |
|
29 #include <AccMonitor.h> |
|
30 #include <AccMonitorInfo.h> |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 // CONSTANTS |
|
36 _LIT(KAMMSAudioOutputControl, "AudioOutputControl"); |
|
37 // CLASS DECLARATION |
|
38 |
|
39 /** |
|
40 * |
|
41 * Controls for the Audio Routing. |
|
42 * This class delegates Audio Routing setting calls to RMMFController. |
|
43 * |
|
44 * |
|
45 * @since X.X |
|
46 */ |
|
47 NONSHARABLE_CLASS(CAMMSAudioOutputControl) |
|
48 : public CAMMSControl, public MMMAPlayerStateListener ,public MAudioOutputObserver,public MAccMonitorObserver |
|
49 { |
|
50 public: |
|
51 // Constructors and destructor |
|
52 /** |
|
53 * Two-phased constructor. |
|
54 * @param aPlayer Player that has this control. |
|
55 */ |
|
56 static CAMMSAudioOutputControl* NewLC(CMMAPlayer* aPlayer); |
|
57 |
|
58 /** |
|
59 * Destructor. |
|
60 */ |
|
61 ~CAMMSAudioOutputControl(); |
|
62 |
|
63 public: |
|
64 // New functions |
|
65 /** |
|
66 * Sets the AudioOutput. |
|
67 * |
|
68 * @param aPreference The new AudioOutput to be set. |
|
69 */ |
|
70 TInt SetAudioOutput(TInt aPreference); |
|
71 |
|
72 /** |
|
73 * Gets the Audio Routing preference. |
|
74 * |
|
75 * @return The previously set Audio Routing preference. |
|
76 */ |
|
77 TInt GetAudioOutput(); |
|
78 /** |
|
79 * Reset the AudioOutput java object with changed value of current |
|
80 */ |
|
81 void GetCurrentPreference(); |
|
82 /** |
|
83 * Gets the Audio Routing preference. |
|
84 * |
|
85 * @return The previously set Audio Routing preference. and if not set retruns the device default |
|
86 */ |
|
87 |
|
88 TInt GetCurrentPrefInt(); |
|
89 /** |
|
90 * Gets the Audio Routing Device Default. |
|
91 * |
|
92 * @returns the device default |
|
93 */ |
|
94 TInt GetDeviceDefaultPreference(); |
|
95 /** |
|
96 * Create an Observer to get the notification for the Headset state. |
|
97 * Also initializes iCurrentActualPreference with CAudioOutput::EPrivate if headset is connected. |
|
98 * @returns the device default |
|
99 */ |
|
100 void CreateHeadsetStateObserverL(); |
|
101 /** |
|
102 * Actual native control is created using this function |
|
103 */ |
|
104 void CreateNativeAudioOutputControlL(); |
|
105 /** |
|
106 * seting java object used to send as callback event |
|
107 */ |
|
108 void SetJavaAudioOutputObject(jobject object); |
|
109 /** |
|
110 * Reset the value of java object with current values |
|
111 */ |
|
112 void ResetJavaAudioOutputObject(); |
|
113 /** |
|
114 * Check if there is any change in Current output Mode,It sends a event to java |
|
115 * If there is no change it returns silently |
|
116 */ |
|
117 void NotifyJavaOnChange(); |
|
118 |
|
119 |
|
120 public: |
|
121 // From MMMAPlayerStateListener |
|
122 void StateChanged(TInt aState); |
|
123 |
|
124 |
|
125 public: |
|
126 // From MAudioOutputObserver |
|
127 void DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, CAudioOutput::TAudioOutputPreference aNewDefault); |
|
128 void DisconnectedL(CAccMonitorInfo *aAccessoryInfo); |
|
129 void ConnectedL(CAccMonitorInfo* aAccessoryInfo); |
|
130 void AccMonitorObserverError(TInt aError); |
|
131 |
|
132 public: |
|
133 // Functions from base classes |
|
134 const TDesC& ClassName() const; |
|
135 |
|
136 protected: |
|
137 // New functions |
|
138 /** |
|
139 * @param aAmmsPreference AMMS preference to be set. |
|
140 */ |
|
141 TInt SetAudioOutputToMmf(CAudioOutput::TAudioOutputPreference aAmmsPreference); |
|
142 |
|
143 private: |
|
144 /** |
|
145 * C++ constructor. |
|
146 * @param aPlayer Player that has this control. |
|
147 */ |
|
148 CAMMSAudioOutputControl(CMMAPlayer* aPlayer); |
|
149 |
|
150 /** |
|
151 * Symbian 2nd phase constructor. |
|
152 */ |
|
153 void ConstructL(); |
|
154 |
|
155 private: |
|
156 //Data |
|
157 // Preference visible in AMMS. |
|
158 CAudioOutput::TAudioOutputPreference iRoutingUserPreference; |
|
159 // Preference of the device changes by inserting/removing Jack. |
|
160 CAudioOutput::TAudioOutputPreference iDefaultDevicePreference; |
|
161 // Preference of the device changes by inserting/removing Jack. |
|
162 TInt iCurrentPreference; |
|
163 // owned |
|
164 CAudioOutput* iAudioOutput; |
|
165 CMMAPlayer::TPlayerState playerState; |
|
166 //To get the peripheral attached/detached notification |
|
167 CAccMonitorInfo* iAccessoryInfo; |
|
168 RAccMonCapabilityArray capabilityArray; |
|
169 CAccMonitor *iAccMonitor; |
|
170 RConnectedAccessories array; |
|
171 jobject iJavaAudioOutputObj; |
|
172 JNIEnv* iJni; |
|
173 |
|
174 }; |
|
175 |
|
176 #endif // CAMMSAUDIOOUTPUTCONTROL_H |
|
177 |
|
178 |
|