diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-03 03:11:58 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-03 03:14:17 -0700 |
commit | 3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e (patch) | |
tree | 49dd735d55dd8d5964c4273998a2f3fc454534bb /src/metadata_pipe.c | |
parent | 86d4a80b0069b2be368bfe4af164be5ff72a48b4 (diff) | |
parent | cdc9bb460e9536577d2747d51c76306a91b3d064 (diff) | |
download | mpd-3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e.tar.gz mpd-3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e.tar.xz mpd-3f29cbaf360c5e9542c7b9e6648626d6e0ea8b1e.zip |
Merge branch 'mk/tag'
* mk/tag: (22 commits)
tag: fix segfault on update
utf8.h: Fix build (broken os_compat.h #include)
tag: optimize tag_dup(), copy item references
tag: fix the shout and oggflac plugins
const pointers
tag: static directory name
tag: try not to reallocate tag.items in every add() call
song: don't export newNullSong()
tag: try not to duplicate the input string
tag: pass length to fix_utf8()
added "length" parameter to validUtf8String()
assert value!=NULL in fix_utf8()
tag: converted macro fixUtf8() to an inline function
tag: added a pool for tag items
tag: converted tag_item.value to a char array
removed tree.c
tag: converted MpdTag.items to a pointer list
tag: moved code to tag_id3.c
wavpack: tag_new() cannot fail
tag: converted tag_add_item() to an inline function
...
Diffstat (limited to 'src/metadata_pipe.c')
-rw-r--r-- | src/metadata_pipe.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/src/metadata_pipe.c b/src/metadata_pipe.c index d5bef630e..d968dee27 100644 --- a/src/metadata_pipe.c +++ b/src/metadata_pipe.c @@ -30,7 +30,7 @@ static struct ringbuf *mp; struct tag_container { float metadata_time; mpd_uint8 seq; /* ob.seq_decoder at time of metadata_pipe_send() */ - MpdTag *tag; /* our payload */ + struct mpd_tag *tag; /* our payload */ }; /* @@ -39,13 +39,13 @@ struct tag_container { * done from one thread, so it will never block or clobber. */ static pthread_mutex_t read_lock = PTHREAD_MUTEX_INITIALIZER; -static MpdTag *current_tag; /* requires read_lock for both r/w access */ +static struct mpd_tag *current_tag; /* requires read_lock for both r/w access */ static void metadata_pipe_finish(void) { ringbuf_free(mp); if (current_tag) - freeMpdTag(current_tag); + tag_free(current_tag); } void init_metadata_pipe(void) @@ -54,7 +54,7 @@ void init_metadata_pipe(void) atexit(metadata_pipe_finish); } -void metadata_pipe_send(MpdTag *tag, float metadata_time) +void metadata_pipe_send(struct mpd_tag *tag, float metadata_time) { struct tag_container tc; size_t written; @@ -64,7 +64,7 @@ void metadata_pipe_send(MpdTag *tag, float metadata_time) if (mpd_unlikely(ringbuf_write_space(mp) < sizeof(struct tag_container))) { DEBUG("metadata_pipe: insufficient buffer space, dropping\n"); - freeMpdTag(tag); + tag_free(tag); return; } @@ -75,14 +75,14 @@ void metadata_pipe_send(MpdTag *tag, float metadata_time) assert(written == sizeof(struct tag_container)); } -MpdTag * metadata_pipe_recv(void) +struct mpd_tag * metadata_pipe_recv(void) { struct tag_container tc; size_t r; static const size_t mpd_uint8_max = 255; /* XXX CLEANUP */ mpd_uint8 expect_seq = ob_get_player_sequence(); unsigned long current_time = ob_get_elapsed_time(); - MpdTag *tag = NULL; + struct mpd_tag *tag = NULL; if (pthread_mutex_trylock(&read_lock) == EBUSY) return NULL; @@ -95,20 +95,20 @@ retry: if (expect_seq == tc.seq) { if (current_time < tc.metadata_time) goto out; /* not ready for tag yet */ - if (mpdTagsAreEqual(tc.tag, current_tag)) { - freeMpdTag(tc.tag); + if (tag_equal(tc.tag, current_tag)) { + tag_free(tc.tag); ringbuf_read_advance(mp, sizeof(struct tag_container)); goto out; /* nothing changed, don't bother */ } - tag = mpdTagDup(tc.tag); + tag = tag_dup(tc.tag); if (current_tag) - freeMpdTag(current_tag); + tag_free(current_tag); current_tag = tc.tag; ringbuf_read_advance(mp, sizeof(struct tag_container)); } else if (expect_seq > tc.seq || (!expect_seq && tc.seq == mpd_uint8_max)) { DEBUG("metadata_pipe: reader is ahead of writer\n"); - freeMpdTag(tc.tag); + tag_free(tc.tag); ringbuf_read_advance(mp, sizeof(struct tag_container)); goto retry; /* read and skip packets */ } else { @@ -120,14 +120,14 @@ out: return tag; } -MpdTag *metadata_pipe_current(void) +struct mpd_tag *metadata_pipe_current(void) { - MpdTag *tag; + struct mpd_tag *tag; assert(! pthread_equal(pthread_self(), dc.thread)); if (pthread_mutex_trylock(&read_lock) == EBUSY) return NULL; - tag = current_tag ? mpdTagDup(current_tag) : NULL; + tag = current_tag ? tag_dup(current_tag) : NULL; pthread_mutex_unlock(&read_lock); return tag; @@ -142,11 +142,11 @@ void metadata_pipe_clear(void) while ((r = ringbuf_read(mp, &tc, sizeof(struct tag_container)))) { assert(r == sizeof(struct tag_container)); - freeMpdTag(tc.tag); + tag_free(tc.tag); } if (current_tag) { - freeMpdTag(current_tag); + tag_free(current_tag); current_tag = NULL; } |