diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-04-12 04:08:12 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-04-12 04:08:12 +0000 |
commit | 45ebb851f4d0bd136b7c246a6a1b71561a6e5800 (patch) | |
tree | 5200c82fbe3489507fe84cbf2b11645dc4a1ad1b /src | |
parent | 9cf66d0e8a7875026d7009d5df331fabf614ac55 (diff) | |
download | mpd-45ebb851f4d0bd136b7c246a6a1b71561a6e5800.tar.gz mpd-45ebb851f4d0bd136b7c246a6a1b71561a6e5800.tar.xz mpd-45ebb851f4d0bd136b7c246a6a1b71561a6e5800.zip |
Drop metadata updates from HTTP for now (input HTTP, and shout)
It is way more complicated than it should be; and
locking it for thread-safety is too difficult.
[merged r7183 from branches/ew]
git-svn-id: https://svn.musicpd.org/mpd/trunk@7241 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/decode.c | 64 | ||||
-rw-r--r-- | src/inputPlugins/mp3_plugin.c | 4 | ||||
-rw-r--r-- | src/inputPlugins/oggvorbis_plugin.c | 2 | ||||
-rw-r--r-- | src/metadataChunk.c | 93 | ||||
-rw-r--r-- | src/metadataChunk.h | 38 | ||||
-rw-r--r-- | src/outputBuffer.c | 78 | ||||
-rw-r--r-- | src/outputBuffer.h | 11 | ||||
-rw-r--r-- | src/player.c | 33 | ||||
-rw-r--r-- | src/player.h | 7 | ||||
-rw-r--r-- | src/playerData.c | 3 |
11 files changed, 7 insertions, 328 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index fbcd953c4..7a3bacea1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -52,7 +52,6 @@ mpd_headers = \ listen.h \ log.h \ ls.h \ - metadataChunk.h \ mpd_types.h \ myfprintf.h \ normalize.h \ @@ -110,7 +109,6 @@ mpd_SOURCES = \ log.c \ ls.c \ main.c \ - metadataChunk.c \ myfprintf.c \ normalize.c \ compress.c \ diff --git a/src/decode.c b/src/decode.c index caf29849a..b1cce7fac 100644 --- a/src/decode.c +++ b/src/decode.c @@ -138,7 +138,6 @@ static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) static int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, int *decodeWaitedOn) { - MpdTag *tag = NULL; pathcpy_trunc(pc->currentUrl, pc->utf8url); while (dc->start) @@ -151,11 +150,6 @@ static int waitOnDecode(PlayerControl * pc, DecoderControl * dc, return -1; } - if ((tag = metadataChunkToMpdTagDup(&(pc->fileMetadataChunk)))) { - sendMetadataToAudioDevice(tag); - freeMpdTag(tag); - } - pc->totalTime = pc->fileTime; pc->bitRate = 0; pc->sampleRate = 0; @@ -267,8 +261,6 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb, rmp2amp_r(path_max_tmp, utf8_to_fs_charset(path_max_tmp, pc->utf8url)); - copyMpdTagToOutputBuffer(cb, NULL); - pathcpy_trunc(dc->utf8url, pc->utf8url); if (openInputStream(&inStream, path_max_tmp) < 0) { @@ -294,7 +286,6 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb, ret = DECODE_ERROR_UNKTYPE; if (isRemoteUrl(dc->utf8url)) { unsigned int next = 0; - cb->acceptMetadata = 1; /* first we try mime types: */ while (ret && (plugin = getInputPluginFromMimeType(inStream.mime, next++))) { @@ -340,7 +331,6 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb, } else { unsigned int next = 0; const char *s = getSuffix(dc->utf8url); - cb->acceptMetadata = 0; while (ret && (plugin = getInputPluginFromSuffix(s, next++))) { if (!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE) continue; @@ -408,53 +398,14 @@ void decoderInit(void) FATAL("Failed to spawn decoder task: %s\n", strerror(errno)); } -static void handleMetadata(OutputBuffer * cb, PlayerControl * pc, int *previous, - int *currentChunkSent, MetadataChunk * currentChunk) -{ - if (cb->begin != cb->end) { - int meta = cb->metaChunk[cb->begin]; - if (meta != *previous) { - DEBUG("player: metadata change\n"); - if (meta >= 0 && cb->metaChunkSet[meta]) { - DEBUG("player: new metadata from decoder!\n"); - memcpy(currentChunk, - cb->metadataChunks + meta, - sizeof(MetadataChunk)); - *currentChunkSent = 0; - cb->metaChunkSet[meta] = 0; - } - } - *previous = meta; - } - if (!(*currentChunkSent) && pc->metadataState == - PLAYER_METADATA_STATE_WRITE) { - MpdTag *tag = NULL; - - *currentChunkSent = 1; - - if ((tag = metadataChunkToMpdTagDup(currentChunk))) { - sendMetadataToAudioDevice(tag); - freeMpdTag(tag); - } - - memcpy(&(pc->metadataChunk), currentChunk, - sizeof(MetadataChunk)); - pc->metadataState = PLAYER_METADATA_STATE_READ; - kill(getppid(), SIGUSR1); - } -} - static void advanceOutputBufferTo(OutputBuffer * cb, PlayerControl * pc, - int *previous, int *currentChunkSent, - MetadataChunk * currentChunk, int to) + int *currentChunkSent, int to) { while (cb->begin != to) { - handleMetadata(cb, pc, previous, currentChunkSent, - currentChunk); - if ((unsigned)cb->begin + 1 >= buffered_chunks) { + if ((unsigned)cb->begin + 1 >= buffered_chunks) cb->begin = 0; - } - else cb->begin++; + else + cb->begin++; } } @@ -471,8 +422,6 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * int decodeWaitedOn = 0; static const char silence[CHUNK_SIZE]; double sizeToTime = 0.0; - int previousMetadataChunk = -1; - MetadataChunk currentMetadataChunk; int currentChunkSent = 1; unsigned int end; int next = -1; @@ -495,8 +444,6 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * while (!quit) { processDecodeInput(); handleDecodeStart(); - handleMetadata(cb, pc, &previousMetadataChunk, - ¤tChunkSent, ¤tMetadataChunk); if (dc->state == DECODE_STATE_STOP && pc->queueState == PLAYER_QUEUE_FULL && pc->queueLockState == PLAYER_QUEUE_UNLOCKED) { @@ -599,9 +546,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer * nextChunk -= buffered_chunks; } advanceOutputBufferTo(cb, pc, - &previousMetadataChunk, ¤tChunkSent, - ¤tMetadataChunk, nextChunk); } } @@ -651,7 +596,6 @@ void decode(void) cb = &(getPlayerData()->buffer); - clearAllMetaChunkSets(cb); cb->begin = 0; cb->end = 0; pc = &(getPlayerData()->playerControl); diff --git a/src/inputPlugins/mp3_plugin.c b/src/inputPlugins/mp3_plugin.c index 76d226b00..f6b45cd2f 100644 --- a/src/inputPlugins/mp3_plugin.c +++ b/src/inputPlugins/mp3_plugin.c @@ -893,7 +893,6 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc, data->inStream->metaTitle); free(data->inStream->metaTitle); data->inStream->metaTitle = NULL; - copyMpdTagToOutputBuffer(cb, tag); freeMpdTag(tag); } @@ -1048,21 +1047,18 @@ static int mp3_decode(OutputBuffer * cb, DecoderControl * dc, if (inStream->metaName) { addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName); } - copyMpdTagToOutputBuffer(cb, tag); freeMpdTag(tag); } else if (tag) { if (inStream->metaName) { clearItemsFromMpdTag(tag, TAG_ITEM_NAME); addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName); } - copyMpdTagToOutputBuffer(cb, tag); freeMpdTag(tag); } else if (inStream->metaName) { tag = newMpdTag(); if (inStream->metaName) { addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName); } - copyMpdTagToOutputBuffer(cb, tag); freeMpdTag(tag); } diff --git a/src/inputPlugins/oggvorbis_plugin.c b/src/inputPlugins/oggvorbis_plugin.c index 8eb075336..c79e7893c 100644 --- a/src/inputPlugins/oggvorbis_plugin.c +++ b/src/inputPlugins/oggvorbis_plugin.c @@ -213,8 +213,6 @@ static void putOggCommentsIntoOutputBuffer(OutputBuffer * cb, char *streamName, addItemToMpdTag(tag, TAG_ITEM_NAME, streamName); } - copyMpdTagToOutputBuffer(cb, tag); - freeMpdTag(tag); } diff --git a/src/metadataChunk.c b/src/metadataChunk.c index 4adfa29c0..e69de29bb 100644 --- a/src/metadataChunk.c +++ b/src/metadataChunk.c @@ -1,93 +0,0 @@ -/* the Music Player Daemon (MPD) - * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com) - * This project's homepage is: http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#include "metadataChunk.h" -#include "gcc.h" -#include "os_compat.h" - -static void initMetadataChunk(MetadataChunk * chunk) -{ - chunk->name = -1; - chunk->artist = -1; - chunk->album = -1; - chunk->title = -1; -} - -#define dupElementToTag(item, element) { \ - if(element >= 0 && element < METADATA_BUFFER_LENGTH) { \ - addItemToMpdTag(ret, item, chunk->buffer+element); \ - } \ -} - -MpdTag *metadataChunkToMpdTagDup(MetadataChunk * chunk) -{ - MpdTag *ret = newMpdTag(); - - chunk->buffer[METADATA_BUFFER_LENGTH - 1] = '\0'; - - dupElementToTag(TAG_ITEM_NAME, chunk->name); - dupElementToTag(TAG_ITEM_TITLE, chunk->title); - dupElementToTag(TAG_ITEM_ARTIST, chunk->artist); - dupElementToTag(TAG_ITEM_ALBUM, chunk->album); - - return ret; -} - -#define copyStringToChunk(string, element) { \ - if(element < 0 && string && (slen = strlen(string)) && \ - pos < METADATA_BUFFER_LENGTH-1) \ - { \ - size_t len = slen; \ - size_t max = METADATA_BUFFER_LENGTH - 1 - pos; \ - if (mpd_unlikely(len > max)) \ - len = max; \ - memcpy(chunk->buffer+pos, string, len); \ - *(chunk->buffer+pos+len) = '\0'; \ - element = pos; \ - pos += slen+1; \ - } \ -} - -void copyMpdTagToMetadataChunk(MpdTag * tag, MetadataChunk * chunk) -{ - int pos = 0; - int slen; - int i; - - initMetadataChunk(chunk); - - if (!tag) - return; - - for (i = 0; i < tag->numOfItems; i++) { - switch (tag->items[i].type) { - case TAG_ITEM_NAME: - copyStringToChunk(tag->items[i].value, chunk->name); - break; - case TAG_ITEM_TITLE: - copyStringToChunk(tag->items[i].value, chunk->title); - break; - case TAG_ITEM_ARTIST: - copyStringToChunk(tag->items[i].value, chunk->artist); - break; - case TAG_ITEM_ALBUM: - copyStringToChunk(tag->items[i].value, chunk->album); - break; - } - } -} diff --git a/src/metadataChunk.h b/src/metadataChunk.h index c1da8b320..e69de29bb 100644 --- a/src/metadataChunk.h +++ b/src/metadataChunk.h @@ -1,38 +0,0 @@ -/* the Music Player Daemon (MPD) - * Copyright (C) 2003-2007 by Warren Dukes (warren.dukes@gmail.com) - * This project's homepage is: http://www.musicpd.org - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifndef METADATA_CHUNK_H -#define METADATA_CHUNK_H - -#define METADATA_BUFFER_LENGTH 1024 - -#include "tag.h" - -typedef struct _MetadataChunk { - int name; - int title; - int artist; - int album; - char buffer[METADATA_BUFFER_LENGTH]; -} MetadataChunk; - -MpdTag *metadataChunkToMpdTagDup(MetadataChunk * chunk); - -void copyMpdTagToMetadataChunk(MpdTag * tag, MetadataChunk * chunk); - -#endif diff --git a/src/outputBuffer.c b/src/outputBuffer.c index 7a47a44e7..a42e2f121 100644 --- a/src/outputBuffer.c +++ b/src/outputBuffer.c @@ -27,8 +27,6 @@ #include "os_compat.h" static mpd_sint16 currentChunk = -1; -static mpd_sint8 currentMetaChunk = -1; -static mpd_sint8 sendMetaChunk; void initOutputBuffer(OutputBuffer * cb, char *chunks) { @@ -38,35 +36,14 @@ void initOutputBuffer(OutputBuffer * cb, char *chunks) buffered_chunks * CHUNK_SIZE); cb->bitRate = (mpd_uint16 *) (((char *)cb->chunkSize) + buffered_chunks * sizeof(mpd_sint16)); - cb->metaChunk = (mpd_sint8 *) (((char *)cb->bitRate) + - buffered_chunks * - sizeof(mpd_sint16)); - cb->times = - (float *)(((char *)cb->metaChunk) + - buffered_chunks * sizeof(mpd_sint8)); - cb->acceptMetadata = 0; -} - -void clearAllMetaChunkSets(OutputBuffer * cb) -{ - memset(cb->metaChunkSet, 0, BUFFERED_METACHUNKS); + cb->times = (float *)(((char *)cb->bitRate) + + buffered_chunks * sizeof(mpd_sint8)); } void clearOutputBuffer(OutputBuffer * cb) { int currentSet = 1; - cb->end = cb->begin; - - /* be sure to reset metaChunkSets cause we are skipping over audio - * audio chunks, and thus skipping over metadata */ - if (currentChunk >= 0 && sendMetaChunk == 0 && currentMetaChunk >= 0) { - currentSet = cb->metaChunkSet[currentChunk]; - } - clearAllMetaChunkSets(cb); - if (currentChunk >= 0 && sendMetaChunk == 0 && currentMetaChunk >= 0) { - cb->metaChunkSet[currentChunk] = currentSet; - } currentChunk = -1; } @@ -140,11 +117,6 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream, currentChunk = cb->end; cb->chunkSize[currentChunk] = 0; - - if (sendMetaChunk) { - cb->metaChunk[currentChunk] = currentMetaChunk; - } else - cb->metaChunk[currentChunk] = -1; cb->bitRate[currentChunk] = bitRate; cb->times[currentChunk] = data_time; } @@ -167,49 +139,3 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream, return 0; } -int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag) -{ - int nextChunk; - static MpdTag *last; - - if (!cb->acceptMetadata || !tag) { - sendMetaChunk = 0; - if (last) - freeMpdTag(last); - last = NULL; - DEBUG("copyMpdTagToOB: !acceptMetadata || !tag\n"); - return 0; - } - - if (last && mpdTagsAreEqual(last, tag)) { - DEBUG("copyMpdTagToOB: same as last\n"); - return 0; - } - - if (last) - freeMpdTag(last); - last = NULL; - - nextChunk = currentMetaChunk + 1; - if (nextChunk >= BUFFERED_METACHUNKS) - nextChunk = 0; - - if (cb->metaChunkSet[nextChunk]) { - sendMetaChunk = 0; - DEBUG("copyMpdTagToOB: metachunk in use!\n"); - return -1; - } - - sendMetaChunk = 1; - currentMetaChunk = nextChunk; - - last = mpdTagDup(tag); - - copyMpdTagToMetadataChunk(tag, &(cb->metadataChunks[currentMetaChunk])); - - cb->metaChunkSet[nextChunk] = 1; - - DEBUG("copyMpdTagToOB: copiedTag\n"); - - return 0; -} diff --git a/src/outputBuffer.h b/src/outputBuffer.h index 563c1904b..6ab171879 100644 --- a/src/outputBuffer.h +++ b/src/outputBuffer.h @@ -24,14 +24,11 @@ #include "decode.h" #include "audio.h" #include "inputStream.h" -#include "metadataChunk.h" #include "replayGain.h" #define OUTPUT_BUFFER_DC_STOP -1 #define OUTPUT_BUFFER_DC_SEEK -2 -#define BUFFERED_METACHUNKS 25 - typedef struct _OutputBuffer { char *volatile chunks; mpd_uint16 *volatile chunkSize; @@ -41,10 +38,6 @@ typedef struct _OutputBuffer { mpd_uint16 volatile end; AudioFormat audioFormat; ConvState convState; - MetadataChunk metadataChunks[BUFFERED_METACHUNKS]; - mpd_sint8 metaChunkSet[BUFFERED_METACHUNKS]; - mpd_sint8 *volatile metaChunk; - volatile mpd_sint8 acceptMetadata; } OutputBuffer; void initOutputBuffer(OutputBuffer * cb, char *chunks); @@ -64,8 +57,4 @@ int sendDataToOutputBuffer(OutputBuffer * cb, float time, mpd_uint16 bitRate, ReplayGainInfo * replayGainInfo); -int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag); - -void clearAllMetaChunkSets(OutputBuffer * cb); - #endif diff --git a/src/player.c b/src/player.c index 4071b5a57..109cbe936 100644 --- a/src/player.c +++ b/src/player.c @@ -95,15 +95,6 @@ static void * player_task(mpd_unused void *unused) return NULL; } -static void resetPlayerMetadata(void) -{ - PlayerControl *pc = &(getPlayerData()->playerControl); - - if (pc->metadataState == PLAYER_METADATA_STATE_READ) { - pc->metadataState = PLAYER_METADATA_STATE_WRITE; - } -} - void playerInit(void) { pthread_attr_t attr; @@ -130,7 +121,6 @@ static void set_current_song(Song *song) PlayerControl *pc = &(getPlayerData()->playerControl); pc->fileTime = song->tag ? song->tag->time : 0; - copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk)); get_song_url(pc->utf8url, song); } @@ -143,7 +133,6 @@ int playerPlay(int fd, Song * song) set_current_song(song); - resetPlayerMetadata(); pc->play = 1; /* FIXME: _nb() variant is probably wrong here, and everywhere... */ do { wakeup_player_nb(); } while (pc->play); @@ -346,7 +335,6 @@ int playerSeek(int fd, Song * song, float seek_time) set_current_song(song); if (pc->error == PLAYER_ERROR_NOERROR) { - resetPlayerMetadata(); pc->seekWhere = seek_time; pc->seek = 1; /* FIXME: _nb() is probably wrong here, too */ @@ -415,24 +403,5 @@ int getPlayerChannels(void) /* this actually creates a dupe of the current metadata */ Song *playerCurrentDecodeSong(void) { - static Song *song; - static MetadataChunk *prev; - Song *ret = NULL; - PlayerControl *pc = &(getPlayerData()->playerControl); - - if (pc->metadataState == PLAYER_METADATA_STATE_READ) { - if (prev) - free(prev); - prev = xmalloc(sizeof(MetadataChunk)); - memcpy(prev, &(pc->metadataChunk), sizeof(MetadataChunk)); - if (song) - freeJustSong(song); - song = newNullSong(); - song->url = xstrdup(pc->currentUrl); - song->tag = metadataChunkToMpdTagDup(prev); - ret = song; - resetPlayerMetadata(); - } - - return ret; + return NULL; } diff --git a/src/player.h b/src/player.h index 71b0e9094..605a25a80 100644 --- a/src/player.h +++ b/src/player.h @@ -24,7 +24,6 @@ #include "decode.h" #include "mpd_types.h" #include "song.h" -#include "metadataChunk.h" #include "os_compat.h" #define PLAYER_STATE_STOP 0 @@ -51,9 +50,6 @@ #define PLAYER_QUEUE_UNLOCKED 0 #define PLAYER_QUEUE_LOCKED 1 -#define PLAYER_METADATA_STATE_READ 1 -#define PLAYER_METADATA_STATE_WRITE 2 - typedef struct _PlayerControl { volatile mpd_sint8 stop; volatile mpd_sint8 play; @@ -80,9 +76,6 @@ typedef struct _PlayerControl { volatile float crossFade; volatile mpd_uint16 softwareVolume; volatile double totalPlayTime; - volatile mpd_sint8 metadataState; - MetadataChunk metadataChunk; - MetadataChunk fileMetadataChunk; } PlayerControl; void wakeup_main_task(void); diff --git a/src/playerData.c b/src/playerData.c index 31a3bbd94..43852a4c6 100644 --- a/src/playerData.c +++ b/src/playerData.c @@ -78,7 +78,6 @@ void initPlayerData(void) allocationSize += buffered_chunks * sizeof(float); /*for times */ allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for chunkSize */ allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for bitRate */ - allocationSize += buffered_chunks * sizeof(mpd_sint8); /*for metaChunk */ allocationSize += sizeof(PlayerData); /*for playerData struct */ /* for audioDeviceStates[] */ @@ -114,8 +113,6 @@ void initPlayerData(void) playerData_pd->playerControl.crossFade = crossfade; playerData_pd->playerControl.softwareVolume = 1000; playerData_pd->playerControl.totalPlayTime = 0; - playerData_pd->playerControl.metadataState = - PLAYER_METADATA_STATE_WRITE; playerData_pd->decoderControl.stop = 0; playerData_pd->decoderControl.start = 0; |