Instance: add StateFile* attribute
This commit is contained in:
parent
710def8e38
commit
031410c72b
@ -40,6 +40,7 @@ class UpdateService;
|
|||||||
class Error;
|
class Error;
|
||||||
class ClientList;
|
class ClientList;
|
||||||
struct Partition;
|
struct Partition;
|
||||||
|
class StateFile;
|
||||||
|
|
||||||
struct Instance final
|
struct Instance final
|
||||||
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
|
#if defined(ENABLE_DATABASE) || defined(ENABLE_NEIGHBOR_PLUGINS)
|
||||||
@ -79,6 +80,8 @@ struct Instance final
|
|||||||
|
|
||||||
Partition *partition;
|
Partition *partition;
|
||||||
|
|
||||||
|
StateFile *state_file;
|
||||||
|
|
||||||
Instance():global_events(event_loop) {}
|
Instance():global_events(event_loop) {}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
20
src/Main.cxx
20
src/Main.cxx
@ -128,8 +128,6 @@ Context *context;
|
|||||||
|
|
||||||
Instance *instance;
|
Instance *instance;
|
||||||
|
|
||||||
static StateFile *state_file;
|
|
||||||
|
|
||||||
#ifdef ENABLE_DAEMON
|
#ifdef ENABLE_DAEMON
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
@ -284,10 +282,10 @@ glue_state_file_init(Error &error)
|
|||||||
config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
|
config_get_unsigned(ConfigOption::STATE_FILE_INTERVAL,
|
||||||
StateFile::DEFAULT_INTERVAL);
|
StateFile::DEFAULT_INTERVAL);
|
||||||
|
|
||||||
state_file = new StateFile(std::move(path_fs), interval,
|
instance->state_file = new StateFile(std::move(path_fs), interval,
|
||||||
*instance->partition,
|
*instance->partition,
|
||||||
instance->event_loop);
|
instance->event_loop);
|
||||||
state_file->Read();
|
instance->state_file->Read();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -380,8 +378,8 @@ idle_event_emitted(void)
|
|||||||
instance->client_list->IdleAdd(flags);
|
instance->client_list->IdleAdd(flags);
|
||||||
|
|
||||||
if (flags & (IDLE_PLAYLIST|IDLE_PLAYER|IDLE_MIXER|IDLE_OUTPUT) &&
|
if (flags & (IDLE_PLAYLIST|IDLE_PLAYER|IDLE_MIXER|IDLE_OUTPUT) &&
|
||||||
state_file != nullptr)
|
instance->state_file != nullptr)
|
||||||
state_file->CheckModified();
|
instance->state_file->CheckModified();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef ANDROID
|
#ifndef ANDROID
|
||||||
@ -655,9 +653,9 @@ try {
|
|||||||
instance->update->CancelAllAsync();
|
instance->update->CancelAllAsync();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (state_file != nullptr) {
|
if (instance->state_file != nullptr) {
|
||||||
state_file->Write();
|
instance->state_file->Write();
|
||||||
delete state_file;
|
delete instance->state_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
instance->partition->pc.Kill();
|
instance->partition->pc.Kill();
|
||||||
|
Loading…
Reference in New Issue
Block a user