Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
96882175
Commit
96882175
authored
Apr 08, 2013
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
StateFile: move code to RememberVersions(), IsModified()
parent
484841fc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
12 deletions
+33
-12
StateFile.cxx
src/StateFile.cxx
+21
-12
StateFile.hxx
src/StateFile.hxx
+12
-0
No files found.
src/StateFile.cxx
View file @
96882175
...
...
@@ -45,6 +45,24 @@ StateFile::StateFile(Path &&_path, const char *_path_utf8,
}
void
StateFile
::
RememberVersions
()
{
prev_volume_version
=
sw_volume_state_get_hash
();
prev_output_version
=
audio_output_state_get_version
();
prev_playlist_version
=
playlist_state_get_hash
(
&
partition
.
playlist
,
&
partition
.
pc
);
}
bool
StateFile
::
IsModified
()
const
{
return
prev_volume_version
!=
sw_volume_state_get_hash
()
||
prev_output_version
!=
audio_output_state_get_version
()
||
prev_playlist_version
!=
playlist_state_get_hash
(
&
partition
.
playlist
,
&
partition
.
pc
);
}
void
StateFile
::
Write
()
{
g_debug
(
"Saving state file %s"
,
path_utf8
.
c_str
());
...
...
@@ -62,10 +80,7 @@ StateFile::Write()
fclose
(
fp
);
prev_volume_version
=
sw_volume_state_get_hash
();
prev_output_version
=
audio_output_state_get_version
();
prev_playlist_version
=
playlist_state_get_hash
(
&
partition
.
playlist
,
&
partition
.
pc
);
RememberVersions
();
}
void
...
...
@@ -92,19 +107,13 @@ StateFile::Read()
g_warning
(
"Unrecognized line in state file: %s"
,
line
);
}
prev_volume_version
=
sw_volume_state_get_hash
();
prev_output_version
=
audio_output_state_get_version
();
prev_playlist_version
=
playlist_state_get_hash
(
&
partition
.
playlist
,
&
partition
.
pc
);
RememberVersions
();
}
inline
void
StateFile
::
AutoWrite
()
{
if
(
prev_volume_version
==
sw_volume_state_get_hash
()
&&
prev_output_version
==
audio_output_state_get_version
()
&&
prev_playlist_version
==
playlist_state_get_hash
(
&
partition
.
playlist
,
&
partition
.
pc
))
if
(
!
IsModified
())
/* nothing has changed - don't save the state file,
don't spin up the hard disk */
return
;
...
...
src/StateFile.hxx
View file @
96882175
...
...
@@ -49,6 +49,18 @@ public:
void
Write
();
private
:
/**
* Save the current state versions for use with IsModified().
*/
void
RememberVersions
();
/**
* Check if MPD's state was modified since the last
* RememberVersions() call.
*/
gcc_pure
bool
IsModified
()
const
;
void
AutoWrite
();
/* virtual methods from TimeoutMonitor */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment