forked from gentoo/gentoo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audacious-3.2.3-fix-mutex.patch
89 lines (71 loc) · 3.36 KB
/
audacious-3.2.3-fix-mutex.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
commit b53935921298b8164f80454c2016bd40de29704b
Author: John Lindgren <[email protected]>
Date: Sat May 26 11:55:42 2012 -0400
Fix violation of mutex locking order (playback then playlist). Found by Helgrind.
diff --git a/src/audacious/playlist-new.c b/src/audacious/playlist-new.c
index 6407f64..596fbaa 100644
--- a/src/audacious/playlist-new.c
+++ b/src/audacious/playlist-new.c
@@ -822,6 +822,7 @@ void playlist_reorder (int from, int to, int count)
void playlist_delete (int playlist_num)
{
+ /* stop playback before locking playlists */
if (playback_get_playing () && playlist_num == playlist_get_playing ())
playback_stop ();
@@ -969,6 +970,7 @@ int playlist_get_active (void)
void playlist_set_playing (int playlist_num)
{
+ /* stop playback before locking playlists */
if (playback_get_playing ())
playback_stop ();
@@ -1112,6 +1114,7 @@ void playlist_entry_insert_batch_raw (int playlist_num, int at,
void playlist_entry_delete (int playlist_num, int at, int number)
{
+ /* stop playback before locking playlists */
if (playback_get_playing () && playlist_num == playlist_get_playing () &&
playlist_get_position (playlist_num) >= at && playlist_get_position
(playlist_num) < at + number)
@@ -1225,6 +1228,7 @@ int playlist_entry_get_length (int playlist_num, int entry_num, bool_t fast)
void playlist_set_position (int playlist_num, int entry_num)
{
+ /* stop playback before locking playlists */
if (playback_get_playing () && playlist_num == playlist_get_playing ())
playback_stop ();
@@ -1423,6 +1427,7 @@ int playlist_shift (int playlist_num, int entry_num, int distance)
void playlist_delete_selected (int playlist_num)
{
+ /* stop playback before locking playlists */
if (playback_get_playing () && playlist_num == playlist_get_playing () &&
playlist_get_position (playlist_num) >= 0 && playlist_entry_get_selected
(playlist_num, playlist_get_position (playlist_num)))
@@ -2023,6 +2028,7 @@ static bool_t shuffle_prev (Playlist * playlist)
bool_t playlist_prev_song (int playlist_num)
{
+ /* stop playback before locking playlists */
if (playback_get_playing () && playlist_num == playlist_get_playing ())
playback_stop ();
@@ -2110,6 +2116,7 @@ static void shuffle_reset (Playlist * playlist)
bool_t playlist_next_song (int playlist_num, bool_t repeat)
{
+ /* stop playback before locking playlists */
if (playback_get_playing () && playlist_num == playlist_get_playing ())
playback_stop ();
@@ -2253,6 +2260,11 @@ int playback_entry_get_end_time (void)
void playlist_save_state (void)
{
+ /* get playback state before locking playlists */
+ resume_state = playback_get_playing () ? (playback_get_paused () ?
+ RESUME_PAUSE : RESUME_PLAY) : RESUME_STOP;
+ resume_time = playback_get_playing () ? playback_get_time () : 0;
+
ENTER;
char * path = g_strdup_printf ("%s/" STATE_FILE, get_path (AUD_PATH_USER_DIR));
@@ -2261,10 +2273,6 @@ void playlist_save_state (void)
if (! handle)
LEAVE_RET_VOID;
- resume_state = playback_get_playing () ? (playback_get_paused () ?
- RESUME_PAUSE : RESUME_PLAY) : RESUME_STOP;
- resume_time = playback_get_playing () ? playback_get_time () : 0;
-
fprintf (handle, "resume-state %d\n", resume_state);
fprintf (handle, "resume-time %d\n", resume_time);