Merge lp:~jpakkane/mediascanner/quickfix into lp:mediascanner

Proposed by Jussi Pakkanen
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 384
Merged at revision: 382
Proposed branch: lp:~jpakkane/mediascanner/quickfix
Merge into: lp:mediascanner
Diff against target: 104 lines (+11/-29)
1 file modified
src/mediascanner/filesystemwalker.cpp (+11/-29)
To merge this branch: bzr merge lp:~jpakkane/mediascanner/quickfix
Reviewer Review Type Date Requested Status
Paweł Stołowski (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+184563@code.launchpad.net

Commit message

Quickfix for crasher.

Description of the change

Quickfix for crasher. Behaviour should not be impacted.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~jpakkane/mediascanner/quickfix updated
383. By Jussi Pakkanen

Try to recreate GstDiscoverer instead of exiting.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
lp:~jpakkane/mediascanner/quickfix updated
384. By Jussi Pakkanen

Do not reuse gst_discoverers.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

Looks good. +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/mediascanner/filesystemwalker.cpp'
2--- src/mediascanner/filesystemwalker.cpp 2013-08-23 07:49:06 +0000
3+++ src/mediascanner/filesystemwalker.cpp 2013-09-09 14:58:26 +0000
4@@ -40,6 +40,7 @@
5 #include <map>
6 #include <string>
7 #include <vector>
8+#include <memory>
9
10 // Media Scanner Library
11 #include "mediascanner/glibutils.h"
12@@ -160,7 +161,6 @@
13
14 void take_file_task(const std::string &path);
15
16- bool SetupDiscoverer();
17 void CancelDiscoverer();
18
19 void ScanDirectory(Wrapper<GFile> directory, ScanDetails details);
20@@ -190,7 +190,6 @@
21 const ErrorFunction report_fatal_error_;
22 const Wrapper<GCancellable> cancellable_;
23 const MetadataResolverPtr metadata_resolver_;
24- Wrapper<GstDiscoverer> discoverer_;
25 const TaskManagerPtr file_task_manager_;
26 const TaskManagerPtr index_task_manager_;
27 const TaskFacadePtr index_task_facade_;
28@@ -425,25 +424,6 @@
29 (index_task_facade_->bind(task, report_fatal_error_));
30 }
31
32-bool FileSystemWalker::Private::SetupDiscoverer() {
33- Wrapper<GError> error;
34-
35- discoverer_ = gst_discoverer_new(1 * GST_SECOND, error.out_param());
36-
37- if (not discoverer_) {
38- const std::string error_message = to_string(error);
39- ReportError(format("Cannot create discoverer: {1}") % error_message);
40- return false;
41- }
42-
43- return true;
44-}
45-
46-void FileSystemWalker::Private::CancelDiscoverer() {
47- gst_discoverer_stop(discoverer_.get());
48- discoverer_.reset();
49-}
50-
51 bool FileSystemWalker::start() {
52 return d->start(Private::ScanAll);
53 }
54@@ -517,9 +497,6 @@
55
56 error_message_.clear();
57
58- if (not SetupDiscoverer())
59- return false;
60-
61 push_file_task(&Private::ScanDirectory, media_root().file(), details);
62
63 file_task_manager_->AppendGroupedTask
64@@ -544,8 +521,6 @@
65 const std::string root_path = media_root_.path();
66 kInfo("Finished scanning directories below \"{1}\".") % root_path;
67
68- CancelDiscoverer();
69-
70 // Wakeup joiners
71 g_mutex_lock(&mutex_);
72 walking_ = false;
73@@ -764,13 +739,20 @@
74
75 void FileSystemWalker::Private::ScanFile(Wrapper<GFile> file,
76 ScanDetails details) {
77+ Wrapper<GError> error;
78+
79+ std::unique_ptr<GstDiscoverer, void(*)(GstDiscoverer*)> discoverer(gst_discoverer_new(GST_SECOND, error.out_param()),
80+ [](GstDiscoverer *p) { g_object_unref(p);});
81+ if (!discoverer) {
82+ const std::string error_message = to_string(error);
83+ ReportError(format("Cannot create discoverer: {1}") % error_message);
84+ return;
85+ }
86 const std::string path = get_path(file.get());
87 take_file_task(path);
88
89 kDebug(" Scanning \"{1}\"") % path;
90
91- Wrapper<GError> error;
92-
93 const Wrapper<GFileInfo> file_info =
94 take(g_file_query_info(file.get(), "standard::*,etag::*,time::*",
95 G_FILE_QUERY_INFO_NONE, cancellable_.get(),
96@@ -837,7 +819,7 @@
97 // FIXME(M5): Obey ScanStreams flag
98 // FIXME(M5): Discover in background
99 const Wrapper<GstDiscovererInfo> media =
100- take(gst_discoverer_discover_uri(discoverer_.get(), url.c_str(),
101+ take(gst_discoverer_discover_uri(discoverer.get(), url.c_str(),
102 error.out_param()));
103
104 if (error) {

Subscribers

People subscribed via source and target branches