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
1=== modified file 'src/aal/aalmediaplayerservice.cpp'
2--- src/aal/aalmediaplayerservice.cpp 2015-05-22 17:36:54 +0000
3+++ src/aal/aalmediaplayerservice.cpp 2015-05-27 15:02:27 +0000
4@@ -163,7 +163,7 @@
5 try {
6 m_hubPlayerSession = m_hubService->create_session(media::Player::Client::default_configuration());
7 }
8- catch (std::runtime_error &e) {
9+ catch (const std::runtime_error &e) {
10 qWarning() << "Failed to start a new media-hub player session: " << e.what();
11 return false;
12 }
13@@ -197,7 +197,13 @@
14 if (m_hubPlayerSession == NULL)
15 return QMediaPlayer::MultimediaRole;
16
17- return static_cast<QMediaPlayer::AudioRole>(m_hubPlayerSession->audio_stream_role().get());
18+ try {
19+ return static_cast<QMediaPlayer::AudioRole>(m_hubPlayerSession->audio_stream_role().get());
20+ }
21+ catch (const std::runtime_error &e) {
22+ qWarning() << "Failed to get audio stream role: " << e.what();
23+ return QMediaPlayer::MultimediaRole;
24+ }
25 }
26
27 void AalMediaPlayerService::setAudioRole(QMediaPlayer::AudioRole audioRole)
28@@ -205,8 +211,12 @@
29 if (m_hubPlayerSession == NULL)
30 return;
31
32- qDebug() << __PRETTY_FUNCTION__;
33- m_hubPlayerSession->audio_stream_role().set(static_cast<media::Player::AudioStreamRole>(audioRole));
34+ try {
35+ m_hubPlayerSession->audio_stream_role().set(static_cast<media::Player::AudioStreamRole>(audioRole));
36+ }
37+ catch (const std::runtime_error &e) {
38+ qWarning() << "Failed to set audio stream role: " << e.what();
39+ }
40 }
41
42 void AalMediaPlayerService::setMediaPlaylist(const QMediaPlaylist &playlist)
43@@ -243,7 +253,7 @@
44 try {
45 m_hubPlayerSession->open_uri(uri);
46 }
47- catch (std::runtime_error &e) {
48+ catch (const std::runtime_error &e) {
49 qWarning() << "Failed to open media " << url << ": " << e.what();
50 return;
51 }
52@@ -287,7 +297,7 @@
53
54 m_mediaPlayerControl->mediaPrepared();
55 }
56- catch (std::runtime_error &e) {
57+ catch (const std::runtime_error &e) {
58 qWarning() << "Failed to start playback: " << e.what();
59 return;
60 }
61@@ -307,7 +317,7 @@
62 try {
63 m_hubPlayerSession->pause();
64 }
65- catch (std::runtime_error &e) {
66+ catch (const std::runtime_error &e) {
67 qWarning() << "Failed to pause playback: " << e.what();
68 return;
69 }
70@@ -325,7 +335,7 @@
71 m_hubPlayerSession->stop();
72 m_videoOutputReady = false;
73 }
74- catch (std::runtime_error &e) {
75+ catch (const std::runtime_error &e) {
76 qWarning() << "Failed to stop playback: " << e.what();
77 return;
78 }
79@@ -342,7 +352,7 @@
80 try {
81 return m_hubPlayerSession->position() / 1e6;
82 }
83- catch (std::runtime_error &e) {
84+ catch (const std::runtime_error &e) {
85 qWarning() << "Failed to get current playback position: " << e.what();
86 return 0;
87 }
88@@ -355,7 +365,12 @@
89 qWarning() << "Cannot set current playback position without a valid media-hub player session";
90 return;
91 }
92- m_hubPlayerSession->seek_to(std::chrono::microseconds{msec * 1000});
93+ try {
94+ m_hubPlayerSession->seek_to(std::chrono::microseconds{msec * 1000});
95+ }
96+ catch (const std::runtime_error &e) {
97+ qWarning() << "Failed to set position to " << msec << ": " << e.what();
98+ }
99 }
100
101 int64_t AalMediaPlayerService::duration()
102@@ -376,7 +391,7 @@
103 }
104 return d / 1e6;
105 }
106- catch (std::runtime_error &e) {
107+ catch (const std::runtime_error &e) {
108 qWarning() << "Failed to get current playback duration: " << e.what();
109 return 0;
110 }
111@@ -393,7 +408,7 @@
112 try {
113 return m_hubPlayerSession->is_video_source();
114 }
115- catch (std::runtime_error &e) {
116+ catch (const std::runtime_error &e) {
117 qWarning() << "Failed to check if source is video: " << e.what();
118 return false;
119 }
120@@ -410,7 +425,7 @@
121 try {
122 return m_hubPlayerSession->is_audio_source();
123 }
124- catch (std::runtime_error &e) {
125+ catch (const std::runtime_error &e) {
126 qWarning() << "Failed to check if source is video: " << e.what();
127 return false;
128 }
129@@ -427,7 +442,7 @@
130 try {
131 return m_hubPlayerSession->volume();
132 }
133- catch (std::runtime_error &e) {
134+ catch (const std::runtime_error &e) {
135 qWarning() << "Failed to get current volume level: " << e.what();
136 return 0;
137 }

Subscribers

People subscribed via source and target branches

to all changes: