41 |
41 |
42 #include "s60audioplayersession.h" |
42 #include "s60audioplayersession.h" |
43 #include <QtCore/qdebug.h> |
43 #include <QtCore/qdebug.h> |
44 #include <QtCore/qvariant.h> |
44 #include <QtCore/qvariant.h> |
45 |
45 |
46 #include <AudioOutput.h> |
|
47 #include <MAudioOutputObserver.h> |
|
48 |
|
49 S60AudioPlayerSession::S60AudioPlayerSession(QObject *parent) |
46 S60AudioPlayerSession::S60AudioPlayerSession(QObject *parent) |
50 : S60MediaPlayerSession(parent) |
47 : S60MediaPlayerSession(parent) |
51 , m_player(0) |
48 , m_player(0) |
52 , m_audioOutput(0) |
|
53 , m_audioEndpoint("Default") |
49 , m_audioEndpoint("Default") |
54 { |
50 { |
|
51 #ifdef HAS_AUDIOROUTING |
|
52 m_audioOutput = 0; |
|
53 #endif //HAS_AUDIOROUTING |
55 QT_TRAP_THROWING(m_player = CAudioPlayer::NewL(*this, 0, EMdaPriorityPreferenceNone)); |
54 QT_TRAP_THROWING(m_player = CAudioPlayer::NewL(*this, 0, EMdaPriorityPreferenceNone)); |
56 m_player->RegisterForAudioLoadingNotification(*this); |
55 m_player->RegisterForAudioLoadingNotification(*this); |
57 } |
56 } |
58 |
57 |
59 S60AudioPlayerSession::~S60AudioPlayerSession() |
58 S60AudioPlayerSession::~S60AudioPlayerSession() |
60 { |
59 { |
61 #if !defined(HAS_NO_AUDIOROUTING) |
60 #ifdef HAS_AUDIOROUTING |
62 if (m_audioOutput) |
61 if (m_audioOutput) |
63 m_audioOutput->UnregisterObserver(*this); |
62 m_audioOutput->UnregisterObserver(*this); |
64 delete m_audioOutput; |
63 delete m_audioOutput; |
65 #endif |
64 #endif |
66 m_player->Close(); |
65 m_player->Close(); |
67 delete m_player; |
66 delete m_player; |
68 } |
67 } |
69 |
68 |
70 void S60AudioPlayerSession::doLoadL(const TDesC &path) |
69 void S60AudioPlayerSession::doLoadL(const TDesC &path) |
71 { |
70 { |
|
71 #ifdef HAS_AUDIOROUTING |
72 // m_audioOutput needs to be reinitialized after MapcInitComplete |
72 // m_audioOutput needs to be reinitialized after MapcInitComplete |
73 if (m_audioOutput) |
73 if (m_audioOutput) |
74 m_audioOutput->UnregisterObserver(*this); |
74 m_audioOutput->UnregisterObserver(*this); |
75 delete m_audioOutput; |
75 delete m_audioOutput; |
76 m_audioOutput = NULL; |
76 m_audioOutput = NULL; |
77 |
77 #endif //HAS_AUDIOROUTING |
78 m_player->OpenFileL(path); |
78 m_player->OpenFileL(path); |
79 } |
79 } |
80 |
80 |
81 qint64 S60AudioPlayerSession::doGetDurationL() const |
81 qint64 S60AudioPlayerSession::doGetDurationL() const |
82 { |
82 { |
171 void S60AudioPlayerSession::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration) |
171 void S60AudioPlayerSession::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aDuration) |
172 #endif |
172 #endif |
173 { |
173 { |
174 Q_UNUSED(aDuration); |
174 Q_UNUSED(aDuration); |
175 setError(aError); |
175 setError(aError); |
|
176 #ifdef HAS_AUDIOROUTING |
176 TRAPD(err, |
177 TRAPD(err, |
177 m_audioOutput = CAudioOutput::NewL(*m_player); |
178 m_audioOutput = CAudioOutput::NewL(*m_player); |
178 m_audioOutput->RegisterObserverL(*this); |
179 m_audioOutput->RegisterObserverL(*this); |
179 ); |
180 ); |
180 setActiveEndpoint(m_audioEndpoint); |
181 setActiveEndpoint(m_audioEndpoint); |
181 setError(err); |
182 setError(err); |
|
183 #endif //HAS_AUDIOROUTING |
182 loaded(); |
184 loaded(); |
183 } |
185 } |
184 |
186 |
185 #ifdef S60_DRM_SUPPORTED |
187 #ifdef S60_DRM_SUPPORTED |
186 void S60AudioPlayerSession::MdapcPlayComplete(TInt aError) |
188 void S60AudioPlayerSession::MdapcPlayComplete(TInt aError) |
198 } |
200 } |
199 |
201 |
200 QString S60AudioPlayerSession::activeEndpoint() const |
202 QString S60AudioPlayerSession::activeEndpoint() const |
201 { |
203 { |
202 QString outputName = QString("Default"); |
204 QString outputName = QString("Default"); |
203 #if !defined(HAS_NO_AUDIOROUTING) |
205 #ifdef HAS_AUDIOROUTING |
204 if (m_audioOutput) { |
206 if (m_audioOutput) { |
205 CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); |
207 CAudioOutput::TAudioOutputPreference output = m_audioOutput->AudioOutput(); |
206 outputName = qStringFromTAudioOutputPreference(output); |
208 outputName = qStringFromTAudioOutputPreference(output); |
207 } |
209 } |
208 #endif |
210 #endif |
210 } |
212 } |
211 |
213 |
212 QString S60AudioPlayerSession::defaultEndpoint() const |
214 QString S60AudioPlayerSession::defaultEndpoint() const |
213 { |
215 { |
214 QString outputName = QString("Default"); |
216 QString outputName = QString("Default"); |
215 #if !defined(HAS_NO_AUDIOROUTING) |
217 #ifdef HAS_AUDIOROUTING |
216 if (m_audioOutput) { |
218 if (m_audioOutput) { |
217 CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); |
219 CAudioOutput::TAudioOutputPreference output = m_audioOutput->DefaultAudioOutput(); |
218 outputName = qStringFromTAudioOutputPreference(output); |
220 outputName = qStringFromTAudioOutputPreference(output); |
219 } |
221 } |
220 #endif |
222 #endif |
221 return outputName; |
223 return outputName; |
222 } |
224 } |
223 |
225 |
224 void S60AudioPlayerSession::setActiveEndpoint(const QString& name) |
226 void S60AudioPlayerSession::setActiveEndpoint(const QString& name) |
225 { |
227 { |
|
228 #ifdef HAS_AUDIOROUTING |
226 CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; |
229 CAudioOutput::TAudioOutputPreference output = CAudioOutput::ENoPreference; |
227 |
230 |
228 if (name == QString("Default")) |
231 if (name == QString("Default")) |
229 output = CAudioOutput::ENoPreference; |
232 output = CAudioOutput::ENoPreference; |
230 else if (name == QString("All")) |
233 else if (name == QString("All")) |
233 output = CAudioOutput::ENoOutput; |
236 output = CAudioOutput::ENoOutput; |
234 else if (name == QString("Earphone")) |
237 else if (name == QString("Earphone")) |
235 output = CAudioOutput::EPrivate; |
238 output = CAudioOutput::EPrivate; |
236 else if (name == QString("Speaker")) |
239 else if (name == QString("Speaker")) |
237 output = CAudioOutput::EPublic; |
240 output = CAudioOutput::EPublic; |
238 #if !defined(HAS_NO_AUDIOROUTING) |
241 |
239 if (m_audioOutput) { |
242 if (m_audioOutput) { |
240 TRAPD(err, m_audioOutput->SetAudioOutputL(output)); |
243 TRAPD(err, m_audioOutput->SetAudioOutputL(output)); |
241 setError(err); |
244 setError(err); |
242 |
245 |
243 if (m_audioEndpoint != name) { |
246 if (m_audioEndpoint != name) { |
245 emit activeEndpointChanged(name); |
248 emit activeEndpointChanged(name); |
246 } |
249 } |
247 } |
250 } |
248 #endif |
251 #endif |
249 } |
252 } |
250 |
253 #ifdef HAS_AUDIOROUTING |
251 void S60AudioPlayerSession::DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, |
254 void S60AudioPlayerSession::DefaultAudioOutputChanged(CAudioOutput& aAudioOutput, |
252 CAudioOutput::TAudioOutputPreference aNewDefault) |
255 CAudioOutput::TAudioOutputPreference aNewDefault) |
253 { |
256 { |
254 // Emit already implemented in setActiveEndpoint function |
257 // Emit already implemented in setActiveEndpoint function |
255 Q_UNUSED(aAudioOutput) |
258 Q_UNUSED(aAudioOutput) |