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
This commit is contained in:
parent
9cf66d0e8a
commit
45ebb851f4
@ -52,7 +52,6 @@ mpd_headers = \
|
|||||||
listen.h \
|
listen.h \
|
||||||
log.h \
|
log.h \
|
||||||
ls.h \
|
ls.h \
|
||||||
metadataChunk.h \
|
|
||||||
mpd_types.h \
|
mpd_types.h \
|
||||||
myfprintf.h \
|
myfprintf.h \
|
||||||
normalize.h \
|
normalize.h \
|
||||||
@ -110,7 +109,6 @@ mpd_SOURCES = \
|
|||||||
log.c \
|
log.c \
|
||||||
ls.c \
|
ls.c \
|
||||||
main.c \
|
main.c \
|
||||||
metadataChunk.c \
|
|
||||||
myfprintf.c \
|
myfprintf.c \
|
||||||
normalize.c \
|
normalize.c \
|
||||||
compress.c \
|
compress.c \
|
||||||
|
64
src/decode.c
64
src/decode.c
@ -138,7 +138,6 @@ static int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af)
|
|||||||
static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
|
static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
|
||||||
OutputBuffer * cb, int *decodeWaitedOn)
|
OutputBuffer * cb, int *decodeWaitedOn)
|
||||||
{
|
{
|
||||||
MpdTag *tag = NULL;
|
|
||||||
pathcpy_trunc(pc->currentUrl, pc->utf8url);
|
pathcpy_trunc(pc->currentUrl, pc->utf8url);
|
||||||
|
|
||||||
while (dc->start)
|
while (dc->start)
|
||||||
@ -151,11 +150,6 @@ static int waitOnDecode(PlayerControl * pc, DecoderControl * dc,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((tag = metadataChunkToMpdTagDup(&(pc->fileMetadataChunk)))) {
|
|
||||||
sendMetadataToAudioDevice(tag);
|
|
||||||
freeMpdTag(tag);
|
|
||||||
}
|
|
||||||
|
|
||||||
pc->totalTime = pc->fileTime;
|
pc->totalTime = pc->fileTime;
|
||||||
pc->bitRate = 0;
|
pc->bitRate = 0;
|
||||||
pc->sampleRate = 0;
|
pc->sampleRate = 0;
|
||||||
@ -267,8 +261,6 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
|
|||||||
rmp2amp_r(path_max_tmp,
|
rmp2amp_r(path_max_tmp,
|
||||||
utf8_to_fs_charset(path_max_tmp, pc->utf8url));
|
utf8_to_fs_charset(path_max_tmp, pc->utf8url));
|
||||||
|
|
||||||
copyMpdTagToOutputBuffer(cb, NULL);
|
|
||||||
|
|
||||||
pathcpy_trunc(dc->utf8url, pc->utf8url);
|
pathcpy_trunc(dc->utf8url, pc->utf8url);
|
||||||
|
|
||||||
if (openInputStream(&inStream, path_max_tmp) < 0) {
|
if (openInputStream(&inStream, path_max_tmp) < 0) {
|
||||||
@ -294,7 +286,6 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
|
|||||||
ret = DECODE_ERROR_UNKTYPE;
|
ret = DECODE_ERROR_UNKTYPE;
|
||||||
if (isRemoteUrl(dc->utf8url)) {
|
if (isRemoteUrl(dc->utf8url)) {
|
||||||
unsigned int next = 0;
|
unsigned int next = 0;
|
||||||
cb->acceptMetadata = 1;
|
|
||||||
|
|
||||||
/* first we try mime types: */
|
/* first we try mime types: */
|
||||||
while (ret && (plugin = getInputPluginFromMimeType(inStream.mime, next++))) {
|
while (ret && (plugin = getInputPluginFromMimeType(inStream.mime, next++))) {
|
||||||
@ -340,7 +331,6 @@ static void decodeStart(PlayerControl * pc, OutputBuffer * cb,
|
|||||||
} else {
|
} else {
|
||||||
unsigned int next = 0;
|
unsigned int next = 0;
|
||||||
const char *s = getSuffix(dc->utf8url);
|
const char *s = getSuffix(dc->utf8url);
|
||||||
cb->acceptMetadata = 0;
|
|
||||||
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
|
while (ret && (plugin = getInputPluginFromSuffix(s, next++))) {
|
||||||
if (!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE)
|
if (!plugin->streamTypes & INPUT_PLUGIN_STREAM_FILE)
|
||||||
continue;
|
continue;
|
||||||
@ -408,53 +398,14 @@ void decoderInit(void)
|
|||||||
FATAL("Failed to spawn decoder task: %s\n", strerror(errno));
|
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,
|
static void advanceOutputBufferTo(OutputBuffer * cb, PlayerControl * pc,
|
||||||
int *previous, int *currentChunkSent,
|
int *currentChunkSent, int to)
|
||||||
MetadataChunk * currentChunk, int to)
|
|
||||||
{
|
{
|
||||||
while (cb->begin != to) {
|
while (cb->begin != to) {
|
||||||
handleMetadata(cb, pc, previous, currentChunkSent,
|
if ((unsigned)cb->begin + 1 >= buffered_chunks)
|
||||||
currentChunk);
|
|
||||||
if ((unsigned)cb->begin + 1 >= buffered_chunks) {
|
|
||||||
cb->begin = 0;
|
cb->begin = 0;
|
||||||
}
|
else
|
||||||
else cb->begin++;
|
cb->begin++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -471,8 +422,6 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
|
|||||||
int decodeWaitedOn = 0;
|
int decodeWaitedOn = 0;
|
||||||
static const char silence[CHUNK_SIZE];
|
static const char silence[CHUNK_SIZE];
|
||||||
double sizeToTime = 0.0;
|
double sizeToTime = 0.0;
|
||||||
int previousMetadataChunk = -1;
|
|
||||||
MetadataChunk currentMetadataChunk;
|
|
||||||
int currentChunkSent = 1;
|
int currentChunkSent = 1;
|
||||||
unsigned int end;
|
unsigned int end;
|
||||||
int next = -1;
|
int next = -1;
|
||||||
@ -495,8 +444,6 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
|
|||||||
while (!quit) {
|
while (!quit) {
|
||||||
processDecodeInput();
|
processDecodeInput();
|
||||||
handleDecodeStart();
|
handleDecodeStart();
|
||||||
handleMetadata(cb, pc, &previousMetadataChunk,
|
|
||||||
¤tChunkSent, ¤tMetadataChunk);
|
|
||||||
if (dc->state == DECODE_STATE_STOP &&
|
if (dc->state == DECODE_STATE_STOP &&
|
||||||
pc->queueState == PLAYER_QUEUE_FULL &&
|
pc->queueState == PLAYER_QUEUE_FULL &&
|
||||||
pc->queueLockState == PLAYER_QUEUE_UNLOCKED) {
|
pc->queueLockState == PLAYER_QUEUE_UNLOCKED) {
|
||||||
@ -599,9 +546,7 @@ static void decodeParent(PlayerControl * pc, DecoderControl * dc, OutputBuffer *
|
|||||||
nextChunk -= buffered_chunks;
|
nextChunk -= buffered_chunks;
|
||||||
}
|
}
|
||||||
advanceOutputBufferTo(cb, pc,
|
advanceOutputBufferTo(cb, pc,
|
||||||
&previousMetadataChunk,
|
|
||||||
¤tChunkSent,
|
¤tChunkSent,
|
||||||
¤tMetadataChunk,
|
|
||||||
nextChunk);
|
nextChunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -651,7 +596,6 @@ void decode(void)
|
|||||||
|
|
||||||
cb = &(getPlayerData()->buffer);
|
cb = &(getPlayerData()->buffer);
|
||||||
|
|
||||||
clearAllMetaChunkSets(cb);
|
|
||||||
cb->begin = 0;
|
cb->begin = 0;
|
||||||
cb->end = 0;
|
cb->end = 0;
|
||||||
pc = &(getPlayerData()->playerControl);
|
pc = &(getPlayerData()->playerControl);
|
||||||
|
@ -893,7 +893,6 @@ static int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc,
|
|||||||
data->inStream->metaTitle);
|
data->inStream->metaTitle);
|
||||||
free(data->inStream->metaTitle);
|
free(data->inStream->metaTitle);
|
||||||
data->inStream->metaTitle = NULL;
|
data->inStream->metaTitle = NULL;
|
||||||
copyMpdTagToOutputBuffer(cb, tag);
|
|
||||||
freeMpdTag(tag);
|
freeMpdTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1048,21 +1047,18 @@ static int mp3_decode(OutputBuffer * cb, DecoderControl * dc,
|
|||||||
if (inStream->metaName) {
|
if (inStream->metaName) {
|
||||||
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
|
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
|
||||||
}
|
}
|
||||||
copyMpdTagToOutputBuffer(cb, tag);
|
|
||||||
freeMpdTag(tag);
|
freeMpdTag(tag);
|
||||||
} else if (tag) {
|
} else if (tag) {
|
||||||
if (inStream->metaName) {
|
if (inStream->metaName) {
|
||||||
clearItemsFromMpdTag(tag, TAG_ITEM_NAME);
|
clearItemsFromMpdTag(tag, TAG_ITEM_NAME);
|
||||||
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
|
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
|
||||||
}
|
}
|
||||||
copyMpdTagToOutputBuffer(cb, tag);
|
|
||||||
freeMpdTag(tag);
|
freeMpdTag(tag);
|
||||||
} else if (inStream->metaName) {
|
} else if (inStream->metaName) {
|
||||||
tag = newMpdTag();
|
tag = newMpdTag();
|
||||||
if (inStream->metaName) {
|
if (inStream->metaName) {
|
||||||
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
|
addItemToMpdTag(tag, TAG_ITEM_NAME, inStream->metaName);
|
||||||
}
|
}
|
||||||
copyMpdTagToOutputBuffer(cb, tag);
|
|
||||||
freeMpdTag(tag);
|
freeMpdTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,8 +213,6 @@ static void putOggCommentsIntoOutputBuffer(OutputBuffer * cb, char *streamName,
|
|||||||
addItemToMpdTag(tag, TAG_ITEM_NAME, streamName);
|
addItemToMpdTag(tag, TAG_ITEM_NAME, streamName);
|
||||||
}
|
}
|
||||||
|
|
||||||
copyMpdTagToOutputBuffer(cb, tag);
|
|
||||||
|
|
||||||
freeMpdTag(tag);
|
freeMpdTag(tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
@ -27,8 +27,6 @@
|
|||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
static mpd_sint16 currentChunk = -1;
|
static mpd_sint16 currentChunk = -1;
|
||||||
static mpd_sint8 currentMetaChunk = -1;
|
|
||||||
static mpd_sint8 sendMetaChunk;
|
|
||||||
|
|
||||||
void initOutputBuffer(OutputBuffer * cb, char *chunks)
|
void initOutputBuffer(OutputBuffer * cb, char *chunks)
|
||||||
{
|
{
|
||||||
@ -38,35 +36,14 @@ void initOutputBuffer(OutputBuffer * cb, char *chunks)
|
|||||||
buffered_chunks * CHUNK_SIZE);
|
buffered_chunks * CHUNK_SIZE);
|
||||||
cb->bitRate = (mpd_uint16 *) (((char *)cb->chunkSize) +
|
cb->bitRate = (mpd_uint16 *) (((char *)cb->chunkSize) +
|
||||||
buffered_chunks * sizeof(mpd_sint16));
|
buffered_chunks * sizeof(mpd_sint16));
|
||||||
cb->metaChunk = (mpd_sint8 *) (((char *)cb->bitRate) +
|
cb->times = (float *)(((char *)cb->bitRate) +
|
||||||
buffered_chunks *
|
buffered_chunks * sizeof(mpd_sint8));
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearOutputBuffer(OutputBuffer * cb)
|
void clearOutputBuffer(OutputBuffer * cb)
|
||||||
{
|
{
|
||||||
int currentSet = 1;
|
int currentSet = 1;
|
||||||
|
|
||||||
cb->end = cb->begin;
|
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;
|
currentChunk = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,11 +117,6 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
|
|||||||
|
|
||||||
currentChunk = cb->end;
|
currentChunk = cb->end;
|
||||||
cb->chunkSize[currentChunk] = 0;
|
cb->chunkSize[currentChunk] = 0;
|
||||||
|
|
||||||
if (sendMetaChunk) {
|
|
||||||
cb->metaChunk[currentChunk] = currentMetaChunk;
|
|
||||||
} else
|
|
||||||
cb->metaChunk[currentChunk] = -1;
|
|
||||||
cb->bitRate[currentChunk] = bitRate;
|
cb->bitRate[currentChunk] = bitRate;
|
||||||
cb->times[currentChunk] = data_time;
|
cb->times[currentChunk] = data_time;
|
||||||
}
|
}
|
||||||
@ -167,49 +139,3 @@ int sendDataToOutputBuffer(OutputBuffer * cb, InputStream * inStream,
|
|||||||
return 0;
|
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;
|
|
||||||
}
|
|
||||||
|
@ -24,14 +24,11 @@
|
|||||||
#include "decode.h"
|
#include "decode.h"
|
||||||
#include "audio.h"
|
#include "audio.h"
|
||||||
#include "inputStream.h"
|
#include "inputStream.h"
|
||||||
#include "metadataChunk.h"
|
|
||||||
#include "replayGain.h"
|
#include "replayGain.h"
|
||||||
|
|
||||||
#define OUTPUT_BUFFER_DC_STOP -1
|
#define OUTPUT_BUFFER_DC_STOP -1
|
||||||
#define OUTPUT_BUFFER_DC_SEEK -2
|
#define OUTPUT_BUFFER_DC_SEEK -2
|
||||||
|
|
||||||
#define BUFFERED_METACHUNKS 25
|
|
||||||
|
|
||||||
typedef struct _OutputBuffer {
|
typedef struct _OutputBuffer {
|
||||||
char *volatile chunks;
|
char *volatile chunks;
|
||||||
mpd_uint16 *volatile chunkSize;
|
mpd_uint16 *volatile chunkSize;
|
||||||
@ -41,10 +38,6 @@ typedef struct _OutputBuffer {
|
|||||||
mpd_uint16 volatile end;
|
mpd_uint16 volatile end;
|
||||||
AudioFormat audioFormat;
|
AudioFormat audioFormat;
|
||||||
ConvState convState;
|
ConvState convState;
|
||||||
MetadataChunk metadataChunks[BUFFERED_METACHUNKS];
|
|
||||||
mpd_sint8 metaChunkSet[BUFFERED_METACHUNKS];
|
|
||||||
mpd_sint8 *volatile metaChunk;
|
|
||||||
volatile mpd_sint8 acceptMetadata;
|
|
||||||
} OutputBuffer;
|
} OutputBuffer;
|
||||||
|
|
||||||
void initOutputBuffer(OutputBuffer * cb, char *chunks);
|
void initOutputBuffer(OutputBuffer * cb, char *chunks);
|
||||||
@ -64,8 +57,4 @@ int sendDataToOutputBuffer(OutputBuffer * cb,
|
|||||||
float time,
|
float time,
|
||||||
mpd_uint16 bitRate, ReplayGainInfo * replayGainInfo);
|
mpd_uint16 bitRate, ReplayGainInfo * replayGainInfo);
|
||||||
|
|
||||||
int copyMpdTagToOutputBuffer(OutputBuffer * cb, MpdTag * tag);
|
|
||||||
|
|
||||||
void clearAllMetaChunkSets(OutputBuffer * cb);
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
33
src/player.c
33
src/player.c
@ -95,15 +95,6 @@ static void * player_task(mpd_unused void *unused)
|
|||||||
return NULL;
|
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)
|
void playerInit(void)
|
||||||
{
|
{
|
||||||
pthread_attr_t attr;
|
pthread_attr_t attr;
|
||||||
@ -130,7 +121,6 @@ static void set_current_song(Song *song)
|
|||||||
PlayerControl *pc = &(getPlayerData()->playerControl);
|
PlayerControl *pc = &(getPlayerData()->playerControl);
|
||||||
|
|
||||||
pc->fileTime = song->tag ? song->tag->time : 0;
|
pc->fileTime = song->tag ? song->tag->time : 0;
|
||||||
copyMpdTagToMetadataChunk(song->tag, &(pc->fileMetadataChunk));
|
|
||||||
get_song_url(pc->utf8url, song);
|
get_song_url(pc->utf8url, song);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +133,6 @@ int playerPlay(int fd, Song * song)
|
|||||||
|
|
||||||
set_current_song(song);
|
set_current_song(song);
|
||||||
|
|
||||||
resetPlayerMetadata();
|
|
||||||
pc->play = 1;
|
pc->play = 1;
|
||||||
/* FIXME: _nb() variant is probably wrong here, and everywhere... */
|
/* FIXME: _nb() variant is probably wrong here, and everywhere... */
|
||||||
do { wakeup_player_nb(); } while (pc->play);
|
do { wakeup_player_nb(); } while (pc->play);
|
||||||
@ -346,7 +335,6 @@ int playerSeek(int fd, Song * song, float seek_time)
|
|||||||
set_current_song(song);
|
set_current_song(song);
|
||||||
|
|
||||||
if (pc->error == PLAYER_ERROR_NOERROR) {
|
if (pc->error == PLAYER_ERROR_NOERROR) {
|
||||||
resetPlayerMetadata();
|
|
||||||
pc->seekWhere = seek_time;
|
pc->seekWhere = seek_time;
|
||||||
pc->seek = 1;
|
pc->seek = 1;
|
||||||
/* FIXME: _nb() is probably wrong here, too */
|
/* FIXME: _nb() is probably wrong here, too */
|
||||||
@ -415,24 +403,5 @@ int getPlayerChannels(void)
|
|||||||
/* this actually creates a dupe of the current metadata */
|
/* this actually creates a dupe of the current metadata */
|
||||||
Song *playerCurrentDecodeSong(void)
|
Song *playerCurrentDecodeSong(void)
|
||||||
{
|
{
|
||||||
static Song *song;
|
return NULL;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "decode.h"
|
#include "decode.h"
|
||||||
#include "mpd_types.h"
|
#include "mpd_types.h"
|
||||||
#include "song.h"
|
#include "song.h"
|
||||||
#include "metadataChunk.h"
|
|
||||||
#include "os_compat.h"
|
#include "os_compat.h"
|
||||||
|
|
||||||
#define PLAYER_STATE_STOP 0
|
#define PLAYER_STATE_STOP 0
|
||||||
@ -51,9 +50,6 @@
|
|||||||
#define PLAYER_QUEUE_UNLOCKED 0
|
#define PLAYER_QUEUE_UNLOCKED 0
|
||||||
#define PLAYER_QUEUE_LOCKED 1
|
#define PLAYER_QUEUE_LOCKED 1
|
||||||
|
|
||||||
#define PLAYER_METADATA_STATE_READ 1
|
|
||||||
#define PLAYER_METADATA_STATE_WRITE 2
|
|
||||||
|
|
||||||
typedef struct _PlayerControl {
|
typedef struct _PlayerControl {
|
||||||
volatile mpd_sint8 stop;
|
volatile mpd_sint8 stop;
|
||||||
volatile mpd_sint8 play;
|
volatile mpd_sint8 play;
|
||||||
@ -80,9 +76,6 @@ typedef struct _PlayerControl {
|
|||||||
volatile float crossFade;
|
volatile float crossFade;
|
||||||
volatile mpd_uint16 softwareVolume;
|
volatile mpd_uint16 softwareVolume;
|
||||||
volatile double totalPlayTime;
|
volatile double totalPlayTime;
|
||||||
volatile mpd_sint8 metadataState;
|
|
||||||
MetadataChunk metadataChunk;
|
|
||||||
MetadataChunk fileMetadataChunk;
|
|
||||||
} PlayerControl;
|
} PlayerControl;
|
||||||
|
|
||||||
void wakeup_main_task(void);
|
void wakeup_main_task(void);
|
||||||
|
@ -78,7 +78,6 @@ void initPlayerData(void)
|
|||||||
allocationSize += buffered_chunks * sizeof(float); /*for times */
|
allocationSize += buffered_chunks * sizeof(float); /*for times */
|
||||||
allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for chunkSize */
|
allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for chunkSize */
|
||||||
allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for bitRate */
|
allocationSize += buffered_chunks * sizeof(mpd_sint16); /*for bitRate */
|
||||||
allocationSize += buffered_chunks * sizeof(mpd_sint8); /*for metaChunk */
|
|
||||||
allocationSize += sizeof(PlayerData); /*for playerData struct */
|
allocationSize += sizeof(PlayerData); /*for playerData struct */
|
||||||
|
|
||||||
/* for audioDeviceStates[] */
|
/* for audioDeviceStates[] */
|
||||||
@ -114,8 +113,6 @@ void initPlayerData(void)
|
|||||||
playerData_pd->playerControl.crossFade = crossfade;
|
playerData_pd->playerControl.crossFade = crossfade;
|
||||||
playerData_pd->playerControl.softwareVolume = 1000;
|
playerData_pd->playerControl.softwareVolume = 1000;
|
||||||
playerData_pd->playerControl.totalPlayTime = 0;
|
playerData_pd->playerControl.totalPlayTime = 0;
|
||||||
playerData_pd->playerControl.metadataState =
|
|
||||||
PLAYER_METADATA_STATE_WRITE;
|
|
||||||
|
|
||||||
playerData_pd->decoderControl.stop = 0;
|
playerData_pd->decoderControl.stop = 0;
|
||||||
playerData_pd->decoderControl.start = 0;
|
playerData_pd->decoderControl.start = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user