diff options
author | Max Kellermann <max@duempel.org> | 2008-11-02 16:56:09 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-11-02 16:56:09 +0100 |
commit | e9e9d2bc2d9a144a09eb9954dd7857381e77a78a (patch) | |
tree | 1f31154bd41e939917a05e48e1a4c664f678bc65 | |
parent | d430b1dc542c4a8954eaaaf1c165c40216e32f26 (diff) | |
download | mpd-e9e9d2bc2d9a144a09eb9954dd7857381e77a78a.tar.gz mpd-e9e9d2bc2d9a144a09eb9954dd7857381e77a78a.tar.xz mpd-e9e9d2bc2d9a144a09eb9954dd7857381e77a78a.zip |
music_pipe: renamed "ob" to "music_pipe"
Last music_pipe rename patch: renamed the global variable (singleton).
Diffstat (limited to '')
-rw-r--r-- | src/pipe.c | 86 | ||||
-rw-r--r-- | src/pipe.h | 12 |
2 files changed, 49 insertions, 49 deletions
diff --git a/src/pipe.c b/src/pipe.c index 17b018ff1..f1853dbac 100644 --- a/src/pipe.c +++ b/src/pipe.c @@ -24,41 +24,41 @@ #include <assert.h> #include <string.h> -struct music_pipe ob; +struct music_pipe music_pipe; void music_pipe_init(unsigned int size, struct notify *notify) { assert(size > 0); - ob.chunks = g_new(struct music_chunk, size); - ob.size = size; - ob.begin = 0; - ob.end = 0; - ob.lazy = false; - ob.notify = notify; - ob.chunks[0].chunkSize = 0; + music_pipe.chunks = g_new(struct music_chunk, size); + music_pipe.size = size; + music_pipe.begin = 0; + music_pipe.end = 0; + music_pipe.lazy = false; + music_pipe.notify = notify; + music_pipe.chunks[0].chunkSize = 0; } void music_pipe_free(void) { - assert(ob.chunks != NULL); - g_free(ob.chunks); + assert(music_pipe.chunks != NULL); + g_free(music_pipe.chunks); } void music_pipe_clear(void) { - ob.end = ob.begin; - ob.chunks[ob.end].chunkSize = 0; + music_pipe.end = music_pipe.begin; + music_pipe.chunks[music_pipe.end].chunkSize = 0; } /** return the index of the chunk after i */ static inline unsigned successor(unsigned i) { - assert(i <= ob.size); + assert(i <= music_pipe.size); ++i; - return i == ob.size ? 0 : i; + return i == music_pipe.size ? 0 : i; } /** @@ -67,27 +67,27 @@ static inline unsigned successor(unsigned i) */ static void output_buffer_expand(unsigned i) { - int was_empty = ob.notify != NULL && (!ob.lazy || music_pipe_is_empty()); + int was_empty = music_pipe.notify != NULL && (!music_pipe.lazy || music_pipe_is_empty()); - assert(i == (ob.end + 1) % ob.size); - assert(i != ob.end); + assert(i == (music_pipe.end + 1) % music_pipe.size); + assert(i != music_pipe.end); - ob.end = i; - ob.chunks[i].chunkSize = 0; + music_pipe.end = i; + music_pipe.chunks[i].chunkSize = 0; if (was_empty) /* if the buffer was empty, the player thread might be waiting for us; wake it up now that another decoded buffer has become available. */ - notify_signal(ob.notify); + notify_signal(music_pipe.notify); } void music_pipe_flush(void) { - struct music_chunk *chunk = music_pipe_get_chunk(ob.end); + struct music_chunk *chunk = music_pipe_get_chunk(music_pipe.end); if (chunk->chunkSize > 0) { - unsigned int next = successor(ob.end); - if (next == ob.begin) + unsigned int next = successor(music_pipe.end); + if (next == music_pipe.begin) /* all buffers are full; we have to wait for the player to free one, so don't flush right now */ @@ -99,43 +99,43 @@ void music_pipe_flush(void) void music_pipe_set_lazy(bool lazy) { - ob.lazy = lazy; + music_pipe.lazy = lazy; } void music_pipe_shift(void) { - assert(ob.begin != ob.end); - assert(ob.begin < ob.size); + assert(music_pipe.begin != music_pipe.end); + assert(music_pipe.begin < music_pipe.size); - ob.begin = successor(ob.begin); + music_pipe.begin = successor(music_pipe.begin); } unsigned int music_pipe_relative(const unsigned i) { - if (i >= ob.begin) - return i - ob.begin; + if (i >= music_pipe.begin) + return i - music_pipe.begin; else - return i + ob.size - ob.begin; + return i + music_pipe.size - music_pipe.begin; } unsigned music_pipe_available(void) { - return music_pipe_relative(ob.end); + return music_pipe_relative(music_pipe.end); } int music_pipe_absolute(const unsigned relative) { unsigned i, max; - max = ob.end; - if (max < ob.begin) - max += ob.size; - i = (unsigned)ob.begin + relative; + max = music_pipe.end; + if (max < music_pipe.begin) + max += music_pipe.size; + i = (unsigned)music_pipe.begin + relative; if (i >= max) return -1; - if (i >= ob.size) - i -= ob.size; + if (i >= music_pipe.size) + i -= music_pipe.size; return (int)i; } @@ -143,9 +143,9 @@ int music_pipe_absolute(const unsigned relative) struct music_chunk * music_pipe_get_chunk(const unsigned i) { - assert(i < ob.size); + assert(i < music_pipe.size); - return &ob.chunks[i]; + return &music_pipe.chunks[i]; } /** @@ -160,12 +160,12 @@ tail_chunk(float data_time, uint16_t bitRate, size_t frame_size) unsigned int next; struct music_chunk *chunk; - chunk = music_pipe_get_chunk(ob.end); + chunk = music_pipe_get_chunk(music_pipe.end); assert(chunk->chunkSize <= sizeof(chunk->data)); if (chunk->chunkSize + frame_size > sizeof(chunk->data)) { /* this chunk is full; allocate a new chunk */ - next = successor(ob.end); - if (ob.begin == next) + next = successor(music_pipe.end); + if (music_pipe.begin == next) /* no chunks available */ return NULL; @@ -227,5 +227,5 @@ void music_pipe_skip(unsigned num) { int i = music_pipe_absolute(num); if (i >= 0) - ob.begin = i; + music_pipe.begin = i; } diff --git a/src/pipe.h b/src/pipe.h index 3af0bbd16..ae5fa64d5 100644 --- a/src/pipe.h +++ b/src/pipe.h @@ -57,7 +57,7 @@ struct music_pipe { struct notify *notify; }; -extern struct music_pipe ob; +extern struct music_pipe music_pipe; void music_pipe_init(unsigned int size, struct notify *notify); @@ -79,25 +79,25 @@ void music_pipe_set_lazy(bool lazy); static inline unsigned music_pipe_size(void) { - return ob.size; + return music_pipe.size; } /** is the buffer empty? */ static inline bool music_pipe_is_empty(void) { - return ob.begin == ob.end; + return music_pipe.begin == music_pipe.end; } static inline bool music_pipe_head_is(unsigned i) { - return !music_pipe_is_empty() && ob.begin == i; + return !music_pipe_is_empty() && music_pipe.begin == i; } static inline unsigned music_pipe_tail_index(void) { - return ob.end; + return music_pipe.end; } void music_pipe_shift(void); @@ -126,7 +126,7 @@ music_pipe_peek(void) if (music_pipe_is_empty()) return NULL; - return music_pipe_get_chunk(ob.begin); + return music_pipe_get_chunk(music_pipe.begin); } /** |