aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--TODO6
-rw-r--r--src/decode.c15
-rw-r--r--src/inputPlugins/audiofile_plugin.c4
-rw-r--r--src/player.c31
-rw-r--r--src/player.h8
-rw-r--r--src/playerData.c8
6 files changed, 57 insertions, 15 deletions
diff --git a/TODO b/TODO
index fb9ba8a93..736dc41e8 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,6 @@
1) play streams
a) put some sort of error reporting for streaming/inputStream!
- b) fetch metadata and store in DecoderControl and pass to
- PlayerControl! (need todo this to ensure craziness doesn't
- happen)
- 1) eventually deal with icy-metadata
- 2) parse metadata on the fly in decoders
+ b) parse metadata on the fly in decoders
c) command for dealing with the changing metadata, currentsonginfo
or something
d) in songinfo add a metadata tag item for indicating stream
diff --git a/src/decode.c b/src/decode.c
index 6c4beeeed..b361b62f3 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -71,6 +71,7 @@ void stopDecode(DecoderControl * dc) {
void quitDecode(PlayerControl * pc, DecoderControl * dc) {
stopDecode(dc);
+ pc->metadataState = PLAYER_METADATA_STATE_READ;
pc->state = PLAYER_STATE_STOP;
dc->seek = 0;
pc->play = 0;
@@ -110,6 +111,15 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
quitDecode(pc,dc); \
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->sampleRate = dc->audioFormat.sampleRate; \
pc->bits = dc->audioFormat.bits; \
@@ -131,6 +141,9 @@ int calculateCrossFadeChunks(PlayerControl * pc, AudioFormat * af) {
int waitOnDecode(PlayerControl * pc, DecoderControl * dc, OutputBuffer * cb,
int * decodeWaitedOn)
{
+ strncpy(pc->currentUrl, pc->utf8url, MAXPATHLEN);
+ pc->currentUrl[MAXPATHLEN] = '\0';
+
while(decode_pid && *decode_pid>0 && dc->start) my_usleep(10000);
if(dc->start || dc->error!=DECODE_ERROR_NOERROR) {
@@ -570,7 +583,7 @@ void decode() {
dc->seek = 0;
dc->stop = 0;
dc->start = 1;
-
+
if(decode_pid==NULL || *decode_pid<=0) {
if(decoderInit(pc,cb,dc)<0) return;
}
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index 5fe1a5ccd..1b095baa6 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -157,6 +157,8 @@ InputPlugin audiofilePlugin =
{
"audiofile",
NULL,
+ NULL,
+ NULL,
audiofile_decode,
audiofileTagDup,
INPUT_PLUGIN_STREAM_FILE,
@@ -172,6 +174,8 @@ InputPlugin audiofilePlugin =
NULL,
NULL,
NULL,
+ NULL,
+ NULL,
0,
NULL,
NULL
diff --git a/src/player.c b/src/player.c
index e0d8ee93f..f1df0b0b7 100644
--- a/src/player.c
+++ b/src/player.c
@@ -50,6 +50,15 @@ void clearPlayerPid() {
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() {
int pid;
@@ -62,6 +71,9 @@ void resetPlayer() {
getPlayerData()->playerControl.state = PLAYER_STATE_STOP;
getPlayerData()->playerControl.queueState = PLAYER_QUEUE_UNLOCKED;
getPlayerData()->playerControl.seek = 0;
+ getPlayerData()->playerControl.metadataState =
+ PLAYER_METADATA_STATE_WRITE;
+ getPlayerData()->playerControl.title = -1;
/* kill decode process if it got left running */
pid = getPlayerData()->playerControl.decode_pid;
if(pid>0) kill(pid,SIGTERM);
@@ -187,6 +199,7 @@ int playerPlay(FILE * fp, Song * song) {
return -1;
}
+ resetPlayerMetadata();
while(player_pid>0 && pc->play) my_usleep(1000);
return 0;
@@ -385,6 +398,7 @@ int playerSeek(FILE * fp, Song * song, float time) {
}
if(pc->error==PLAYER_ERROR_NOERROR) {
+ resetPlayerMetadata();
pc->seekWhere = time;
pc->seek = 1;
while(player_pid>0 && pc->seek) my_usleep(1000);
@@ -461,20 +475,21 @@ void playerCycleLogFiles() {
/* this actually creates a dupe of the current metadata */
Song * playerCurrentDecodeSong() {
- static Song * song;
- DecoderControl * dc = &(getPlayerData()->decoderControl);
+ static Song * song = NULL;
+ 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);
song = newNullSong();
song->tag = newMpdTag();
if(song->utf8url) free(song->utf8url);
- song->utf8url = strdup(dc->utf8url);
- if(dc->title >= 0) {
- song->tag->title = dc->title + dc->metadata;
+ song->utf8url = strdup(pc->currentUrl);
+ if(pc->title >= 0) {
+ song->tag->title = strdup(pc->title + pc->metadata);
}
- else song->tag->title = NULL;
-
+ resetPlayerMetadata();
return song;
}
diff --git a/src/player.h b/src/player.h
index 31560fb3b..e7d21f7b9 100644
--- a/src/player.h
+++ b/src/player.h
@@ -21,6 +21,7 @@
#include "../config.h"
+#include "decode.h"
#include "mpd_types.h"
#include "song.h"
@@ -51,6 +52,9 @@
#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;
@@ -67,6 +71,7 @@ typedef struct _PlayerControl {
volatile float elapsedTime;
volatile float fileTime;
char utf8url[MAXPATHLEN+1];
+ char currentUrl[MAXPATHLEN+1];
char erroredUrl[MAXPATHLEN+1];
volatile mpd_sint8 queueState;
volatile mpd_sint8 queueLockState;
@@ -79,6 +84,9 @@ typedef struct _PlayerControl {
volatile double totalPlayTime;
volatile int decode_pid;
volatile mpd_sint8 cycleLogFiles;
+ volatile mpd_sint8 metadataState;
+ char metadata[DECODE_METADATA_LENGTH];
+ volatile mpd_sint16 title;
} PlayerControl;
void clearPlayerPid();
diff --git a/src/playerData.c b/src/playerData.c
index f37792914..d78a208b4 100644
--- a/src/playerData.c
+++ b/src/playerData.c
@@ -110,10 +110,16 @@ void initPlayerData() {
playerData_pd->playerControl.seek = 0;
memset(playerData_pd->playerControl.utf8url, 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.softwareVolume = 1000;
playerData_pd->playerControl.totalPlayTime = 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.start = 0;
@@ -122,7 +128,7 @@ void initPlayerData() {
playerData_pd->decoderControl.error = DECODE_ERROR_NOERROR;
memset(playerData_pd->decoderControl.utf8url, 0, MAXPATHLEN+1);
memset(playerData_pd->decoderControl.metadata, 0,
- DECODE_METADATA_LENGTH);
+ DECODE_METADATA_LENGTH);
playerData_pd->decoderControl.title = -1;
playerData_pd->decoderControl.metadataSet = 0;
}