1 /* |
|
2 * Copyright (c) 2008 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 policy implementation for upnp remote plugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDES |
|
24 #include <mmf/common/mmfbase.h> // MMF base classes |
|
25 |
|
26 #include <S60FourCC.h> |
|
27 #include <AudioPreference.h> |
|
28 #include "upnpaudiopolicy.h" // myself |
|
29 |
|
30 _LIT( KComponentLogfile, "musicplugins.txt"); |
|
31 #include "upnplog.h" |
|
32 // CONSTANTS |
|
33 |
|
34 // ======== MEMBER FUNCTIONS ======== |
|
35 |
|
36 // -------------------------------------------------------------------------- |
|
37 // CUPnPAudioPolicy::NewL |
|
38 // 1st phase constructor. |
|
39 // -------------------------------------------------------------------------- |
|
40 // |
|
41 CUPnPAudioPolicy* CUPnPAudioPolicy::NewL( |
|
42 MUPnPAudioPolicyObserver& aObserver ) |
|
43 { |
|
44 __LOG( "CUPnPAudioPolicy::NewL 1" ); |
|
45 CUPnPAudioPolicy* self = |
|
46 new(ELeave) CUPnPAudioPolicy( aObserver ); |
|
47 CleanupStack::PushL( self ); |
|
48 self->ConstructL(); |
|
49 CleanupStack::Pop( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // -------------------------------------------------------------------------- |
|
54 // CUPnPAudioPolicy::CUPnPAudioPolicy |
|
55 // Default constructor. |
|
56 // -------------------------------------------------------------------------- |
|
57 // |
|
58 CUPnPAudioPolicy::CUPnPAudioPolicy( |
|
59 MUPnPAudioPolicyObserver& aObserver ) |
|
60 : iObserver( aObserver ) |
|
61 , iAudioPolicyState( EStateUninitialised ) |
|
62 { |
|
63 } |
|
64 |
|
65 // -------------------------------------------------------------------------- |
|
66 // CUPnPTrack::ConstructL |
|
67 // -------------------------------------------------------------------------- |
|
68 // |
|
69 void CUPnPAudioPolicy::ConstructL() |
|
70 { |
|
71 __LOG( "CUPnPAudioPolicy::ConstructL" ); |
|
72 iDevSound = CMMFDevSound::NewL(); |
|
73 __LOG( "CUPnPAudioPolicy::ConstructL end" ); |
|
74 } |
|
75 |
|
76 // -------------------------------------------------------------------------- |
|
77 // CUPnPAudioPolicy::CUPnPAudioPolicy |
|
78 // destructor. |
|
79 // -------------------------------------------------------------------------- |
|
80 // |
|
81 CUPnPAudioPolicy::~CUPnPAudioPolicy() |
|
82 { |
|
83 __LOG( "CUPnPAudioPolicy destructor" ); |
|
84 delete iDevSound; |
|
85 } |
|
86 |
|
87 // -------------------------------------------------------------------------- |
|
88 // CUPnPAudioPolicy::PlayL |
|
89 // requests for playback start |
|
90 // -------------------------------------------------------------------------- |
|
91 // |
|
92 void CUPnPAudioPolicy::PlayL() |
|
93 { |
|
94 __LOG( "CUPnPAudioPolicy::PlayL()" ); |
|
95 __LOG1( "CUPnPAudioPolicy::PlayL in state(%d)", TInt(iAudioPolicyState) ); |
|
96 |
|
97 // Ignore if already on playing state |
|
98 if( iAudioPolicyState != EStatePlaying ) |
|
99 { |
|
100 __LOG( "CUPnPAudioPolicy: initialising devsound" ); |
|
101 TRAPD( err, iDevSound->InitializeL( |
|
102 *this, KFourCCCodeNokiaUPnP, EMMFStatePlaying ) ); |
|
103 if( err != KErrNone ) |
|
104 { |
|
105 __LOG1( "CUPnPAudioPolicy: DevSound initialize err:(%d)",err ); |
|
106 } |
|
107 } |
|
108 } |
|
109 |
|
110 // -------------------------------------------------------------------------- |
|
111 // CUPnPAudioPolicy::Stop |
|
112 // indicates playback will stop |
|
113 // -------------------------------------------------------------------------- |
|
114 // |
|
115 void CUPnPAudioPolicy::Stop() |
|
116 { |
|
117 __LOG( "CUPnPAudioPolicy::Stop()" ); |
|
118 __LOG1( "CUPnPAudioPolicy::Stop in state(%d)", TInt(iAudioPolicyState) ); |
|
119 |
|
120 // Ignore if already on stopped state |
|
121 if( iAudioPolicyState == EStatePlaying ) |
|
122 { |
|
123 iAudioPolicyState = EStateStopped; |
|
124 iDevSound->Stop(); |
|
125 } |
|
126 } |
|
127 |
|
128 // -------------------------------------------------------------------------- |
|
129 // CUPnPAudioPolicy::InitializeComplete |
|
130 // from MDevSoundObserver |
|
131 // -------------------------------------------------------------------------- |
|
132 // |
|
133 void CUPnPAudioPolicy::InitializeComplete( TInt aError ) |
|
134 { |
|
135 __LOG1( "CUPnPAudioPolicy::InitializeComplete(%d)", aError ); |
|
136 __LOG1( "CUPnPAudioPolicy::InitializeCompl in state(%d)", |
|
137 TInt(iAudioPolicyState) ); |
|
138 if( aError == KErrNone && iAudioPolicyState != EStatePlaying ) |
|
139 { |
|
140 __LOG( "CUPnPAudioPolicy: priority settings" ); |
|
141 TMMFPrioritySettings mmfPrioSettings; |
|
142 mmfPrioSettings.iPriority = KAudioPriorityUPnPRemotePlayback; |
|
143 mmfPrioSettings.iPref = |
|
144 (TMdaPriorityPreference)KAudioPrefUPnPPlayback; |
|
145 mmfPrioSettings.iState = EMMFStatePlaying; |
|
146 iDevSound->SetPrioritySettings(mmfPrioSettings); |
|
147 |
|
148 __LOG( "CUPnPAudioPolicy::InitializeComple calling PlayInitL.." ); |
|
149 TRAPD( err, iDevSound->PlayInitL() ); |
|
150 if( err == KErrNone ) |
|
151 { |
|
152 iAudioPolicyState = EStatePlaying; |
|
153 } |
|
154 else |
|
155 { |
|
156 __LOG1( "CUPnPAudioPolicy: PlayInitL err:(%d)", err ); |
|
157 } |
|
158 __LOG( "CUPnPAudioPolicy::InitializeComplete - end" ); |
|
159 } |
|
160 } |
|
161 |
|
162 // -------------------------------------------------------------------------- |
|
163 // CUPnPAudioPolicy::PlayError |
|
164 // from MDevSoundObserver |
|
165 // -------------------------------------------------------------------------- |
|
166 // |
|
167 void CUPnPAudioPolicy::PlayError( TInt aError ) |
|
168 { |
|
169 __LOG1( "CUPnPAudioPolicy::PlayError(%d)", aError ); |
|
170 __LOG1( "CUPnPAudioPolicylicy::PlayError in state(%d)", |
|
171 TInt(iAudioPolicyState) ); |
|
172 if ( aError == KErrDied || aError == KErrInUse ) |
|
173 { |
|
174 iAudioPolicyState = EStateStopped; |
|
175 iObserver.AudioConflict( aError ); |
|
176 } |
|
177 } |
|
178 |
|
179 // -------------------------------------------------------------------------- |
|
180 // Unused callbacks from MDevSoundObserver |
|
181 // -------------------------------------------------------------------------- |
|
182 void CUPnPAudioPolicy::ToneFinished( TInt /*aError*/ ) |
|
183 { |
|
184 __LOG( "CUPnPAudioPolicy::ToneFinished()" ); |
|
185 } |
|
186 void CUPnPAudioPolicy::BufferToBeFilled( CMMFBuffer* /*aBuffer*/ ) |
|
187 { |
|
188 __LOG( "CUPnPAudioPolicy::BufferToBeFilled()" ); |
|
189 } |
|
190 void CUPnPAudioPolicy::DeviceMessage( TUid /*aMessageType*/, |
|
191 const TDesC8& /*aMsg*/ ) |
|
192 { |
|
193 __LOG( "CUPnPAudioPolicy::DeviceMessage()" ); |
|
194 } |
|
195 void CUPnPAudioPolicy::SendEventToClient( const TMMFEvent& /*aEvent*/ ) |
|
196 { |
|
197 __LOG( "CUPnPAudioPolicy::SendEventToClient()" ); |
|
198 } |
|
199 void CUPnPAudioPolicy::RecordError( TInt /*aError*/ ) |
|
200 { |
|
201 __LOG( "CUPnPAudioPolicy::RecordError()" ); |
|
202 } |
|
203 void CUPnPAudioPolicy::ConvertError( TInt /*aError*/ ) |
|
204 { |
|
205 __LOG( "CUPnPAudioPolicy::ConvertError()" ); |
|
206 } |
|
207 void CUPnPAudioPolicy::BufferToBeEmptied( CMMFBuffer* /*aBuffer*/ ) |
|
208 { |
|
209 __LOG( "CUPnPAudioPolicy::BufferToBeEmptied()" ); |
|
210 } |
|
211 |
|