From eefc7c73e2495decdc6f242515696fe0e3f85609 Mon Sep 17 00:00:00 2001 From: Michael Sevakis Date: Sat, 8 Apr 2017 18:11:25 -0400 Subject: Fix some problems with playback crashing I'm not sure all the situations it affects, to be honest. The fix aimed to address the strange symptom here: http://forums.rockbox.org/index.php/topic,50793.0.html It turns out that ringbuf_add_cross was used when handles were butted up against one another with the first parameter equal to the last, which it interprets as being an empty case when it should be interpreted as full in the context it was used. To fix this, introduce full/empty variants of ringbuf_add_cross and ringbuf_sub and use them at the appropriate time. The other way to address the problem is ensure there's always at least a space byte between the end of one handle and the start of another but this make the code a bit trickier to reason about than using additional function variants. bufopen() may yield after creating a handle and so do some more locking so that the buffering thread doesn't mess things up by moving anything or not seeing the yet-to-be linked-in allocation. Add alignof() macro to use proper method to get alignment of struct memory_handle. That should be useful in general anyway. It's merely defined as __alignof__ but looks nicer. Change-Id: If21739eaa33a4f6c084a28ee5b3c8fceecfd87ce --- firmware/export/system.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'firmware/export/system.h') diff --git a/firmware/export/system.h b/firmware/export/system.h index 050c3074aa..62da252e80 100644 --- a/firmware/export/system.h +++ b/firmware/export/system.h @@ -135,6 +135,10 @@ int get_cpu_boost_counter(void); #define PTR_ADD(ptr, x) ((typeof(ptr))((char*)(ptr) + (x))) #define PTR_SUB(ptr, x) ((typeof(ptr))((char*)(ptr) - (x))) +#ifndef alignof +#define alignof __alignof__ +#endif + /* Get the byte offset of a type's member */ #ifndef offsetof #define offsetof(type, member) __builtin_offsetof(type, member) -- cgit v1.2.3