Merge lp:~phablet-team/media-hub/add-logger into lp:media-hub
- add-logger
- Merge into trunk
Status: | Superseded |
---|---|
Proposed branch: | lp:~phablet-team/media-hub/add-logger |
Merge into: | lp:media-hub |
Diff against target: |
2780 lines (+819/-331) 32 files modified
CMakeLists.txt (+1/-1) debian/bileto_pre_release_hook (+21/-52) debian/control (+6/-6) debian/control.in (+1/-0) debian/get-versions.sh (+5/-3) debian/rules (+1/-1) include/core/media/player.h (+23/-0) src/core/media/CMakeLists.txt (+9/-0) src/core/media/apparmor/ubuntu.cpp (+7/-6) src/core/media/audio/pulse_audio_output_observer.cpp (+10/-8) src/core/media/gstreamer/engine.cpp (+30/-29) src/core/media/gstreamer/playbin.cpp (+39/-46) src/core/media/logger/logger.cpp (+161/-0) src/core/media/logger/logger.h (+131/-0) src/core/media/non_copyable.h (+36/-0) src/core/media/player_implementation.cpp (+39/-38) src/core/media/player_skeleton.cpp (+6/-4) src/core/media/player_stub.cpp (+10/-6) src/core/media/power/state_controller.cpp (+13/-13) src/core/media/server/server.cpp (+34/-0) src/core/media/service.cpp (+3/-1) src/core/media/service_implementation.cpp (+27/-26) src/core/media/service_skeleton.cpp (+20/-19) src/core/media/telephony/CMakeLists.txt (+1/-0) src/core/media/telephony/call_monitor.cpp (+9/-7) src/core/media/telephony/qtbridge.cpp (+0/-2) src/core/media/track_list_implementation.cpp (+25/-23) src/core/media/track_list_skeleton.cpp (+31/-32) src/core/media/track_list_stub.cpp (+9/-7) src/core/media/util/utils.cpp (+41/-0) src/core/media/util/utils.h (+69/-0) src/core/media/video/platform_default_sink.cpp (+1/-1) |
To merge this branch: | bzr merge lp:~phablet-team/media-hub/add-logger |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Alfonso Sanchez-Beato | Approve | ||
Konrad Zapałowicz (community) | code | Approve | |
Review via email:
|
This proposal has been superseded by a proposal from 2016-04-06.
Commit message
Add a proper logger to media-hub that includes traces, timestamps and other conveniences and no longer rely on cout/cerr.
Description of the change
Add a proper logger to media-hub that includes traces, timestamps and other conveniences and no longer rely on cout/cerr.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Konrad Zapałowicz (kzapalowicz) wrote : | # |
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
I have some concerns with this MP:
* I do not really like moving to the printf way of doing things. Why should be drop type safeness? It would be better to use the boost logger more "natively" with "<<" operators, changing the wrapper class to something similar to what Qt does (qDebug() << message, etc.). Even more, using printf way in the end we need to resort to using stringstream in several places where it was not needed before.
* I still see cout and cerr being used in many places. But please do not change that yet until we have an agreement on how the class Logger should be used.
* I do not think we should introduce functions in the Utils namespace that we do not use. Specially taking into account that I would prefer to avoid using the only one that seems to be used, Sprintf :)
* Line sizes in new files are > 100 in many cases
There are also a couple of inline comments.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : | # |
> Not many issues compared to the length of the diff and frankly I'm mostly
> concerned about the own noncopyable class.
I am using this same logger which comes from aethercast. It relies on it's own noncopyable class, so just maintaing consistency. Really, this logger should be brought into a standard library for everyone to use, but that's out of the scope of this story.
>
> There is also one thing which is not bad however I would like to highlight it.
> I did not like the need to create stringstream in so many cases to log a line
> as basically this is repeating.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : | # |
> I have some concerns with this MP:
>
> * I do not really like moving to the printf way of doing things. Why should be
> drop type safeness? It would be better to use the boost logger more "natively"
> with "<<" operators, changing the wrapper class to something similar to what
> Qt does (qDebug() << message, etc.). Even more, using printf way in the end we
> need to resort to using stringstream in several places where it was not needed
> before.
Boost still maintains complete type safety with using the printf style. See the Boost::Log docs about this if you have any questions. This private Boost::Log interface implementation comes from tvoss and we're starting to standardize on it. Not sure why it doesn't use streams but that's outside anything I can really control without rewriting the private logger interface.
>
> * I still see cout and cerr being used in many places. But please do not
> change that yet until we have an agreement on how the class Logger should be
> used.
There are some that will need to remain, but otherwise I've made sure that all superfluous ones have now been removed.
>
> * I do not think we should introduce functions in the Utils namespace that we
> do not use. Specially taking into account that I would prefer to avoid using
> the only one that seems to be used, Sprintf :)
Fixed
>
> * Line sizes in new files are > 100 in many cases
I tried not to do that, any specific ones?
>
> There are also a couple of inline comments.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Jim Hodapp (jhodapp) wrote : | # |
Replied/addressed inline comments.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Konrad Zapałowicz (kzapalowicz) wrote : | # |
Thanks for fixes & explanations, ack.
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Alfonso Sanchez-Beato (alfonsosanchezbeato) wrote : | # |
Thanks for the changes. LGTM, although I do not agree with how the Logger is designed. As discussed, we need to rethink it and come back to this when we do so.
- 194. By Jim Hodapp
-
Merged with prereq to get this to build in a silo until silo 51 lands
- 195. By Jim Hodapp
-
Make sure everything is licensed under LGPL v3
Unmerged revisions
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2015-12-16 16:55:51 +0000 | |||
3 | +++ CMakeLists.txt 2016-04-06 19:07:29 +0000 | |||
4 | @@ -43,7 +43,7 @@ | |||
5 | 43 | include(GNUInstallDirs) | 43 | include(GNUInstallDirs) |
6 | 44 | 44 | ||
7 | 45 | find_package(PkgConfig) | 45 | find_package(PkgConfig) |
9 | 46 | find_package(Boost COMPONENTS filesystem system program_options REQUIRED) | 46 | find_package(Boost COMPONENTS filesystem log system thread program_options REQUIRED) |
10 | 47 | find_package(GLog) | 47 | find_package(GLog) |
11 | 48 | pkg_check_modules(DBUS dbus-1 REQUIRED) | 48 | pkg_check_modules(DBUS dbus-1 REQUIRED) |
12 | 49 | pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED) | 49 | pkg_check_modules(DBUS_CPP dbus-cpp REQUIRED) |
13 | 50 | 50 | ||
14 | === renamed file 'debian/gen-debian-files.sh' => 'debian/bileto_pre_release_hook' | |||
15 | --- debian/gen-debian-files.sh 2015-11-22 21:01:02 +0000 | |||
16 | +++ debian/bileto_pre_release_hook 2016-04-06 19:07:29 +0000 | |||
17 | @@ -16,6 +16,7 @@ | |||
18 | 16 | # | 16 | # |
19 | 17 | # Authored by: Michi Henning <michi.henning@canonical.com> | 17 | # Authored by: Michi Henning <michi.henning@canonical.com> |
20 | 18 | # Thomas Voß <thomas.voss@canonical.com> | 18 | # Thomas Voß <thomas.voss@canonical.com> |
21 | 19 | # Robert Bruce Park <robert.park@canonical.com> | ||
22 | 19 | 20 | ||
23 | 20 | # | 21 | # |
24 | 21 | # Script to generate debian files for dual landing in Vivid (gcc 4.9 ABI) | 22 | # Script to generate debian files for dual landing in Vivid (gcc 4.9 ABI) |
25 | @@ -24,79 +25,47 @@ | |||
26 | 24 | # This script is called from debian/rules and generates: | 25 | # This script is called from debian/rules and generates: |
27 | 25 | # | 26 | # |
28 | 26 | # - control | 27 | # - control |
35 | 27 | # - libtrust-store${soversion}.install.${target_arch} | 28 | # - libmedia-hub-client${MEDIA_HUB_SOVERSION}.install |
36 | 28 | # | 29 | # - libmedia-hub-common${MEDIA_HUB_SOVERSION}.install |
31 | 29 | # For all but control, this is a straight substition and/or renaming exercise for each file. | ||
32 | 30 | # For control, if building on Wily or later, we also fix the "Replaces:" and "Conflicts:" | ||
33 | 31 | # entries, so we don't end up with two packages claiming ownership of the same places | ||
34 | 32 | # in the file system. | ||
37 | 33 | # | 30 | # |
38 | 34 | # Because the debian files for the different distributions are generated on the fly, | 31 | # Because the debian files for the different distributions are generated on the fly, |
41 | 35 | # this allows us to keep a single source tree for both distributions. See ../HACKING | 32 | # this allows us to keep a single source tree for both distributions. |
40 | 36 | # for more explanations. | ||
42 | 37 | # | 33 | # |
43 | 38 | 34 | ||
44 | 39 | set -e # Fail if any command fails. | 35 | set -e # Fail if any command fails. |
45 | 40 | 36 | ||
46 | 41 | progname=$(basename $0) | 37 | progname=$(basename $0) |
47 | 42 | 38 | ||
50 | 43 | [ $# -ne 1 ] && { | 39 | [ $# -gt 1 ] && { |
51 | 44 | echo "usage: $progname path-to-debian-dir" >&2 | 40 | echo "usage: $progname [path-to-debian-dir]" >&2 |
52 | 45 | exit 1 | 41 | exit 1 |
53 | 46 | } | 42 | } |
54 | 43 | version_dir=$(mktemp -d) | ||
55 | 47 | dir=$1 | 44 | dir=$1 |
57 | 48 | version_dir=$(mktemp -d) | 45 | |
58 | 46 | [ -n "$dir" ] || dir="./debian" | ||
59 | 49 | 47 | ||
60 | 50 | # Dump version numbers into files and initialize vars from those files. | 48 | # Dump version numbers into files and initialize vars from those files. |
61 | 51 | |||
62 | 52 | sh ${dir}/get-versions.sh ${dir} ${version_dir} | 49 | sh ${dir}/get-versions.sh ${dir} ${version_dir} |
63 | 53 | 50 | ||
74 | 54 | full_version=$(cat "${version_dir}"/libmedia-hub.full-version) | 51 | export MEDIA_HUB_SOVERSION=$(cat "$version_dir/libmedia-hub.soversion") |
75 | 55 | major_minor=$(cat "${version_dir}"/libmedia-hub.major-minor-version) | 52 | |
76 | 56 | soversion=$(cat "${version_dir}"/libmedia-hub.soversion) | 53 | trap "rm -fr $version_dir" 0 INT TERM QUIT |
77 | 57 | vivid_soversion=$(cat "${version_dir}"/libmedia-hub.vivid-soversion) | 54 | |
78 | 58 | 55 | process() | |
69 | 59 | warning=$(mktemp -t gen-debian-files-msg.XXX) | ||
70 | 60 | |||
71 | 61 | trap "rm -fr $warning $version_dir" 0 INT TERM QUIT | ||
72 | 62 | |||
73 | 63 | warning_msg() | ||
79 | 64 | { | 56 | { |
81 | 65 | cat >$warning <<EOF | 57 | cat <<EOF |
82 | 66 | # This file is autogenerated. DO NOT EDIT! | 58 | # This file is autogenerated. DO NOT EDIT! |
83 | 67 | # | 59 | # |
84 | 68 | # Modifications should be made to $(basename "$1") instead. | 60 | # Modifications should be made to $(basename "$1") instead. |
85 | 69 | # This file is regenerated automatically in the clean target. | 61 | # This file is regenerated automatically in the clean target. |
86 | 70 | # | 62 | # |
87 | 71 | EOF | 63 | EOF |
117 | 72 | } | 64 | perl -pe 's/@([A-Z_]+)@/$ENV{$1} or die "$1 undefined"/eg' <"$1" |
118 | 73 | 65 | } | |
119 | 74 | # Generate debian/control from debian/control.in, substituting the soversion for both libs. | 66 | |
120 | 75 | # For wily onwards, we also add an entry for the vivid versions to "Conflicts:" and "Replaces:". | 67 | process "$dir/control.in" >"$dir/control" |
121 | 76 | 68 | process "$dir/libmedia-hub-client.install.in" >"$dir/libmedia-hub-client${MEDIA_HUB_SOVERSION}.install" | |
122 | 77 | infile="${dir}"/control.in | 69 | process "$dir/libmedia-hub-common.install.in" >"$dir/libmedia-hub-common${MEDIA_HUB_SOVERSION}.install" |
94 | 78 | outfile="${dir}"/control | ||
95 | 79 | warning_msg $infile | ||
96 | 80 | cat $warning $infile \ | ||
97 | 81 | | sed -e "s/@MEDIA_HUB_SOVERSION@/${soversion}/" > "$outfile" | ||
98 | 82 | |||
99 | 83 | [ "$distro" != "vivid" ] && { | ||
100 | 84 | sed -i -e "/Replaces: libdbus-cpp4,/a\ | ||
101 | 85 | \ libdbus-cpp${vivid_soversion}," \ | ||
102 | 86 | "$outfile" | ||
103 | 87 | } | ||
104 | 88 | |||
105 | 89 | # Generate the install files, naming them according to the soversion. | ||
106 | 90 | |||
107 | 91 | # Install file for binary package | ||
108 | 92 | infile="${dir}"/libmedia-hub-client.install.in | ||
109 | 93 | outfile="${dir}"/libmedia-hub-client${soversion}.install | ||
110 | 94 | warning_msg "$infile" | ||
111 | 95 | cat $warning "$infile" >"$outfile" | ||
112 | 96 | |||
113 | 97 | infile="${dir}"/libmedia-hub-common.install.in | ||
114 | 98 | outfile="${dir}"/libmedia-hub-common${soversion}.install | ||
115 | 99 | warning_msg "$infile" | ||
116 | 100 | cat $warning "$infile" >"$outfile" | ||
123 | 101 | 70 | ||
124 | 102 | exit 0 | 71 | exit 0 |
125 | 103 | 72 | ||
126 | === modified file 'debian/control' | |||
127 | --- debian/control 2016-03-04 18:17:11 +0000 | |||
128 | +++ debian/control 2016-04-06 19:07:29 +0000 | |||
129 | @@ -20,9 +20,9 @@ | |||
130 | 20 | libboost-program-options-dev (>=1.53), | 20 | libboost-program-options-dev (>=1.53), |
131 | 21 | libboost-system-dev (>=1.53), | 21 | libboost-system-dev (>=1.53), |
132 | 22 | libdbus-1-dev, | 22 | libdbus-1-dev, |
134 | 23 | libdbus-cpp-dev (>= 5.0.0), | 23 | libdbus-cpp-dev (>= 4.3.0), |
135 | 24 | libgoogle-glog-dev, | 24 | libgoogle-glog-dev, |
137 | 25 | libhybris-dev, | 25 | libhybris-dev (>=0.1.0+git20131207+e452e83-0ubuntu30), |
138 | 26 | libprocess-cpp-dev, | 26 | libprocess-cpp-dev, |
139 | 27 | libproperties-cpp-dev, | 27 | libproperties-cpp-dev, |
140 | 28 | libgstreamer1.0-dev, | 28 | libgstreamer1.0-dev, |
141 | @@ -42,8 +42,8 @@ | |||
142 | 42 | Section: libdevel | 42 | Section: libdevel |
143 | 43 | Architecture: any | 43 | Architecture: any |
144 | 44 | Multi-Arch: same | 44 | Multi-Arch: same |
147 | 45 | Depends: libmedia-hub-common4 (= ${binary:Version}), | 45 | Depends: libmedia-hub-common5 (= ${binary:Version}), |
148 | 46 | libmedia-hub-client4 (= ${binary:Version}), | 46 | libmedia-hub-client5 (= ${binary:Version}), |
149 | 47 | ${misc:Depends}, | 47 | ${misc:Depends}, |
150 | 48 | libproperties-cpp-dev, | 48 | libproperties-cpp-dev, |
151 | 49 | Suggests: libmedia-hub-doc | 49 | Suggests: libmedia-hub-doc |
152 | @@ -64,7 +64,7 @@ | |||
153 | 64 | . | 64 | . |
154 | 65 | This package contains the runtime. | 65 | This package contains the runtime. |
155 | 66 | 66 | ||
157 | 67 | Package: libmedia-hub-common4 | 67 | Package: libmedia-hub-common5 |
158 | 68 | Architecture: any | 68 | Architecture: any |
159 | 69 | Multi-Arch: same | 69 | Multi-Arch: same |
160 | 70 | Depends: ${misc:Depends}, | 70 | Depends: ${misc:Depends}, |
161 | @@ -75,7 +75,7 @@ | |||
162 | 75 | . | 75 | . |
163 | 76 | This package contains the common libraries. | 76 | This package contains the common libraries. |
164 | 77 | 77 | ||
166 | 78 | Package: libmedia-hub-client4 | 78 | Package: libmedia-hub-client5 |
167 | 79 | Architecture: any | 79 | Architecture: any |
168 | 80 | Multi-Arch: same | 80 | Multi-Arch: same |
169 | 81 | Depends: ${misc:Depends}, | 81 | Depends: ${misc:Depends}, |
170 | 82 | 82 | ||
171 | === modified file 'debian/control.in' | |||
172 | --- debian/control.in 2015-11-22 21:01:02 +0000 | |||
173 | +++ debian/control.in 2016-04-06 19:07:29 +0000 | |||
174 | @@ -12,6 +12,7 @@ | |||
175 | 12 | gstreamer1.0-plugins-good, | 12 | gstreamer1.0-plugins-good, |
176 | 13 | libboost-dev (>=1.53), | 13 | libboost-dev (>=1.53), |
177 | 14 | libboost-filesystem-dev (>=1.53), | 14 | libboost-filesystem-dev (>=1.53), |
178 | 15 | libboost-log-dev (>=1.53), | ||
179 | 15 | libboost-program-options-dev (>=1.53), | 16 | libboost-program-options-dev (>=1.53), |
180 | 16 | libboost-system-dev (>=1.53), | 17 | libboost-system-dev (>=1.53), |
181 | 17 | libdbus-1-dev, | 18 | libdbus-1-dev, |
182 | 18 | 19 | ||
183 | === modified file 'debian/get-versions.sh' | |||
184 | --- debian/get-versions.sh 2015-11-22 21:01:02 +0000 | |||
185 | +++ debian/get-versions.sh 2016-04-06 19:07:29 +0000 | |||
186 | @@ -38,7 +38,7 @@ | |||
187 | 38 | # Write the various version numbers into a bunch of files. This allows | 38 | # Write the various version numbers into a bunch of files. This allows |
188 | 39 | # us to easily pick them up from both gen-debian-files.sh and CMakeLists.txt. | 39 | # us to easily pick them up from both gen-debian-files.sh and CMakeLists.txt. |
189 | 40 | 40 | ||
191 | 41 | distro=$(lsb_release -c -s) | 41 | [ -n "$SERIES" ] || SERIES="$(lsb_release -c -s)" |
192 | 42 | 42 | ||
193 | 43 | full_version=$(cat "${dir}"/VERSION) | 43 | full_version=$(cat "${dir}"/VERSION) |
194 | 44 | 44 | ||
195 | @@ -51,13 +51,15 @@ | |||
196 | 51 | vivid_major=$(echo $vivid_full_version | cut -d'.' -f1) | 51 | vivid_major=$(echo $vivid_full_version | cut -d'.' -f1) |
197 | 52 | vivid_soversion=$vivid_major | 52 | vivid_soversion=$vivid_major |
198 | 53 | 53 | ||
200 | 54 | if [ "$distro" = "vivid" ] | 54 | if [ "$SERIES" = "vivid" ] |
201 | 55 | then | 55 | then |
202 | 56 | soversion=${vivid_soversion} | 56 | soversion=${vivid_soversion} |
203 | 57 | else | 57 | else |
204 | 58 | soversion="${major}" | 58 | soversion="${major}" |
205 | 59 | fi | 59 | fi |
207 | 60 | [ -n $soversion ] | 60 | [ -n "$soversion" ] |
208 | 61 | |||
209 | 62 | echo "Using SOVERSION $soversion in $SERIES." >&2 | ||
210 | 61 | 63 | ||
211 | 62 | echo ${full_version} >${output_dir}/libmedia-hub.full-version | 64 | echo ${full_version} >${output_dir}/libmedia-hub.full-version |
212 | 63 | echo ${major} >${output_dir}/libmedia-hub.major-version | 65 | echo ${major} >${output_dir}/libmedia-hub.major-version |
213 | 64 | 66 | ||
214 | === modified file 'debian/rules' | |||
215 | --- debian/rules 2015-11-22 21:01:02 +0000 | |||
216 | +++ debian/rules 2016-04-06 19:07:29 +0000 | |||
217 | @@ -34,5 +34,5 @@ | |||
218 | 34 | dh_installdeb | 34 | dh_installdeb |
219 | 35 | 35 | ||
220 | 36 | override_dh_auto_clean: | 36 | override_dh_auto_clean: |
222 | 37 | /bin/sh $(CURDIR)/debian/gen-debian-files.sh $(CURDIR)/debian | 37 | /bin/sh $(CURDIR)/debian/bileto_pre_release_hook |
223 | 38 | dh_auto_clean | 38 | dh_auto_clean |
224 | 39 | 39 | ||
225 | === modified file 'include/core/media/player.h' | |||
226 | --- include/core/media/player.h 2016-02-19 16:14:42 +0000 | |||
227 | +++ include/core/media/player.h 2016-04-06 19:07:29 +0000 | |||
228 | @@ -229,6 +229,29 @@ | |||
229 | 229 | return out; | 229 | return out; |
230 | 230 | } | 230 | } |
231 | 231 | 231 | ||
232 | 232 | inline std::ostream& operator<<(std::ostream& out, Player::Error e) | ||
233 | 233 | { | ||
234 | 234 | switch (e) | ||
235 | 235 | { | ||
236 | 236 | case Player::Error::no_error: | ||
237 | 237 | return out << "Error::no_error"; | ||
238 | 238 | case Player::Error::resource_error: | ||
239 | 239 | return out << "Error::resource_error"; | ||
240 | 240 | case Player::Error::format_error: | ||
241 | 241 | return out << "Error::format_error"; | ||
242 | 242 | case Player::Error::network_error: | ||
243 | 243 | return out << "Error::network_error"; | ||
244 | 244 | case Player::Error::access_denied_error: | ||
245 | 245 | return out << "Error::access_denied_error"; | ||
246 | 246 | case Player::Error::service_missing_error: | ||
247 | 247 | return out << "Error::service_missing_error"; | ||
248 | 248 | default: | ||
249 | 249 | return out << "Unsupported Player error: " << e; | ||
250 | 250 | } | ||
251 | 251 | |||
252 | 252 | return out; | ||
253 | 253 | } | ||
254 | 254 | |||
255 | 232 | } | 255 | } |
256 | 233 | } | 256 | } |
257 | 234 | } | 257 | } |
258 | 235 | 258 | ||
259 | === modified file 'src/core/media/CMakeLists.txt' | |||
260 | --- src/core/media/CMakeLists.txt 2015-09-04 18:46:08 +0000 | |||
261 | +++ src/core/media/CMakeLists.txt 2016-04-06 19:07:29 +0000 | |||
262 | @@ -18,6 +18,7 @@ | |||
263 | 18 | media-hub-common SHARED | 18 | media-hub-common SHARED |
264 | 19 | 19 | ||
265 | 20 | the_session_bus.cpp | 20 | the_session_bus.cpp |
266 | 21 | util/utils.cpp | ||
267 | 21 | ) | 22 | ) |
268 | 22 | 23 | ||
269 | 23 | target_link_libraries( | 24 | target_link_libraries( |
270 | @@ -42,6 +43,8 @@ | |||
271 | 42 | 43 | ||
272 | 43 | ${MEDIA_HUB_HEADERS} | 44 | ${MEDIA_HUB_HEADERS} |
273 | 44 | 45 | ||
274 | 46 | logger/logger.cpp | ||
275 | 47 | |||
276 | 45 | player.cpp | 48 | player.cpp |
277 | 46 | service.cpp | 49 | service.cpp |
278 | 47 | track.cpp | 50 | track.cpp |
279 | @@ -70,6 +73,8 @@ | |||
280 | 70 | 73 | ||
281 | 71 | media-hub-common | 74 | media-hub-common |
282 | 72 | 75 | ||
283 | 76 | ${Boost_LDFLAGS} | ||
284 | 77 | ${Boost_LIBRARIES} | ||
285 | 73 | ${DBUS_LIBRARIES} | 78 | ${DBUS_LIBRARIES} |
286 | 74 | ${DBUS_CPP_LDFLAGS} | 79 | ${DBUS_CPP_LDFLAGS} |
287 | 75 | ${GLog_LIBRARY} | 80 | ${GLog_LIBRARY} |
288 | @@ -87,6 +92,8 @@ | |||
289 | 87 | ${MEDIA_HUB_HEADERS} | 92 | ${MEDIA_HUB_HEADERS} |
290 | 88 | ${MPRIS_HEADERS} | 93 | ${MPRIS_HEADERS} |
291 | 89 | 94 | ||
292 | 95 | logger/logger.cpp | ||
293 | 96 | |||
294 | 90 | client_death_observer.cpp | 97 | client_death_observer.cpp |
295 | 91 | hashed_keyed_player_store.cpp | 98 | hashed_keyed_player_store.cpp |
296 | 92 | hybris_client_death_observer.cpp | 99 | hybris_client_death_observer.cpp |
297 | @@ -123,6 +130,8 @@ | |||
298 | 123 | media-hub-client | 130 | media-hub-client |
299 | 124 | media-hub-common | 131 | media-hub-common |
300 | 125 | call-monitor | 132 | call-monitor |
301 | 133 | ${Boost_LDFLAGS} | ||
302 | 134 | ${Boost_LIBRARIES} | ||
303 | 126 | ${DBUS_LIBRARIES} | 135 | ${DBUS_LIBRARIES} |
304 | 127 | ${DBUS_CPP_LDFLAGS} | 136 | ${DBUS_CPP_LDFLAGS} |
305 | 128 | ${GLog_LIBRARY} | 137 | ${GLog_LIBRARY} |
306 | 129 | 138 | ||
307 | === modified file 'src/core/media/apparmor/ubuntu.cpp' | |||
308 | --- src/core/media/apparmor/ubuntu.cpp 2016-02-23 14:17:04 +0000 | |||
309 | +++ src/core/media/apparmor/ubuntu.cpp 2016-04-06 19:07:29 +0000 | |||
310 | @@ -20,7 +20,8 @@ | |||
311 | 20 | 20 | ||
312 | 21 | #include <core/media/external_services.h> | 21 | #include <core/media/external_services.h> |
313 | 22 | 22 | ||
315 | 23 | #include <iostream> | 23 | #include "core/media/logger/logger.h" |
316 | 24 | |||
317 | 24 | #include <regex> | 25 | #include <regex> |
318 | 25 | 26 | ||
319 | 26 | namespace apparmor = core::ubuntu::media::apparmor; | 27 | namespace apparmor = core::ubuntu::media::apparmor; |
320 | @@ -107,9 +108,9 @@ | |||
321 | 107 | unity_{name == unity_name}, | 108 | unity_{name == unity_name}, |
322 | 108 | has_package_name_{process_context_name(str(), match_, pkg_name_)} | 109 | has_package_name_{process_context_name(str(), match_, pkg_name_)} |
323 | 109 | { | 110 | { |
327 | 110 | std::cout << "apparmor profile name: " << name; | 111 | MH_DEBUG("apparmor profile name: %s", name); |
328 | 111 | std::cout << ", is_unconfined(): " << is_unconfined(); | 112 | MH_DEBUG("is_unconfined(): %s", (is_unconfined() ? "true" : "false")); |
329 | 112 | std::cout << ", has_package_name(): " << has_package_name() << std::endl; | 113 | MH_DEBUG("has_package_name(): %s", (has_package_name() ? "true" : "false")); |
330 | 113 | if (not is_unconfined() and not is_unity() and not has_package_name()) | 114 | if (not is_unconfined() and not is_unity() and not has_package_name()) |
331 | 114 | throw std::logic_error | 115 | throw std::logic_error |
332 | 115 | { | 116 | { |
333 | @@ -163,8 +164,8 @@ | |||
334 | 163 | 164 | ||
335 | 164 | Uri parsed_uri = parse_uri(uri); | 165 | Uri parsed_uri = parse_uri(uri); |
336 | 165 | 166 | ||
339 | 166 | std::cout << "context.profile_name(): " << context.profile_name() << std::endl; | 167 | MH_DEBUG("context.profile_name(): %s", context.profile_name()); |
340 | 167 | std::cout << "parsed_uri.path: " << parsed_uri.path << std::endl; | 168 | MH_DEBUG("parsed_uri.path: %s", parsed_uri.path); |
341 | 168 | 169 | ||
342 | 169 | // All confined apps can access their own files | 170 | // All confined apps can access their own files |
343 | 170 | if (parsed_uri.path.find(std::string(".local/share/" + context.package_name() + "/")) != std::string::npos || | 171 | if (parsed_uri.path.find(std::string(".local/share/" + context.package_name() + "/")) != std::string::npos || |
344 | 171 | 172 | ||
345 | === modified file 'src/core/media/audio/pulse_audio_output_observer.cpp' | |||
346 | --- src/core/media/audio/pulse_audio_output_observer.cpp 2015-03-19 00:04:12 +0000 | |||
347 | +++ src/core/media/audio/pulse_audio_output_observer.cpp 2016-04-06 19:07:29 +0000 | |||
348 | @@ -21,6 +21,8 @@ | |||
349 | 21 | 21 | ||
350 | 22 | #include <pulse/pulseaudio.h> | 22 | #include <pulse/pulseaudio.h> |
351 | 23 | 23 | ||
352 | 24 | #include "core/media/logger/logger.h" | ||
353 | 25 | |||
354 | 24 | #include <cstdint> | 26 | #include <cstdint> |
355 | 25 | 27 | ||
356 | 26 | #include <map> | 28 | #include <map> |
357 | @@ -245,7 +247,7 @@ | |||
358 | 245 | std::get<1>(outputs.back()) | properties.external_output_state; | 247 | std::get<1>(outputs.back()) | properties.external_output_state; |
359 | 246 | std::get<1>(outputs.back()).changed().connect([](media::audio::OutputState state) | 248 | std::get<1>(outputs.back()).changed().connect([](media::audio::OutputState state) |
360 | 247 | { | 249 | { |
362 | 248 | std::cout << "Connection state for port changed to: " << state << std::endl; | 250 | MH_DEBUG("Connection state for port changed to: %s", state); |
363 | 249 | }); | 251 | }); |
364 | 250 | } | 252 | } |
365 | 251 | 253 | ||
366 | @@ -289,8 +291,8 @@ | |||
367 | 289 | void on_sink_event_with_index(std::int32_t index) | 291 | void on_sink_event_with_index(std::int32_t index) |
368 | 290 | { | 292 | { |
369 | 291 | config.reporter->sink_event_with_index(index); | 293 | config.reporter->sink_event_with_index(index); |
372 | 292 | 294 | ||
373 | 293 | // Update server info (active sink) | 295 | // Update server info (active sink) |
374 | 294 | pa::get_server_info_async(context, main_loop, Private::query_for_server_info_finished, this); | 296 | pa::get_server_info_async(context, main_loop, Private::query_for_server_info_finished, this); |
375 | 295 | 297 | ||
376 | 296 | } | 298 | } |
377 | @@ -317,15 +319,15 @@ | |||
378 | 317 | if (std::get<0>(active_sink) != info->index) | 319 | if (std::get<0>(active_sink) != info->index) |
379 | 318 | continue; | 320 | continue; |
380 | 319 | 321 | ||
384 | 320 | std::cout << "Checking if port is available " << " -> " << std::boolalpha << pa::is_port_available_on_sink(info, std::get<0>(element)) << std::endl; | 322 | MH_INFO("Checking if port is available -> %s", |
385 | 321 | bool available = pa::is_port_available_on_sink(info, std::get<0>(element)); | 323 | pa::is_port_available_on_sink(info, std::get<0>(element))); |
386 | 322 | 324 | const bool available = pa::is_port_available_on_sink(info, std::get<0>(element)); | |
387 | 323 | if (available) | 325 | if (available) |
388 | 324 | { | 326 | { |
389 | 325 | std::get<1>(element) = audio::OutputState::Earpiece; | 327 | std::get<1>(element) = audio::OutputState::Earpiece; |
390 | 326 | continue; | 328 | continue; |
391 | 327 | } | 329 | } |
393 | 328 | 330 | ||
394 | 329 | audio::OutputState state; | 331 | audio::OutputState state; |
395 | 330 | if (info->index == primary_sink_index) | 332 | if (info->index == primary_sink_index) |
396 | 331 | state = audio::OutputState::Speaker; | 333 | state = audio::OutputState::Speaker; |
397 | @@ -386,7 +388,7 @@ | |||
398 | 386 | } | 388 | } |
399 | 387 | } | 389 | } |
400 | 388 | 390 | ||
402 | 389 | PulseAudioOutputObserver::Configuration config; | 391 | PulseAudioOutputObserver::Configuration config; |
403 | 390 | pa::ThreadedMainLoopPtr main_loop; | 392 | pa::ThreadedMainLoopPtr main_loop; |
404 | 391 | pa::ContextPtr context; | 393 | pa::ContextPtr context; |
405 | 392 | std::int32_t primary_sink_index; | 394 | std::int32_t primary_sink_index; |
406 | 393 | 395 | ||
407 | === modified file 'src/core/media/gstreamer/engine.cpp' | |||
408 | --- src/core/media/gstreamer/engine.cpp 2016-02-19 16:14:42 +0000 | |||
409 | +++ src/core/media/gstreamer/engine.cpp 2016-04-06 19:07:29 +0000 | |||
410 | @@ -25,6 +25,8 @@ | |||
411 | 25 | #include "meta_data_extractor.h" | 25 | #include "meta_data_extractor.h" |
412 | 26 | #include "playbin.h" | 26 | #include "playbin.h" |
413 | 27 | 27 | ||
414 | 28 | #include "core/media/logger/logger.h" | ||
415 | 29 | |||
416 | 28 | #include <cassert> | 30 | #include <cassert> |
417 | 29 | 31 | ||
418 | 30 | namespace media = core::ubuntu::media; | 32 | namespace media = core::ubuntu::media; |
419 | @@ -67,8 +69,8 @@ | |||
420 | 67 | { | 69 | { |
421 | 68 | if (p.second == "playbin") | 70 | if (p.second == "playbin") |
422 | 69 | { | 71 | { |
425 | 70 | std::cout << "State changed on playbin: " | 72 | MH_INFO("State changed on playbin: %s", |
426 | 71 | << gst_element_state_get_name(p.first.new_state) << std::endl; | 73 | gst_element_state_get_name(p.first.new_state)); |
427 | 72 | const auto status = gst_state_to_player_status(p.first); | 74 | const auto status = gst_state_to_player_status(p.first); |
428 | 73 | /* | 75 | /* |
429 | 74 | * When state moves to "paused" the pipeline is already set. We check that we | 76 | * When state moves to "paused" the pipeline is already set. We check that we |
430 | @@ -76,7 +78,7 @@ | |||
431 | 76 | */ | 78 | */ |
432 | 77 | if (status == media::Player::PlaybackStatus::paused && | 79 | if (status == media::Player::PlaybackStatus::paused && |
433 | 78 | !playbin.can_play_streams()) { | 80 | !playbin.can_play_streams()) { |
435 | 79 | std::cerr << "** Cannot play: some codecs are missing" << std::endl; | 81 | MH_ERROR("** Cannot play: some codecs are missing"); |
436 | 80 | playbin.reset(); | 82 | playbin.reset(); |
437 | 81 | const media::Player::Error e = media::Player::Error::format_error; | 83 | const media::Player::Error e = media::Player::Error::format_error; |
438 | 82 | error(e); | 84 | error(e); |
439 | @@ -96,20 +98,20 @@ | |||
440 | 96 | switch (ewi.error->code) | 98 | switch (ewi.error->code) |
441 | 97 | { | 99 | { |
442 | 98 | case GST_CORE_ERROR_FAILED: | 100 | case GST_CORE_ERROR_FAILED: |
444 | 99 | std::cerr << "** Encountered a GST_CORE_ERROR_FAILED" << std::endl; | 101 | MH_ERROR("** Encountered a GST_CORE_ERROR_FAILED"); |
445 | 100 | ret_error = media::Player::Error::resource_error; | 102 | ret_error = media::Player::Error::resource_error; |
446 | 101 | break; | 103 | break; |
447 | 102 | case GST_CORE_ERROR_NEGOTIATION: | 104 | case GST_CORE_ERROR_NEGOTIATION: |
449 | 103 | std::cerr << "** Encountered a GST_CORE_ERROR_NEGOTIATION" << std::endl; | 105 | MH_ERROR("** Encountered a GST_CORE_ERROR_NEGOTIATION"); |
450 | 104 | ret_error = media::Player::Error::resource_error; | 106 | ret_error = media::Player::Error::resource_error; |
451 | 105 | break; | 107 | break; |
452 | 106 | case GST_CORE_ERROR_MISSING_PLUGIN: | 108 | case GST_CORE_ERROR_MISSING_PLUGIN: |
454 | 107 | std::cerr << "** Encountered a GST_CORE_ERROR_MISSING_PLUGIN" << std::endl; | 109 | MH_ERROR("** Encountered a GST_CORE_ERROR_MISSING_PLUGIN"); |
455 | 108 | ret_error = media::Player::Error::format_error; | 110 | ret_error = media::Player::Error::format_error; |
456 | 109 | break; | 111 | break; |
457 | 110 | default: | 112 | default: |
460 | 111 | std::cerr << "** Encountered an unhandled core error: '" | 113 | MH_ERROR("** Encountered an unhandled core error: '%s' (code: %d)", |
461 | 112 | << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl; | 114 | ewi.debug, ewi.error->code); |
462 | 113 | ret_error = media::Player::Error::no_error; | 115 | ret_error = media::Player::Error::no_error; |
463 | 114 | break; | 116 | break; |
464 | 115 | } | 117 | } |
465 | @@ -119,36 +121,36 @@ | |||
466 | 119 | switch (ewi.error->code) | 121 | switch (ewi.error->code) |
467 | 120 | { | 122 | { |
468 | 121 | case GST_RESOURCE_ERROR_FAILED: | 123 | case GST_RESOURCE_ERROR_FAILED: |
470 | 122 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_FAILED" << std::endl; | 124 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_FAILED"); |
471 | 123 | ret_error = media::Player::Error::resource_error; | 125 | ret_error = media::Player::Error::resource_error; |
472 | 124 | break; | 126 | break; |
473 | 125 | case GST_RESOURCE_ERROR_NOT_FOUND: | 127 | case GST_RESOURCE_ERROR_NOT_FOUND: |
475 | 126 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_NOT_FOUND" << std::endl; | 128 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_NOT_FOUND"); |
476 | 127 | ret_error = media::Player::Error::resource_error; | 129 | ret_error = media::Player::Error::resource_error; |
477 | 128 | break; | 130 | break; |
478 | 129 | case GST_RESOURCE_ERROR_OPEN_READ: | 131 | case GST_RESOURCE_ERROR_OPEN_READ: |
480 | 130 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_OPEN_READ" << std::endl; | 132 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_OPEN_READ"); |
481 | 131 | ret_error = media::Player::Error::resource_error; | 133 | ret_error = media::Player::Error::resource_error; |
482 | 132 | break; | 134 | break; |
483 | 133 | case GST_RESOURCE_ERROR_OPEN_WRITE: | 135 | case GST_RESOURCE_ERROR_OPEN_WRITE: |
485 | 134 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_OPEN_WRITE" << std::endl; | 136 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_OPEN_WRITE"); |
486 | 135 | ret_error = media::Player::Error::resource_error; | 137 | ret_error = media::Player::Error::resource_error; |
487 | 136 | break; | 138 | break; |
488 | 137 | case GST_RESOURCE_ERROR_READ: | 139 | case GST_RESOURCE_ERROR_READ: |
490 | 138 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_READ" << std::endl; | 140 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_READ"); |
491 | 139 | ret_error = media::Player::Error::resource_error; | 141 | ret_error = media::Player::Error::resource_error; |
492 | 140 | break; | 142 | break; |
493 | 141 | case GST_RESOURCE_ERROR_WRITE: | 143 | case GST_RESOURCE_ERROR_WRITE: |
495 | 142 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_WRITE" << std::endl; | 144 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_WRITE"); |
496 | 143 | ret_error = media::Player::Error::resource_error; | 145 | ret_error = media::Player::Error::resource_error; |
497 | 144 | break; | 146 | break; |
498 | 145 | case GST_RESOURCE_ERROR_NOT_AUTHORIZED: | 147 | case GST_RESOURCE_ERROR_NOT_AUTHORIZED: |
500 | 146 | std::cerr << "** Encountered a GST_RESOURCE_ERROR_NOT_AUTHORIZED" << std::endl; | 148 | MH_ERROR("** Encountered a GST_RESOURCE_ERROR_NOT_AUTHORIZED"); |
501 | 147 | ret_error = media::Player::Error::access_denied_error; | 149 | ret_error = media::Player::Error::access_denied_error; |
502 | 148 | break; | 150 | break; |
503 | 149 | default: | 151 | default: |
506 | 150 | std::cerr << "** Encountered an unhandled resource error: '" | 152 | MH_ERROR("** Encountered an unhandled resource error: '%s' (code: %d)", |
507 | 151 | << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl; | 153 | ewi.debug, ewi.error->code); |
508 | 152 | ret_error = media::Player::Error::no_error; | 154 | ret_error = media::Player::Error::no_error; |
509 | 153 | break; | 155 | break; |
510 | 154 | } | 156 | } |
511 | @@ -158,28 +160,28 @@ | |||
512 | 158 | switch (ewi.error->code) | 160 | switch (ewi.error->code) |
513 | 159 | { | 161 | { |
514 | 160 | case GST_STREAM_ERROR_FAILED: | 162 | case GST_STREAM_ERROR_FAILED: |
516 | 161 | std::cerr << "** Encountered a GST_STREAM_ERROR_FAILED" << std::endl; | 163 | MH_ERROR("** Encountered a GST_STREAM_ERROR_FAILED"); |
517 | 162 | ret_error = media::Player::Error::resource_error; | 164 | ret_error = media::Player::Error::resource_error; |
518 | 163 | break; | 165 | break; |
519 | 164 | case GST_STREAM_ERROR_CODEC_NOT_FOUND: | 166 | case GST_STREAM_ERROR_CODEC_NOT_FOUND: |
521 | 165 | std::cerr << "** Encountered a GST_STREAM_ERROR_CODEC_NOT_FOUND" << std::endl; | 167 | MH_ERROR("** Encountered a GST_STREAM_ERROR_CODEC_NOT_FOUND"); |
522 | 166 | // Missing codecs are handled later, when state switches to "paused" | 168 | // Missing codecs are handled later, when state switches to "paused" |
523 | 167 | ret_error = media::Player::Error::no_error; | 169 | ret_error = media::Player::Error::no_error; |
524 | 168 | break; | 170 | break; |
525 | 169 | case GST_STREAM_ERROR_DECODE: | 171 | case GST_STREAM_ERROR_DECODE: |
527 | 170 | std::cerr << "** Encountered a GST_STREAM_ERROR_DECODE" << std::endl; | 172 | MH_ERROR("** Encountered a GST_STREAM_ERROR_DECODE"); |
528 | 171 | ret_error = media::Player::Error::format_error; | 173 | ret_error = media::Player::Error::format_error; |
529 | 172 | break; | 174 | break; |
530 | 173 | default: | 175 | default: |
533 | 174 | std::cerr << "** Encountered an unhandled stream error: '" | 176 | MH_ERROR("** Encountered an unhandled stream error: '%s' code(%d)", |
534 | 175 | << ewi.debug << "' (code: " << ewi.error->code << ")" << std::endl; | 177 | ewi.debug, ewi.error->code); |
535 | 176 | ret_error = media::Player::Error::no_error; | 178 | ret_error = media::Player::Error::no_error; |
536 | 177 | break; | 179 | break; |
537 | 178 | } | 180 | } |
538 | 179 | } | 181 | } |
539 | 180 | 182 | ||
540 | 181 | if (ret_error != media::Player::Error::no_error) { | 183 | if (ret_error != media::Player::Error::no_error) { |
542 | 182 | std::cerr << "Resetting playbin pipeline after unrecoverable error" << std::endl; | 184 | MH_ERROR("Resetting playbin pipeline after unrecoverable error"); |
543 | 183 | playbin.reset(); | 185 | playbin.reset(); |
544 | 184 | } | 186 | } |
545 | 185 | return ret_error; | 187 | return ret_error; |
546 | @@ -201,7 +203,7 @@ | |||
547 | 201 | 203 | ||
548 | 202 | void on_playbin_info(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi) | 204 | void on_playbin_info(const gstreamer::Bus::Message::Detail::ErrorWarningInfo& ewi) |
549 | 203 | { | 205 | { |
551 | 204 | std::cerr << "Got a playbin info message (no action taken): " << ewi.debug << std::endl; | 206 | MH_DEBUG("Got a playbin info message (no action taken): %s", ewi.debug); |
552 | 205 | } | 207 | } |
553 | 206 | 208 | ||
554 | 207 | void on_tag_available(const gstreamer::Bus::Message::Detail::Tag& tag) | 209 | void on_tag_available(const gstreamer::Bus::Message::Detail::Tag& tag) |
555 | @@ -437,8 +439,7 @@ | |||
556 | 437 | if (result) | 439 | if (result) |
557 | 438 | { | 440 | { |
558 | 439 | d->state = media::Engine::State::playing; | 441 | d->state = media::Engine::State::playing; |
561 | 440 | cout << __PRETTY_FUNCTION__ << endl; | 442 | MH_INFO("Engine: playing uri: %s", d->playbin.uri()); |
560 | 441 | cout << "Engine: playing uri: " << d->playbin.uri() << endl; | ||
562 | 442 | d->playback_status_changed(media::Player::PlaybackStatus::playing); | 443 | d->playback_status_changed(media::Player::PlaybackStatus::playing); |
563 | 443 | } | 444 | } |
564 | 444 | 445 | ||
565 | @@ -450,7 +451,7 @@ | |||
566 | 450 | // No need to wait, and we can immediately return. | 451 | // No need to wait, and we can immediately return. |
567 | 451 | if (d->state == media::Engine::State::stopped) | 452 | if (d->state == media::Engine::State::stopped) |
568 | 452 | { | 453 | { |
570 | 453 | std::cerr << "Current player state is already stopped - no need to change state to stopped" << std::endl; | 454 | MH_DEBUG("Current player state is already stopped - no need to change state to stopped"); |
571 | 454 | return true; | 455 | return true; |
572 | 455 | } | 456 | } |
573 | 456 | 457 | ||
574 | @@ -458,7 +459,7 @@ | |||
575 | 458 | if (result) | 459 | if (result) |
576 | 459 | { | 460 | { |
577 | 460 | d->state = media::Engine::State::stopped; | 461 | d->state = media::Engine::State::stopped; |
579 | 461 | cout << __PRETTY_FUNCTION__ << endl; | 462 | MH_TRACE(""); |
580 | 462 | d->playback_status_changed(media::Player::PlaybackStatus::stopped); | 463 | d->playback_status_changed(media::Player::PlaybackStatus::stopped); |
581 | 463 | } | 464 | } |
582 | 464 | 465 | ||
583 | @@ -472,7 +473,7 @@ | |||
584 | 472 | if (result) | 473 | if (result) |
585 | 473 | { | 474 | { |
586 | 474 | d->state = media::Engine::State::paused; | 475 | d->state = media::Engine::State::paused; |
588 | 475 | cout << __PRETTY_FUNCTION__ << endl; | 476 | MH_TRACE(""); |
589 | 476 | d->playback_status_changed(media::Player::PlaybackStatus::paused); | 477 | d->playback_status_changed(media::Player::PlaybackStatus::paused); |
590 | 477 | } | 478 | } |
591 | 478 | 479 | ||
592 | 479 | 480 | ||
593 | === modified file 'src/core/media/gstreamer/playbin.cpp' | |||
594 | --- src/core/media/gstreamer/playbin.cpp 2016-03-07 21:05:26 +0000 | |||
595 | +++ src/core/media/gstreamer/playbin.cpp 2016-04-06 19:07:29 +0000 | |||
596 | @@ -25,7 +25,8 @@ | |||
597 | 25 | #include <hybris/media/surface_texture_client_hybris.h> | 25 | #include <hybris/media/surface_texture_client_hybris.h> |
598 | 26 | #include <hybris/media/media_codec_layer.h> | 26 | #include <hybris/media/media_codec_layer.h> |
599 | 27 | 27 | ||
601 | 28 | #include "../util/uri_check.h" | 28 | #include "core/media/logger/logger.h" |
602 | 29 | #include "core/media/util/uri_check.h" | ||
603 | 29 | 30 | ||
604 | 30 | #include <utility> | 31 | #include <utility> |
605 | 31 | 32 | ||
606 | @@ -154,13 +155,13 @@ | |||
607 | 154 | { | 155 | { |
608 | 155 | using namespace std; | 156 | using namespace std; |
609 | 156 | 157 | ||
611 | 157 | cout << func << endl; | 158 | MH_DEBUG("%s", func); |
612 | 158 | if (pb.pipeline) | 159 | if (pb.pipeline) |
614 | 159 | cout << "pipeline: " << GST_OBJECT_REFCOUNT(pb.pipeline) << endl; | 160 | MH_DEBUG("pipeline: %d", GST_OBJECT_REFCOUNT(pb.pipeline)); |
615 | 160 | if (pb.video_sink) | 161 | if (pb.video_sink) |
617 | 161 | cout << "video_sink: " << GST_OBJECT_REFCOUNT(pb.video_sink) << endl; | 162 | MH_DEBUG("video_sink: %d", GST_OBJECT_REFCOUNT(pb.video_sink)); |
618 | 162 | if (pb.audio_sink) | 163 | if (pb.audio_sink) |
620 | 163 | cout << "audio_sink: " << GST_OBJECT_REFCOUNT(pb.audio_sink) << endl; | 164 | MH_DEBUG("audio_sink: %d", GST_OBJECT_REFCOUNT(pb.audio_sink)); |
621 | 164 | } | 165 | } |
622 | 165 | #endif | 166 | #endif |
623 | 166 | 167 | ||
624 | @@ -183,7 +184,7 @@ | |||
625 | 183 | 184 | ||
626 | 184 | void gstreamer::Playbin::reset() | 185 | void gstreamer::Playbin::reset() |
627 | 185 | { | 186 | { |
629 | 186 | std::cout << "Client died, resetting pipeline" << std::endl; | 187 | MH_INFO("Client died, resetting pipeline"); |
630 | 187 | // When the client dies, tear down the current pipeline and get it | 188 | // When the client dies, tear down the current pipeline and get it |
631 | 188 | // in a state that is ready for the next client that connects to the | 189 | // in a state that is ready for the next client that connects to the |
632 | 189 | // service | 190 | // service |
633 | @@ -198,19 +199,19 @@ | |||
634 | 198 | 199 | ||
635 | 199 | void gstreamer::Playbin::reset_pipeline() | 200 | void gstreamer::Playbin::reset_pipeline() |
636 | 200 | { | 201 | { |
640 | 201 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 202 | MH_TRACE(""); |
641 | 202 | auto ret = gst_element_set_state(pipeline, GST_STATE_NULL); | 203 | const auto ret = gst_element_set_state(pipeline, GST_STATE_NULL); |
642 | 203 | switch(ret) | 204 | switch (ret) |
643 | 204 | { | 205 | { |
644 | 205 | case GST_STATE_CHANGE_FAILURE: | 206 | case GST_STATE_CHANGE_FAILURE: |
646 | 206 | std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl; | 207 | MH_WARNING("Failed to reset the pipeline state. Client reconnect may not function properly."); |
647 | 207 | break; | 208 | break; |
648 | 208 | case GST_STATE_CHANGE_NO_PREROLL: | 209 | case GST_STATE_CHANGE_NO_PREROLL: |
649 | 209 | case GST_STATE_CHANGE_SUCCESS: | 210 | case GST_STATE_CHANGE_SUCCESS: |
650 | 210 | case GST_STATE_CHANGE_ASYNC: | 211 | case GST_STATE_CHANGE_ASYNC: |
651 | 211 | break; | 212 | break; |
652 | 212 | default: | 213 | default: |
654 | 213 | std::cout << "Failed to reset the pipeline state. Client reconnect may not function properly." << std::endl; | 214 | MH_WARNING("Failed to reset the pipeline state. Client reconnect may not function properly."); |
655 | 214 | } | 215 | } |
656 | 215 | file_type = MEDIA_FILE_TYPE_NONE; | 216 | file_type = MEDIA_FILE_TYPE_NONE; |
657 | 216 | is_missing_audio_codec = false; | 217 | is_missing_audio_codec = false; |
658 | @@ -225,7 +226,7 @@ | |||
659 | 225 | return; | 226 | return; |
660 | 226 | 227 | ||
661 | 227 | gchar *desc = gst_missing_plugin_message_get_description(message); | 228 | gchar *desc = gst_missing_plugin_message_get_description(message); |
663 | 228 | std::cerr << "Missing plugin: " << desc << std::endl; | 229 | MH_WARNING("Missing plugin: %s", desc); |
664 | 229 | g_free(desc); | 230 | g_free(desc); |
665 | 230 | 231 | ||
666 | 231 | const GstStructure *msg_data = gst_message_get_structure(message); | 232 | const GstStructure *msg_data = gst_message_get_structure(message); |
667 | @@ -234,13 +235,13 @@ | |||
668 | 234 | 235 | ||
669 | 235 | GstCaps *caps; | 236 | GstCaps *caps; |
670 | 236 | if (!gst_structure_get(msg_data, "detail", GST_TYPE_CAPS, &caps, NULL)) { | 237 | if (!gst_structure_get(msg_data, "detail", GST_TYPE_CAPS, &caps, NULL)) { |
672 | 237 | std::cerr << __PRETTY_FUNCTION__ << ": No detail" << std::endl; | 238 | MH_ERROR("No detail"); |
673 | 238 | return; | 239 | return; |
674 | 239 | } | 240 | } |
675 | 240 | 241 | ||
676 | 241 | GstStructure *caps_data = gst_caps_get_structure(caps, 0); | 242 | GstStructure *caps_data = gst_caps_get_structure(caps, 0); |
677 | 242 | if (!caps_data) { | 243 | if (!caps_data) { |
679 | 243 | std::cerr << __PRETTY_FUNCTION__ << ": No caps data" << std::endl; | 244 | MH_ERROR("No caps data"); |
680 | 244 | return; | 245 | return; |
681 | 245 | } | 246 | } |
682 | 246 | 247 | ||
683 | @@ -250,7 +251,7 @@ | |||
684 | 250 | else if (strstr(mime, "video")) | 251 | else if (strstr(mime, "video")) |
685 | 251 | is_missing_video_codec = true; | 252 | is_missing_video_codec = true; |
686 | 252 | 253 | ||
688 | 253 | std::cerr << "Missing decoder for " << mime << std::endl; | 254 | MH_ERROR("Missing decoder for %s", mime); |
689 | 254 | } | 255 | } |
690 | 255 | 256 | ||
691 | 256 | void gstreamer::Playbin::on_new_message_async(const Bus::Message& message) | 257 | void gstreamer::Playbin::on_new_message_async(const Bus::Message& message) |
692 | @@ -324,7 +325,7 @@ | |||
693 | 324 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME"), | 325 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME"), |
694 | 325 | "audio-sink"); | 326 | "audio-sink"); |
695 | 326 | 327 | ||
697 | 327 | std::cout << "audio_sink: " << ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME") << std::endl; | 328 | MH_INFO("audio_sink: %s", ::getenv("CORE_UBUNTU_MEDIA_SERVICE_AUDIO_SINK_NAME")); |
698 | 328 | 329 | ||
699 | 329 | g_object_set ( | 330 | g_object_set ( |
700 | 330 | pipeline, | 331 | pipeline, |
701 | @@ -339,7 +340,7 @@ | |||
702 | 339 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME"), | 340 | ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME"), |
703 | 340 | "video-sink"); | 341 | "video-sink"); |
704 | 341 | 342 | ||
706 | 342 | std::cout << "video_sink: " << ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME") << std::endl; | 343 | MH_INFO("video_sink: %s", ::getenv("CORE_UBUNTU_MEDIA_SERVICE_VIDEO_SINK_NAME")); |
707 | 343 | 344 | ||
708 | 344 | g_object_set ( | 345 | g_object_set ( |
709 | 345 | pipeline, | 346 | pipeline, |
710 | @@ -404,16 +405,17 @@ | |||
711 | 404 | /** Sets the new audio stream role on the pulsesink in playbin */ | 405 | /** Sets the new audio stream role on the pulsesink in playbin */ |
712 | 405 | void gstreamer::Playbin::set_audio_stream_role(media::Player::AudioStreamRole new_audio_role) | 406 | void gstreamer::Playbin::set_audio_stream_role(media::Player::AudioStreamRole new_audio_role) |
713 | 406 | { | 407 | { |
716 | 407 | std::string role_str("props,media.role=" + get_audio_role_str(new_audio_role)); | 408 | const std::string role_str("props,media.role=" + get_audio_role_str(new_audio_role)); |
717 | 408 | std::cout << "Audio stream role: " << role_str << std::endl; | 409 | MH_INFO("Audio stream role: %s", role_str); |
718 | 409 | 410 | ||
719 | 410 | GstStructure *props = gst_structure_from_string (role_str.c_str(), NULL); | 411 | GstStructure *props = gst_structure_from_string (role_str.c_str(), NULL); |
721 | 411 | if (audio_sink != nullptr && props != nullptr) { | 412 | if (audio_sink != nullptr && props != nullptr) |
722 | 413 | { | ||
723 | 412 | g_object_set (audio_sink, "stream-properties", props, NULL); | 414 | g_object_set (audio_sink, "stream-properties", props, NULL); |
728 | 413 | } else { | 415 | } |
729 | 414 | std::cerr << | 416 | else |
730 | 415 | "Warning: couldn't set audio stream role - couldn't get audio_sink from pipeline" << | 417 | { |
731 | 416 | std::endl; | 418 | MH_WARNING("Couldn't set audio stream role - couldn't get audio_sink from pipeline"); |
732 | 417 | } | 419 | } |
733 | 418 | 420 | ||
734 | 419 | gst_structure_free (props); | 421 | gst_structure_free (props); |
735 | @@ -475,9 +477,7 @@ | |||
736 | 475 | { | 477 | { |
737 | 476 | // First decode the URI just in case it's partially encoded already | 478 | // First decode the URI just in case it's partially encoded already |
738 | 477 | tmp_uri = decode_uri(uri); | 479 | tmp_uri = decode_uri(uri); |
742 | 478 | #ifdef VERBOSE_DEBUG | 480 | MH_DEBUG("File URI was encoded, now decoded: %s", tmp_uri); |
740 | 479 | std::cout << "File URI was encoded, now decoded: " << tmp_uri << std::endl; | ||
741 | 480 | #endif | ||
743 | 481 | } | 481 | } |
744 | 482 | tmp_uri = encode_uri(tmp_uri); | 482 | tmp_uri = encode_uri(tmp_uri); |
745 | 483 | } | 483 | } |
746 | @@ -538,7 +538,7 @@ | |||
747 | 538 | 538 | ||
748 | 539 | auto ret = gst_element_set_state(pipeline, new_state); | 539 | auto ret = gst_element_set_state(pipeline, new_state); |
749 | 540 | 540 | ||
751 | 541 | std::cout << __PRETTY_FUNCTION__ << ": requested state change." << std::endl; | 541 | MH_DEBUG("Requested state change."); |
752 | 542 | 542 | ||
753 | 543 | bool result = false; GstState current, pending; | 543 | bool result = false; GstState current, pending; |
754 | 544 | switch(ret) | 544 | switch(ret) |
755 | @@ -570,15 +570,15 @@ | |||
756 | 570 | } | 570 | } |
757 | 571 | catch (const std::exception& e) | 571 | catch (const std::exception& e) |
758 | 572 | { | 572 | { |
760 | 573 | std::cerr << "Problem querying video dimensions: " << e.what() << std::endl; | 573 | MH_WARNING("Problem querying video dimensions: %s", e.what()); |
761 | 574 | } | 574 | } |
762 | 575 | catch (...) | 575 | catch (...) |
763 | 576 | { | 576 | { |
765 | 577 | std::cerr << "Problem querying video dimensions." << std::endl; | 577 | MH_WARNING("Problem querying video dimensions."); |
766 | 578 | } | 578 | } |
767 | 579 | 579 | ||
768 | 580 | #ifdef DEBUG_GST_PIPELINE | 580 | #ifdef DEBUG_GST_PIPELINE |
770 | 581 | std::cout << "Dumping pipeline dot file" << std::endl; | 581 | MH_DEBUG("Dumping pipeline dot file"); |
771 | 582 | GST_DEBUG_BIN_TO_DOT_FILE((GstBin*)pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); | 582 | GST_DEBUG_BIN_TO_DOT_FILE((GstBin*)pipeline, GST_DEBUG_GRAPH_SHOW_ALL, "pipeline"); |
772 | 583 | #endif | 583 | #endif |
773 | 584 | } | 584 | } |
774 | @@ -656,17 +656,13 @@ | |||
775 | 656 | // We have a URI and it is already percent encoded | 656 | // We have a URI and it is already percent encoded |
776 | 657 | if (uri_scheme and strlen(uri_scheme) > 0 and uri_check->is_encoded()) | 657 | if (uri_scheme and strlen(uri_scheme) > 0 and uri_check->is_encoded()) |
777 | 658 | { | 658 | { |
781 | 659 | #ifdef VERBOSE_DEBUG | 659 | MH_DEBUG("Is a URI and is already percent encoded"); |
779 | 660 | std::cout << "Is a URI and is already percent encoded" << std::endl; | ||
780 | 661 | #endif | ||
782 | 662 | encoded_uri = uri; | 660 | encoded_uri = uri; |
783 | 663 | } | 661 | } |
784 | 664 | // We have a URI but it's not already percent encoded | 662 | // We have a URI but it's not already percent encoded |
785 | 665 | else if (uri_scheme and strlen(uri_scheme) > 0 and !uri_check->is_encoded()) | 663 | else if (uri_scheme and strlen(uri_scheme) > 0 and !uri_check->is_encoded()) |
786 | 666 | { | 664 | { |
790 | 667 | #ifdef VERBOSE_DEBUG | 665 | MH_DEBUG("Is a URI and is not already percent encoded"); |
788 | 668 | std::cout << "Is a URI and is not already percent encoded" << std::endl; | ||
789 | 669 | #endif | ||
791 | 670 | gchar *encoded = g_uri_escape_string(uri.c_str(), | 666 | gchar *encoded = g_uri_escape_string(uri.c_str(), |
792 | 671 | "!$&'()*+,;=:/?[]@", // reserved chars | 667 | "!$&'()*+,;=:/?[]@", // reserved chars |
793 | 672 | TRUE); // Allow UTF-8 chars | 668 | TRUE); // Allow UTF-8 chars |
794 | @@ -681,9 +677,7 @@ | |||
795 | 681 | else // We have a path and not a URI. Turn it into a full URI and encode it | 677 | else // We have a path and not a URI. Turn it into a full URI and encode it |
796 | 682 | { | 678 | { |
797 | 683 | GError *error = nullptr; | 679 | GError *error = nullptr; |
801 | 684 | #ifdef VERBOSE_DEBUG | 680 | MH_DEBUG("Is a path and is not already percent encoded"); |
799 | 685 | std::cout << "Is a path and is not already percent encoded" << std::endl; | ||
800 | 686 | #endif | ||
802 | 687 | gchar *str = g_filename_to_uri(uri.c_str(), nullptr, &error); | 681 | gchar *str = g_filename_to_uri(uri.c_str(), nullptr, &error); |
803 | 688 | if (!str) | 682 | if (!str) |
804 | 689 | { | 683 | { |
805 | @@ -694,8 +688,7 @@ | |||
806 | 694 | g_free(str); | 688 | g_free(str); |
807 | 695 | if (error != nullptr) | 689 | if (error != nullptr) |
808 | 696 | { | 690 | { |
811 | 697 | std::cerr << "Warning: failed to get actual track content type: " << error->message | 691 | MH_WARNING("Failed to get actual track content type: %s", error->message); |
810 | 698 | << std::endl; | ||
812 | 699 | g_error_free(error); | 692 | g_error_free(error); |
813 | 700 | g_free(str); | 693 | g_free(str); |
814 | 701 | g_free(uri_scheme); | 694 | g_free(uri_scheme); |
815 | @@ -742,11 +735,11 @@ | |||
816 | 742 | const std::string content_type {file_info_from_uri(encoded_uri)}; | 735 | const std::string content_type {file_info_from_uri(encoded_uri)}; |
817 | 743 | if (content_type.empty()) | 736 | if (content_type.empty()) |
818 | 744 | { | 737 | { |
820 | 745 | std::cerr << "Warning: failed to get actual track content type" << std::endl; | 738 | MH_WARNING("Failed to get actual track content type"); |
821 | 746 | return std::string("audio/video/"); | 739 | return std::string("audio/video/"); |
822 | 747 | } | 740 | } |
823 | 748 | 741 | ||
825 | 749 | std::cout << "Found content type: " << content_type << std::endl; | 742 | MH_INFO("Found content type: %s", content_type); |
826 | 750 | 743 | ||
827 | 751 | return content_type; | 744 | return content_type; |
828 | 752 | } | 745 | } |
829 | @@ -758,7 +751,7 @@ | |||
830 | 758 | 751 | ||
831 | 759 | if (get_file_content_type(uri).find("audio/") == 0) | 752 | if (get_file_content_type(uri).find("audio/") == 0) |
832 | 760 | { | 753 | { |
834 | 761 | std::cout << "Found audio content" << std::endl; | 754 | MH_INFO("Found audio content"); |
835 | 762 | return true; | 755 | return true; |
836 | 763 | } | 756 | } |
837 | 764 | 757 | ||
838 | @@ -772,7 +765,7 @@ | |||
839 | 772 | 765 | ||
840 | 773 | if (get_file_content_type(uri).find("video/") == 0) | 766 | if (get_file_content_type(uri).find("video/") == 0) |
841 | 774 | { | 767 | { |
843 | 775 | std::cout << "Found video content" << std::endl; | 768 | MH_INFO("Found video content"); |
844 | 776 | return true; | 769 | return true; |
845 | 777 | } | 770 | } |
846 | 778 | 771 | ||
847 | 779 | 772 | ||
848 | === added directory 'src/core/media/logger' | |||
849 | === added file 'src/core/media/logger/logger.cpp' | |||
850 | --- src/core/media/logger/logger.cpp 1970-01-01 00:00:00 +0000 | |||
851 | +++ src/core/media/logger/logger.cpp 2016-04-06 19:07:29 +0000 | |||
852 | @@ -0,0 +1,161 @@ | |||
853 | 1 | /* | ||
854 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
855 | 3 | * | ||
856 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
857 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
858 | 6 | * by the Free Software Foundation. | ||
859 | 7 | * | ||
860 | 8 | * This program is distributed in the hope that it will be useful, but | ||
861 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
862 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
863 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
864 | 12 | * | ||
865 | 13 | * You should have received a copy of the GNU General Public License along | ||
866 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
867 | 15 | * | ||
868 | 16 | */ | ||
869 | 17 | |||
870 | 18 | #include <thread> | ||
871 | 19 | |||
872 | 20 | #include "logger.h" | ||
873 | 21 | |||
874 | 22 | #define BOOST_LOG_DYN_LINK | ||
875 | 23 | #include <boost/date_time.hpp> | ||
876 | 24 | #include <boost/filesystem.hpp> | ||
877 | 25 | #include <boost/log/trivial.hpp> | ||
878 | 26 | #include <boost/log/expressions.hpp> | ||
879 | 27 | #include <boost/log/support/date_time.hpp> | ||
880 | 28 | #include <boost/log/utility/manipulators.hpp> | ||
881 | 29 | #include <boost/log/utility/setup.hpp> | ||
882 | 30 | |||
883 | 31 | namespace media = core::ubuntu::media; | ||
884 | 32 | |||
885 | 33 | namespace { | ||
886 | 34 | namespace attrs { | ||
887 | 35 | BOOST_LOG_ATTRIBUTE_KEYWORD(Severity, "core::ubuntu::media::Severity", media::Logger::Severity) | ||
888 | 36 | BOOST_LOG_ATTRIBUTE_KEYWORD(Location, "Location", media::Logger::Location) | ||
889 | 37 | BOOST_LOG_ATTRIBUTE_KEYWORD(Timestamp, "Timestamp", boost::posix_time::ptime) | ||
890 | 38 | } | ||
891 | 39 | |||
892 | 40 | struct BoostLogLogger : public media::Logger { | ||
893 | 41 | BoostLogLogger() : | ||
894 | 42 | initialized_(false) { | ||
895 | 43 | } | ||
896 | 44 | |||
897 | 45 | void Init(const media::Logger::Severity &severity = media::Logger::Severity::kWarning) override { | ||
898 | 46 | if (initialized_) | ||
899 | 47 | return; | ||
900 | 48 | |||
901 | 49 | boost::log::formatter formatter = boost::log::expressions::stream | ||
902 | 50 | << "[" << attrs::Severity << " " | ||
903 | 51 | << boost::log::expressions::format_date_time< boost::posix_time::ptime >("Timestamp", "%Y-%m-%d %H:%M:%S.%f") | ||
904 | 52 | << "] " | ||
905 | 53 | << boost::log::expressions::if_(boost::log::expressions::has_attr(attrs::Location)) | ||
906 | 54 | [ | ||
907 | 55 | boost::log::expressions::stream << "[" << attrs::Location << "] " | ||
908 | 56 | ] | ||
909 | 57 | << boost::log::expressions::smessage; | ||
910 | 58 | |||
911 | 59 | boost::log::core::get()->remove_all_sinks(); | ||
912 | 60 | auto logger = boost::log::add_console_log(std::cout); | ||
913 | 61 | logger->set_formatter(formatter); | ||
914 | 62 | |||
915 | 63 | // FIXME need to enable this once we found how we wrap this | ||
916 | 64 | // properly into our service architecture. For now left as | ||
917 | 65 | // it is. | ||
918 | 66 | boost::ignore_unused_variable_warning(severity); | ||
919 | 67 | // logger->set_filter(attrs::Severity < severity); | ||
920 | 68 | |||
921 | 69 | initialized_ = true; | ||
922 | 70 | } | ||
923 | 71 | |||
924 | 72 | void Log(Severity severity, const std::string& message, const boost::optional<Location> &loc) { | ||
925 | 73 | if (!initialized_) | ||
926 | 74 | Init(); | ||
927 | 75 | |||
928 | 76 | if (auto rec = boost::log::trivial::logger::get().open_record()) { | ||
929 | 77 | boost::log::record_ostream out{rec}; | ||
930 | 78 | out << boost::log::add_value(attrs::Severity, severity) | ||
931 | 79 | << boost::log::add_value(attrs::Timestamp, boost::posix_time::microsec_clock::universal_time()) | ||
932 | 80 | << message; | ||
933 | 81 | |||
934 | 82 | if (loc) { | ||
935 | 83 | // We have to pass in a temporary as boost::log (<= 1.55) expects a | ||
936 | 84 | // mutable reference to be passed to boost::log::add_value(...). | ||
937 | 85 | auto tmp = *loc; | ||
938 | 86 | out << boost::log::add_value(attrs::Location, tmp); | ||
939 | 87 | } | ||
940 | 88 | |||
941 | 89 | boost::log::trivial::logger::get().push_record(std::move(rec)); | ||
942 | 90 | } | ||
943 | 91 | } | ||
944 | 92 | |||
945 | 93 | private: | ||
946 | 94 | bool initialized_; | ||
947 | 95 | }; | ||
948 | 96 | |||
949 | 97 | std::shared_ptr<media::Logger>& MutableInstance() { | ||
950 | 98 | static std::shared_ptr<media::Logger> instance{new BoostLogLogger()}; | ||
951 | 99 | return instance; | ||
952 | 100 | } | ||
953 | 101 | |||
954 | 102 | void SetInstance(const std::shared_ptr<media::Logger>& logger) { | ||
955 | 103 | MutableInstance() = logger; | ||
956 | 104 | } | ||
957 | 105 | } | ||
958 | 106 | |||
959 | 107 | void media::Logger::Trace(const std::string& message, const boost::optional<Location>& location) { | ||
960 | 108 | Log(Severity::kTrace, message, location); | ||
961 | 109 | } | ||
962 | 110 | |||
963 | 111 | void media::Logger::Debug(const std::string& message, const boost::optional<Location>& location) { | ||
964 | 112 | Log(Severity::kDebug, message, location); | ||
965 | 113 | } | ||
966 | 114 | |||
967 | 115 | void media::Logger::Info(const std::string& message, const boost::optional<Location>& location) { | ||
968 | 116 | Log(Severity::kInfo, message, location); | ||
969 | 117 | } | ||
970 | 118 | |||
971 | 119 | void media::Logger::Warning(const std::string& message, const boost::optional<Location>& location) { | ||
972 | 120 | Log(Severity::kWarning, message, location); | ||
973 | 121 | } | ||
974 | 122 | |||
975 | 123 | void media::Logger::Error(const std::string& message, const boost::optional<Location>& location) { | ||
976 | 124 | Log(Severity::kError, message, location); | ||
977 | 125 | } | ||
978 | 126 | |||
979 | 127 | void media::Logger::Fatal(const std::string& message, const boost::optional<Location>& location) { | ||
980 | 128 | Log(Severity::kFatal, message, location); | ||
981 | 129 | } | ||
982 | 130 | |||
983 | 131 | namespace core { | ||
984 | 132 | namespace ubuntu { | ||
985 | 133 | namespace media { | ||
986 | 134 | |||
987 | 135 | std::ostream& operator<<(std::ostream& strm, Logger::Severity severity) { | ||
988 | 136 | switch (severity) { | ||
989 | 137 | case media::Logger::Severity::kTrace: return strm << "TT"; | ||
990 | 138 | case media::Logger::Severity::kDebug: return strm << "DD"; | ||
991 | 139 | case media::Logger::Severity::kInfo: return strm << "II"; | ||
992 | 140 | case media::Logger::Severity::kWarning: return strm << "WW"; | ||
993 | 141 | case media::Logger::Severity::kError: return strm << "EE"; | ||
994 | 142 | case media::Logger::Severity::kFatal: return strm << "FF"; | ||
995 | 143 | default: return strm << static_cast<uint>(severity); | ||
996 | 144 | } | ||
997 | 145 | } | ||
998 | 146 | |||
999 | 147 | std::ostream& operator<<(std::ostream& out, const Logger::Location &location) { | ||
1000 | 148 | return out << Utils::Sprintf("%s:%d@%s", boost::filesystem::path(location.file).filename().string(), location.line, location.function); | ||
1001 | 149 | } | ||
1002 | 150 | |||
1003 | 151 | Logger& Log() { | ||
1004 | 152 | return *MutableInstance(); | ||
1005 | 153 | } | ||
1006 | 154 | |||
1007 | 155 | void SetLogger(const std::shared_ptr<Logger>& logger) { | ||
1008 | 156 | SetInstance(logger); | ||
1009 | 157 | } | ||
1010 | 158 | |||
1011 | 159 | } // namespace media | ||
1012 | 160 | } // namespace ubuntu | ||
1013 | 161 | } // namespace core | ||
1014 | 0 | 162 | ||
1015 | === added file 'src/core/media/logger/logger.h' | |||
1016 | --- src/core/media/logger/logger.h 1970-01-01 00:00:00 +0000 | |||
1017 | +++ src/core/media/logger/logger.h 2016-04-06 19:07:29 +0000 | |||
1018 | @@ -0,0 +1,131 @@ | |||
1019 | 1 | /* | ||
1020 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
1021 | 3 | * | ||
1022 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1023 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1024 | 6 | * by the Free Software Foundation. | ||
1025 | 7 | * | ||
1026 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1027 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1028 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1029 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1030 | 12 | * | ||
1031 | 13 | * You should have received a copy of the GNU General Public License along | ||
1032 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1033 | 15 | * | ||
1034 | 16 | */ | ||
1035 | 17 | |||
1036 | 18 | #ifndef LOGGER_H_ | ||
1037 | 19 | #define LOGGER_H_ | ||
1038 | 20 | |||
1039 | 21 | #include "core/media/non_copyable.h" | ||
1040 | 22 | #include "core/media/util/utils.h" | ||
1041 | 23 | |||
1042 | 24 | #include <boost/optional.hpp> | ||
1043 | 25 | |||
1044 | 26 | #include <string> | ||
1045 | 27 | |||
1046 | 28 | namespace core { | ||
1047 | 29 | namespace ubuntu { | ||
1048 | 30 | namespace media { | ||
1049 | 31 | // A Logger enables persisting of messages describing & explaining the | ||
1050 | 32 | // state of the system. | ||
1051 | 33 | class Logger : public core::ubuntu::media::NonCopyable { | ||
1052 | 34 | public: | ||
1053 | 35 | // Severity enumerates all known severity levels | ||
1054 | 36 | // applicable to log messages. | ||
1055 | 37 | enum class Severity { | ||
1056 | 38 | kTrace, | ||
1057 | 39 | kDebug, | ||
1058 | 40 | kInfo, | ||
1059 | 41 | kWarning, | ||
1060 | 42 | kError, | ||
1061 | 43 | kFatal | ||
1062 | 44 | }; | ||
1063 | 45 | |||
1064 | 46 | // A Location describes the origin of a log message. | ||
1065 | 47 | struct Location { | ||
1066 | 48 | std::string file; // The name of the file that contains the log message. | ||
1067 | 49 | std::string function; // The function that contains the log message. | ||
1068 | 50 | std::uint32_t line; // The line in file that resulted in the log message. | ||
1069 | 51 | }; | ||
1070 | 52 | |||
1071 | 53 | virtual void Init(const core::ubuntu::media::Logger::Severity &severity = core::ubuntu::media::Logger::Severity::kWarning) = 0; | ||
1072 | 54 | |||
1073 | 55 | virtual void Log(Severity severity, const std::string &message, const boost::optional<Location>& location) = 0; | ||
1074 | 56 | |||
1075 | 57 | virtual void Trace(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
1076 | 58 | virtual void Debug(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
1077 | 59 | virtual void Info(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
1078 | 60 | virtual void Warning(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
1079 | 61 | virtual void Error(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
1080 | 62 | virtual void Fatal(const std::string& message, const boost::optional<Location>& location = boost::optional<Location>{}); | ||
1081 | 63 | |||
1082 | 64 | |||
1083 | 65 | template<typename... T> | ||
1084 | 66 | void Tracef(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
1085 | 67 | Trace(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
1086 | 68 | } | ||
1087 | 69 | |||
1088 | 70 | template<typename... T> | ||
1089 | 71 | void Debugf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
1090 | 72 | Debug(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
1091 | 73 | } | ||
1092 | 74 | |||
1093 | 75 | template<typename... T> | ||
1094 | 76 | void Infof(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
1095 | 77 | Info(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
1096 | 78 | } | ||
1097 | 79 | |||
1098 | 80 | template<typename... T> | ||
1099 | 81 | void Warningf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
1100 | 82 | Warning(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
1101 | 83 | } | ||
1102 | 84 | |||
1103 | 85 | template<typename... T> | ||
1104 | 86 | void Errorf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
1105 | 87 | Error(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
1106 | 88 | } | ||
1107 | 89 | |||
1108 | 90 | template<typename... T> | ||
1109 | 91 | void Fatalf(const boost::optional<Location>& location, const std::string& pattern, T&&...args) { | ||
1110 | 92 | Fatal(Utils::Sprintf(pattern, std::forward<T>(args)...), location); | ||
1111 | 93 | } | ||
1112 | 94 | |||
1113 | 95 | protected: | ||
1114 | 96 | Logger() = default; | ||
1115 | 97 | }; | ||
1116 | 98 | |||
1117 | 99 | // operator<< inserts severity into out. | ||
1118 | 100 | std::ostream& operator<<(std::ostream& out, Logger::Severity severity); | ||
1119 | 101 | |||
1120 | 102 | // operator<< inserts location into out. | ||
1121 | 103 | std::ostream& operator<<(std::ostream& out, const Logger::Location &location); | ||
1122 | 104 | |||
1123 | 105 | // Log returns the core::ubuntu::media-wide configured logger instance. | ||
1124 | 106 | // Save to call before/after main. | ||
1125 | 107 | Logger& Log(); | ||
1126 | 108 | // SetLog installs the given logger as core::ubuntu::media-wide default logger. | ||
1127 | 109 | void SetLogger(const std::shared_ptr<Logger>& logger); | ||
1128 | 110 | |||
1129 | 111 | #define TRACE(...) Log().Tracef(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1130 | 112 | #define DEBUG(...) Log().Debugf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1131 | 113 | #define INFO(...) Log().Infof(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1132 | 114 | #define WARNING(...) Log().Warningf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1133 | 115 | #define ERROR(...) Log().Errorf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1134 | 116 | #define FATAL(...) Log().Fatalf(Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1135 | 117 | } // namespace media | ||
1136 | 118 | } // namespace ubuntu | ||
1137 | 119 | } // namespace core | ||
1138 | 120 | |||
1139 | 121 | #define MH_TRACE(...) core::ubuntu::media::Log().Tracef(\ | ||
1140 | 122 | core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1141 | 123 | #define MH_DEBUG(...) core::ubuntu::media::Log().Debugf(\ | ||
1142 | 124 | core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1143 | 125 | #define MH_INFO(...) core::ubuntu::media::Log().Infof(\ | ||
1144 | 126 | core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1145 | 127 | #define MH_WARNING(...) core::ubuntu::media::Log().Warningf(core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1146 | 128 | #define MH_ERROR(...) core::ubuntu::media::Log().Errorf(core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1147 | 129 | #define MH_FATAL(...) core::ubuntu::media::Log().Fatalf(core::ubuntu::media::Logger::Location{__FILE__, __FUNCTION__, __LINE__}, __VA_ARGS__) | ||
1148 | 130 | |||
1149 | 131 | #endif | ||
1150 | 0 | 132 | ||
1151 | === added file 'src/core/media/non_copyable.h' | |||
1152 | --- src/core/media/non_copyable.h 1970-01-01 00:00:00 +0000 | |||
1153 | +++ src/core/media/non_copyable.h 2016-04-06 19:07:29 +0000 | |||
1154 | @@ -0,0 +1,36 @@ | |||
1155 | 1 | /* | ||
1156 | 2 | * Copyright (C) 2015 Canonical, Ltd. | ||
1157 | 3 | * | ||
1158 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
1159 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
1160 | 6 | * by the Free Software Foundation. | ||
1161 | 7 | * | ||
1162 | 8 | * This program is distributed in the hope that it will be useful, but | ||
1163 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
1164 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
1165 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
1166 | 12 | * | ||
1167 | 13 | * You should have received a copy of the GNU General Public License along | ||
1168 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
1169 | 15 | * | ||
1170 | 16 | */ | ||
1171 | 17 | |||
1172 | 18 | #ifndef NON_COPYABLE_H_ | ||
1173 | 19 | #define NON_COPYABLE_H_ | ||
1174 | 20 | |||
1175 | 21 | namespace core { | ||
1176 | 22 | namespace ubuntu { | ||
1177 | 23 | namespace media { | ||
1178 | 24 | // The alert reader might wonder why we don't use boost::noncopyable. The reason | ||
1179 | 25 | // is simple: We would like to have a convenient virtual d'tor available. | ||
1180 | 26 | struct NonCopyable { | ||
1181 | 27 | NonCopyable() = default; | ||
1182 | 28 | NonCopyable(const NonCopyable&) = delete; | ||
1183 | 29 | virtual ~NonCopyable() = default; | ||
1184 | 30 | NonCopyable& operator=(const NonCopyable&) = delete; | ||
1185 | 31 | }; | ||
1186 | 32 | } | ||
1187 | 33 | } | ||
1188 | 34 | } | ||
1189 | 35 | |||
1190 | 36 | #endif | ||
1191 | 0 | 37 | ||
1192 | === modified file 'src/core/media/player_implementation.cpp' | |||
1193 | --- src/core/media/player_implementation.cpp 2016-02-19 16:14:42 +0000 | |||
1194 | +++ src/core/media/player_implementation.cpp 2016-04-06 19:07:29 +0000 | |||
1195 | @@ -28,9 +28,10 @@ | |||
1196 | 28 | 28 | ||
1197 | 29 | #include "gstreamer/engine.h" | 29 | #include "gstreamer/engine.h" |
1198 | 30 | 30 | ||
1199 | 31 | #include "core/media/logger/logger.h" | ||
1200 | 32 | |||
1201 | 31 | #include <memory> | 33 | #include <memory> |
1202 | 32 | #include <exception> | 34 | #include <exception> |
1203 | 33 | #include <iostream> | ||
1204 | 34 | #include <mutex> | 35 | #include <mutex> |
1205 | 35 | 36 | ||
1206 | 36 | #define UNUSED __attribute__((unused)) | 37 | #define UNUSED __attribute__((unused)) |
1207 | @@ -75,22 +76,22 @@ | |||
1208 | 75 | // Poor man's logging of release/acquire events. | 76 | // Poor man's logging of release/acquire events. |
1209 | 76 | display_state_lock->acquired().connect([](media::power::DisplayState state) | 77 | display_state_lock->acquired().connect([](media::power::DisplayState state) |
1210 | 77 | { | 78 | { |
1212 | 78 | std::cout << "Acquired new display state: " << state << std::endl; | 79 | MH_INFO("Acquired new display state: %s", state); |
1213 | 79 | }); | 80 | }); |
1214 | 80 | 81 | ||
1215 | 81 | display_state_lock->released().connect([](media::power::DisplayState state) | 82 | display_state_lock->released().connect([](media::power::DisplayState state) |
1216 | 82 | { | 83 | { |
1218 | 83 | std::cout << "Released display state: " << state << std::endl; | 84 | MH_INFO("Released display state: %s", state); |
1219 | 84 | }); | 85 | }); |
1220 | 85 | 86 | ||
1221 | 86 | system_state_lock->acquired().connect([](media::power::SystemState state) | 87 | system_state_lock->acquired().connect([](media::power::SystemState state) |
1222 | 87 | { | 88 | { |
1224 | 88 | std::cout << "Acquired new system state: " << state << std::endl; | 89 | MH_INFO("Acquired new system state: %s", state); |
1225 | 89 | }); | 90 | }); |
1226 | 90 | 91 | ||
1227 | 91 | system_state_lock->released().connect([](media::power::SystemState state) | 92 | system_state_lock->released().connect([](media::power::SystemState state) |
1228 | 92 | { | 93 | { |
1230 | 93 | std::cout << "Released system state: " << state << std::endl; | 94 | MH_INFO("Released system state: %s", state); |
1231 | 94 | }); | 95 | }); |
1232 | 95 | } | 96 | } |
1233 | 96 | 97 | ||
1234 | @@ -120,7 +121,7 @@ | |||
1235 | 120 | */ | 121 | */ |
1236 | 121 | return [this](const Engine::State& state) | 122 | return [this](const Engine::State& state) |
1237 | 122 | { | 123 | { |
1239 | 123 | std::cout << "Setting state for parent: " << parent << std::endl; | 124 | MH_DEBUG("Setting state for parent: %s", parent); |
1240 | 124 | switch(state) | 125 | switch(state) |
1241 | 125 | { | 126 | { |
1242 | 126 | case Engine::State::ready: | 127 | case Engine::State::ready: |
1243 | @@ -139,7 +140,7 @@ | |||
1244 | 139 | parent->meta_data_for_current_track().set(std::get<1>(engine->track_meta_data().get())); | 140 | parent->meta_data_for_current_track().set(std::get<1>(engine->track_meta_data().get())); |
1245 | 140 | // And update our playback status. | 141 | // And update our playback status. |
1246 | 141 | parent->playback_status().set(media::Player::playing); | 142 | parent->playback_status().set(media::Player::playing); |
1248 | 142 | std::cout << "Requesting power state" << std::endl; | 143 | MH_INFO("Requesting power state"); |
1249 | 143 | request_power_state(); | 144 | request_power_state(); |
1250 | 144 | break; | 145 | break; |
1251 | 145 | } | 146 | } |
1252 | @@ -174,45 +175,44 @@ | |||
1253 | 174 | { | 175 | { |
1254 | 175 | return [this](const media::Player::PlaybackStatus& status) | 176 | return [this](const media::Player::PlaybackStatus& status) |
1255 | 176 | { | 177 | { |
1257 | 177 | std::cout << "Emiting playback_status_changed signal: " << status << std::endl; | 178 | MH_INFO("Emiting playback_status_changed signal: %s", status); |
1258 | 178 | parent->emit_playback_status_changed(status); | 179 | parent->emit_playback_status_changed(status); |
1259 | 179 | }; | 180 | }; |
1260 | 180 | } | 181 | } |
1261 | 181 | 182 | ||
1262 | 182 | void request_power_state() | 183 | void request_power_state() |
1263 | 183 | { | 184 | { |
1265 | 184 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 185 | MH_TRACE(""); |
1266 | 185 | try | 186 | try |
1267 | 186 | { | 187 | { |
1268 | 187 | if (parent->is_video_source()) | 188 | if (parent->is_video_source()) |
1269 | 188 | { | 189 | { |
1270 | 189 | if (++display_wakelock_count == 1) | 190 | if (++display_wakelock_count == 1) |
1271 | 190 | { | 191 | { |
1273 | 191 | std::cout << "Requesting new display wakelock." << std::endl; | 192 | MH_INFO("Requesting new display wakelock."); |
1274 | 192 | display_state_lock->request_acquire(media::power::DisplayState::on); | 193 | display_state_lock->request_acquire(media::power::DisplayState::on); |
1276 | 193 | std::cout << "Requested new display wakelock." << std::endl; | 194 | MH_INFO("Requested new display wakelock."); |
1277 | 194 | } | 195 | } |
1278 | 195 | } | 196 | } |
1279 | 196 | else | 197 | else |
1280 | 197 | { | 198 | { |
1281 | 198 | if (++system_wakelock_count == 1) | 199 | if (++system_wakelock_count == 1) |
1282 | 199 | { | 200 | { |
1284 | 200 | std::cout << "Requesting new system wakelock." << std::endl; | 201 | MH_INFO("Requesting new system wakelock."); |
1285 | 201 | system_state_lock->request_acquire(media::power::SystemState::active); | 202 | system_state_lock->request_acquire(media::power::SystemState::active); |
1287 | 202 | std::cout << "Requested new system wakelock." << std::endl; | 203 | MH_INFO("Requested new system wakelock."); |
1288 | 203 | } | 204 | } |
1289 | 204 | } | 205 | } |
1290 | 205 | } | 206 | } |
1291 | 206 | catch(const std::exception& e) | 207 | catch(const std::exception& e) |
1292 | 207 | { | 208 | { |
1295 | 208 | std::cerr << "Warning: failed to request power state: "; | 209 | MH_WARNING("Failed to request power state: %s", e.what()); |
1294 | 209 | std::cerr << e.what() << std::endl; | ||
1296 | 210 | } | 210 | } |
1297 | 211 | } | 211 | } |
1298 | 212 | 212 | ||
1299 | 213 | void clear_wakelock(const wakelock_clear_t &wakelock) | 213 | void clear_wakelock(const wakelock_clear_t &wakelock) |
1300 | 214 | { | 214 | { |
1302 | 215 | cout << __PRETTY_FUNCTION__ << endl; | 215 | MH_TRACE(""); |
1303 | 216 | try | 216 | try |
1304 | 217 | { | 217 | { |
1305 | 218 | switch (wakelock) | 218 | switch (wakelock) |
1306 | @@ -223,7 +223,7 @@ | |||
1307 | 223 | // Only actually clear the system wakelock once the count reaches zero | 223 | // Only actually clear the system wakelock once the count reaches zero |
1308 | 224 | if (--system_wakelock_count == 0) | 224 | if (--system_wakelock_count == 0) |
1309 | 225 | { | 225 | { |
1311 | 226 | std::cout << "Clearing system wakelock." << std::endl; | 226 | MH_INFO("Clearing system wakelock."); |
1312 | 227 | system_state_lock->request_release(media::power::SystemState::active); | 227 | system_state_lock->request_release(media::power::SystemState::active); |
1313 | 228 | } | 228 | } |
1314 | 229 | break; | 229 | break; |
1315 | @@ -231,19 +231,18 @@ | |||
1316 | 231 | // Only actually clear the display wakelock once the count reaches zero | 231 | // Only actually clear the display wakelock once the count reaches zero |
1317 | 232 | if (--display_wakelock_count == 0) | 232 | if (--display_wakelock_count == 0) |
1318 | 233 | { | 233 | { |
1320 | 234 | std::cout << "Clearing display wakelock." << std::endl; | 234 | MH_INFO("Clearing display wakelock."); |
1321 | 235 | display_state_lock->request_release(media::power::DisplayState::on); | 235 | display_state_lock->request_release(media::power::DisplayState::on); |
1322 | 236 | } | 236 | } |
1323 | 237 | break; | 237 | break; |
1324 | 238 | case wakelock_clear_t::WAKELOCK_CLEAR_INVALID: | 238 | case wakelock_clear_t::WAKELOCK_CLEAR_INVALID: |
1325 | 239 | default: | 239 | default: |
1327 | 240 | cerr << "Can't clear invalid wakelock type" << endl; | 240 | MH_WARNING("Can't clear invalid wakelock type"); |
1328 | 241 | } | 241 | } |
1329 | 242 | } | 242 | } |
1330 | 243 | catch(const std::exception& e) | 243 | catch(const std::exception& e) |
1331 | 244 | { | 244 | { |
1334 | 245 | std::cerr << "Warning: failed to clear power state: "; | 245 | MH_WARNING("Failed to request clear power state: %s", e.what()); |
1333 | 246 | std::cerr << e.what() << std::endl; | ||
1335 | 247 | } | 246 | } |
1336 | 248 | } | 247 | } |
1337 | 249 | 248 | ||
1338 | @@ -294,9 +293,9 @@ | |||
1339 | 294 | { | 293 | { |
1340 | 295 | // Using a TrackList for playback, added tracks via add_track(), but open_uri hasn't | 294 | // Using a TrackList for playback, added tracks via add_track(), but open_uri hasn't |
1341 | 296 | // been called yet to load a media resource | 295 | // been called yet to load a media resource |
1345 | 297 | std::cout << "Calling d->engine->open_resource_for_uri() for first track added only: " | 296 | MH_INFO("Calling d->engine->open_resource_for_uri() for first track added only: %s", |
1346 | 298 | << uri << std::endl; | 297 | uri); |
1347 | 299 | std::cout << "\twith a Track::Id: " << id << std::endl; | 298 | MH_INFO("\twith a Track::Id: %s", id); |
1348 | 300 | static const bool do_pipeline_reset = false; | 299 | static const bool do_pipeline_reset = false; |
1349 | 301 | engine->open_resource_for_uri(uri, do_pipeline_reset); | 300 | engine->open_resource_for_uri(uri, do_pipeline_reset); |
1350 | 302 | } | 301 | } |
1351 | @@ -311,10 +310,10 @@ | |||
1352 | 311 | auto n_tracks = track_list->tracks()->size(); | 310 | auto n_tracks = track_list->tracks()->size(); |
1353 | 312 | bool has_tracks = (n_tracks > 0) ? true : false; | 311 | bool has_tracks = (n_tracks > 0) ? true : false; |
1354 | 313 | 312 | ||
1359 | 314 | std::cout << "Updating MPRIS TrackList properties" | 313 | MH_INFO("Updating MPRIS TrackList properties:"); |
1360 | 315 | << "; Tracks: " << n_tracks | 314 | MH_INFO("\tTracks: %d", n_tracks); |
1361 | 316 | << ", has_previous: " << has_previous | 315 | MH_INFO("\thas_previous: %d", has_previous); |
1362 | 317 | << ", has_next: " << has_next << std::endl; | 316 | MH_INFO("\thas_next: %d", has_next); |
1363 | 318 | 317 | ||
1364 | 319 | // Update properties | 318 | // Update properties |
1365 | 320 | parent->can_play().set(has_tracks); | 319 | parent->can_play().set(has_tracks); |
1366 | @@ -418,7 +417,7 @@ | |||
1367 | 418 | // When the client changes the loop status, make sure to update the TrackList | 417 | // When the client changes the loop status, make sure to update the TrackList |
1368 | 419 | Parent::loop_status().changed().connect([this](media::Player::LoopStatus loop_status) | 418 | Parent::loop_status().changed().connect([this](media::Player::LoopStatus loop_status) |
1369 | 420 | { | 419 | { |
1371 | 421 | std::cout << "LoopStatus: " << loop_status << std::endl; | 420 | MH_INFO("LoopStatus: %s", loop_status); |
1372 | 422 | d->track_list->on_loop_status_changed(loop_status); | 421 | d->track_list->on_loop_status_changed(loop_status); |
1373 | 423 | }); | 422 | }); |
1374 | 424 | 423 | ||
1375 | @@ -465,7 +464,7 @@ | |||
1376 | 465 | const Track::UriType uri = d->track_list->query_uri_for_track(d->track_list->next()); | 464 | const Track::UriType uri = d->track_list->query_uri_for_track(d->track_list->next()); |
1377 | 466 | if (prev_track_id != d->track_list->current() && !uri.empty()) | 465 | if (prev_track_id != d->track_list->current() && !uri.empty()) |
1378 | 467 | { | 466 | { |
1380 | 468 | std::cout << "Advancing to next track on playbin: " << uri << std::endl; | 467 | MH_INFO("Advancing to next track on playbin: %s", uri); |
1381 | 469 | static const bool do_pipeline_reset = false; | 468 | static const bool do_pipeline_reset = false; |
1382 | 470 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); | 469 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); |
1383 | 471 | } | 470 | } |
1384 | @@ -508,7 +507,7 @@ | |||
1385 | 508 | if (d->engine->state() != gstreamer::Engine::State::ready | 507 | if (d->engine->state() != gstreamer::Engine::State::ready |
1386 | 509 | && d->engine->state() != gstreamer::Engine::State::stopped) | 508 | && d->engine->state() != gstreamer::Engine::State::stopped) |
1387 | 510 | { | 509 | { |
1389 | 511 | std::cout << "End of tracklist reached, stopping playback" << std::endl; | 510 | MH_INFO("End of tracklist reached, stopping playback"); |
1390 | 512 | d->engine->stop(); | 511 | d->engine->stop(); |
1391 | 513 | } | 512 | } |
1392 | 514 | }); | 513 | }); |
1393 | @@ -528,15 +527,15 @@ | |||
1394 | 528 | const Track::UriType uri = d->track_list->query_uri_for_track(id); | 527 | const Track::UriType uri = d->track_list->query_uri_for_track(id); |
1395 | 529 | if (!uri.empty()) | 528 | if (!uri.empty()) |
1396 | 530 | { | 529 | { |
1399 | 531 | std::cout << "Setting next track on playbin (on_go_to_track signal): " << uri << std::endl; | 530 | MH_INFO("Setting next track on playbin (on_go_to_track signal): %s", uri); |
1400 | 532 | std::cout << "\twith a Track::Id: " << id << std::endl; | 531 | MH_INFO("\twith a Track::Id: %s", id); |
1401 | 533 | static const bool do_pipeline_reset = true; | 532 | static const bool do_pipeline_reset = true; |
1402 | 534 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); | 533 | d->engine->open_resource_for_uri(uri, do_pipeline_reset); |
1403 | 535 | } | 534 | } |
1404 | 536 | 535 | ||
1405 | 537 | if (auto_play) | 536 | if (auto_play) |
1406 | 538 | { | 537 | { |
1408 | 539 | std::cout << "Restoring playing state in on_go_to_track()" << std::endl; | 538 | MH_DEBUG("Restoring playing state"); |
1409 | 540 | d->engine->play(); | 539 | d->engine->play(); |
1410 | 541 | } | 540 | } |
1411 | 542 | 541 | ||
1412 | @@ -545,7 +544,7 @@ | |||
1413 | 545 | 544 | ||
1414 | 546 | d->track_list->on_track_added().connect([this](const media::Track::Id& id) | 545 | d->track_list->on_track_added().connect([this](const media::Track::Id& id) |
1415 | 547 | { | 546 | { |
1417 | 548 | std::cout << "** Track was added, handling in PlayerImplementation" << std::endl; | 547 | MH_TRACE("** Track was added, handling in PlayerImplementation"); |
1418 | 549 | if (d->track_list->tracks()->size() == 1) | 548 | if (d->track_list->tracks()->size() == 1) |
1419 | 550 | d->open_first_track_from_tracklist(id); | 549 | d->open_first_track_from_tracklist(id); |
1420 | 551 | 550 | ||
1421 | @@ -554,7 +553,7 @@ | |||
1422 | 554 | 553 | ||
1423 | 555 | d->track_list->on_tracks_added().connect([this](const media::TrackList::ContainerURI& tracks) | 554 | d->track_list->on_tracks_added().connect([this](const media::TrackList::ContainerURI& tracks) |
1424 | 556 | { | 555 | { |
1426 | 557 | std::cout << "** Track was added, handling in PlayerImplementation" << std::endl; | 556 | MH_TRACE("** Track was added, handling in PlayerImplementation"); |
1427 | 558 | // If the two sizes are the same, that means the TrackList was previously empty and we need | 557 | // If the two sizes are the same, that means the TrackList was previously empty and we need |
1428 | 559 | // to open the first track in the TrackList so that is_audio_source() and is_video_source() | 558 | // to open the first track in the TrackList so that is_audio_source() and is_video_source() |
1429 | 560 | // will function correctly. | 559 | // will function correctly. |
1430 | @@ -689,7 +688,7 @@ | |||
1431 | 689 | 688 | ||
1432 | 690 | // If empty uri, give the same meaning as QMediaPlayer::setMedia("") | 689 | // If empty uri, give the same meaning as QMediaPlayer::setMedia("") |
1433 | 691 | if (uri.empty()) { | 690 | if (uri.empty()) { |
1435 | 692 | cout << __PRETTY_FUNCTION__ << ": resetting current media" << endl; | 691 | MH_DEBUG("Resetting current media"); |
1436 | 693 | return true; | 692 | return true; |
1437 | 694 | } | 693 | } |
1438 | 695 | 694 | ||
1439 | @@ -722,19 +721,21 @@ | |||
1440 | 722 | template<typename Parent> | 721 | template<typename Parent> |
1441 | 723 | void media::PlayerImplementation<Parent>::play() | 722 | void media::PlayerImplementation<Parent>::play() |
1442 | 724 | { | 723 | { |
1443 | 724 | MH_TRACE(""); | ||
1444 | 725 | d->engine->play(); | 725 | d->engine->play(); |
1445 | 726 | } | 726 | } |
1446 | 727 | 727 | ||
1447 | 728 | template<typename Parent> | 728 | template<typename Parent> |
1448 | 729 | void media::PlayerImplementation<Parent>::pause() | 729 | void media::PlayerImplementation<Parent>::pause() |
1449 | 730 | { | 730 | { |
1450 | 731 | MH_TRACE(""); | ||
1451 | 731 | d->engine->pause(); | 732 | d->engine->pause(); |
1452 | 732 | } | 733 | } |
1453 | 733 | 734 | ||
1454 | 734 | template<typename Parent> | 735 | template<typename Parent> |
1455 | 735 | void media::PlayerImplementation<Parent>::stop() | 736 | void media::PlayerImplementation<Parent>::stop() |
1456 | 736 | { | 737 | { |
1458 | 737 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 738 | MH_TRACE(""); |
1459 | 738 | d->engine->stop(); | 739 | d->engine->stop(); |
1460 | 739 | } | 740 | } |
1461 | 740 | 741 | ||
1462 | 741 | 742 | ||
1463 | === modified file 'src/core/media/player_skeleton.cpp' | |||
1464 | --- src/core/media/player_skeleton.cpp 2016-02-19 16:14:42 +0000 | |||
1465 | +++ src/core/media/player_skeleton.cpp 2016-04-06 19:07:29 +0000 | |||
1466 | @@ -31,6 +31,8 @@ | |||
1467 | 31 | #include "mpris/metadata.h" | 31 | #include "mpris/metadata.h" |
1468 | 32 | #include "mpris/player.h" | 32 | #include "mpris/player.h" |
1469 | 33 | #include "mpris/playlists.h" | 33 | #include "mpris/playlists.h" |
1470 | 34 | |||
1471 | 35 | #include "core/media/logger/logger.h" | ||
1472 | 34 | #include "util/uri_check.h" | 36 | #include "util/uri_check.h" |
1473 | 35 | 37 | ||
1474 | 36 | #include <core/dbus/object.h> | 38 | #include <core/dbus/object.h> |
1475 | @@ -189,7 +191,7 @@ | |||
1476 | 189 | { | 191 | { |
1477 | 190 | const std::string err_str = {"Warning: Failed to open uri " + uri + | 192 | const std::string err_str = {"Warning: Failed to open uri " + uri + |
1478 | 191 | " because it can't be found."}; | 193 | " because it can't be found."}; |
1480 | 192 | std::cerr << err_str << std::endl; | 194 | MH_ERROR("%s", err_str); |
1481 | 193 | reply = dbus::Message::make_error( | 195 | reply = dbus::Message::make_error( |
1482 | 194 | in, | 196 | in, |
1483 | 195 | mpris::Player::Error::UriNotFound::name, | 197 | mpris::Player::Error::UriNotFound::name, |
1484 | @@ -207,7 +209,7 @@ | |||
1485 | 207 | { | 209 | { |
1486 | 208 | const std::string err_str = {"Warning: Failed to authenticate necessary " | 210 | const std::string err_str = {"Warning: Failed to authenticate necessary " |
1487 | 209 | "apparmor permissions to open uri: " + std::get<1>(result)}; | 211 | "apparmor permissions to open uri: " + std::get<1>(result)}; |
1489 | 210 | std::cerr << err_str << std::endl; | 212 | MH_ERROR("%s", err_str); |
1490 | 211 | reply = dbus::Message::make_error( | 213 | reply = dbus::Message::make_error( |
1491 | 212 | in, | 214 | in, |
1492 | 213 | mpris::Player::Error::InsufficientAppArmorPermissions::name, | 215 | mpris::Player::Error::InsufficientAppArmorPermissions::name, |
1493 | @@ -236,7 +238,7 @@ | |||
1494 | 236 | { | 238 | { |
1495 | 237 | const std::string err_str = {"Warning: Failed to open uri " + uri + | 239 | const std::string err_str = {"Warning: Failed to open uri " + uri + |
1496 | 238 | " because it can't be found."}; | 240 | " because it can't be found."}; |
1498 | 239 | std::cerr << err_str << std::endl; | 241 | MH_ERROR("%s", err_str); |
1499 | 240 | reply = dbus::Message::make_error( | 242 | reply = dbus::Message::make_error( |
1500 | 241 | in, | 243 | in, |
1501 | 242 | mpris::Player::Error::UriNotFound::name, | 244 | mpris::Player::Error::UriNotFound::name, |
1502 | @@ -254,7 +256,7 @@ | |||
1503 | 254 | { | 256 | { |
1504 | 255 | const std::string err_str = {"Warning: Failed to authenticate necessary " | 257 | const std::string err_str = {"Warning: Failed to authenticate necessary " |
1505 | 256 | "apparmor permissions to open uri: " + std::get<1>(result)}; | 258 | "apparmor permissions to open uri: " + std::get<1>(result)}; |
1507 | 257 | std::cerr << err_str << std::endl; | 259 | MH_ERROR("%s", err_str); |
1508 | 258 | reply = dbus::Message::make_error( | 260 | reply = dbus::Message::make_error( |
1509 | 259 | in, | 261 | in, |
1510 | 260 | mpris::Player::Error::InsufficientAppArmorPermissions::name, | 262 | mpris::Player::Error::InsufficientAppArmorPermissions::name, |
1511 | 261 | 263 | ||
1512 | === modified file 'src/core/media/player_stub.cpp' | |||
1513 | --- src/core/media/player_stub.cpp 2016-02-19 16:14:42 +0000 | |||
1514 | +++ src/core/media/player_stub.cpp 2016-04-06 19:07:29 +0000 | |||
1515 | @@ -30,10 +30,13 @@ | |||
1516 | 30 | 30 | ||
1517 | 31 | #include "mpris/player.h" | 31 | #include "mpris/player.h" |
1518 | 32 | 32 | ||
1519 | 33 | #include "core/media/logger/logger.h" | ||
1520 | 34 | |||
1521 | 33 | #include <core/dbus/property.h> | 35 | #include <core/dbus/property.h> |
1522 | 34 | #include <core/dbus/types/object_path.h> | 36 | #include <core/dbus/types/object_path.h> |
1523 | 35 | 37 | ||
1524 | 36 | #include <limits> | 38 | #include <limits> |
1525 | 39 | #include <sstream> | ||
1526 | 37 | 40 | ||
1527 | 38 | #define UNUSED __attribute__((unused)) | 41 | #define UNUSED __attribute__((unused)) |
1528 | 39 | 42 | ||
1529 | @@ -159,37 +162,38 @@ | |||
1530 | 159 | { | 162 | { |
1531 | 160 | dbus.seeked_to->connect([this](std::uint64_t value) | 163 | dbus.seeked_to->connect([this](std::uint64_t value) |
1532 | 161 | { | 164 | { |
1534 | 162 | std::cout << "SeekedTo signal arrived via the bus." << std::endl; | 165 | MH_DEBUG("SeekedTo signal arrived via the bus."); |
1535 | 163 | seeked_to(value); | 166 | seeked_to(value); |
1536 | 164 | }); | 167 | }); |
1537 | 165 | 168 | ||
1538 | 166 | dbus.about_to_finish->connect([this]() | 169 | dbus.about_to_finish->connect([this]() |
1539 | 167 | { | 170 | { |
1541 | 168 | std::cout << "AboutToFinish signal arrived via the bus." << std::endl; | 171 | MH_DEBUG("AboutToFinish signal arrived via the bus."); |
1542 | 169 | about_to_finish(); | 172 | about_to_finish(); |
1543 | 170 | }); | 173 | }); |
1544 | 171 | 174 | ||
1545 | 172 | dbus.end_of_stream->connect([this]() | 175 | dbus.end_of_stream->connect([this]() |
1546 | 173 | { | 176 | { |
1548 | 174 | std::cout << "EndOfStream signal arrived via the bus." << std::endl; | 177 | MH_DEBUG("EndOfStream signal arrived via the bus."); |
1549 | 175 | end_of_stream(); | 178 | end_of_stream(); |
1550 | 176 | }); | 179 | }); |
1551 | 177 | 180 | ||
1552 | 178 | dbus.playback_status_changed->connect([this](const media::Player::PlaybackStatus& status) | 181 | dbus.playback_status_changed->connect([this](const media::Player::PlaybackStatus& status) |
1553 | 179 | { | 182 | { |
1555 | 180 | std::cout << "PlaybackStatusChanged signal arrived via the bus (Status: " << status << ")" << std::endl; | 183 | MH_DEBUG("PlaybackStatusChanged signal arrived via the bus (status: %s)", |
1556 | 184 | status); | ||
1557 | 181 | playback_status_changed(status); | 185 | playback_status_changed(status); |
1558 | 182 | }); | 186 | }); |
1559 | 183 | 187 | ||
1560 | 184 | dbus.video_dimension_changed->connect([this](const media::video::Dimensions dimensions) | 188 | dbus.video_dimension_changed->connect([this](const media::video::Dimensions dimensions) |
1561 | 185 | { | 189 | { |
1563 | 186 | std::cout << "VideoDimensionChanged signal arrived via the bus." << std::endl; | 190 | MH_DEBUG("VideoDimensionChanged signal arrived via the bus."); |
1564 | 187 | video_dimension_changed(dimensions); | 191 | video_dimension_changed(dimensions); |
1565 | 188 | }); | 192 | }); |
1566 | 189 | 193 | ||
1567 | 190 | dbus.error->connect([this](const media::Player::Error& e) | 194 | dbus.error->connect([this](const media::Player::Error& e) |
1568 | 191 | { | 195 | { |
1570 | 192 | std::cout << "Error signal arrived via the bus (Error: " << e << ")" << std::endl; | 196 | MH_DEBUG("Error signal arrived via the bus (error: %s)", e); |
1571 | 193 | error(e); | 197 | error(e); |
1572 | 194 | }); | 198 | }); |
1573 | 195 | } | 199 | } |
1574 | 196 | 200 | ||
1575 | === modified file 'src/core/media/power/state_controller.cpp' | |||
1576 | --- src/core/media/power/state_controller.cpp 2015-05-27 18:37:24 +0000 | |||
1577 | +++ src/core/media/power/state_controller.cpp 2016-04-06 19:07:29 +0000 | |||
1578 | @@ -16,13 +16,13 @@ | |||
1579 | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> | 16 | * Authored by: Thomas Voß <thomas.voss@canonical.com> |
1580 | 17 | */ | 17 | */ |
1581 | 18 | 18 | ||
1582 | 19 | #include "core/media/logger/logger.h" | ||
1583 | 20 | |||
1584 | 19 | #include <core/media/power/state_controller.h> | 21 | #include <core/media/power/state_controller.h> |
1585 | 20 | 22 | ||
1586 | 21 | #include <core/dbus/macros.h> | 23 | #include <core/dbus/macros.h> |
1587 | 22 | #include <core/dbus/object.h> | 24 | #include <core/dbus/object.h> |
1588 | 23 | 25 | ||
1589 | 24 | #include <iostream> | ||
1590 | 25 | |||
1591 | 26 | namespace media = core::ubuntu::media; | 26 | namespace media = core::ubuntu::media; |
1592 | 27 | 27 | ||
1593 | 28 | namespace com { namespace canonical { | 28 | namespace com { namespace canonical { |
1594 | @@ -98,7 +98,7 @@ | |||
1595 | 98 | // From core::ubuntu::media::power::StateController::Lock<DisplayState> | 98 | // From core::ubuntu::media::power::StateController::Lock<DisplayState> |
1596 | 99 | void request_acquire(media::power::DisplayState state) override | 99 | void request_acquire(media::power::DisplayState state) override |
1597 | 100 | { | 100 | { |
1599 | 101 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 101 | MH_TRACE(""); |
1600 | 102 | 102 | ||
1601 | 103 | if (state == media::power::DisplayState::off) | 103 | if (state == media::power::DisplayState::off) |
1602 | 104 | return; | 104 | return; |
1603 | @@ -110,7 +110,7 @@ | |||
1604 | 110 | { | 110 | { |
1605 | 111 | if (result.is_error()) | 111 | if (result.is_error()) |
1606 | 112 | { | 112 | { |
1608 | 113 | std::cerr << result.error().print() << std::endl; | 113 | MH_ERROR("%s", result.error().print()); |
1609 | 114 | return; | 114 | return; |
1610 | 115 | } | 115 | } |
1611 | 116 | 116 | ||
1612 | @@ -149,7 +149,7 @@ | |||
1613 | 149 | { | 149 | { |
1614 | 150 | if (result.is_error()) | 150 | if (result.is_error()) |
1615 | 151 | { | 151 | { |
1617 | 152 | std::cerr << result.error().print() << std::endl; | 152 | MH_ERROR("%s", result.error().print()); |
1618 | 153 | return; | 153 | return; |
1619 | 154 | } | 154 | } |
1620 | 155 | 155 | ||
1621 | @@ -207,7 +207,7 @@ | |||
1622 | 207 | // the system to stay active. | 207 | // the system to stay active. |
1623 | 208 | void request_acquire(media::power::SystemState state) override | 208 | void request_acquire(media::power::SystemState state) override |
1624 | 209 | { | 209 | { |
1626 | 210 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 210 | MH_TRACE(""); |
1627 | 211 | 211 | ||
1628 | 212 | if (state == media::power::SystemState::suspend) | 212 | if (state == media::power::SystemState::suspend) |
1629 | 213 | return; | 213 | return; |
1630 | @@ -223,7 +223,7 @@ | |||
1631 | 223 | } | 223 | } |
1632 | 224 | else | 224 | else |
1633 | 225 | { | 225 | { |
1635 | 226 | std::cerr << "Failed to lock system_state_cookie_store_guard and check system lock state" << std::endl; | 226 | MH_WARNING("Failed to lock system_state_cookie_store_guard and check system lock state"); |
1636 | 227 | // Prevent system_state_cookie_store.count(state) and the actual call to requestSysState below from | 227 | // Prevent system_state_cookie_store.count(state) and the actual call to requestSysState below from |
1637 | 228 | // getting out of sync. | 228 | // getting out of sync. |
1638 | 229 | return; | 229 | return; |
1639 | @@ -236,7 +236,7 @@ | |||
1640 | 236 | { | 236 | { |
1641 | 237 | if (result.is_error()) | 237 | if (result.is_error()) |
1642 | 238 | { | 238 | { |
1644 | 239 | std::cerr << result.error().print() << std::endl; | 239 | MH_ERROR("%s", result.error().print()); |
1645 | 240 | return; | 240 | return; |
1646 | 241 | } | 241 | } |
1647 | 242 | 242 | ||
1648 | @@ -249,7 +249,7 @@ | |||
1649 | 249 | if (ul.owns_lock()) | 249 | if (ul.owns_lock()) |
1650 | 250 | sp->system_state_cookie_store[state] = result.value(); | 250 | sp->system_state_cookie_store[state] = result.value(); |
1651 | 251 | else | 251 | else |
1653 | 252 | std::cerr << "Failed to lock system_state_cookie_store_guard and update system lock state" << std::endl; | 252 | MH_WARNING("Failed to lock system_state_cookie_store_guard and update system lock state"); |
1654 | 253 | } | 253 | } |
1655 | 254 | 254 | ||
1656 | 255 | sp->signals.acquired(state); | 255 | sp->signals.acquired(state); |
1657 | @@ -275,7 +275,7 @@ | |||
1658 | 275 | } | 275 | } |
1659 | 276 | else | 276 | else |
1660 | 277 | { | 277 | { |
1662 | 278 | std::cerr << "Failed to lock system_state_cookie_store_guard and check system lock state" << std::endl; | 278 | MH_WARNING("Failed to lock system_state_cookie_store_guard and check system lock state"); |
1663 | 279 | // Prevent system_state_cookie_store.count(state) and the actual call to clearSysState below from | 279 | // Prevent system_state_cookie_store.count(state) and the actual call to clearSysState below from |
1664 | 280 | // getting out of sync. | 280 | // getting out of sync. |
1665 | 281 | return; | 281 | return; |
1666 | @@ -287,7 +287,7 @@ | |||
1667 | 287 | object->invoke_method_asynchronously_with_callback<com::canonical::powerd::Interface::clearSysState, void>([this, wp, state](const core::dbus::Result<void>& result) | 287 | object->invoke_method_asynchronously_with_callback<com::canonical::powerd::Interface::clearSysState, void>([this, wp, state](const core::dbus::Result<void>& result) |
1668 | 288 | { | 288 | { |
1669 | 289 | if (result.is_error()) | 289 | if (result.is_error()) |
1671 | 290 | std::cerr << result.error().print() << std::endl; | 290 | MH_ERROR("%s", result.error().print()); |
1672 | 291 | 291 | ||
1673 | 292 | if (auto sp = wp.lock()) | 292 | if (auto sp = wp.lock()) |
1674 | 293 | { | 293 | { |
1675 | @@ -297,7 +297,7 @@ | |||
1676 | 297 | if (ul.owns_lock()) | 297 | if (ul.owns_lock()) |
1677 | 298 | sp->system_state_cookie_store.erase(state); | 298 | sp->system_state_cookie_store.erase(state); |
1678 | 299 | else | 299 | else |
1680 | 300 | std::cerr << "Failed to lock system_state_cookie_store_guard and erase system lock state" << std::endl; | 300 | MH_WARNING("Failed to lock system_state_cookie_store_guard and erase system lock state"); |
1681 | 301 | } | 301 | } |
1682 | 302 | 302 | ||
1683 | 303 | sp->signals.released(state); | 303 | sp->signals.released(state); |
1684 | @@ -369,7 +369,7 @@ | |||
1685 | 369 | 369 | ||
1686 | 370 | media::power::StateController::Ptr media::power::make_platform_default_state_controller(core::ubuntu::media::helper::ExternalServices& external_services) | 370 | media::power::StateController::Ptr media::power::make_platform_default_state_controller(core::ubuntu::media::helper::ExternalServices& external_services) |
1687 | 371 | { | 371 | { |
1689 | 372 | return std::make_shared<impl::StateController>(external_services); | 372 | return std::make_shared<::impl::StateController>(external_services); |
1690 | 373 | } | 373 | } |
1691 | 374 | 374 | ||
1692 | 375 | // operator<< pretty prints the given display state to the given output stream. | 375 | // operator<< pretty prints the given display state to the given output stream. |
1693 | 376 | 376 | ||
1694 | === modified file 'src/core/media/server/server.cpp' | |||
1695 | --- src/core/media/server/server.cpp 2015-04-10 16:13:55 +0000 | |||
1696 | +++ src/core/media/server/server.cpp 2016-04-06 19:07:29 +0000 | |||
1697 | @@ -21,6 +21,7 @@ | |||
1698 | 21 | #include <core/media/track_list.h> | 21 | #include <core/media/track_list.h> |
1699 | 22 | 22 | ||
1700 | 23 | #include "core/media/hashed_keyed_player_store.h" | 23 | #include "core/media/hashed_keyed_player_store.h" |
1701 | 24 | #include "core/media/logger/logger.h" | ||
1702 | 24 | #include "core/media/service_implementation.h" | 25 | #include "core/media/service_implementation.h" |
1703 | 25 | 26 | ||
1704 | 26 | #include <core/posix/signal.h> | 27 | #include <core/posix/signal.h> |
1705 | @@ -36,6 +37,37 @@ | |||
1706 | 36 | 37 | ||
1707 | 37 | namespace | 38 | namespace |
1708 | 38 | { | 39 | { |
1709 | 40 | void logger_init() | ||
1710 | 41 | { | ||
1711 | 42 | const char *level = ::getenv("MH_LOG_LEVEL"); | ||
1712 | 43 | // Default level is kInfo | ||
1713 | 44 | media::Logger::Severity severity{media::Logger::Severity::kInfo}; | ||
1714 | 45 | if (level) | ||
1715 | 46 | { | ||
1716 | 47 | if (strcmp(level, "trace") == 0) | ||
1717 | 48 | severity = media::Logger::Severity::kTrace; | ||
1718 | 49 | else if (strcmp(level, "debug") == 0) | ||
1719 | 50 | severity = media::Logger::Severity::kDebug; | ||
1720 | 51 | else if (strcmp(level, "info") == 0) | ||
1721 | 52 | severity = media::Logger::Severity::kInfo; | ||
1722 | 53 | else if (strcmp(level, "warning") == 0) | ||
1723 | 54 | severity = media::Logger::Severity::kWarning; | ||
1724 | 55 | else if (strcmp(level, "error") == 0) | ||
1725 | 56 | severity = media::Logger::Severity::kError; | ||
1726 | 57 | else if (strcmp(level, "fatal") == 0) | ||
1727 | 58 | severity = media::Logger::Severity::kFatal; | ||
1728 | 59 | else | ||
1729 | 60 | std::cerr << "Invalid log level \"" << level | ||
1730 | 61 | << "\", setting to info. Valid options: [trace, debug, info, warning, error, fatal]. " | ||
1731 | 62 | << std::endl; | ||
1732 | 63 | } | ||
1733 | 64 | else | ||
1734 | 65 | std::cout << "Using default log level: info" << std::endl; | ||
1735 | 66 | |||
1736 | 67 | media::Log().Init(severity); | ||
1737 | 68 | cout << "Log level: " << severity << std::endl; | ||
1738 | 69 | } | ||
1739 | 70 | |||
1740 | 39 | // All platform-specific initialization routines go here. | 71 | // All platform-specific initialization routines go here. |
1741 | 40 | void platform_init() | 72 | void platform_init() |
1742 | 41 | { | 73 | { |
1743 | @@ -66,6 +98,8 @@ | |||
1744 | 66 | trap->stop(); | 98 | trap->stop(); |
1745 | 67 | }); | 99 | }); |
1746 | 68 | 100 | ||
1747 | 101 | logger_init(); | ||
1748 | 102 | |||
1749 | 69 | // Init platform-specific functionality. | 103 | // Init platform-specific functionality. |
1750 | 70 | platform_init(); | 104 | platform_init(); |
1751 | 71 | 105 | ||
1752 | 72 | 106 | ||
1753 | === modified file 'src/core/media/service.cpp' | |||
1754 | --- src/core/media/service.cpp 2014-04-09 14:05:55 +0000 | |||
1755 | +++ src/core/media/service.cpp 2016-04-06 19:07:29 +0000 | |||
1756 | @@ -18,13 +18,15 @@ | |||
1757 | 18 | 18 | ||
1758 | 19 | #include <core/media/service.h> | 19 | #include <core/media/service.h> |
1759 | 20 | 20 | ||
1760 | 21 | #include "core/media/logger/logger.h" | ||
1761 | 22 | |||
1762 | 21 | #include "service_stub.h" | 23 | #include "service_stub.h" |
1763 | 22 | 24 | ||
1764 | 23 | namespace media = core::ubuntu::media; | 25 | namespace media = core::ubuntu::media; |
1765 | 24 | 26 | ||
1766 | 25 | const std::shared_ptr<media::Service> media::Service::Client::instance() | 27 | const std::shared_ptr<media::Service> media::Service::Client::instance() |
1767 | 26 | { | 28 | { |
1769 | 27 | std::cout << "Creating a new static Service instance" << std::endl; | 29 | MH_TRACE(""); |
1770 | 28 | static std::shared_ptr<media::Service> instance{new media::ServiceStub()}; | 30 | static std::shared_ptr<media::Service> instance{new media::ServiceStub()}; |
1771 | 29 | return instance; | 31 | return instance; |
1772 | 30 | } | 32 | } |
1773 | 31 | 33 | ||
1774 | === modified file 'src/core/media/service_implementation.cpp' | |||
1775 | --- src/core/media/service_implementation.cpp 2016-03-02 18:32:46 +0000 | |||
1776 | +++ src/core/media/service_implementation.cpp 2016-04-06 19:07:29 +0000 | |||
1777 | @@ -33,6 +33,9 @@ | |||
1778 | 33 | #include "recorder_observer.h" | 33 | #include "recorder_observer.h" |
1779 | 34 | #include "telephony/call_monitor.h" | 34 | #include "telephony/call_monitor.h" |
1780 | 35 | 35 | ||
1781 | 36 | #include "util/timeout.h" | ||
1782 | 37 | #include "core/media/logger/logger.h" | ||
1783 | 38 | |||
1784 | 36 | #include <boost/asio.hpp> | 39 | #include <boost/asio.hpp> |
1785 | 37 | 40 | ||
1786 | 38 | #include <string> | 41 | #include <string> |
1787 | @@ -45,8 +48,6 @@ | |||
1788 | 45 | 48 | ||
1789 | 46 | #include <pulse/pulseaudio.h> | 49 | #include <pulse/pulseaudio.h> |
1790 | 47 | 50 | ||
1791 | 48 | #include "util/timeout.h" | ||
1792 | 49 | |||
1793 | 50 | namespace media = core::ubuntu::media; | 51 | namespace media = core::ubuntu::media; |
1794 | 51 | 52 | ||
1795 | 52 | using namespace std; | 53 | using namespace std; |
1796 | @@ -126,16 +127,16 @@ | |||
1797 | 126 | switch (state) | 127 | switch (state) |
1798 | 127 | { | 128 | { |
1799 | 128 | case audio::OutputState::Earpiece: | 129 | case audio::OutputState::Earpiece: |
1801 | 129 | std::cout << "AudioOutputObserver reports that output is now Headphones/Headset." << std::endl; | 130 | MH_INFO("AudioOutputObserver reports that output is now Headphones/Headset."); |
1802 | 130 | break; | 131 | break; |
1803 | 131 | case audio::OutputState::Speaker: | 132 | case audio::OutputState::Speaker: |
1805 | 132 | std::cout << "AudioOutputObserver reports that output is now Speaker." << std::endl; | 133 | MH_INFO("AudioOutputObserver reports that output is now Speaker."); |
1806 | 133 | // Whatever player session is currently playing, make sure it is NOT resumed after | 134 | // Whatever player session is currently playing, make sure it is NOT resumed after |
1807 | 134 | // a phonecall is hung up | 135 | // a phonecall is hung up |
1808 | 135 | pause_all_multimedia_sessions(resume_play_after_phonecall); | 136 | pause_all_multimedia_sessions(resume_play_after_phonecall); |
1809 | 136 | break; | 137 | break; |
1810 | 137 | case audio::OutputState::External: | 138 | case audio::OutputState::External: |
1812 | 138 | std::cout << "AudioOutputObserver reports that output is now External." << std::endl; | 139 | MH_INFO("AudioOutputObserver reports that output is now External."); |
1813 | 139 | break; | 140 | break; |
1814 | 140 | } | 141 | } |
1815 | 141 | d->audio_output_state = state; | 142 | d->audio_output_state = state; |
1816 | @@ -146,13 +147,13 @@ | |||
1817 | 146 | const bool resume_play_after_phonecall = true; | 147 | const bool resume_play_after_phonecall = true; |
1818 | 147 | switch (state) { | 148 | switch (state) { |
1819 | 148 | case media::telephony::CallMonitor::State::OffHook: | 149 | case media::telephony::CallMonitor::State::OffHook: |
1821 | 149 | std::cout << "Got call started signal, pausing all multimedia sessions" << std::endl; | 150 | MH_INFO("Got call started signal, pausing all multimedia sessions"); |
1822 | 150 | // Whatever player session is currently playing, make sure it gets resumed after | 151 | // Whatever player session is currently playing, make sure it gets resumed after |
1823 | 151 | // a phonecall is hung up | 152 | // a phonecall is hung up |
1824 | 152 | pause_all_multimedia_sessions(resume_play_after_phonecall); | 153 | pause_all_multimedia_sessions(resume_play_after_phonecall); |
1825 | 153 | break; | 154 | break; |
1826 | 154 | case media::telephony::CallMonitor::State::OnHook: | 155 | case media::telephony::CallMonitor::State::OnHook: |
1828 | 155 | std::cout << "Got call ended signal, resuming paused multimedia sessions" << std::endl; | 156 | MH_INFO("Got call ended signal, resuming paused multimedia sessions"); |
1829 | 156 | resume_paused_multimedia_sessions(false); | 157 | resume_paused_multimedia_sessions(false); |
1830 | 157 | break; | 158 | break; |
1831 | 158 | } | 159 | } |
1832 | @@ -217,10 +218,10 @@ | |||
1833 | 217 | d->configuration.player_store->remove_player_for_key(key); | 218 | d->configuration.player_store->remove_player_for_key(key); |
1834 | 218 | } | 219 | } |
1835 | 219 | catch (const std::out_of_range &e) { | 220 | catch (const std::out_of_range &e) { |
1840 | 220 | std::cerr << "Failed to look up Player instance for key " << key | 221 | MH_WARNING("Failed to look up Player instance for key %d" |
1841 | 221 | << ", no valid Player instance for that key value. Removal of Player from Player store" | 222 | ", no valid Player instance for that key value. Removal of Player from Player store" |
1842 | 222 | << " might not have completed. This most likely means that media-hub-server has" | 223 | " might not have completed. This most likely means that media-hub-server has" |
1843 | 223 | << " crashed and restarted." << std::endl; | 224 | " crashed and restarted.", key); |
1844 | 224 | return; | 225 | return; |
1845 | 225 | } | 226 | } |
1846 | 226 | }); | 227 | }); |
1847 | @@ -264,11 +265,11 @@ | |||
1848 | 264 | 265 | ||
1849 | 265 | void media::ServiceImplementation::pause_other_sessions(media::Player::PlayerKey key) | 266 | void media::ServiceImplementation::pause_other_sessions(media::Player::PlayerKey key) |
1850 | 266 | { | 267 | { |
1852 | 267 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 268 | MH_TRACE(""); |
1853 | 268 | 269 | ||
1854 | 269 | if (not d->configuration.player_store->has_player_for_key(key)) | 270 | if (not d->configuration.player_store->has_player_for_key(key)) |
1855 | 270 | { | 271 | { |
1857 | 271 | cerr << "Could not find Player by key: " << key << endl; | 272 | MH_WARNING("Could not find Player by key: %d", key); |
1858 | 272 | return; | 273 | return; |
1859 | 273 | } | 274 | } |
1860 | 274 | 275 | ||
1861 | @@ -291,7 +292,7 @@ | |||
1862 | 291 | current_player->audio_stream_role() == media::Player::multimedia && | 292 | current_player->audio_stream_role() == media::Player::multimedia && |
1863 | 292 | other_player->audio_stream_role() == media::Player::multimedia) | 293 | other_player->audio_stream_role() == media::Player::multimedia) |
1864 | 293 | { | 294 | { |
1866 | 294 | cout << "Pausing Player with key: " << other_key << endl; | 295 | MH_INFO("Pausing Player with key: %d", other_key); |
1867 | 295 | other_player->pause(); | 296 | other_player->pause(); |
1868 | 296 | } | 297 | } |
1869 | 297 | }); | 298 | }); |
1870 | @@ -306,8 +307,8 @@ | |||
1871 | 306 | { | 307 | { |
1872 | 307 | auto paused_player_pair = std::make_pair(key, resume_play_after_phonecall); | 308 | auto paused_player_pair = std::make_pair(key, resume_play_after_phonecall); |
1873 | 308 | d->paused_sessions.push_back(paused_player_pair); | 309 | d->paused_sessions.push_back(paused_player_pair); |
1876 | 309 | std::cout << "Pausing Player with key: " << key << ", resuming after phone call? " | 310 | MH_INFO("Pausing Player with key: %d, resuming after phone call? %s", key, |
1877 | 310 | << (resume_play_after_phonecall ? "yes" : "no") << std::endl; | 311 | (resume_play_after_phonecall ? "yes" : "no")); |
1878 | 311 | player->pause(); | 312 | player->pause(); |
1879 | 312 | } | 313 | } |
1880 | 313 | }); | 314 | }); |
1881 | @@ -324,17 +325,17 @@ | |||
1882 | 324 | player = d->configuration.player_store->player_for_key(key); | 325 | player = d->configuration.player_store->player_for_key(key); |
1883 | 325 | } | 326 | } |
1884 | 326 | catch (const std::out_of_range &e) { | 327 | catch (const std::out_of_range &e) { |
1889 | 327 | std::cerr << "Failed to look up Player instance for key " << key | 328 | MH_WARNING("Failed to look up Player instance for key %d" |
1890 | 328 | << ", no valid Player instance for that key value and cannot automatically resume" | 329 | ", no valid Player instance for that key value and cannot automatically resume" |
1891 | 329 | << " paused players. This most likely means that media-hub-server has crashed and" | 330 | " paused players. This most likely means that media-hub-server has crashed and" |
1892 | 330 | << " restarted." << std::endl; | 331 | " restarted.", key); |
1893 | 331 | return; | 332 | return; |
1894 | 332 | } | 333 | } |
1895 | 333 | // Only resume video playback if explicitly desired | 334 | // Only resume video playback if explicitly desired |
1896 | 334 | if ((resume_video_sessions || player->is_audio_source()) && resume_play_after_phonecall) | 335 | if ((resume_video_sessions || player->is_audio_source()) && resume_play_after_phonecall) |
1897 | 335 | player->play(); | 336 | player->play(); |
1898 | 336 | else | 337 | else |
1900 | 337 | std::cout << "Not auto-resuming video player session or other type of player session." << std::endl; | 338 | MH_INFO("Not auto-resuming video player session or other type of player session."); |
1901 | 338 | }); | 339 | }); |
1902 | 339 | 340 | ||
1903 | 340 | d->paused_sessions.clear(); | 341 | d->paused_sessions.clear(); |
1904 | @@ -350,16 +351,16 @@ | |||
1905 | 350 | player = d->configuration.player_store->player_for_key(d->resume_key); | 351 | player = d->configuration.player_store->player_for_key(d->resume_key); |
1906 | 351 | } | 352 | } |
1907 | 352 | catch (const std::out_of_range &e) { | 353 | catch (const std::out_of_range &e) { |
1912 | 353 | std::cerr << "Failed to look up Player instance for key " << d->resume_key | 354 | MH_WARNING("Failed to look up Player instance for key %d" |
1913 | 354 | << ", no valid Player instance for that key value and cannot automatically resume" | 355 | ", no valid Player instance for that key value and cannot automatically resume" |
1914 | 355 | << " paused Player. This most likely means that media-hub-server has crashed and" | 356 | " paused Player. This most likely means that media-hub-server has crashed and" |
1915 | 356 | << " restarted." << std::endl; | 357 | " restarted.", d->resume_key); |
1916 | 357 | return; | 358 | return; |
1917 | 358 | } | 359 | } |
1918 | 359 | 360 | ||
1919 | 360 | if (player->playback_status() == Player::paused) | 361 | if (player->playback_status() == Player::paused) |
1920 | 361 | { | 362 | { |
1922 | 362 | cout << "Resuming playback of Player with key: " << d->resume_key << endl; | 363 | MH_INFO("Resuming playback of Player with key: %d", d->resume_key); |
1923 | 363 | player->play(); | 364 | player->play(); |
1924 | 364 | d->resume_key = std::numeric_limits<std::uint32_t>::max(); | 365 | d->resume_key = std::numeric_limits<std::uint32_t>::max(); |
1925 | 365 | } | 366 | } |
1926 | 366 | 367 | ||
1927 | === modified file 'src/core/media/service_skeleton.cpp' | |||
1928 | --- src/core/media/service_skeleton.cpp 2016-03-02 18:32:46 +0000 | |||
1929 | +++ src/core/media/service_skeleton.cpp 2016-04-06 19:07:29 +0000 | |||
1930 | @@ -29,6 +29,8 @@ | |||
1931 | 29 | #include "the_session_bus.h" | 29 | #include "the_session_bus.h" |
1932 | 30 | #include "xesam.h" | 30 | #include "xesam.h" |
1933 | 31 | 31 | ||
1934 | 32 | #include "core/media/logger/logger.h" | ||
1935 | 33 | |||
1936 | 32 | #include <core/dbus/message.h> | 34 | #include <core/dbus/message.h> |
1937 | 33 | #include <core/dbus/object.h> | 35 | #include <core/dbus/object.h> |
1938 | 34 | #include <core/dbus/types/object_path.h> | 36 | #include <core/dbus/types/object_path.h> |
1939 | @@ -134,9 +136,8 @@ | |||
1940 | 134 | impl->access_service()->add_object_for_path(op) | 136 | impl->access_service()->add_object_for_path(op) |
1941 | 135 | }; | 137 | }; |
1942 | 136 | 138 | ||
1946 | 137 | cout << "Session created by request of: " << msg->sender() | 139 | MH_DEBUG("Session created by request of: %s, key: %d, uuid: %d, path: %s", |
1947 | 138 | << ", key: " << key << ", uuid: " << uuid | 140 | msg->sender(), key, uuid, op); |
1945 | 139 | << ", path:" << op << std::endl; | ||
1948 | 140 | 141 | ||
1949 | 141 | try | 142 | try |
1950 | 142 | { | 143 | { |
1951 | @@ -147,7 +148,7 @@ | |||
1952 | 147 | request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), | 148 | request_context_resolver->resolve_context_for_dbus_name_async(msg->sender(), |
1953 | 148 | [this, key, msg](const media::apparmor::ubuntu::Context& context) | 149 | [this, key, msg](const media::apparmor::ubuntu::Context& context) |
1954 | 149 | { | 150 | { |
1956 | 150 | fprintf(stderr, "%s():%d -- app_name='%s', attached\n", __func__, __LINE__, context.str().c_str()); | 151 | MH_DEBUG(" -- app_name='%s', attached", context.str()); |
1957 | 151 | player_owner_map.emplace(std::make_pair(key, std::make_tuple(context.str(), true, msg->sender()))); | 152 | player_owner_map.emplace(std::make_pair(key, std::make_tuple(context.str(), true, msg->sender()))); |
1958 | 152 | }); | 153 | }); |
1959 | 153 | 154 | ||
1960 | @@ -231,7 +232,8 @@ | |||
1961 | 231 | [this, msg, key, op](const media::apparmor::ubuntu::Context& context) | 232 | [this, msg, key, op](const media::apparmor::ubuntu::Context& context) |
1962 | 232 | { | 233 | { |
1963 | 233 | auto info = player_owner_map.at(key); | 234 | auto info = player_owner_map.at(key); |
1965 | 234 | fprintf(stderr, "%s():%d -- reattach app_name='%s', info='%s', '%s'\n", __func__, __LINE__, context.str().c_str(), std::get<0>(info).c_str(), std::get<2>(info).c_str()); | 235 | MH_DEBUG(" -- reattach app_name='%s', info='%s', '%s'", |
1966 | 236 | context.str(), std::get<0>(info), std::get<2>(info)); | ||
1967 | 235 | if (std::get<0>(info) == context.str()) { | 237 | if (std::get<0>(info) == context.str()) { |
1968 | 236 | std::get<1>(info) = true; // Set to Attached | 238 | std::get<1>(info) = true; // Set to Attached |
1969 | 237 | std::get<2>(info) = msg->sender(); // Register new owner | 239 | std::get<2>(info) = msg->sender(); // Register new owner |
1970 | @@ -242,7 +244,7 @@ | |||
1971 | 242 | // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) | 244 | // We only care to allow the MPRIS controls to apply to multimedia player (i.e. audio, video) |
1972 | 243 | if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) | 245 | if (player->audio_stream_role() == media::Player::AudioStreamRole::multimedia) |
1973 | 244 | { | 246 | { |
1975 | 245 | std::cout << "Setting current_player" << std::endl; | 247 | MH_TRACE("Setting current_player"); |
1976 | 246 | exported.set_current_player(player); | 248 | exported.set_current_player(player); |
1977 | 247 | } | 249 | } |
1978 | 248 | 250 | ||
1979 | @@ -305,7 +307,8 @@ | |||
1980 | 305 | [this, msg, key](const media::apparmor::ubuntu::Context& context) | 307 | [this, msg, key](const media::apparmor::ubuntu::Context& context) |
1981 | 306 | { | 308 | { |
1982 | 307 | auto info = player_owner_map.at(key); | 309 | auto info = player_owner_map.at(key); |
1984 | 308 | fprintf(stderr, "%s():%d -- Destroying app_name='%s', info='%s', '%s'\n", __func__, __LINE__, context.str().c_str(), std::get<0>(info).c_str(), std::get<2>(info).c_str()); | 310 | MH_DEBUG(" -- Destroying app_name='%s', info='%s', '%s'", |
1985 | 311 | context.str(), std::get<0>(info), std::get<2>(info)); | ||
1986 | 309 | if (std::get<0>(info) == context.str()) { | 312 | if (std::get<0>(info) == context.str()) { |
1987 | 310 | player_owner_map.erase(key); | 313 | player_owner_map.erase(key); |
1988 | 311 | 314 | ||
1989 | @@ -454,7 +457,7 @@ | |||
1990 | 454 | core::dbus::Message::Ptr reply; | 457 | core::dbus::Message::Ptr reply; |
1991 | 455 | if (not configuration.player_store->has_player_for_key(key)) | 458 | if (not configuration.player_store->has_player_for_key(key)) |
1992 | 456 | { | 459 | { |
1994 | 457 | std::cerr << __PRETTY_FUNCTION__ << " player key not found - " << key << std::endl; | 460 | MH_WARNING("Player key not found: %d", key); |
1995 | 458 | reply = dbus::Message::make_error( | 461 | reply = dbus::Message::make_error( |
1996 | 459 | msg, | 462 | msg, |
1997 | 460 | mpris::Service::Errors::PlayerKeyNotFound::name(), | 463 | mpris::Service::Errors::PlayerKeyNotFound::name(), |
1998 | @@ -467,10 +470,9 @@ | |||
1999 | 467 | reply = dbus::Message::make_method_return(msg); | 470 | reply = dbus::Message::make_method_return(msg); |
2000 | 468 | } | 471 | } |
2001 | 469 | catch (const std::out_of_range &e) { | 472 | catch (const std::out_of_range &e) { |
2006 | 470 | std::cerr << "Failed to look up Player instance for key " << key | 473 | MH_WARNING("Failed to look up Player instance for key %d\ |
2007 | 471 | << ", no valid Player instance for that key value and cannot set current player." | 474 | , no valid Player instance for that key value and cannot set current player.\ |
2008 | 472 | << " This most likely means that media-hub-server has crashed and restarted." | 475 | This most likely means that media-hub-server has crashed and restarted.", key); |
2005 | 473 | << std::endl; | ||
2009 | 474 | reply = dbus::Message::make_error( | 476 | reply = dbus::Message::make_error( |
2010 | 475 | msg, | 477 | msg, |
2011 | 476 | mpris::Service::Errors::PlayerKeyNotFound::name(), | 478 | mpris::Service::Errors::PlayerKeyNotFound::name(), |
2012 | @@ -491,10 +493,9 @@ | |||
2013 | 491 | reply = dbus::Message::make_method_return(msg); | 493 | reply = dbus::Message::make_method_return(msg); |
2014 | 492 | } | 494 | } |
2015 | 493 | catch (const std::out_of_range &e) { | 495 | catch (const std::out_of_range &e) { |
2020 | 494 | std::cerr << "Failed to look up Player instance for key " << key | 496 | MH_WARNING("Failed to look up Player instance for key %d\ |
2021 | 495 | << ", no valid Player instance for that key value and cannot pause other Players." | 497 | , no valid Player instance for that key value and cannot set current player.\ |
2022 | 496 | << " This most likely means that media-hub-server has crashed and restarted." | 498 | This most likely means that media-hub-server has crashed and restarted.", key); |
2019 | 497 | << std::endl; | ||
2023 | 498 | reply = dbus::Message::make_error( | 499 | reply = dbus::Message::make_error( |
2024 | 499 | msg, | 500 | msg, |
2025 | 500 | mpris::Service::Errors::PlayerKeyNotFound::name(), | 501 | mpris::Service::Errors::PlayerKeyNotFound::name(), |
2026 | @@ -529,7 +530,7 @@ | |||
2027 | 529 | // TODO(tvoss): These three elements really should be configurable. | 530 | // TODO(tvoss): These three elements really should be configurable. |
2028 | 530 | defaults.identity = "core::media::Hub"; | 531 | defaults.identity = "core::media::Hub"; |
2029 | 531 | defaults.desktop_entry = "mediaplayer-app"; | 532 | defaults.desktop_entry = "mediaplayer-app"; |
2031 | 532 | defaults.supported_mime_types = {"audio/mpeg3"}; | 533 | defaults.supported_mime_types = {"audio/mpeg3", "video/mpeg4"}; |
2032 | 533 | 534 | ||
2033 | 534 | return defaults; | 535 | return defaults; |
2034 | 535 | } | 536 | } |
2035 | @@ -668,7 +669,7 @@ | |||
2036 | 668 | 669 | ||
2037 | 669 | void set_current_player(const std::shared_ptr<media::Player>& cp) | 670 | void set_current_player(const std::shared_ptr<media::Player>& cp) |
2038 | 670 | { | 671 | { |
2040 | 671 | std::cout << "*** " << __PRETTY_FUNCTION__ << std::endl; | 672 | MH_TRACE(""); |
2041 | 672 | // We will not keep the object alive. | 673 | // We will not keep the object alive. |
2042 | 673 | current_player = cp; | 674 | current_player = cp; |
2043 | 674 | 675 | ||
2044 | @@ -784,7 +785,7 @@ | |||
2045 | 784 | 785 | ||
2046 | 785 | void reset_current_player() | 786 | void reset_current_player() |
2047 | 786 | { | 787 | { |
2049 | 787 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 788 | MH_TRACE(""); |
2050 | 788 | // And announce that we can no longer be controlled. | 789 | // And announce that we can no longer be controlled. |
2051 | 789 | player.properties.can_control->set(false); | 790 | player.properties.can_control->set(false); |
2052 | 790 | current_player.reset(); | 791 | current_player.reset(); |
2053 | 791 | 792 | ||
2054 | === modified file 'src/core/media/telephony/CMakeLists.txt' | |||
2055 | --- src/core/media/telephony/CMakeLists.txt 2014-10-31 07:49:33 +0000 | |||
2056 | +++ src/core/media/telephony/CMakeLists.txt 2016-04-06 19:07:29 +0000 | |||
2057 | @@ -9,6 +9,7 @@ | |||
2058 | 9 | 9 | ||
2059 | 10 | include_directories( | 10 | include_directories( |
2060 | 11 | ${TP_QT5_INCLUDE_DIRS} | 11 | ${TP_QT5_INCLUDE_DIRS} |
2061 | 12 | ${PROJECT_SOURCE_DIR}/src/ | ||
2062 | 12 | ) | 13 | ) |
2063 | 13 | 14 | ||
2064 | 14 | add_library(call-monitor STATIC | 15 | add_library(call-monitor STATIC |
2065 | 15 | 16 | ||
2066 | === modified file 'src/core/media/telephony/call_monitor.cpp' | |||
2067 | --- src/core/media/telephony/call_monitor.cpp 2015-01-26 11:01:02 +0000 | |||
2068 | +++ src/core/media/telephony/call_monitor.cpp 2016-04-06 19:07:29 +0000 | |||
2069 | @@ -19,6 +19,8 @@ | |||
2070 | 19 | 19 | ||
2071 | 20 | #include "call_monitor.h" | 20 | #include "call_monitor.h" |
2072 | 21 | 21 | ||
2073 | 22 | #include "core/media/logger/logger.h" | ||
2074 | 23 | |||
2075 | 22 | #include "qtbridge.h" | 24 | #include "qtbridge.h" |
2076 | 23 | #include <TelepathyQt/AccountManager> | 25 | #include <TelepathyQt/AccountManager> |
2077 | 24 | #include <TelepathyQt/SimpleCallObserver> | 26 | #include <TelepathyQt/SimpleCallObserver> |
2078 | @@ -95,7 +97,7 @@ | |||
2079 | 95 | 97 | ||
2080 | 96 | void accountManagerReady(Tp::PendingOperation* operation) { | 98 | void accountManagerReady(Tp::PendingOperation* operation) { |
2081 | 97 | if (operation->isError()) { | 99 | if (operation->isError()) { |
2083 | 98 | std::cerr << "TelepathyBridge: Operation failed (accountManagerReady)" << std::endl; | 100 | MH_ERROR("TelepathyBridge: Operation failed (accountManagerReady)"); |
2084 | 99 | QTimer::singleShot(1000, this, SLOT(accountManagerSetup())); // again | 101 | QTimer::singleShot(1000, this, SLOT(accountManagerSetup())); // again |
2085 | 100 | return; | 102 | return; |
2086 | 101 | } | 103 | } |
2087 | @@ -118,13 +120,13 @@ | |||
2088 | 118 | 120 | ||
2089 | 119 | void accountReady(Tp::PendingOperation* operation) { | 121 | void accountReady(Tp::PendingOperation* operation) { |
2090 | 120 | if (operation->isError()) { | 122 | if (operation->isError()) { |
2092 | 121 | std::cerr << "TelepathyAccount: Operation failed (accountReady)" << std::endl; | 123 | MH_ERROR("TelepathyAccount: Operation failed (accountReady)"); |
2093 | 122 | return; | 124 | return; |
2094 | 123 | } | 125 | } |
2095 | 124 | 126 | ||
2096 | 125 | Tp::PendingReady* pendingReady = qobject_cast<Tp::PendingReady*>(operation); | 127 | Tp::PendingReady* pendingReady = qobject_cast<Tp::PendingReady*>(operation); |
2097 | 126 | if (pendingReady == 0) { | 128 | if (pendingReady == 0) { |
2099 | 127 | std::cerr << "Rejecting account because could not understand ready status" << std::endl; | 129 | MH_ERROR("Rejecting account because could not understand ready status"); |
2100 | 128 | return; | 130 | return; |
2101 | 129 | } | 131 | } |
2102 | 130 | 132 | ||
2103 | @@ -176,16 +178,16 @@ | |||
2104 | 176 | { | 178 | { |
2105 | 177 | qt::core::world::enter_with_task([this]() | 179 | qt::core::world::enter_with_task([this]() |
2106 | 178 | { | 180 | { |
2108 | 179 | std::cout << "CallMonitor: Creating TelepathyBridge" << std::endl; | 181 | MH_DEBUG("CallMonitor: Creating TelepathyBridge"); |
2109 | 180 | mBridge = new TelepathyBridge(); | 182 | mBridge = new TelepathyBridge(); |
2110 | 181 | cv.notify_all(); | 183 | cv.notify_all(); |
2111 | 182 | }); | 184 | }); |
2112 | 183 | }); | 185 | }); |
2113 | 184 | })); | 186 | })); |
2114 | 185 | } catch(const std::system_error& error) { | 187 | } catch(const std::system_error& error) { |
2116 | 186 | std::cerr << "exception(std::system_error) in CallMonitor thread start" << error.what() << std::endl; | 188 | MH_ERROR("exception(std::system_error) in CallMonitor thread start %s", error.what()); |
2117 | 187 | } catch(...) { | 189 | } catch(...) { |
2119 | 188 | std::cerr << "exception(...) in CallMonitor thread start" << std::endl; | 190 | MH_ERROR("exception(...) in CallMonitor thread start"); |
2120 | 189 | } | 191 | } |
2121 | 190 | 192 | ||
2122 | 191 | // Wait until telepathy bridge is set, so we can hook up the change signals | 193 | // Wait until telepathy bridge is set, so we can hook up the change signals |
2123 | @@ -234,7 +236,7 @@ | |||
2124 | 234 | 236 | ||
2125 | 235 | media::telephony::CallMonitor::Ptr media::telephony::make_platform_default_call_monitor() | 237 | media::telephony::CallMonitor::Ptr media::telephony::make_platform_default_call_monitor() |
2126 | 236 | { | 238 | { |
2128 | 237 | return std::make_shared<impl::CallMonitor>(); | 239 | return std::make_shared<::impl::CallMonitor>(); |
2129 | 238 | } | 240 | } |
2130 | 239 | 241 | ||
2131 | 240 | #include "call_monitor.moc" | 242 | #include "call_monitor.moc" |
2132 | 241 | 243 | ||
2133 | === modified file 'src/core/media/telephony/qtbridge.cpp' | |||
2134 | --- src/core/media/telephony/qtbridge.cpp 2014-10-31 07:49:33 +0000 | |||
2135 | +++ src/core/media/telephony/qtbridge.cpp 2016-04-06 19:07:29 +0000 | |||
2136 | @@ -26,8 +26,6 @@ | |||
2137 | 26 | #include<QThread> | 26 | #include<QThread> |
2138 | 27 | #include<QDebug> | 27 | #include<QDebug> |
2139 | 28 | 28 | ||
2140 | 29 | #include <iostream> | ||
2141 | 30 | |||
2142 | 31 | namespace | 29 | namespace |
2143 | 32 | { | 30 | { |
2144 | 33 | QCoreApplication* app = nullptr; | 31 | QCoreApplication* app = nullptr; |
2145 | 34 | 32 | ||
2146 | === modified file 'src/core/media/track_list_implementation.cpp' | |||
2147 | --- src/core/media/track_list_implementation.cpp 2016-02-22 18:58:52 +0000 | |||
2148 | +++ src/core/media/track_list_implementation.cpp 2016-04-06 19:07:29 +0000 | |||
2149 | @@ -18,6 +18,7 @@ | |||
2150 | 18 | 18 | ||
2151 | 19 | #include <algorithm> | 19 | #include <algorithm> |
2152 | 20 | #include <random> | 20 | #include <random> |
2153 | 21 | #include <sstream> | ||
2154 | 21 | #include <stdio.h> | 22 | #include <stdio.h> |
2155 | 22 | #include <stdlib.h> | 23 | #include <stdlib.h> |
2156 | 23 | #include <tuple> | 24 | #include <tuple> |
2157 | @@ -29,6 +30,8 @@ | |||
2158 | 29 | 30 | ||
2159 | 30 | #include "engine.h" | 31 | #include "engine.h" |
2160 | 31 | 32 | ||
2161 | 33 | #include "core/media/logger/logger.h" | ||
2162 | 34 | |||
2163 | 32 | namespace dbus = core::dbus; | 35 | namespace dbus = core::dbus; |
2164 | 33 | namespace media = core::ubuntu::media; | 36 | namespace media = core::ubuntu::media; |
2165 | 34 | 37 | ||
2166 | @@ -125,14 +128,14 @@ | |||
2167 | 125 | const media::Track::Id& position, | 128 | const media::Track::Id& position, |
2168 | 126 | bool make_current) | 129 | bool make_current) |
2169 | 127 | { | 130 | { |
2171 | 128 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 131 | MH_TRACE(""); |
2172 | 129 | 132 | ||
2173 | 130 | std::stringstream ss; | 133 | std::stringstream ss; |
2174 | 131 | ss << d->object->path().as_string() << "/" << d->track_counter++; | 134 | ss << d->object->path().as_string() << "/" << d->track_counter++; |
2175 | 132 | Track::Id id{ss.str()}; | 135 | Track::Id id{ss.str()}; |
2176 | 133 | 136 | ||
2179 | 134 | std::cout << "Adding Track::Id: " << id << std::endl; | 137 | MH_DEBUG("Adding Track::Id: %s", id); |
2180 | 135 | std::cout << "\tURI: " << uri << std::endl; | 138 | MH_DEBUG("\tURI: %s", uri); |
2181 | 136 | 139 | ||
2182 | 137 | const auto current = get_current_track(); | 140 | const auto current = get_current_track(); |
2183 | 138 | 141 | ||
2184 | @@ -159,7 +162,7 @@ | |||
2185 | 159 | set_current_track(current); | 162 | set_current_track(current); |
2186 | 160 | } | 163 | } |
2187 | 161 | 164 | ||
2189 | 162 | std::cout << "Signaling that we just added track id: " << id << std::endl; | 165 | MH_DEBUG("Signaling that we just added track id: %s", id); |
2190 | 163 | // Signal to the client that a track was added to the TrackList | 166 | // Signal to the client that a track was added to the TrackList |
2191 | 164 | on_track_added()(id); | 167 | on_track_added()(id); |
2192 | 165 | 168 | ||
2193 | @@ -172,7 +175,7 @@ | |||
2194 | 172 | 175 | ||
2195 | 173 | void media::TrackListImplementation::add_tracks_with_uri_at(const ContainerURI& uris, const Track::Id& position) | 176 | void media::TrackListImplementation::add_tracks_with_uri_at(const ContainerURI& uris, const Track::Id& position) |
2196 | 174 | { | 177 | { |
2198 | 175 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 178 | MH_TRACE(""); |
2199 | 176 | 179 | ||
2200 | 177 | const auto current = get_current_track(); | 180 | const auto current = get_current_track(); |
2201 | 178 | 181 | ||
2202 | @@ -184,8 +187,8 @@ | |||
2203 | 184 | std::stringstream ss; | 187 | std::stringstream ss; |
2204 | 185 | ss << d->object->path().as_string() << "/" << d->track_counter++; | 188 | ss << d->object->path().as_string() << "/" << d->track_counter++; |
2205 | 186 | Track::Id id{ss.str()}; | 189 | Track::Id id{ss.str()}; |
2208 | 187 | std::cout << "Adding Track::Id: " << id << std::endl; | 190 | MH_DEBUG("Adding Track::Id: %s", id); |
2209 | 188 | std::cout << "\tURI: " << uri << std::endl; | 191 | MH_DEBUG("\tURI: %s", uri); |
2210 | 189 | 192 | ||
2211 | 190 | tmp.push_back(id); | 193 | tmp.push_back(id); |
2212 | 191 | 194 | ||
2213 | @@ -217,7 +220,7 @@ | |||
2214 | 217 | 220 | ||
2215 | 218 | set_current_track(current); | 221 | set_current_track(current); |
2216 | 219 | 222 | ||
2218 | 220 | std::cout << "Signaling that we just added " << tmp.size() << " tracks to the TrackList" << std::endl; | 223 | MH_DEBUG("Signaling that we just added %d tracks to the TrackList", tmp.size()); |
2219 | 221 | on_tracks_added()(tmp); | 224 | on_tracks_added()(tmp); |
2220 | 222 | 225 | ||
2221 | 223 | if (!current_id.empty()) | 226 | if (!current_id.empty()) |
2222 | @@ -227,30 +230,30 @@ | |||
2223 | 227 | bool media::TrackListImplementation::move_track(const media::Track::Id& id, | 230 | bool media::TrackListImplementation::move_track(const media::Track::Id& id, |
2224 | 228 | const media::Track::Id& to) | 231 | const media::Track::Id& to) |
2225 | 229 | { | 232 | { |
2227 | 230 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 233 | MH_TRACE(""); |
2228 | 231 | 234 | ||
2230 | 232 | std::cout << "-----------------------------------------------------" << std::endl; | 235 | MH_DEBUG("-----------------------------------------------------"); |
2231 | 233 | if (id.empty() or to.empty()) | 236 | if (id.empty() or to.empty()) |
2232 | 234 | { | 237 | { |
2234 | 235 | std::cerr << "Can't move track since 'id' or 'to' are empty" << std::endl; | 238 | MH_ERROR("Can't move track since 'id' or 'to' are empty"); |
2235 | 236 | return false; | 239 | return false; |
2236 | 237 | } | 240 | } |
2237 | 238 | 241 | ||
2238 | 239 | if (id == to) | 242 | if (id == to) |
2239 | 240 | { | 243 | { |
2241 | 241 | std::cerr << "Can't move track to it's same position" << std::endl; | 244 | MH_ERROR("Can't move track to it's same position"); |
2242 | 242 | return false; | 245 | return false; |
2243 | 243 | } | 246 | } |
2244 | 244 | 247 | ||
2245 | 245 | if (tracks().get().size() == 1) | 248 | if (tracks().get().size() == 1) |
2246 | 246 | { | 249 | { |
2248 | 247 | std::cerr << "Can't move track since TrackList contains only one track" << std::endl; | 250 | MH_ERROR("Can't move track since TrackList contains only one track"); |
2249 | 248 | return false; | 251 | return false; |
2250 | 249 | } | 252 | } |
2251 | 250 | 253 | ||
2252 | 251 | bool ret = false; | 254 | bool ret = false; |
2253 | 252 | const media::Track::Id current_id = *current_iterator(); | 255 | const media::Track::Id current_id = *current_iterator(); |
2255 | 253 | std::cout << "current_track id: " << current_id << std::endl; | 256 | MH_DEBUG("current_track id: %s", current_id); |
2256 | 254 | // Get an iterator that points to the track that is the insertion point | 257 | // Get an iterator that points to the track that is the insertion point |
2257 | 255 | auto insert_point_it = std::find(tracks().get().begin(), tracks().get().end(), to); | 258 | auto insert_point_it = std::find(tracks().get().begin(), tracks().get().end(), to); |
2258 | 256 | if (insert_point_it != tracks().get().end()) | 259 | if (insert_point_it != tracks().get().end()) |
2259 | @@ -260,7 +263,6 @@ | |||
2260 | 260 | { | 263 | { |
2261 | 261 | // Get an iterator that points to the track to move within the TrackList | 264 | // Get an iterator that points to the track to move within the TrackList |
2262 | 262 | auto to_move_it = std::find(tracks().get().begin(), tracks().get().end(), id); | 265 | auto to_move_it = std::find(tracks().get().begin(), tracks().get().end(), id); |
2263 | 263 | std::cout << "Erasing old track position: " << *to_move_it << std::endl; | ||
2264 | 264 | if (to_move_it != tracks().get().end()) | 266 | if (to_move_it != tracks().get().end()) |
2265 | 265 | { | 267 | { |
2266 | 266 | container.erase(to_move_it); | 268 | container.erase(to_move_it); |
2267 | @@ -282,11 +284,11 @@ | |||
2268 | 282 | { | 284 | { |
2269 | 283 | throw media::TrackList::Errors::FailedToMoveTrack(); | 285 | throw media::TrackList::Errors::FailedToMoveTrack(); |
2270 | 284 | } | 286 | } |
2272 | 285 | std::cout << "*** Updated current_iterator, id: " << *current_iterator() << std::endl; | 287 | MH_DEBUG("*** Updated current_iterator, id: %s", *current_iterator()); |
2273 | 286 | } | 288 | } |
2274 | 287 | else | 289 | else |
2275 | 288 | { | 290 | { |
2277 | 289 | std::cerr << "Can't update current_iterator - failed to find track after move" << std::endl; | 291 | MH_ERROR("Can't update current_iterator - failed to find track after move"); |
2278 | 290 | throw media::TrackList::Errors::FailedToMoveTrack(); | 292 | throw media::TrackList::Errors::FailedToMoveTrack(); |
2279 | 291 | } | 293 | } |
2280 | 292 | 294 | ||
2281 | @@ -295,10 +297,10 @@ | |||
2282 | 295 | 297 | ||
2283 | 296 | if (result) | 298 | if (result) |
2284 | 297 | { | 299 | { |
2287 | 298 | std::cout << "TrackList after move" << std::endl; | 300 | MH_DEBUG("TrackList after move"); |
2288 | 299 | for(auto track : tracks().get()) | 301 | for(const auto track : tracks().get()) |
2289 | 300 | { | 302 | { |
2291 | 301 | std::cout << track << std::endl; | 303 | MH_DEBUG("%s", track); |
2292 | 302 | } | 304 | } |
2293 | 303 | const media::TrackList::TrackIdTuple ids = std::make_tuple(id, to); | 305 | const media::TrackList::TrackIdTuple ids = std::make_tuple(id, to); |
2294 | 304 | // Signal to the client that track 'id' was moved within the TrackList | 306 | // Signal to the client that track 'id' was moved within the TrackList |
2295 | @@ -312,7 +314,7 @@ | |||
2296 | 312 | ("Failed to find source track " + id); | 314 | ("Failed to find source track " + id); |
2297 | 313 | } | 315 | } |
2298 | 314 | 316 | ||
2300 | 315 | std::cout << "-----------------------------------------------------" << std::endl; | 317 | MH_DEBUG("-----------------------------------------------------"); |
2301 | 316 | 318 | ||
2302 | 317 | return ret; | 319 | return ret; |
2303 | 318 | } | 320 | } |
2304 | @@ -345,7 +347,7 @@ | |||
2305 | 345 | 347 | ||
2306 | 346 | void media::TrackListImplementation::go_to(const media::Track::Id& track) | 348 | void media::TrackListImplementation::go_to(const media::Track::Id& track) |
2307 | 347 | { | 349 | { |
2309 | 348 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 350 | MH_TRACE(""); |
2310 | 349 | // Signal the Player instance to go to a specific track for playback | 351 | // Signal the Player instance to go to a specific track for playback |
2311 | 350 | on_go_to_track()(track); | 352 | on_go_to_track()(track); |
2312 | 351 | on_track_changed()(track); | 353 | on_track_changed()(track); |
2313 | @@ -373,7 +375,7 @@ | |||
2314 | 373 | 375 | ||
2315 | 374 | void media::TrackListImplementation::reset() | 376 | void media::TrackListImplementation::reset() |
2316 | 375 | { | 377 | { |
2318 | 376 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 378 | MH_TRACE(""); |
2319 | 377 | 379 | ||
2320 | 378 | // Make sure playback stops | 380 | // Make sure playback stops |
2321 | 379 | on_end_of_tracklist()(); | 381 | on_end_of_tracklist()(); |
2322 | 380 | 382 | ||
2323 | === modified file 'src/core/media/track_list_skeleton.cpp' | |||
2324 | --- src/core/media/track_list_skeleton.cpp 2016-02-22 16:16:52 +0000 | |||
2325 | +++ src/core/media/track_list_skeleton.cpp 2016-04-06 19:07:29 +0000 | |||
2326 | @@ -29,7 +29,9 @@ | |||
2327 | 29 | 29 | ||
2328 | 30 | #include "mpris/player.h" | 30 | #include "mpris/player.h" |
2329 | 31 | #include "mpris/track_list.h" | 31 | #include "mpris/track_list.h" |
2330 | 32 | |||
2331 | 32 | #include "util/uri_check.h" | 33 | #include "util/uri_check.h" |
2332 | 34 | #include "core/media/logger/logger.h" | ||
2333 | 33 | 35 | ||
2334 | 34 | #include <core/dbus/object.h> | 36 | #include <core/dbus/object.h> |
2335 | 35 | #include <core/dbus/property.h> | 37 | #include <core/dbus/property.h> |
2336 | @@ -40,7 +42,6 @@ | |||
2337 | 40 | 42 | ||
2338 | 41 | #include <iostream> | 43 | #include <iostream> |
2339 | 42 | #include <limits> | 44 | #include <limits> |
2340 | 43 | #include <sstream> | ||
2341 | 44 | #include <cstdint> | 45 | #include <cstdint> |
2342 | 45 | 46 | ||
2343 | 46 | namespace dbus = core::dbus; | 47 | namespace dbus = core::dbus; |
2344 | @@ -104,7 +105,7 @@ | |||
2345 | 104 | 105 | ||
2346 | 105 | void handle_add_track_with_uri_at(const core::dbus::Message::Ptr& msg) | 106 | void handle_add_track_with_uri_at(const core::dbus::Message::Ptr& msg) |
2347 | 106 | { | 107 | { |
2349 | 107 | std::cout << "*** " << __PRETTY_FUNCTION__ << std::endl; | 108 | MH_TRACE(""); |
2350 | 108 | request_context_resolver->resolve_context_for_dbus_name_async | 109 | request_context_resolver->resolve_context_for_dbus_name_async |
2351 | 109 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) | 110 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) |
2352 | 110 | { | 111 | { |
2353 | @@ -124,7 +125,7 @@ | |||
2354 | 124 | { | 125 | { |
2355 | 125 | const std::string err_str = {"Warning: Not adding track " + uri + | 126 | const std::string err_str = {"Warning: Not adding track " + uri + |
2356 | 126 | " to TrackList because it can't be found."}; | 127 | " to TrackList because it can't be found."}; |
2358 | 127 | std::cerr << err_str << std::endl; | 128 | MH_WARNING("%s", err_str.c_str()); |
2359 | 128 | reply = dbus::Message::make_error( | 129 | reply = dbus::Message::make_error( |
2360 | 129 | msg, | 130 | msg, |
2361 | 130 | mpris::Player::Error::UriNotFound::name, | 131 | mpris::Player::Error::UriNotFound::name, |
2362 | @@ -141,7 +142,7 @@ | |||
2363 | 141 | { | 142 | { |
2364 | 142 | const std::string err_str = {"Warning: Not adding track " + uri + | 143 | const std::string err_str = {"Warning: Not adding track " + uri + |
2365 | 143 | " to TrackList because of inadequate client apparmor permissions."}; | 144 | " to TrackList because of inadequate client apparmor permissions."}; |
2367 | 144 | std::cerr << err_str << std::endl; | 145 | MH_WARNING("%s", err_str.c_str()); |
2368 | 145 | reply = dbus::Message::make_error( | 146 | reply = dbus::Message::make_error( |
2369 | 146 | msg, | 147 | msg, |
2370 | 147 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, | 148 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, |
2371 | @@ -155,7 +156,7 @@ | |||
2372 | 155 | 156 | ||
2373 | 156 | void handle_add_tracks_with_uri_at(const core::dbus::Message::Ptr& msg) | 157 | void handle_add_tracks_with_uri_at(const core::dbus::Message::Ptr& msg) |
2374 | 157 | { | 158 | { |
2376 | 158 | std::cout << "*** " << __PRETTY_FUNCTION__ << std::endl; | 159 | MH_TRACE(""); |
2377 | 159 | request_context_resolver->resolve_context_for_dbus_name_async | 160 | request_context_resolver->resolve_context_for_dbus_name_async |
2378 | 160 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) | 161 | (msg->sender(), [this, msg](const media::apparmor::ubuntu::Context& context) |
2379 | 161 | { | 162 | { |
2380 | @@ -176,7 +177,7 @@ | |||
2381 | 176 | { | 177 | { |
2382 | 177 | uri_err_str = {"Warning: Not adding track " + uri + | 178 | uri_err_str = {"Warning: Not adding track " + uri + |
2383 | 178 | " to TrackList because it can't be found."}; | 179 | " to TrackList because it can't be found."}; |
2385 | 179 | std::cerr << uri_err_str << std::endl; | 180 | MH_WARNING("%s", uri_err_str.c_str()); |
2386 | 180 | reply = dbus::Message::make_error( | 181 | reply = dbus::Message::make_error( |
2387 | 181 | msg, | 182 | msg, |
2388 | 182 | mpris::Player::Error::UriNotFound::name, | 183 | mpris::Player::Error::UriNotFound::name, |
2389 | @@ -201,7 +202,7 @@ | |||
2390 | 201 | } | 202 | } |
2391 | 202 | else | 203 | else |
2392 | 203 | { | 204 | { |
2394 | 204 | std::cerr << err_str << std::endl; | 205 | MH_WARNING("%s", err_str.c_str()); |
2395 | 205 | reply = dbus::Message::make_error( | 206 | reply = dbus::Message::make_error( |
2396 | 206 | msg, | 207 | msg, |
2397 | 207 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, | 208 | mpris::TrackList::Error::InsufficientPermissionsToAddTrack::name, |
2398 | @@ -225,7 +226,7 @@ | |||
2399 | 225 | { | 226 | { |
2400 | 226 | const std::string err_str = {"Error: Not moving track " + id + | 227 | const std::string err_str = {"Error: Not moving track " + id + |
2401 | 227 | " to destination " + to}; | 228 | " to destination " + to}; |
2403 | 228 | std::cerr << err_str << std::endl; | 229 | MH_WARNING("%s", err_str.c_str()); |
2404 | 229 | reply = dbus::Message::make_error( | 230 | reply = dbus::Message::make_error( |
2405 | 230 | msg, | 231 | msg, |
2406 | 231 | mpris::TrackList::Error::FailedToMoveTrack::name, | 232 | mpris::TrackList::Error::FailedToMoveTrack::name, |
2407 | @@ -262,9 +263,9 @@ | |||
2408 | 262 | 263 | ||
2409 | 263 | auto id_it = find(impl->tracks().get().begin(), impl->tracks().get().end(), track); | 264 | auto id_it = find(impl->tracks().get().begin(), impl->tracks().get().end(), track); |
2410 | 264 | if (id_it == impl->tracks().get().end()) { | 265 | if (id_it == impl->tracks().get().end()) { |
2412 | 265 | ostringstream err_str; | 266 | stringstream err_str; |
2413 | 266 | err_str << "Track " << track << " not found in track list"; | 267 | err_str << "Track " << track << " not found in track list"; |
2415 | 267 | cout << __PRETTY_FUNCTION__ << " WARNING " << err_str.str() << endl; | 268 | MH_WARNING("%s", err_str.str()); |
2416 | 268 | auto reply = dbus::Message::make_error( | 269 | auto reply = dbus::Message::make_error( |
2417 | 269 | msg, | 270 | msg, |
2418 | 270 | mpris::TrackList::Error::TrackNotFound::name, | 271 | mpris::TrackList::Error::TrackNotFound::name, |
2419 | @@ -278,7 +279,7 @@ | |||
2420 | 278 | 279 | ||
2421 | 279 | if (id_it == impl->current_iterator()) | 280 | if (id_it == impl->current_iterator()) |
2422 | 280 | { | 281 | { |
2424 | 281 | cout << "Removing current track" << endl; | 282 | MH_DEBUG("Removing current track"); |
2425 | 282 | deleting_current = true; | 283 | deleting_current = true; |
2426 | 283 | 284 | ||
2427 | 284 | if (current_track != empty_iterator) | 285 | if (current_track != empty_iterator) |
2428 | @@ -537,10 +538,10 @@ | |||
2429 | 537 | 538 | ||
2430 | 538 | media::Track::Id media::TrackListSkeleton::next() | 539 | media::Track::Id media::TrackListSkeleton::next() |
2431 | 539 | { | 540 | { |
2433 | 540 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 541 | MH_TRACE(""); |
2434 | 541 | if (tracks().get().empty()) { | 542 | if (tracks().get().empty()) { |
2435 | 542 | // TODO Change ServiceSkeleton to return with error from DBus call | 543 | // TODO Change ServiceSkeleton to return with error from DBus call |
2437 | 543 | std::cerr << "ERROR: no tracks, cannot go to next" << std::endl; | 544 | MH_ERROR("No tracks, cannot go to next"); |
2438 | 544 | return media::Track::Id{}; | 545 | return media::Track::Id{}; |
2439 | 545 | } | 546 | } |
2440 | 546 | 547 | ||
2441 | @@ -549,13 +550,13 @@ | |||
2442 | 549 | // End of the track reached so loop around to the beginning of the track | 550 | // End of the track reached so loop around to the beginning of the track |
2443 | 550 | if (d->loop_status == media::Player::LoopStatus::track) | 551 | if (d->loop_status == media::Player::LoopStatus::track) |
2444 | 551 | { | 552 | { |
2446 | 552 | std::cout << "Looping on the current track since LoopStatus is set to track" << std::endl; | 553 | MH_INFO("Looping on the current track since LoopStatus is set to track"); |
2447 | 553 | go_to_track = true; | 554 | go_to_track = true; |
2448 | 554 | } | 555 | } |
2449 | 555 | // End of the tracklist reached so loop around to the beginning of the tracklist | 556 | // End of the tracklist reached so loop around to the beginning of the tracklist |
2450 | 556 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_next()) | 557 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_next()) |
2451 | 557 | { | 558 | { |
2453 | 558 | std::cout << "Looping on the tracklist since LoopStatus is set to playlist" << std::endl; | 559 | MH_INFO("Looping on the tracklist since LoopStatus is set to playlist"); |
2454 | 559 | 560 | ||
2455 | 560 | if (shuffle()) | 561 | if (shuffle()) |
2456 | 561 | { | 562 | { |
2457 | @@ -574,7 +575,7 @@ | |||
2458 | 574 | { | 575 | { |
2459 | 575 | auto it = get_current_shuffled(); | 576 | auto it = get_current_shuffled(); |
2460 | 576 | if (++it != shuffled_tracks().end()) { | 577 | if (++it != shuffled_tracks().end()) { |
2462 | 577 | cout << "Advancing to next track: " << *it << endl; | 578 | MH_INFO("Advancing to next track: %s", *it); |
2463 | 578 | set_current_track(*it); | 579 | set_current_track(*it); |
2464 | 579 | go_to_track = true; | 580 | go_to_track = true; |
2465 | 580 | } | 581 | } |
2466 | @@ -584,7 +585,7 @@ | |||
2467 | 584 | const auto it = std::next(current_iterator()); | 585 | const auto it = std::next(current_iterator()); |
2468 | 585 | if (not is_last_track(it)) | 586 | if (not is_last_track(it)) |
2469 | 586 | { | 587 | { |
2471 | 587 | cout << "Advancing to next track: " << *it << endl; | 588 | MH_INFO("Advancing to next track: %s", *it); |
2472 | 588 | d->current_track = it; | 589 | d->current_track = it; |
2473 | 589 | go_to_track = true; | 590 | go_to_track = true; |
2474 | 590 | } | 591 | } |
2475 | @@ -594,7 +595,7 @@ | |||
2476 | 594 | 595 | ||
2477 | 595 | if (go_to_track) | 596 | if (go_to_track) |
2478 | 596 | { | 597 | { |
2480 | 597 | cout << "next track id is " << *(current_iterator()) << endl; | 598 | MH_DEBUG("next track id is %s", *(current_iterator())); |
2481 | 598 | on_track_changed()(*(current_iterator())); | 599 | on_track_changed()(*(current_iterator())); |
2482 | 599 | const media::Track::Id id = *(current_iterator()); | 600 | const media::Track::Id id = *(current_iterator()); |
2483 | 600 | // Signal the PlayerImplementation to play the next track | 601 | // Signal the PlayerImplementation to play the next track |
2484 | @@ -603,7 +604,7 @@ | |||
2485 | 603 | else | 604 | else |
2486 | 604 | { | 605 | { |
2487 | 605 | // At the end of the tracklist and not set to loop | 606 | // At the end of the tracklist and not set to loop |
2489 | 606 | cout << "End of tracklist reached" << endl; | 607 | MH_INFO("End of tracklist reached"); |
2490 | 607 | on_end_of_tracklist()(); | 608 | on_end_of_tracklist()(); |
2491 | 608 | } | 609 | } |
2492 | 609 | 610 | ||
2493 | @@ -612,10 +613,10 @@ | |||
2494 | 612 | 613 | ||
2495 | 613 | media::Track::Id media::TrackListSkeleton::previous() | 614 | media::Track::Id media::TrackListSkeleton::previous() |
2496 | 614 | { | 615 | { |
2498 | 615 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 616 | MH_TRACE(""); |
2499 | 616 | if (tracks().get().empty()) { | 617 | if (tracks().get().empty()) { |
2500 | 617 | // TODO Change ServiceSkeleton to return with error from DBus call | 618 | // TODO Change ServiceSkeleton to return with error from DBus call |
2502 | 618 | std::cerr << "ERROR: no tracks, cannot go to previous" << std::endl; | 619 | MH_ERROR("No tracks, cannot go to previous"); |
2503 | 619 | return media::Track::Id{}; | 620 | return media::Track::Id{}; |
2504 | 620 | } | 621 | } |
2505 | 621 | 622 | ||
2506 | @@ -627,19 +628,19 @@ | |||
2507 | 627 | // repeat it from the beginning | 628 | // repeat it from the beginning |
2508 | 628 | if (d->current_position > max_position) | 629 | if (d->current_position > max_position) |
2509 | 629 | { | 630 | { |
2511 | 630 | std::cout << "Repeating current track..." << std::endl; | 631 | MH_INFO("Repeating current track..."); |
2512 | 631 | go_to_track = true; | 632 | go_to_track = true; |
2513 | 632 | } | 633 | } |
2514 | 633 | // Loop on the current track forever | 634 | // Loop on the current track forever |
2515 | 634 | else if (d->loop_status == media::Player::LoopStatus::track) | 635 | else if (d->loop_status == media::Player::LoopStatus::track) |
2516 | 635 | { | 636 | { |
2518 | 636 | std::cout << "Looping on the current track..." << std::endl; | 637 | MH_INFO("Looping on the current track..."); |
2519 | 637 | go_to_track = true; | 638 | go_to_track = true; |
2520 | 638 | } | 639 | } |
2521 | 639 | // Loop over the whole playlist and repeat | 640 | // Loop over the whole playlist and repeat |
2522 | 640 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_previous()) | 641 | else if (d->loop_status == media::Player::LoopStatus::playlist && not has_previous()) |
2523 | 641 | { | 642 | { |
2525 | 642 | std::cout << "Looping on the entire TrackList..." << std::endl; | 643 | MH_INFO("Looping on the entire TrackList..."); |
2526 | 643 | 644 | ||
2527 | 644 | if (shuffle()) | 645 | if (shuffle()) |
2528 | 645 | { | 646 | { |
2529 | @@ -680,7 +681,7 @@ | |||
2530 | 680 | else | 681 | else |
2531 | 681 | { | 682 | { |
2532 | 682 | // At the beginning of the tracklist and not set to loop | 683 | // At the beginning of the tracklist and not set to loop |
2534 | 683 | cout << "Beginning of tracklist reached" << endl; | 684 | MH_INFO("Beginning of tracklist reached"); |
2535 | 684 | on_end_of_tracklist()(); | 685 | on_end_of_tracklist()(); |
2536 | 685 | } | 686 | } |
2537 | 686 | 687 | ||
2538 | @@ -698,12 +699,12 @@ | |||
2539 | 698 | // a segfault when calling current() | 699 | // a segfault when calling current() |
2540 | 699 | if (tracks().get().size() && (d->current_track == d->empty_iterator)) | 700 | if (tracks().get().size() && (d->current_track == d->empty_iterator)) |
2541 | 700 | { | 701 | { |
2543 | 701 | std::cout << "Wrapping d->current_track back to begin()" << std::endl; | 702 | MH_DEBUG("Wrapping d->current_track back to begin()"); |
2544 | 702 | d->current_track = d->skeleton.properties.tracks->get().begin(); | 703 | d->current_track = d->skeleton.properties.tracks->get().begin(); |
2545 | 703 | } | 704 | } |
2546 | 704 | else if (tracks().get().empty()) | 705 | else if (tracks().get().empty()) |
2547 | 705 | { | 706 | { |
2549 | 706 | std::cerr << "TrackList is empty therefore there is no valid current track" << std::endl; | 707 | MH_ERROR("TrackList is empty therefore there is no valid current track"); |
2550 | 707 | } | 708 | } |
2551 | 708 | 709 | ||
2552 | 709 | return d->current_track; | 710 | return d->current_track; |
2553 | @@ -711,11 +712,10 @@ | |||
2554 | 711 | 712 | ||
2555 | 712 | bool media::TrackListSkeleton::update_current_iterator(const TrackList::ConstIterator &it) | 713 | bool media::TrackListSkeleton::update_current_iterator(const TrackList::ConstIterator &it) |
2556 | 713 | { | 714 | { |
2558 | 714 | std::cout << __PRETTY_FUNCTION__ << std::endl; | 715 | MH_TRACE(""); |
2559 | 715 | if (it == tracks().get().end()) | 716 | if (it == tracks().get().end()) |
2560 | 716 | return false; | 717 | return false; |
2561 | 717 | 718 | ||
2562 | 718 | std::cout << "Updating current_track iterator" << std::endl; | ||
2563 | 719 | d->current_track = it; | 719 | d->current_track = it; |
2564 | 720 | 720 | ||
2565 | 721 | return true; | 721 | return true; |
2566 | @@ -780,8 +780,7 @@ | |||
2567 | 780 | 780 | ||
2568 | 781 | void media::TrackListSkeleton::on_shuffle_changed(bool shuffle) | 781 | void media::TrackListSkeleton::on_shuffle_changed(bool shuffle) |
2569 | 782 | { | 782 | { |
2572 | 783 | cout << __PRETTY_FUNCTION__ << endl; | 783 | MH_TRACE(""); |
2571 | 784 | |||
2573 | 785 | set_shuffle(shuffle); | 784 | set_shuffle(shuffle); |
2574 | 786 | } | 785 | } |
2575 | 787 | 786 | ||
2576 | @@ -793,7 +792,7 @@ | |||
2577 | 793 | const core::Signal<media::TrackList::ContainerTrackIdTuple>& media::TrackListSkeleton::on_track_list_replaced() const | 792 | const core::Signal<media::TrackList::ContainerTrackIdTuple>& media::TrackListSkeleton::on_track_list_replaced() const |
2578 | 794 | { | 793 | { |
2579 | 795 | // Print the TrackList instance | 794 | // Print the TrackList instance |
2581 | 796 | std::cout << *this << std::endl; | 795 | MH_DEBUG("%s", *this); |
2582 | 797 | return d->signals.on_track_list_replaced; | 796 | return d->signals.on_track_list_replaced; |
2583 | 798 | } | 797 | } |
2584 | 799 | 798 | ||
2585 | 800 | 799 | ||
2586 | === modified file 'src/core/media/track_list_stub.cpp' | |||
2587 | --- src/core/media/track_list_stub.cpp 2016-02-19 16:14:42 +0000 | |||
2588 | +++ src/core/media/track_list_stub.cpp 2016-04-06 19:07:29 +0000 | |||
2589 | @@ -28,6 +28,8 @@ | |||
2590 | 28 | #include "mpris/player.h" | 28 | #include "mpris/player.h" |
2591 | 29 | #include "mpris/track_list.h" | 29 | #include "mpris/track_list.h" |
2592 | 30 | 30 | ||
2593 | 31 | #include "core/media/logger/logger.h" | ||
2594 | 32 | |||
2595 | 31 | #include <core/dbus/property.h> | 33 | #include <core/dbus/property.h> |
2596 | 32 | #include <core/dbus/types/object_path.h> | 34 | #include <core/dbus/types/object_path.h> |
2597 | 33 | #include <core/dbus/types/variant.h> | 35 | #include <core/dbus/types/variant.h> |
2598 | @@ -111,43 +113,43 @@ | |||
2599 | 111 | { | 113 | { |
2600 | 112 | dbus.on_track_added->connect([this](const Track::Id& id) | 114 | dbus.on_track_added->connect([this](const Track::Id& id) |
2601 | 113 | { | 115 | { |
2603 | 114 | std::cout << "OnTrackAdded signal arrived via the bus." << std::endl; | 116 | MH_DEBUG("OnTrackAdded signal arrived via the bus."); |
2604 | 115 | on_track_added(id); | 117 | on_track_added(id); |
2605 | 116 | }); | 118 | }); |
2606 | 117 | 119 | ||
2607 | 118 | dbus.on_tracks_added->connect([this](const media::TrackList::ContainerURI& tracks) | 120 | dbus.on_tracks_added->connect([this](const media::TrackList::ContainerURI& tracks) |
2608 | 119 | { | 121 | { |
2610 | 120 | std::cout << "OnTracksAdded signal arrived via the bus." << std::endl; | 122 | MH_DEBUG("OnTracksAdded signal arrived via the bus."); |
2611 | 121 | on_tracks_added(tracks); | 123 | on_tracks_added(tracks); |
2612 | 122 | }); | 124 | }); |
2613 | 123 | 125 | ||
2614 | 124 | dbus.on_track_moved->connect([this](const media::TrackList::TrackIdTuple& ids) | 126 | dbus.on_track_moved->connect([this](const media::TrackList::TrackIdTuple& ids) |
2615 | 125 | { | 127 | { |
2617 | 126 | std::cout << "OnTrackMoved signal arrived via the bus." << std::endl; | 128 | MH_DEBUG("OnTrackMoved signal arrived via the bus."); |
2618 | 127 | on_track_moved(ids); | 129 | on_track_moved(ids); |
2619 | 128 | }); | 130 | }); |
2620 | 129 | 131 | ||
2621 | 130 | dbus.on_track_removed->connect([this](const Track::Id& id) | 132 | dbus.on_track_removed->connect([this](const Track::Id& id) |
2622 | 131 | { | 133 | { |
2624 | 132 | std::cout << "OnTrackRemoved signal arrived via the bus." << std::endl; | 134 | MH_DEBUG("OnTrackRemoved signal arrived via the bus."); |
2625 | 133 | on_track_removed(id); | 135 | on_track_removed(id); |
2626 | 134 | }); | 136 | }); |
2627 | 135 | 137 | ||
2628 | 136 | dbus.on_track_list_reset->connect([this](void) | 138 | dbus.on_track_list_reset->connect([this](void) |
2629 | 137 | { | 139 | { |
2631 | 138 | std::cout << "OnTrackListReset signal arrived via the bus." << std::endl; | 140 | MH_DEBUG("OnTrackListReset signal arrived via the bus."); |
2632 | 139 | on_track_list_reset(); | 141 | on_track_list_reset(); |
2633 | 140 | }); | 142 | }); |
2634 | 141 | 143 | ||
2635 | 142 | dbus.on_track_list_replaced->connect([this](const media::TrackList::ContainerTrackIdTuple& list) | 144 | dbus.on_track_list_replaced->connect([this](const media::TrackList::ContainerTrackIdTuple& list) |
2636 | 143 | { | 145 | { |
2638 | 144 | std::cout << "OnTrackListReplaced signal arrived via the bus." << std::endl; | 146 | MH_DEBUG("OnTrackListReplaced signal arrived via the bus."); |
2639 | 145 | on_track_list_replaced(list); | 147 | on_track_list_replaced(list); |
2640 | 146 | }); | 148 | }); |
2641 | 147 | 149 | ||
2642 | 148 | dbus.on_track_changed->connect([this](const Track::Id& id) | 150 | dbus.on_track_changed->connect([this](const Track::Id& id) |
2643 | 149 | { | 151 | { |
2645 | 150 | std::cout << "OnTrackChanged signal arrived via the bus." << std::endl; | 152 | MH_DEBUG("OnTrackChanged signal arrived via the bus."); |
2646 | 151 | on_track_changed(id); | 153 | on_track_changed(id); |
2647 | 152 | }); | 154 | }); |
2648 | 153 | } | 155 | } |
2649 | 154 | 156 | ||
2650 | === added file 'src/core/media/util/utils.cpp' | |||
2651 | --- src/core/media/util/utils.cpp 1970-01-01 00:00:00 +0000 | |||
2652 | +++ src/core/media/util/utils.cpp 2016-04-06 19:07:29 +0000 | |||
2653 | @@ -0,0 +1,41 @@ | |||
2654 | 1 | /* | ||
2655 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
2656 | 3 | * | ||
2657 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2658 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
2659 | 6 | * by the Free Software Foundation. | ||
2660 | 7 | * | ||
2661 | 8 | * This program is distributed in the hope that it will be useful, but | ||
2662 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2663 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2664 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
2665 | 12 | * | ||
2666 | 13 | * You should have received a copy of the GNU General Public License along | ||
2667 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2668 | 15 | * | ||
2669 | 16 | */ | ||
2670 | 17 | |||
2671 | 18 | #include <boost/filesystem.hpp> | ||
2672 | 19 | #include <boost/algorithm/string.hpp> | ||
2673 | 20 | |||
2674 | 21 | #include <memory> | ||
2675 | 22 | #include <fstream> | ||
2676 | 23 | #include <sstream> | ||
2677 | 24 | |||
2678 | 25 | #include <cstring> | ||
2679 | 26 | #include <cstdarg> | ||
2680 | 27 | |||
2681 | 28 | #include "utils.h" | ||
2682 | 29 | |||
2683 | 30 | namespace media = core::ubuntu::media; | ||
2684 | 31 | |||
2685 | 32 | uint64_t media::Utils::GetNowNs() { | ||
2686 | 33 | struct timespec ts; | ||
2687 | 34 | memset(&ts, 0, sizeof(ts)); | ||
2688 | 35 | clock_gettime(CLOCK_MONOTONIC, &ts); | ||
2689 | 36 | return ts.tv_sec * 1000000000LL + ts.tv_nsec; | ||
2690 | 37 | } | ||
2691 | 38 | |||
2692 | 39 | uint64_t media::Utils::GetNowUs() { | ||
2693 | 40 | return GetNowNs() / 1000; | ||
2694 | 41 | } | ||
2695 | 0 | 42 | ||
2696 | === added file 'src/core/media/util/utils.h' | |||
2697 | --- src/core/media/util/utils.h 1970-01-01 00:00:00 +0000 | |||
2698 | +++ src/core/media/util/utils.h 2016-04-06 19:07:29 +0000 | |||
2699 | @@ -0,0 +1,69 @@ | |||
2700 | 1 | /* | ||
2701 | 2 | * Copyright (C) 2016 Canonical, Ltd. | ||
2702 | 3 | * | ||
2703 | 4 | * This program is free software: you can redistribute it and/or modify it | ||
2704 | 5 | * under the terms of the GNU General Public License version 3, as published | ||
2705 | 6 | * by the Free Software Foundation. | ||
2706 | 7 | * | ||
2707 | 8 | * This program is distributed in the hope that it will be useful, but | ||
2708 | 9 | * WITHOUT ANY WARRANTY; without even the implied warranties of | ||
2709 | 10 | * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR | ||
2710 | 11 | * PURPOSE. See the GNU General Public License for more details. | ||
2711 | 12 | * | ||
2712 | 13 | * You should have received a copy of the GNU General Public License along | ||
2713 | 14 | * with this program. If not, see <http://www.gnu.org/licenses/>. | ||
2714 | 15 | * | ||
2715 | 16 | */ | ||
2716 | 17 | |||
2717 | 18 | #ifndef UTILS_H_ | ||
2718 | 19 | #define UTILS_H_ | ||
2719 | 20 | |||
2720 | 21 | #include <boost/format.hpp> | ||
2721 | 22 | |||
2722 | 23 | #include <string> | ||
2723 | 24 | #include <vector> | ||
2724 | 25 | |||
2725 | 26 | #define MCS_STR_VALUE(str) #str | ||
2726 | 27 | |||
2727 | 28 | namespace core { | ||
2728 | 29 | namespace ubuntu { | ||
2729 | 30 | namespace media { | ||
2730 | 31 | typedef int64_t TimestampNs; | ||
2731 | 32 | typedef int64_t TimestampUs; | ||
2732 | 33 | struct Utils | ||
2733 | 34 | { | ||
2734 | 35 | // Merely used as a namespace. | ||
2735 | 36 | Utils() = delete; | ||
2736 | 37 | |||
2737 | 38 | // Sprintf - much like what you would expect :) | ||
2738 | 39 | template<typename... Types> | ||
2739 | 40 | static std::string Sprintf(const std::string& fmt_str, Types&&... args); | ||
2740 | 41 | // GetEnv - returns a variable value from the environment | ||
2741 | 42 | static uint64_t GetNowNs(); | ||
2742 | 43 | // GetNowUs - get a timestamp in microseconds | ||
2743 | 44 | static uint64_t GetNowUs(); | ||
2744 | 45 | }; | ||
2745 | 46 | |||
2746 | 47 | namespace impl { | ||
2747 | 48 | // Base case, just return the passed in boost::format instance. | ||
2748 | 49 | inline boost::format& Sprintf(boost::format& f) | ||
2749 | 50 | { | ||
2750 | 51 | return f; | ||
2751 | 52 | } | ||
2752 | 53 | // Sprintf recursively walks the parameter pack at compile time. | ||
2753 | 54 | template <typename Head, typename... Tail> | ||
2754 | 55 | inline boost::format& Sprintf(boost::format& f, Head const& head, Tail&&... tail) { | ||
2755 | 56 | return Sprintf(f % head, std::forward<Tail>(tail)...); | ||
2756 | 57 | } | ||
2757 | 58 | } // namespace impl | ||
2758 | 59 | } // namespace media | ||
2759 | 60 | } // namespace ubuntu | ||
2760 | 61 | } // namespace core | ||
2761 | 62 | |||
2762 | 63 | template <typename... Types> | ||
2763 | 64 | inline std::string core::ubuntu::media::Utils::Sprintf(const std::string& format, Types&&... args) { | ||
2764 | 65 | boost::format f(format); | ||
2765 | 66 | return core::ubuntu::media::impl::Sprintf(f, std::forward<Types>(args)...).str(); | ||
2766 | 67 | } | ||
2767 | 68 | |||
2768 | 69 | #endif | ||
2769 | 0 | 70 | ||
2770 | === modified file 'src/core/media/video/platform_default_sink.cpp' | |||
2771 | --- src/core/media/video/platform_default_sink.cpp 2015-01-29 12:12:43 +0000 | |||
2772 | +++ src/core/media/video/platform_default_sink.cpp 2016-04-06 19:07:29 +0000 | |||
2773 | @@ -36,7 +36,7 @@ | |||
2774 | 36 | // and returns true or returns false and leaves 'matrix' unchanged in case | 36 | // and returns true or returns false and leaves 'matrix' unchanged in case |
2775 | 37 | // of issues. | 37 | // of issues. |
2776 | 38 | bool transformation_matrix(float*) const | 38 | bool transformation_matrix(float*) const |
2778 | 39 | { | 39 | { |
2779 | 40 | return true; | 40 | return true; |
2780 | 41 | } | 41 | } |
2781 | 42 | 42 |
Not many issues compared to the length of the diff and frankly I'm mostly concerned about the own noncopyable class.
There is also one thing which is not bad however I would like to highlight it. I did not like the need to create stringstream in so many cases to log a line as basically this is repeating.