Merge lp:~mhr3/mediascanner/fixes into lp:mediascanner

Proposed by Michal Hruby
Status: Merged
Approved by: James Henstridge
Approved revision: 398
Merged at revision: 395
Proposed branch: lp:~mhr3/mediascanner/fixes
Merge into: lp:mediascanner
Diff against target: 160 lines (+38/-17)
5 files modified
src/mediascanner-service/main.cpp (+13/-2)
src/mediascanner/commitpolicy.cpp (+4/-3)
src/mediascanner/filesystemwalker.cpp (+12/-11)
src/mediascanner/mediaroot.cpp (+4/-1)
tests/auto/filesystemscannertest.cpp (+5/-0)
To merge this branch: bzr merge lp:~mhr3/mediascanner/fixes
Reviewer Review Type Date Requested Status
James Henstridge Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+190748@code.launchpad.net

Commit message

A couple of fixes.

Description of the change

A couple of fixes.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~mhr3/mediascanner/fixes updated
397. By Michal Hruby

Merge lp:~jamesh/mediascanner/bug-1237484

398. By Michal Hruby

Remove the GNetworkMonitor fix which is now duplicated

Revision history for this message
James Henstridge (jamesh) wrote :

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mediascanner-service/main.cpp'
2--- src/mediascanner-service/main.cpp 2013-10-08 14:44:18 +0000
3+++ src/mediascanner-service/main.cpp 2013-10-14 09:40:03 +0000
4@@ -20,6 +20,7 @@
5
6 // GLib based libraries
7 #include <grilo.h>
8+#include <gio/gio.h>
9 #include <gst/pbutils/pbutils.h>
10
11 // Boost C++
12@@ -701,8 +702,10 @@
13 available_caps.get(),
14 GST_CAPS_INTERSECT_FIRST));
15
16- kTraceGSt("mandatory: {1}") % to_string(mandatory_caps);
17- kTraceGSt("common: {1}") % to_string(common_caps);
18+ std::string mand_caps_str = to_string(mandatory_caps);
19+ std::string common_caps_str = to_string(common_caps);
20+ kTraceGSt("mandatory: {1}") % mand_caps_str;
21+ kTraceGSt("common: {1}") % common_caps_str;
22
23 if (gst_caps_is_empty(common_caps)) {
24 // TODO(M5): L10N or maybe trigger plugin installer
25@@ -806,6 +809,14 @@
26 return false;
27 }
28
29+ // Make sure the network monitor is initialised early, since it is
30+ // not reliable if initialised from a thread.
31+ GNetworkMonitor *network_monitor = g_network_monitor_get_default();
32+ if (not network_monitor) {
33+ kError("Could not initialize GNetworkMonitor");
34+ return false;
35+ }
36+
37 // Really check all plugins. Avoid lazy evaluation.
38 // Don't abort on missing codecs. We already print a warning.
39 VerifyMediaFeatures(list_gst_demuxers(), settings_.mandatory_containers());
40
41=== modified file 'src/mediascanner/commitpolicy.cpp'
42--- src/mediascanner/commitpolicy.cpp 2013-09-09 12:17:56 +0000
43+++ src/mediascanner/commitpolicy.cpp 2013-10-14 09:40:03 +0000
44@@ -185,9 +185,10 @@
45 (DelayedCommitPolicy *policy) {
46 cancel_timeout();
47
48- const Source::OneCallFunction commit_function =
49- std::bind(&WritableMediaIndex::CommitPendingChanges,
50- media_index_);
51+ const Source::OneCallFunction commit_function = [this] () {
52+ media_index_->CommitPendingChanges();
53+ timeout_id_ = 0;
54+ };
55
56 due_time_ = Clock::universal_time() + policy->maximium_delay();
57 timeout_id_ = Timeout::AddOnce(policy->maximium_delay(), commit_function);
58
59=== modified file 'src/mediascanner/filesystemwalker.cpp'
60--- src/mediascanner/filesystemwalker.cpp 2013-10-10 02:31:44 +0000
61+++ src/mediascanner/filesystemwalker.cpp 2013-10-14 09:40:03 +0000
62@@ -377,9 +377,9 @@
63 std::placeholders::_1, media, nullptr, &media_properties));
64 metadata->add_related(media_properties);
65
66- const GList *const stream_list = gst_discoverer_info_get_stream_list(media);
67+ std::unique_ptr<GList, void(*)(GList*)> stream_list(gst_discoverer_info_get_stream_list(media), gst_discoverer_stream_info_list_free);
68
69- for (const GList *l = stream_list; l; l = l->next) {
70+ for (const GList *l = stream_list.get(); l; l = l->next) {
71 GstDiscovererStreamInfo *const stream =
72 GST_DISCOVERER_STREAM_INFO(l->data);
73
74@@ -746,8 +746,9 @@
75 ScanDetails details) {
76 Wrapper<GError> error;
77
78- std::unique_ptr<GstDiscoverer, void(*)(GstDiscoverer*)> discoverer(gst_discoverer_new(GST_SECOND * 25, error.out_param()),
79- [](GstDiscoverer *p) { g_object_unref(p);});
80+ const Wrapper<GstDiscoverer> discoverer =
81+ take(gst_discoverer_new(GST_SECOND * 25, error.out_param()));
82+
83 if (!discoverer) {
84 const std::string error_message = to_string(error);
85 ReportError(format("Cannot create discoverer: {1}") % error_message);
86@@ -837,13 +838,13 @@
87 if (media) {
88 GstDiscovererResult res = gst_discoverer_info_get_result (media.get());
89 if (res != GST_DISCOVERER_OK) {
90- kInfo(" Unable to discover \"{1}\", error code: {2}") % path % res;
91+ kWarning(" Unable to discover \"{1}\", error code: {2}") % path % res;
92 return;
93 }
94- GList *const streams = gst_discoverer_info_get_stream_list(media.get());
95+ std::unique_ptr<GList, void(*)(GList*)> streams(gst_discoverer_info_get_stream_list(media.get()), gst_discoverer_stream_info_list_free);
96
97 // Skip any file that doesn't provide GStreamer compatible streams.
98- if (streams == nullptr) {
99+ if (not streams) {
100 kDebug(" No media streams found in \"{1}\"") % path;
101 return;
102 }
103@@ -851,11 +852,11 @@
104 // File must be an image if duration is zero. Check that.
105 if (gst_discoverer_info_get_duration(media) == 0) {
106 // No streams at all? That's suspecious, but well.
107- if (not GST_IS_DISCOVERER_VIDEO_INFO(streams->data))
108+ if (not GST_IS_DISCOVERER_VIDEO_INFO(streams.get()->data))
109 return;
110
111 GstDiscovererVideoInfo *const video_info =
112- static_cast<GstDiscovererVideoInfo *>(streams->data);
113+ static_cast<GstDiscovererVideoInfo *>(streams.get()->data);
114
115 // Duration is zero, but it's also no image? Let's skip!
116 if (not gst_discoverer_video_info_is_image(video_info))
117@@ -874,8 +875,8 @@
118 text << ", gstinfo={result="
119 << gst_discoverer_info_get_result(media);
120
121- GList *streams = gst_discoverer_info_get_stream_list(media.get());
122- text << PrintStreams(streams);
123+ std::unique_ptr<GList, void(*)(GList*)> streams(gst_discoverer_info_get_stream_list(media.get()), gst_discoverer_stream_info_list_free);
124+ text << PrintStreams(streams.get());
125
126 text << "}";
127 }
128
129=== modified file 'src/mediascanner/mediaroot.cpp'
130--- src/mediascanner/mediaroot.cpp 2013-09-11 09:49:12 +0000
131+++ src/mediascanner/mediaroot.cpp 2013-10-14 09:40:03 +0000
132@@ -274,8 +274,11 @@
133
134 if (volume_monitor_)
135 g_signal_handlers_disconnect_by_data(volume_monitor_.get(), this);
136- if (idle_id_)
137+
138+ if (idle_id_) {
139 Idle::Remove(idle_id_);
140+ idle_id_ = 0;
141+ }
142 }
143
144 void MediaRootManager::Private::on_init() {
145
146=== modified file 'tests/auto/filesystemscannertest.cpp'
147--- tests/auto/filesystemscannertest.cpp 2013-10-08 14:44:18 +0000
148+++ tests/auto/filesystemscannertest.cpp 2013-10-14 09:40:03 +0000
149@@ -353,6 +353,11 @@
150 grl_init(&argc, &argv);
151 gst_init(&argc, &argv);
152
153+ // Initialise GNetworkMonitor early so it doesn't get initialised
154+ // in a thread other than than the main loop.
155+ GNetworkMonitor *network_monitor = g_network_monitor_get_default();
156+ g_assert(network_monitor != NULL);
157+
158 mediascanner::filesystemscannertest::SetupTestEnvironments();
159
160 return RUN_ALL_TESTS();

Subscribers

People subscribed via source and target branches