aboutsummaryrefslogtreecommitdiff
path: root/src/pipe.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-11-02 17:01:00 +0100
committerMax Kellermann <max@duempel.org>2008-11-02 17:01:00 +0100
commitc7a374bdcbe85a794b047c638e57b9358d2d095b (patch)
tree9fa015038bc31bca343e2b09a669040ba60b949d /src/pipe.c
parentfcc11bc9d85854f9b0dab74dd0ce7f76c412f4a1 (diff)
music_pipe: add tag pointer to the music_chunk struct
Each music chunk can now carry a tag object. Decoder plugins which support it (e.g. oggvorbis) may use this to inject decoded tags into their output.
Diffstat (limited to 'src/pipe.c')
-rw-r--r--src/pipe.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/pipe.c b/src/pipe.c
index d94bac21..54d10dd4 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -19,6 +19,7 @@
#include "pipe.h"
#include "notify.h"
#include "audio_format.h"
+#include "tag.h"
#include <glib.h>
#include <assert.h>
@@ -30,12 +31,14 @@ static void
music_chunk_init(struct music_chunk *chunk)
{
chunk->length = 0;
+ chunk->tag = NULL;
}
static void
music_chunk_free(struct music_chunk *chunk)
{
- (void)chunk;
+ if (chunk->tag != NULL)
+ tag_free(chunk->tag);
}
void
@@ -263,6 +266,29 @@ size_t music_pipe_append(const void *data0, size_t datalen,
return ret;
}
+bool music_pipe_tag(const struct tag *tag)
+{
+ struct music_chunk *chunk;
+
+ chunk = music_pipe_get_chunk(music_pipe.end);
+ if (chunk->length > 0 || chunk->tag != NULL) {
+ /* this chunk is not empty; allocate a new chunk,
+ because chunk.tag refers to the beginning of the
+ chunk data */
+ unsigned next = successor(music_pipe.end);
+ if (music_pipe.begin == next)
+ /* no chunks available */
+ return false;
+
+ output_buffer_expand(next);
+ chunk = music_pipe_get_chunk(next);
+ assert(chunk->length == 0 && chunk->tag == NULL);
+ }
+
+ chunk->tag = tag_dup(tag);
+ return true;
+}
+
void music_pipe_skip(unsigned num)
{
int i = music_pipe_absolute(num);