diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/buffering.c | 4 | ||||
-rw-r--r-- | apps/codec_thread.c | 6 | ||||
-rw-r--r-- | apps/mpeg.c | 2 | ||||
-rw-r--r-- | apps/playlist.c | 37 | ||||
-rw-r--r-- | apps/playlist.h | 2 | ||||
-rw-r--r-- | apps/plugins/battery_bench.c | 2 | ||||
-rw-r--r-- | apps/plugins/mikmod/mikmod.c | 2 | ||||
-rw-r--r-- | apps/tagcache.c | 4 |
8 files changed, 33 insertions, 26 deletions
diff --git a/apps/buffering.c b/apps/buffering.c index cbc47c63e7..54c6c05baa 100644 --- a/apps/buffering.c +++ b/apps/buffering.c @@ -176,8 +176,8 @@ static void buffering_thread(void); static long buffering_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)]; static const char buffering_thread_name[] = "buffering"; static unsigned int buffering_thread_id = 0; -static struct event_queue buffering_queue; -static struct queue_sender_list buffering_queue_sender_list; +static struct event_queue buffering_queue SHAREDBSS_ATTR; +static struct queue_sender_list buffering_queue_sender_list SHAREDBSS_ATTR; diff --git a/apps/codec_thread.c b/apps/codec_thread.c index ef02f70811..03ab5622e2 100644 --- a/apps/codec_thread.c +++ b/apps/codec_thread.c @@ -81,15 +81,15 @@ extern bool automatic_skip; /* Who initiated in-progress skip? (C/A-) */ */ static bool codec_requested_stop = false; -extern struct event_queue audio_queue; -extern struct event_queue codec_queue; +extern struct event_queue audio_queue SHAREDBSS_ATTR; +extern struct event_queue codec_queue SHAREDBSS_ATTR; extern struct codec_api ci; /* from codecs.c */ /* Codec thread */ unsigned int codec_thread_id; /* For modifying thread priority later. Used by playback.c and pcmbuf.c */ -static struct queue_sender_list codec_queue_sender_list; +static struct queue_sender_list codec_queue_sender_list SHAREDBSS_ATTR; static long codec_stack[(DEFAULT_STACK_SIZE + 0x2000)/sizeof(long)] IBSS_ATTR; static const char codec_thread_name[] = "codec"; diff --git a/apps/mpeg.c b/apps/mpeg.c index bdca92048f..690e530d9b 100644 --- a/apps/mpeg.c +++ b/apps/mpeg.c @@ -150,7 +150,7 @@ static char mpeg_stack[DEFAULT_STACK_SIZE]; static struct mp3entry taginfo; #else /* !SIMULATOR */ -static struct event_queue mpeg_queue; +static struct event_queue mpeg_queue SHAREDBSS_ATTR; static long mpeg_stack[(DEFAULT_STACK_SIZE + 0x1000)/sizeof(long)]; static int audiobuflen; diff --git a/apps/playlist.c b/apps/playlist.c index 41d6ae5ed7..6f6db27b2a 100644 --- a/apps/playlist.c +++ b/apps/playlist.c @@ -192,11 +192,14 @@ static int rotate_index(const struct playlist_info* playlist, int index); #ifdef HAVE_DIRCACHE #define PLAYLIST_LOAD_POINTERS 1 -static struct event_queue playlist_queue; +static struct event_queue playlist_queue SHAREDBSS_ATTR; static long playlist_stack[(DEFAULT_STACK_SIZE + 0x800)/sizeof(long)]; static const char playlist_thread_name[] = "playlist cachectrl"; #endif +static struct mutex current_playlist_mutex SHAREDBSS_ATTR; +static struct mutex created_playlist_mutex SHAREDBSS_ATTR; + /* Check if the filename suggests M3U or M3U8 format. */ static bool is_m3u8(const char* filename) { @@ -1232,9 +1235,9 @@ static void playlist_flush_callback(void *param) { if (playlist->num_cached > 0) { - mutex_lock(&playlist->control_mutex); + mutex_lock(playlist->control_mutex); flush_cached_control(playlist); - mutex_unlock(&playlist->control_mutex); + mutex_unlock(playlist->control_mutex); } sync_control(playlist, true); } @@ -1362,7 +1365,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek, } else if (max < 0) { - mutex_lock(&playlist->control_mutex); + mutex_lock(playlist->control_mutex); if (control_file) { @@ -1396,7 +1399,7 @@ static int get_filename(struct playlist_info* playlist, int index, int seek, } } - mutex_unlock(&playlist->control_mutex); + mutex_unlock(playlist->control_mutex); if (max < 0) { @@ -1829,7 +1832,7 @@ static int update_control(struct playlist_info* playlist, struct playlist_control_cache* cache; bool flush = false; - mutex_lock(&playlist->control_mutex); + mutex_lock(playlist->control_mutex); cache = &(playlist->control_cache[playlist->num_cached++]); @@ -1861,7 +1864,7 @@ static int update_control(struct playlist_info* playlist, if (flush || playlist->num_cached == PLAYLIST_MAX_CACHE) result = flush_cached_control(playlist); - mutex_unlock(&playlist->control_mutex); + mutex_unlock(playlist->control_mutex); return result; } @@ -1881,10 +1884,10 @@ static void sync_control(struct playlist_info* playlist, bool force) { if (playlist->pending_control_sync) { - mutex_lock(&playlist->control_mutex); + mutex_lock(playlist->control_mutex); fsync(playlist->control_fd); playlist->pending_control_sync = false; - mutex_unlock(&playlist->control_mutex); + mutex_unlock(playlist->control_mutex); } } } @@ -1908,6 +1911,9 @@ void playlist_init(void) { struct playlist_info* playlist = ¤t_playlist; + mutex_init(¤t_playlist_mutex); + mutex_init(&created_playlist_mutex); + playlist->current = true; strlcpy(playlist->control_filename, PLAYLIST_CONTROL_FILE, sizeof(playlist->control_filename)); @@ -1919,7 +1925,8 @@ void playlist_init(void) playlist->buffer_size = AVERAGE_FILENAME_LENGTH * global_settings.max_files_in_dir; playlist->buffer = buffer_alloc(playlist->buffer_size); - mutex_init(&playlist->control_mutex); + playlist->control_mutex = ¤t_playlist_mutex; + empty_playlist(playlist, true); #ifdef HAVE_DIRCACHE @@ -1943,14 +1950,14 @@ void playlist_shutdown(void) if (playlist->control_fd >= 0) { - mutex_lock(&playlist->control_mutex); + mutex_lock(playlist->control_mutex); if (playlist->num_cached > 0) flush_cached_control(playlist); close(playlist->control_fd); - mutex_unlock(&playlist->control_mutex); + mutex_unlock(playlist->control_mutex); } } @@ -2705,7 +2712,7 @@ int playlist_create_ex(struct playlist_info* playlist, playlist->buffer_size = 0; playlist->buffer = NULL; - mutex_init(&playlist->control_mutex); + playlist->control_mutex = &created_playlist_mutex; } new_playlist(playlist, dir, file); @@ -3441,7 +3448,7 @@ int playlist_save(struct playlist_info* playlist, char *filename) { result = -1; - mutex_lock(&playlist->control_mutex); + mutex_lock(playlist->control_mutex); /* Replace the current playlist with the new one and update indices */ close(playlist->fd); @@ -3471,7 +3478,7 @@ int playlist_save(struct playlist_info* playlist, char *filename) } } - mutex_unlock(&playlist->control_mutex); + mutex_unlock(playlist->control_mutex); } diff --git a/apps/playlist.h b/apps/playlist.h index fb30b7ac8c..9c45769981 100644 --- a/apps/playlist.h +++ b/apps/playlist.h @@ -105,7 +105,7 @@ struct playlist_info int num_cached; /* number of cached entries */ bool pending_control_sync; /* control file needs to be synced */ - struct mutex control_mutex; /* mutex for control file access */ + struct mutex *control_mutex; /* mutex for control file access */ int last_shuffled_start; /* number of tracks when insert last shuffled command start */ }; diff --git a/apps/plugins/battery_bench.c b/apps/plugins/battery_bench.c index 044db9ff1f..6a0493ceaa 100644 --- a/apps/plugins/battery_bench.c +++ b/apps/plugins/battery_bench.c @@ -266,7 +266,7 @@ static struct batt_info #define BUF_ELEMENTS (sizeof(bat)/sizeof(struct batt_info)) static unsigned int thread_id; -static struct event_queue thread_q; +static struct event_queue thread_q SHAREDBSS_ATTR; static bool in_usb_mode; static unsigned int buf_idx; diff --git a/apps/plugins/mikmod/mikmod.c b/apps/plugins/mikmod/mikmod.c index fe1768376e..c99d11d636 100644 --- a/apps/plugins/mikmod/mikmod.c +++ b/apps/plugins/mikmod/mikmod.c @@ -31,7 +31,7 @@ #define EV_EXIT 9999 #define THREAD_STACK_SIZE DEFAULT_STACK_SIZE + 0x200 static unsigned int thread_id; -static struct event_queue thread_q; +static struct event_queue thread_q SHAREDBSS_ATTR; /* use long for aligning */ unsigned long thread_stack[THREAD_STACK_SIZE/sizeof(long)]; #endif diff --git a/apps/tagcache.c b/apps/tagcache.c index ae7199ffd6..ea7768139b 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c @@ -96,7 +96,7 @@ #ifndef __PCTOOL__ /* Tag Cache thread. */ -static struct event_queue tagcache_queue; +static struct event_queue tagcache_queue SHAREDBSS_ATTR; static long tagcache_stack[(DEFAULT_STACK_SIZE + 0x4000)/sizeof(long)]; static const char tagcache_thread_name[] = "tagcache"; #endif @@ -159,7 +159,7 @@ struct tagcache_command_entry { static struct tagcache_command_entry command_queue[TAGCACHE_COMMAND_QUEUE_LENGTH]; static volatile int command_queue_widx = 0; static volatile int command_queue_ridx = 0; -static struct mutex command_queue_mutex; +static struct mutex command_queue_mutex SHAREDBSS_ATTR; #endif /* Tag database structures. */ |