static int __msc_dir_and_storage_scan_same_path(char *start_path);
static int __msc_check_memory_status(uid_t uid);
static int __msc_check_remain_space(uid_t uid);
-static void __msc_del_cancel_scan_item(void);
-static void msc_set_cur_scan_item(const char* cur_scan_path, int pid);
-static void __msc_del_cur_scan_item(void);
static void __msc_del_blocked_path(void);
static int __msc_set_dir_scan_cb(DIR_SCAN_CB cb)
return err;
}
-static void __msc_pop_new_request(ms_comm_msg_s **scan_data)
+static int __msc_set_scan_item(s_scan_item **item, const char* path, int pid)
{
- *scan_data = g_async_queue_pop(scan_queue2);
+ s_scan_item* scan_item = *item;
+
+ if (!scan_item)
+ scan_item = g_new0(s_scan_item, 1);
+
+ g_free(scan_item->path);
+
+ scan_item->path = g_strdup(path);
+ scan_item->pid = pid;
+
+ *item = scan_item;
+
+ MS_DBG_SWARN("path[%s],pid[%d]", scan_item->path, scan_item->pid);
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+static void __msc_del_cancel_scan_item(void)
+{
+ g_mutex_lock(&scan_item_mutex);
+
+ if (cancel_scan_item) {
+ g_free(cancel_scan_item->path);
+ g_free(cancel_scan_item);
+ cancel_scan_item = NULL;
+ }
+
+ g_mutex_unlock(&scan_item_mutex);
+}
+
+static void __msc_del_cur_scan_item(void)
+{
+ g_mutex_lock(&scan_item_mutex);
+
+ if (cur_scan_item) {
+ g_free(cur_scan_item->path);
+ g_free(cur_scan_item);
+ cur_scan_item = NULL;
+ }
+
+ g_mutex_unlock(&scan_item_mutex);
}
gpointer msc_directory_scan_thread(gpointer data)
uid_t uid = MEDIA_DEFAULT_UID;
while (1) {
- __msc_pop_new_request(&scan_data);
+ scan_data = g_async_queue_pop(scan_queue2);
ret = MS_MEDIA_ERR_NONE;
if (scan_data->pid == POWEROFF) {
goto _POWEROFF;
}
- MS_DBG_WARN("DIRECTORY SCAN START [%.*s, %d]", MAX_MSG_SIZE, scan_data->msg, scan_data->msg_type);
+ MS_DBG_WARN("DIRECTORY SCAN START [%.*s][%s][%d]", MAX_MSG_SIZE, scan_data->msg, scan_data->storage_id, scan_data->msg_type);
+
+ g_mutex_lock(&scan_item_mutex);
+ __msc_set_scan_item(&cur_scan_item, scan_data->msg, scan_data->pid);
+ g_mutex_unlock(&scan_item_mutex);
- msc_set_cur_scan_item(scan_data->msg, scan_data->pid);
g_directory_scan_processing2 = DIR_SCAN_NON_RECURSIVE;
uid = scan_data->uid;
return NULL;
}
-static int __msc_set_scan_item(s_scan_item** item, const char* path, int pid)
-{
- s_scan_item* scan_item = *item;
-
- if (!scan_item)
- scan_item = g_new0(s_scan_item, 1);
-
- g_free(scan_item->path);
-
- scan_item->path = g_strdup(path);
- scan_item->pid = pid;
-
- *item = scan_item;
-
- MS_DBG_SWARN("path[%s],pid[%d]", scan_item->path, scan_item->pid);
-
- return MS_MEDIA_ERR_NONE;
-}
-
-static void __msc_del_scan_item(s_scan_item** item)
-{
- if (*item != NULL) {
- g_free((*item)->path);
- g_free(*item);
- *item = NULL;
- }
-}
-
int msc_set_cancel_scan_item(const char* cancel_path, int pid)
{
int ret = -1;
return ret;
}
-static void __msc_del_cancel_scan_item(void)
-{
- g_mutex_lock(&scan_item_mutex);
- __msc_del_scan_item(&cancel_scan_item);
- g_mutex_unlock(&scan_item_mutex);
-}
-
-static void msc_set_cur_scan_item(const char* cur_scan_path, int pid)
-{
- g_mutex_lock(&scan_item_mutex);
- __msc_set_scan_item(&cur_scan_item, cur_scan_path, pid);
- g_mutex_unlock(&scan_item_mutex);
-}
-
-static void __msc_del_cur_scan_item(void)
-{
- g_mutex_lock(&scan_item_mutex);
- __msc_del_scan_item(&cur_scan_item);
- g_mutex_unlock(&scan_item_mutex);
-}
-
void msc_set_blocked_path(const char *blocked_path)
{
MS_DBG_FENTER();
#include "media-scanner-socket-v2.h"
#include "media-scanner-extract-v2.h"
-#include "private.h"
-
#define APP_NAME "media-scanner-v2"
static GMainLoop *scanner_mainloop2 = NULL;
static guint scanner_source_id2;
-static void __msc_add_event_receiver(void *data);
-static void __msc_remove_event_receiver(void);
-
-static void __power_off_cb(void)
+static int __msc_power_off_cb(int option, void *data)
{
- MS_DBG_ERR("POWER OFF CB Begin");
- //display_lock_state(POWER_STATE_STANDBY, 0);
+ MS_DBG_ERR("POWER OFF BEGIN");
_msc_set_power_status(true);
g_main_loop_quit(scanner_mainloop2);
MS_DBG_ERR("POWER OFF END");
+
+ return MS_MEDIA_ERR_NONE;
+}
+
+static void __msc_add_event_receiver(void *data)
+{
+ /*set power off callback function*/
+ ms_sys_set_poweroff_cb(__msc_power_off_cb, NULL);
+ ms_sys_set_device_block_event_cb(msc_device_block_changed_cb, NULL);
+}
+
+static void __msc_remove_event_receiver(void)
+{
+ ms_sys_unset_device_block_event_cb();
+ ms_sys_unset_poweroff_cb();
}
int main(int argc, char **argv)
MS_DBG_INFO("Scanner-V2 is shutting down");
return 0;
}
-
-static int __msc_power_off_cb(int option, void *data)
-{
- __power_off_cb();
-
- return MS_MEDIA_ERR_NONE;
-}
-
-static void __msc_add_event_receiver(void *data)
-{
- /*set power off callback function*/
- ms_sys_set_poweroff_cb(__msc_power_off_cb, NULL);
- ms_sys_set_device_block_event_cb(msc_device_block_changed_cb, NULL);
-}
-
-static void __msc_remove_event_receiver(void)
-{
- ms_sys_unset_device_block_event_cb();
- ms_sys_unset_poweroff_cb();
-}
-