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
616dc9d4
Commit
616dc9d4
authored
Apr 25, 2009
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
playlist_control: use GTimer in previousSongInPlaylist()
To determine whether to rewind the current song or to go to the previous song, use a GTimer instead of manually diffing time(NULL).
parent
d2010c02
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
6 deletions
+15
-6
playlist.c
src/playlist.c
+4
-0
playlist.h
src/playlist.h
+7
-0
playlist_control.c
src/playlist_control.c
+4
-6
No files found.
src/playlist.c
View file @
616dc9d4
...
...
@@ -61,12 +61,16 @@ playlist_init(struct playlist *playlist)
playlist
->
queued
=
-
1
;
playlist
->
current
=
-
1
;
playlist
->
prev_elapsed
=
g_timer_new
();
}
void
playlist_finish
(
struct
playlist
*
playlist
)
{
queue_finish
(
&
playlist
->
queue
);
g_timer_destroy
(
playlist
->
prev_elapsed
);
}
/**
...
...
src/playlist.h
View file @
616dc9d4
...
...
@@ -82,6 +82,13 @@ struct playlist {
* This variable is only valid if #playing is true.
*/
int
queued
;
/**
* This timer tracks the time elapsed since the last "prev"
* command. If that is less than one second ago, "prev" jumps
* to the previous song instead of rewinding the current song.
*/
GTimer
*
prev_elapsed
;
};
/** the global playlist object */
...
...
src/playlist_control.c
View file @
616dc9d4
...
...
@@ -185,15 +185,11 @@ nextSongInPlaylist(struct playlist *playlist)
void
previousSongInPlaylist
(
struct
playlist
*
playlist
)
{
static
time_t
lastTime
;
time_t
diff
=
time
(
NULL
)
-
lastTime
;
lastTime
+=
diff
;
if
(
!
playlist
->
playing
)
return
;
if
(
diff
&&
getPlayerElapsedTime
()
>
PLAYLIST_PREV_UNLESS_ELAPSED
)
{
if
(
g_timer_elapsed
(
playlist
->
prev_elapsed
,
NULL
)
>=
1
.
0
&&
getPlayerElapsedTime
()
>
PLAYLIST_PREV_UNLESS_ELAPSED
)
{
/* re-start playing the current song (just like the
"prev" button on CD players) */
...
...
@@ -213,6 +209,8 @@ void previousSongInPlaylist(struct playlist *playlist)
playPlaylistOrderNumber
(
playlist
,
playlist
->
current
);
}
}
g_timer_start
(
playlist
->
prev_elapsed
);
}
enum
playlist_result
...
...
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