aboutsummaryrefslogtreecommitdiffstats
path: root/src/pipe.h
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-02 16:55:53 +0100
committerMax Kellermann <max@duempel.org>2008-11-02 16:55:53 +0100
commitd430b1dc542c4a8954eaaaf1c165c40216e32f26 (patch)
treec2621ae49ba14d2ff7dbaa4af0adb182da30a7c2 /src/pipe.h
parent260a0cc33c335a96a6326c6fe24435f55f59b44e (diff)
downloadmpd-d430b1dc542c4a8954eaaaf1c165c40216e32f26.tar.gz
mpd-d430b1dc542c4a8954eaaaf1c165c40216e32f26.tar.xz
mpd-d430b1dc542c4a8954eaaaf1c165c40216e32f26.zip
music_pipe: more wrapper functions
Replace all direct music_pipe struct accesses with wrapper functions. The compiled machine code is the same, but this way, we can change struct internals more easily.
Diffstat (limited to '')
-rw-r--r--src/pipe.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/pipe.h b/src/pipe.h
index 10a3501ec..3af0bbd16 100644
--- a/src/pipe.h
+++ b/src/pipe.h
@@ -76,12 +76,30 @@ void music_pipe_flush(void);
*/
void music_pipe_set_lazy(bool lazy);
+static inline unsigned
+music_pipe_size(void)
+{
+ return ob.size;
+}
+
/** is the buffer empty? */
static inline bool music_pipe_is_empty(void)
{
return ob.begin == ob.end;
}
+static inline bool
+music_pipe_head_is(unsigned i)
+{
+ return !music_pipe_is_empty() && ob.begin == i;
+}
+
+static inline unsigned
+music_pipe_tail_index(void)
+{
+ return ob.end;
+}
+
void music_pipe_shift(void);
/**
@@ -102,6 +120,15 @@ int music_pipe_absolute(const unsigned relative);
struct music_chunk *
music_pipe_get_chunk(const unsigned i);
+static inline struct music_chunk *
+music_pipe_peek(void)
+{
+ if (music_pipe_is_empty())
+ return NULL;
+
+ return music_pipe_get_chunk(ob.begin);
+}
+
/**
* Append a data block to the buffer.
*