summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan MacDonald <amachronic@protonmail.com>2023-01-21 21:05:02 +0000
committerAidan MacDonald <amachronic@protonmail.com>2023-01-23 12:24:12 +0000
commitce52d0c870f715ee979a1bf5e51857c200543d9d (patch)
treefe09ebde934dc6072a2b6cfb0a35141f59d4839f
parent2a40d420120c051b9ee79a0086059b5f2059a013 (diff)
downloadrockbox-ce52d0c870f715ee979a1bf5e51857c200543d9d.tar.gz
rockbox-ce52d0c870f715ee979a1bf5e51857c200543d9d.zip
playlist: Fix mutex initialization
This is a one-time thing; make sure it doesn't happen more than once. Change-Id: Ic42f48e5714dff2906c252ecd091989d2d6e5a86
-rw-r--r--apps/playlist.c12
-rw-r--r--apps/playlist_viewer.c9
2 files changed, 12 insertions, 9 deletions
diff --git a/apps/playlist.c b/apps/playlist.c
index 48933664a0..7b7b91c22f 100644
--- a/apps/playlist.c
+++ b/apps/playlist.c
@@ -592,13 +592,6 @@ static void empty_playlist_unlocked(struct playlist_info* playlist, bool resume)
592 } 592 }
593} 593}
594 594
595/* initializes the mutex for a new playlist and sets it as empty */
596static void initalize_new_playlist(struct playlist_info* playlist, bool resume)
597{
598 mutex_init(&(playlist->mutex));
599 empty_playlist_unlocked(playlist, resume);
600}
601
602/* 595/*
603 * Returns absolute path of track 596 * Returns absolute path of track
604 * 597 *
@@ -668,7 +661,7 @@ static void new_playlist_unlocked(struct playlist_info* playlist,
668 const char *fileused = file; 661 const char *fileused = file;
669 const char *dirused = dir; 662 const char *dirused = dir;
670 663
671 initalize_new_playlist(playlist, false); 664 empty_playlist_unlocked(playlist, false);
672 665
673 if (!fileused) 666 if (!fileused)
674 { 667 {
@@ -2079,6 +2072,7 @@ void playlist_init(void)
2079{ 2072{
2080 int handle; 2073 int handle;
2081 struct playlist_info* playlist = &current_playlist; 2074 struct playlist_info* playlist = &current_playlist;
2075 mutex_init(&playlist->mutex);
2082 2076
2083 strmemccpy(playlist->control_filename, PLAYLIST_CONTROL_FILE, 2077 strmemccpy(playlist->control_filename, PLAYLIST_CONTROL_FILE,
2084 sizeof(playlist->control_filename)); 2078 sizeof(playlist->control_filename));
@@ -2089,7 +2083,7 @@ void playlist_init(void)
2089 handle = core_alloc_ex(playlist->max_playlist_size * sizeof(*playlist->indices), &ops); 2083 handle = core_alloc_ex(playlist->max_playlist_size * sizeof(*playlist->indices), &ops);
2090 playlist->indices = core_get_data(handle); 2084 playlist->indices = core_get_data(handle);
2091 2085
2092 initalize_new_playlist(playlist, true); 2086 empty_playlist_unlocked(playlist, true);
2093 2087
2094#ifdef HAVE_DIRCACHE 2088#ifdef HAVE_DIRCACHE
2095 playlist->dcfrefs_handle = core_alloc( 2089 playlist->dcfrefs_handle = core_alloc(
diff --git a/apps/playlist_viewer.c b/apps/playlist_viewer.c
index 4e3d8bade2..4328a6de1d 100644
--- a/apps/playlist_viewer.c
+++ b/apps/playlist_viewer.c
@@ -119,6 +119,7 @@ static struct playlist_viewer viewer;
119 119
120/* Used when viewing playlists on disk */ 120/* Used when viewing playlists on disk */
121static struct playlist_info temp_playlist; 121static struct playlist_info temp_playlist;
122static bool temp_playlist_init = false;
122 123
123static bool dirty = false; 124static bool dirty = false;
124 125
@@ -365,6 +366,14 @@ static bool playlist_viewer_init(struct playlist_viewer * viewer,
365 char *index_buffer = NULL; 366 char *index_buffer = NULL;
366 ssize_t index_buffer_size = 0; 367 ssize_t index_buffer_size = 0;
367 368
369 /* Initialize temp playlist
370 * TODO - move this to playlist.c */
371 if (!temp_playlist_init)
372 {
373 mutex_init(&temp_playlist.mutex);
374 temp_playlist_init = true;
375 }
376
368 viewer->playlist = &temp_playlist; 377 viewer->playlist = &temp_playlist;
369 378
370 /* Separate directory from filename */ 379 /* Separate directory from filename */