summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--binding/media-api.c2
-rw-r--r--binding/media-manager.c31
-rw-r--r--binding/media-manager.h7
3 files changed, 30 insertions, 10 deletions
diff --git a/binding/media-api.c b/binding/media-api.c
index 4a5b5f6..fb0145f 100644
--- a/binding/media-api.c
+++ b/binding/media-api.c
@@ -130,7 +130,7 @@ static void media_results_get (struct afb_req request)
json_object *jresp = NULL;
ListLock();
- list = media_lightmediascanner_scan();
+ list = media_lightmediascanner_scan(NULL);
list = media_local_scan(list);
if (list == NULL) {
afb_req_fail(request, "failed", "media scan error");
diff --git a/binding/media-manager.c b/binding/media-manager.c
index 5fee748..63dd4ff 100644
--- a/binding/media-manager.c
+++ b/binding/media-manager.c
@@ -109,13 +109,14 @@ GList* media_local_scan(GList *list)
return list;
}
-GList* media_lightmediascanner_scan(void)
+GList* media_lightmediascanner_scan(gchar *uri)
{
sqlite3 *conn;
sqlite3_stmt *res;
GList *list = NULL;
const char *tail;
const gchar *db_path;
+ gchar *query;
int ret = 0;
db_path = scanner1_get_data_base_path(MediaPlayerManage.lms_proxy);
@@ -126,9 +127,16 @@ GList* media_lightmediascanner_scan(void)
return NULL;
}
- ret = sqlite3_prepare_v2(conn, SQL_QUERY, strlen(SQL_QUERY) + 1, &res, &tail);
+ query = g_strdup_printf(SQL_QUERY, uri ? uri : "");
+ if (!query) {
+ LOGE("Cannot allocate memory for query\n");
+ return NULL;
+ }
+
+ ret = sqlite3_prepare_v2(conn, query, strlen(query), &res, &tail);
if (ret) {
- LOGE("Cannot execute query '%s'\n", SQL_QUERY);
+ LOGE("Cannot execute query '%s'\n", query);
+ g_free(query);
return NULL;
}
@@ -151,6 +159,8 @@ GList* media_lightmediascanner_scan(void)
list = g_list_append(list, item);
}
+ g_free(query);
+
return list;
}
@@ -199,7 +209,10 @@ on_interface_proxy_properties_changed (GDBusProxy *proxy,
ListLock();
- list = media_lightmediascanner_scan();
+ list = media_lightmediascanner_scan(MediaPlayerManage.uri_filter);
+
+ g_free(MediaPlayerManage.uri_filter);
+ MediaPlayerManage.uri_filter = NULL;
if (list != NULL && g_RegisterCallback.binding_device_added)
g_RegisterCallback.binding_device_added(list);
@@ -255,17 +268,21 @@ unmount_cb (GFileMonitor *mon,
{
gchar *path = g_file_get_path(file);
gchar *uri = g_strconcat("file://", path, NULL);
- g_free(path);
ListLock();
if (g_RegisterCallback.binding_device_removed &&
event == G_FILE_MONITOR_EVENT_DELETED) {
- g_RegisterCallback.binding_device_removed(uri);
+ g_RegisterCallback.binding_device_removed(uri);
+ g_free(path);
+ } else if (event == G_FILE_MONITOR_EVENT_CREATED) {
+ MediaPlayerManage.uri_filter = path;
+ } else {
+ g_free(path);
}
- ListUnlock();
g_free(uri);
+ ListUnlock();
}
/*
diff --git a/binding/media-manager.h b/binding/media-manager.h
index f1f177e..69c866b 100644
--- a/binding/media-manager.h
+++ b/binding/media-manager.h
@@ -83,11 +83,14 @@ void DebugTraceSendMsg(int level, gchar* message);
"ON audio_albums.id = audios.album_id " \
"LEFT JOIN audio_genres " \
"ON audio_genres.id = audios.genre_id " \
- "WHERE audios.id = files.id ORDER BY " \
+ "WHERE audios.id = files.id " \
+ "AND files.path LIKE '%s/%%' " \
+ "ORDER BY " \
"audios.artist_id, audios.album_id, audios.trackno"
typedef struct {
GList *list;
+ gchar *uri_filter;
GMutex m;
Scanner1 *lms_proxy;
} stMediaPlayerManage;
@@ -105,7 +108,7 @@ int MediaPlayerManagerInit(void);
void ListLock();
void ListUnlock();
-GList* media_lightmediascanner_scan(void);
+GList* media_lightmediascanner_scan(gchar *uri);
GList* media_local_scan(GList *list);
struct Media_Item {