Commit 1a5b04e4 authored by Warren Dukes's avatar Warren Dukes

some stream metadata fixes

git-svn-id: https://svn.musicpd.org/mpd/trunk@1266 09075e82-0dd4-0310-85a5-a0d7c8717e4f
parent 5f2c19bf
1) play streams 1) play streams
a) put some sort of error reporting for streaming/inputStream! a) put some sort of error reporting for streaming/inputStream!
b) fetch metadata and store in DecoderControl and pass to b) parse metadata on the fly in decoders
PlayerControl! (need todo this to ensure craziness doesn't
happen)
1) eventually deal with icy-metadata
2) parse metadata on the fly in decoders
c) command for dealing with the changing metadata, currentsonginfo c) command for dealing with the changing metadata, currentsonginfo
or something or something
d) in songinfo add a metadata tag item for indicating stream d) in songinfo add a metadata tag item for indicating stream
......
...@@ -71,6 +71,7 @@ void stopDecode(DecoderControl * dc) { ...@@ -71,6 +71,7 @@ void stopDecode(DecoderControl * dc) {
void quitDecode(PlayerControl * pc, DecoderControl * dc) { void quitDecode(PlayerControl * pc, DecoderControl * dc) {
stopDecode(dc); stopDecode(dc);
pc->metadataState = PLAYER_METADATA_STATE_READ;
pc->state = PLAYER_STATE_STOP; pc->state = PLAYER_STATE_STOP;
dc->seek = 0; dc->seek = 0;
pc->play = 0; pc->play = 0;
...@@ -110,6 +111,15 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) { ...@@ -110,6 +111,15 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
quitDecode(pc,dc); \ quitDecode(pc,dc); \
return; \ return; \
} \ } \
if(pc->metadataState == PLAYER_METADATA_STATE_WRITE && \
dc->metadataSet) \
{ \
memcpy(pc->metadata, dc->metadata, \
DECODE_METADATA_LENGTH); \
pc->metadata[DECODE_METADATA_LENGTH-1] = '\0'; \
pc->title = dc->title; \
} \
pc->metadataState = PLAYER_METADATA_STATE_READ; \
pc->totalTime = dc->totalTime; \ pc->totalTime = dc->totalTime; \
pc->sampleRate = dc->audioFormat.sampleRate; \ pc->sampleRate = dc->audioFormat.sampleRate; \
pc->bits = dc->audioFormat.bits; \ pc->bits = dc->audioFormat.bits; \
...@@ -131,6 +141,9 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) { ...@@ -131,6 +141,9 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb, int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
int * decodeWaitedOn) int * decodeWaitedOn)
{ {
strncpy(pc->currentUrl, pc->utf8url, MAXPATHLEN);
pc->currentUrl[MAXPATHLEN] = '\0';
while(decode_pid && *decode_pid>0 && dc->start) my_usleep(10000); while(decode_pid && *decode_pid>0 && dc->start) my_usleep(10000);
if(dc->start || dc->error!=DECODE_ERROR_NOERROR) { if(dc->start || dc->error!=DECODE_ERROR_NOERROR) {
...@@ -570,7 +583,7 @@ void decode() { ...@@ -570,7 +583,7 @@ void decode() {
dc->seek = 0; dc->seek = 0;
dc->stop = 0; dc->stop = 0;
dc->start = 1; dc->start = 1;
if(decode_pid==NULL || *decode_pid<=0) { if(decode_pid==NULL || *decode_pid<=0) {
if(decoderInit(pc,cb,dc)<0) return; if(decoderInit(pc,cb,dc)<0) return;
} }
......
...@@ -157,6 +157,8 @@ InputPlugin audiofilePlugin = ...@@ -157,6 +157,8 @@ InputPlugin audiofilePlugin =
{ {
"audiofile", "audiofile",
NULL, NULL,
NULL,
NULL,
audiofile_decode, audiofile_decode,
audiofileTagDup, audiofileTagDup,
INPUT_PLUGIN_STREAM_FILE, INPUT_PLUGIN_STREAM_FILE,
...@@ -172,6 +174,8 @@ InputPlugin audiofilePlugin = ...@@ -172,6 +174,8 @@ InputPlugin audiofilePlugin =
NULL, NULL,
NULL, NULL,
NULL, NULL,
NULL,
NULL,
0, 0,
NULL, NULL,
NULL NULL
......
...@@ -50,6 +50,15 @@ void clearPlayerPid() { ...@@ -50,6 +50,15 @@ void clearPlayerPid() {
player_pid = 0; player_pid = 0;
} }
static void resetPlayerMetadata() {
PlayerControl * pc = &(getPlayerData()->playerControl);
if(pc->metadataState == PLAYER_METADATA_STATE_READ) {
pc->metadataState = PLAYER_METADATA_STATE_WRITE;
pc->title = -1;
}
}
void resetPlayer() { void resetPlayer() {
int pid; int pid;
...@@ -62,6 +71,9 @@ void resetPlayer() { ...@@ -62,6 +71,9 @@ void resetPlayer() {
getPlayerData()->playerControl.state = PLAYER_STATE_STOP; getPlayerData()->playerControl.state = PLAYER_STATE_STOP;
getPlayerData()->playerControl.queueState = PLAYER_QUEUE_UNLOCKED; getPlayerData()->playerControl.queueState = PLAYER_QUEUE_UNLOCKED;
getPlayerData()->playerControl.seek = 0; getPlayerData()->playerControl.seek = 0;
getPlayerData()->playerControl.metadataState =
PLAYER_METADATA_STATE_WRITE;
getPlayerData()->playerControl.title = -1;
/* kill decode process if it got left running */ /* kill decode process if it got left running */
pid = getPlayerData()->playerControl.decode_pid; pid = getPlayerData()->playerControl.decode_pid;
if(pid>0) kill(pid,SIGTERM); if(pid>0) kill(pid,SIGTERM);
...@@ -187,6 +199,7 @@ int playerPlay(FILE * fp, Song * song) { ...@@ -187,6 +199,7 @@ int playerPlay(FILE * fp, Song * song) {
return -1; return -1;
} }
resetPlayerMetadata();
while(player_pid>0 && pc->play) my_usleep(1000); while(player_pid>0 && pc->play) my_usleep(1000);
return 0; return 0;
...@@ -385,6 +398,7 @@ int playerSeek(FILE * fp, Song * song, float time) { ...@@ -385,6 +398,7 @@ int playerSeek(FILE * fp, Song * song, float time) {
} }
if(pc->error==PLAYER_ERROR_NOERROR) { if(pc->error==PLAYER_ERROR_NOERROR) {
resetPlayerMetadata();
pc->seekWhere = time; pc->seekWhere = time;
pc->seek = 1; pc->seek = 1;
while(player_pid>0 && pc->seek) my_usleep(1000); while(player_pid>0 && pc->seek) my_usleep(1000);
...@@ -461,20 +475,21 @@ void playerCycleLogFiles() { ...@@ -461,20 +475,21 @@ void playerCycleLogFiles() {
/* this actually creates a dupe of the current metadata */ /* this actually creates a dupe of the current metadata */
Song * playerCurrentDecodeSong() { Song * playerCurrentDecodeSong() {
static Song * song; static Song * song = NULL;
DecoderControl * dc = &(getPlayerData()->decoderControl); PlayerControl * pc = &(getPlayerData()->playerControl);
if(dc->metadataSet && (!song || strcmp(song->utf8url, dc->utf8url))) { if(pc->metadataState == PLAYER_METADATA_STATE_READ &&
(!song || strcmp(song->utf8url, pc->currentUrl)))
{
if(song) freeJustSong(song); if(song) freeJustSong(song);
song = newNullSong(); song = newNullSong();
song->tag = newMpdTag(); song->tag = newMpdTag();
if(song->utf8url) free(song->utf8url); if(song->utf8url) free(song->utf8url);
song->utf8url = strdup(dc->utf8url); song->utf8url = strdup(pc->currentUrl);
if(dc->title >= 0) { if(pc->title >= 0) {
song->tag->title = dc->title + dc->metadata; song->tag->title = strdup(pc->title + pc->metadata);
} }
else song->tag->title = NULL; resetPlayerMetadata();
return song; return song;
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "../config.h" #include "../config.h"
#include "decode.h"
#include "mpd_types.h" #include "mpd_types.h"
#include "song.h" #include "song.h"
...@@ -51,6 +52,9 @@ ...@@ -51,6 +52,9 @@
#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;
...@@ -67,6 +71,7 @@ typedef struct _PlayerControl { ...@@ -67,6 +71,7 @@ typedef struct _PlayerControl {
volatile float elapsedTime; volatile float elapsedTime;
volatile float fileTime; volatile float fileTime;
char utf8url[MAXPATHLEN+1]; char utf8url[MAXPATHLEN+1];
char currentUrl[MAXPATHLEN+1];
char erroredUrl[MAXPATHLEN+1]; char erroredUrl[MAXPATHLEN+1];
volatile mpd_sint8 queueState; volatile mpd_sint8 queueState;
volatile mpd_sint8 queueLockState; volatile mpd_sint8 queueLockState;
...@@ -79,6 +84,9 @@ typedef struct _PlayerControl { ...@@ -79,6 +84,9 @@ typedef struct _PlayerControl {
volatile double totalPlayTime; volatile double totalPlayTime;
volatile int decode_pid; volatile int decode_pid;
volatile mpd_sint8 cycleLogFiles; volatile mpd_sint8 cycleLogFiles;
volatile mpd_sint8 metadataState;
char metadata[DECODE_METADATA_LENGTH];
volatile mpd_sint16 title;
} PlayerControl; } PlayerControl;
void clearPlayerPid(); void clearPlayerPid();
......
...@@ -110,10 +110,16 @@ void initPlayerData() { ...@@ -110,10 +110,16 @@ void initPlayerData() {
playerData_pd->playerControl.seek = 0; playerData_pd->playerControl.seek = 0;
memset(playerData_pd->playerControl.utf8url, 0, MAXPATHLEN+1); memset(playerData_pd->playerControl.utf8url, 0, MAXPATHLEN+1);
memset(playerData_pd->playerControl.erroredUrl, 0, MAXPATHLEN+1); memset(playerData_pd->playerControl.erroredUrl, 0, MAXPATHLEN+1);
memset(playerData_pd->playerControl.currentUrl, 0, MAXPATHLEN+1);
memset(playerData_pd->playerControl.metadata, 0,
DECODE_METADATA_LENGTH);
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.decode_pid = 0; playerData_pd->playerControl.decode_pid = 0;
playerData_pd->playerControl.title = -1;
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;
...@@ -122,7 +128,7 @@ void initPlayerData() { ...@@ -122,7 +128,7 @@ void initPlayerData() {
playerData_pd->decoderControl.error = DECODE_ERROR_NOERROR; playerData_pd->decoderControl.error = DECODE_ERROR_NOERROR;
memset(playerData_pd->decoderControl.utf8url, 0, MAXPATHLEN+1); memset(playerData_pd->decoderControl.utf8url, 0, MAXPATHLEN+1);
memset(playerData_pd->decoderControl.metadata, 0, memset(playerData_pd->decoderControl.metadata, 0,
DECODE_METADATA_LENGTH); DECODE_METADATA_LENGTH);
playerData_pd->decoderControl.title = -1; playerData_pd->decoderControl.title = -1;
playerData_pd->decoderControl.metadataSet = 0; playerData_pd->decoderControl.metadataSet = 0;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment