From bff03a181f8c4102a75144f818ea15ea53165170 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Thu, 23 May 2013 21:23:32 +0200 Subject: core: add a spsc ringbuffer implementation Currently every single AO was implementing it's own ringbuffer, many times with slightly different semantics. This is an attempt to fix the problem. I stole some good ideas from ao_portaudio's ringbuffer and went from there. The main difference is this one stores wpos and rpos which are absolute positions in an "infinite" buffer. To find the actual position for writing / reading just apply modulo size. The producer only modifies wpos while the consumer only modifies rpos. This makes it pretty easy to reason about and make the operations thread safe by using barriers (thread safety is guaranteed only in the Single-Producer/Single- Consumer case). Also adapted ao_coreaudio to use this ringbuffer. --- audio/format.h | 1 + 1 file changed, 1 insertion(+) (limited to 'audio/format.h') diff --git a/audio/format.h b/audio/format.h index 30a4aa1cea..bbc7f0fa69 100644 --- a/audio/format.h +++ b/audio/format.h @@ -132,6 +132,7 @@ extern const struct af_fmt_entry af_fmtstr_table[]; int af_str2fmt_short(bstr str); int af_fmt2bits(int format); char* af_fmt2str(int format, char* str, int size); +int af_fmt_seconds_to_bytes(int format, float seconds, int channels); const char* af_fmt2str_short(int format); #endif /* MPLAYER_AF_FORMAT_H */ -- cgit v1.2.3