Merge lp:~phablet-team/qtubuntu-media/fix-1457129 into lp:qtubuntu-media

Proposed by Jim Hodapp
Status: Merged
Approved by: Bill Filler
Approved revision: 76
Merged at revision: 76
Proposed branch: lp:~phablet-team/qtubuntu-media/fix-1457129
Merge into: lp:qtubuntu-media
Diff against target: 137 lines (+29/-14)
1 file modified
src/aal/aalmediaplayerservice.cpp (+29/-14)
To merge this branch: bzr merge lp:~phablet-team/qtubuntu-media/fix-1457129
Reviewer Review Type Date Requested Status
PS Jenkins bot continuous-integration Approve
Bill Filler Pending
Review via email: mp+260322@code.launchpad.net

Commit message

Wrap seek_to() in a try/catch block so that an exception from libmedia-hub-client is not pushed up to the QML level. Do the same for get/set audio role.

Description of the change

Wrap seek_to() in a try/catch block so that an exception from libmedia-hub-client is not pushed up to the QML level. Do the same for get/set audio role.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'src/aal/aalmediaplayerservice.cpp'
--- src/aal/aalmediaplayerservice.cpp 2015-05-22 17:36:54 +0000
+++ src/aal/aalmediaplayerservice.cpp 2015-05-27 15:02:27 +0000
@@ -163,7 +163,7 @@
163 try {163 try {
164 m_hubPlayerSession = m_hubService->create_session(media::Player::Client::default_configuration());164 m_hubPlayerSession = m_hubService->create_session(media::Player::Client::default_configuration());
165 }165 }
166 catch (std::runtime_error &e) {166 catch (const std::runtime_error &e) {
167 qWarning() << "Failed to start a new media-hub player session: " << e.what();167 qWarning() << "Failed to start a new media-hub player session: " << e.what();
168 return false;168 return false;
169 }169 }
@@ -197,7 +197,13 @@
197 if (m_hubPlayerSession == NULL)197 if (m_hubPlayerSession == NULL)
198 return QMediaPlayer::MultimediaRole;198 return QMediaPlayer::MultimediaRole;
199199
200 return static_cast<QMediaPlayer::AudioRole>(m_hubPlayerSession->audio_stream_role().get());200 try {
201 return static_cast<QMediaPlayer::AudioRole>(m_hubPlayerSession->audio_stream_role().get());
202 }
203 catch (const std::runtime_error &e) {
204 qWarning() << "Failed to get audio stream role: " << e.what();
205 return QMediaPlayer::MultimediaRole;
206 }
201}207}
202208
203void AalMediaPlayerService::setAudioRole(QMediaPlayer::AudioRole audioRole)209void AalMediaPlayerService::setAudioRole(QMediaPlayer::AudioRole audioRole)
@@ -205,8 +211,12 @@
205 if (m_hubPlayerSession == NULL)211 if (m_hubPlayerSession == NULL)
206 return;212 return;
207213
208 qDebug() << __PRETTY_FUNCTION__;214 try {
209 m_hubPlayerSession->audio_stream_role().set(static_cast<media::Player::AudioStreamRole>(audioRole));215 m_hubPlayerSession->audio_stream_role().set(static_cast<media::Player::AudioStreamRole>(audioRole));
216 }
217 catch (const std::runtime_error &e) {
218 qWarning() << "Failed to set audio stream role: " << e.what();
219 }
210}220}
211221
212void AalMediaPlayerService::setMediaPlaylist(const QMediaPlaylist &playlist)222void AalMediaPlayerService::setMediaPlaylist(const QMediaPlaylist &playlist)
@@ -243,7 +253,7 @@
243 try {253 try {
244 m_hubPlayerSession->open_uri(uri);254 m_hubPlayerSession->open_uri(uri);
245 }255 }
246 catch (std::runtime_error &e) {256 catch (const std::runtime_error &e) {
247 qWarning() << "Failed to open media " << url << ": " << e.what();257 qWarning() << "Failed to open media " << url << ": " << e.what();
248 return;258 return;
249 }259 }
@@ -287,7 +297,7 @@
287297
288 m_mediaPlayerControl->mediaPrepared();298 m_mediaPlayerControl->mediaPrepared();
289 }299 }
290 catch (std::runtime_error &e) {300 catch (const std::runtime_error &e) {
291 qWarning() << "Failed to start playback: " << e.what();301 qWarning() << "Failed to start playback: " << e.what();
292 return;302 return;
293 }303 }
@@ -307,7 +317,7 @@
307 try {317 try {
308 m_hubPlayerSession->pause();318 m_hubPlayerSession->pause();
309 }319 }
310 catch (std::runtime_error &e) {320 catch (const std::runtime_error &e) {
311 qWarning() << "Failed to pause playback: " << e.what();321 qWarning() << "Failed to pause playback: " << e.what();
312 return;322 return;
313 }323 }
@@ -325,7 +335,7 @@
325 m_hubPlayerSession->stop();335 m_hubPlayerSession->stop();
326 m_videoOutputReady = false;336 m_videoOutputReady = false;
327 }337 }
328 catch (std::runtime_error &e) {338 catch (const std::runtime_error &e) {
329 qWarning() << "Failed to stop playback: " << e.what();339 qWarning() << "Failed to stop playback: " << e.what();
330 return;340 return;
331 }341 }
@@ -342,7 +352,7 @@
342 try {352 try {
343 return m_hubPlayerSession->position() / 1e6;353 return m_hubPlayerSession->position() / 1e6;
344 }354 }
345 catch (std::runtime_error &e) {355 catch (const std::runtime_error &e) {
346 qWarning() << "Failed to get current playback position: " << e.what();356 qWarning() << "Failed to get current playback position: " << e.what();
347 return 0;357 return 0;
348 }358 }
@@ -355,7 +365,12 @@
355 qWarning() << "Cannot set current playback position without a valid media-hub player session";365 qWarning() << "Cannot set current playback position without a valid media-hub player session";
356 return;366 return;
357 }367 }
358 m_hubPlayerSession->seek_to(std::chrono::microseconds{msec * 1000});368 try {
369 m_hubPlayerSession->seek_to(std::chrono::microseconds{msec * 1000});
370 }
371 catch (const std::runtime_error &e) {
372 qWarning() << "Failed to set position to " << msec << ": " << e.what();
373 }
359}374}
360375
361int64_t AalMediaPlayerService::duration()376int64_t AalMediaPlayerService::duration()
@@ -376,7 +391,7 @@
376 }391 }
377 return d / 1e6;392 return d / 1e6;
378 }393 }
379 catch (std::runtime_error &e) {394 catch (const std::runtime_error &e) {
380 qWarning() << "Failed to get current playback duration: " << e.what();395 qWarning() << "Failed to get current playback duration: " << e.what();
381 return 0;396 return 0;
382 }397 }
@@ -393,7 +408,7 @@
393 try {408 try {
394 return m_hubPlayerSession->is_video_source();409 return m_hubPlayerSession->is_video_source();
395 }410 }
396 catch (std::runtime_error &e) {411 catch (const std::runtime_error &e) {
397 qWarning() << "Failed to check if source is video: " << e.what();412 qWarning() << "Failed to check if source is video: " << e.what();
398 return false;413 return false;
399 }414 }
@@ -410,7 +425,7 @@
410 try {425 try {
411 return m_hubPlayerSession->is_audio_source();426 return m_hubPlayerSession->is_audio_source();
412 }427 }
413 catch (std::runtime_error &e) {428 catch (const std::runtime_error &e) {
414 qWarning() << "Failed to check if source is video: " << e.what();429 qWarning() << "Failed to check if source is video: " << e.what();
415 return false;430 return false;
416 }431 }
@@ -427,7 +442,7 @@
427 try {442 try {
428 return m_hubPlayerSession->volume();443 return m_hubPlayerSession->volume();
429 }444 }
430 catch (std::runtime_error &e) {445 catch (const std::runtime_error &e) {
431 qWarning() << "Failed to get current volume level: " << e.what();446 qWarning() << "Failed to get current volume level: " << e.what();
432 return 0;447 return 0;
433 }448 }

Subscribers

People subscribed via source and target branches

to all changes: