Change __msc_is_stop_needed() to __msc_is_power_off() because this function check only power status.
And msc_get_power_status() has been removed. _msc_is_power_off() can cover it.
Change-Id: Ib51109da141a4596ac67485d3bcdbaf5998dd619
#define _MEDIA_SCANNER_COMMON_V2_H_
#include "stdbool.h"
-#include "media-common-system.h"
#define SCAN_SLEEP_TIME 10000
+bool _msc_is_power_off(void);
void _msc_set_power_status(bool status);
-void msc_get_power_status(bool *status);
#endif /*_MEDIA_SCANNER_COMMON_V2_H_*/
#include "media-scanner-common-v2.h"
#include "media-common-dbg.h"
-bool power_off2;
+static bool power_off2;
-void _msc_set_power_status(bool status)
+bool _msc_is_power_off(void)
{
- power_off2 = status;
+ if (power_off2) {
+ MS_DBG_ERR("Power off");
+ return true;
+ }
- MS_DBG_WARN("media_scanner_v2 set power_off2 to %s", (status) ? "true" : "false");
+ return false;
}
-void msc_get_power_status(bool *status)
+void _msc_set_power_status(bool status)
{
- *status = power_off2;
+ power_off2 = status;
+
+ MS_DBG_WARN("media_scanner_v2 set power_off2 to %s", (status) ? "true" : "false");
}
#include "media-scanner-socket-v2.h"
#include "media-scanner-extract-v2.h"
-extern bool power_off2;
GAsyncQueue *storage_extract_queue;
GAsyncQueue *folder_extract_queue;
static GMutex extract_req_mutex;
NEXT:
g_directory_extract_processing = false;
- if (power_off2) {
- MS_DBG_ERR("power off");
+ if (_msc_is_power_off())
goto _POWEROFF;
- }
/*Active flush */
malloc_trim(0);
g_free(update_path);
update_path = NULL;
- if (power_off2) {
- MS_DBG_ERR("power off");
+ if (_msc_is_power_off())
goto _POWEROFF;
- }
/*disconnect form media db*/
ms_disconnect_db(handle);
int ret = MS_MEDIA_ERR_NONE;
/*check poweroff status*/
- if (power_off2) {
- MS_DBG_ERR("Power off");
+ if (_msc_is_power_off()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
goto END;
}
#define DIR_SCAN_RECURSIVE 1
#define DIR_SCAN_NON_RECURSIVE 2
-extern bool power_off2;
GAsyncQueue *storage_queue2;
GAsyncQueue *scan_queue2;
GAsyncQueue *reg_queue2;
int ret = MS_MEDIA_ERR_NONE;
/*check poweroff status*/
- if (power_off2) {
- MS_DBG_ERR("Power off");
+ if (_msc_is_power_off()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
goto END;
}
}
msc_insert_exactor_request(scan_data->msg_type, true, scan_data->storage_id, scan_data->msg, scan_data->pid, uid, noti_type);
}
- if (power_off2) {
- MS_DBG_ERR("power off");
+
+ if (_msc_is_power_off())
goto _POWEROFF;
- }
NEXT:
/*Active flush */
#ifdef _USE_TVPD_MODE
if (ms_is_support_pvr()) {
MS_DBG_ERR("Waiting PVR service");
- while (!power_off2) {
+ while (!_msc_is_power_off()) {
FILE* file = fopen("/run/pvr_ready", "rb");
if (file != NULL) {
g_free(update_path);
update_path = NULL;
- if (power_off2) {
- MS_DBG_ERR("power off");
+ if (_msc_is_power_off())
goto _POWEROFF;
- }
/*disconnect from media db*/
ms_disconnect_db(handle);
sqlite3 *handle = NULL;
char *insert_path = NULL;
char storage_id[MS_UUID_SIZE] = {0,};
- bool power_off_status = false;
/* connect to media db, if conneting is failed, db updating is stopped */
err = ms_connect_db(&handle, uid);
/* insert to db */
err = ms_insert_item_batch(handle, storage_id, insert_path, uid);
- msc_get_power_status(&power_off_status);
- if (power_off_status) {
- MS_DBG_ERR("power off");
+ if (_msc_is_power_off()) {
/*call for bundle commit*/
break;
}
#include "media-scanner-socket.h"
#include "media-scanner-scan.h"
-bool power_off;
+static bool power_off;
static GAsyncQueue * storage_queue;
GAsyncQueue *scan_queue;
static GAsyncQueue *reg_queue;
GMutex scan_req_mutex;
-static bool __msc_is_stop_needed(void)
+static bool __msc_is_power_off(void)
{
if (power_off) {
- MS_DBG_WARN("Power off");
+ MS_DBG_ERR("Power off");
return true;
}
current_path = g_ptr_array_index(dir_array, 0);
g_ptr_array_remove_index(dir_array, 0);
- if (__msc_is_stop_needed()) {
+ if (__msc_is_power_off()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
MS_SAFE_FREE(current_path);
continue;
MS_DBG_ERR("insert folder failed");
while ((name = g_dir_read_name(dir))) {
- if (__msc_is_stop_needed()) {
+ if (__msc_is_power_off()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
break;
}
ms_disconnect_db(handle);
- if (__msc_is_stop_needed())
+ if (__msc_is_power_off())
goto _POWEROFF;
NEXT:
/*Active flush */
else
ms_set_db_status(MS_DB_UPDATED, storage_type);
NEXT:
- if (__msc_is_stop_needed())
+ if (__msc_is_power_off())
goto _POWEROFF;
/*Active flush */
ret = ms_insert_item_batch(handle, storage_id, insert_path, uid);
- if (__msc_is_stop_needed()) {
+ if (__msc_is_power_off()) {
ret = MS_MEDIA_ERR_SCANNER_FORCE_STOP;
break;
}