aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/audiofile_decode.c3
-rw-r--r--src/flac_decode.c3
-rw-r--r--src/ls.c7
-rw-r--r--src/mp3_decode.c35
-rw-r--r--src/mp4_decode.c3
-rw-r--r--src/ogg_decode.c3
-rw-r--r--src/outputBuffer.c6
-rw-r--r--src/outputBuffer.h2
-rw-r--r--src/player.c31
9 files changed, 57 insertions, 36 deletions
diff --git a/src/audiofile_decode.c b/src/audiofile_decode.c
index b6b459f08..20c05f426 100644
--- a/src/audiofile_decode.c
+++ b/src/audiofile_decode.c
@@ -98,8 +98,7 @@ int audiofile_decode(OutputBuffer * cb, DecoderControl * dc) {
while(!eof) {
if(dc->seek) {
- cb->end = cb->begin;
- cb->wrap = 0;
+ clearOutputBuffer(cb);
current = dc->seekWhere *
dc->audioFormat.sampleRate;
afSeekFrame(af_fp, AF_DEFAULT_TRACK,current);
diff --git a/src/flac_decode.c b/src/flac_decode.c
index 105a3ef6f..6c718f654 100644
--- a/src/flac_decode.c
+++ b/src/flac_decode.c
@@ -147,8 +147,7 @@ int flac_decode(OutputBuffer * cb, DecoderControl *dc) {
if(dc->seek) {
FLAC__uint64 sampleToSeek = dc->seekWhere*
dc->audioFormat.sampleRate+0.5;
- cb->end = cb->begin;
- cb->wrap = 0;
+ clearOutputBuffer(cb);
if(FLAC__seekable_stream_decoder_seek_absolute(flacDec,
sampleToSeek))
{
diff --git a/src/ls.c b/src/ls.c
index 11c69ec37..1b5c36015 100644
--- a/src/ls.c
+++ b/src/ls.c
@@ -44,7 +44,6 @@ char * dupAndStripPlaylistSuffix(char * file) {
int isRemoteUrl(char * url) {
char * prefixes[] = {
"http://",
- "ftp://",
NULL
};
@@ -53,12 +52,12 @@ int isRemoteUrl(char * url) {
while(*urlPrefixes) {
if(strncmp(*urlPrefixes,url,strlen(*urlPrefixes)) == 0) {
#ifdef HAVE_MAD
- if(hasMp3Suffix(*urlPrefixes)) return 1;
+ if(hasMp3Suffix(url)) return 1;
#endif
#ifdef HAVE_OGG
- if(hasOggSuffix(*urlPrefixes)) return 1;
- return 0;
+ if(hasOggSuffix(url)) return 1;
#endif
+ return 0;
}
urlPrefixes++;
}
diff --git a/src/mp3_decode.c b/src/mp3_decode.c
index a5a0d216c..15f423e4a 100644
--- a/src/mp3_decode.c
+++ b/src/mp3_decode.c
@@ -139,8 +139,8 @@ typedef struct _mp3DecodeData {
int initMp3DecodeData(mp3DecodeData * data, char * file) {
int ret;
- while(((ret = openInputStream(&(data->inStream),file))<0)) /*&&
- data->inStream.error==EINTR);*/
+ /*while(((*/ret = openInputStream(&(data->inStream),file)/*)<0)) &&
+ data->inStream.error==EINTR)*/;
if(ret<0) return -1;
data->outputPtr = data->outputBuffer;
@@ -165,10 +165,13 @@ int initMp3DecodeData(mp3DecodeData * data, char * file) {
int fillMp3InputBuffer(mp3DecodeData * data, long offset) {
size_t readSize;
size_t remaining;
+ size_t readed;
unsigned char * readStart;
if(offset>=0) {
- seekInputStream(&(data->inStream),offset,SEEK_SET);
+ if(seekInputStream(&(data->inStream),offset,SEEK_SET) < 0) {
+ return -1;
+ }
}
if(offset==-1 && (data->stream).next_frame!=NULL) {
@@ -182,11 +185,15 @@ int fillMp3InputBuffer(mp3DecodeData * data, long offset) {
readStart = data->readBuffer,
remaining = 0;
}
-
- readSize = readFromInputStream(&(data->inStream),readStart,1,readSize);
- if(readSize<=0) return -1;
- mad_stream_buffer(&data->stream,data->readBuffer,readSize+remaining);
+ readed = 0;
+ while(readed == 0 && !inputStreamAtEOF(&(data->inStream))) {
+ readed = readFromInputStream(&(data->inStream), readStart, 1,
+ readSize);
+ }
+ if(readed<=0) return -1;
+
+ mad_stream_buffer(&data->stream,data->readBuffer,readed+remaining);
(data->stream).error = 0;
return 0;
@@ -441,6 +448,7 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if(data->muteFrame) {
if(!dc->seek) data->muteFrame = 0;
else if(dc->seekWhere<=data->elapsedTime) {
+ clearOutputBuffer(cb);
data->muteFrame = 0;
dc->seek = 0;
}
@@ -485,8 +493,6 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
if(dc->seek) {
long i = 0;
- cb->wrap = 0;
- cb->end = cb->begin;
data->muteFrame = 1;
while(i<data->highestFrame && dc->seekWhere >
((float)mad_timer_count(data->times[i],
@@ -495,9 +501,14 @@ int mp3Read(mp3DecodeData * data, OutputBuffer * cb, DecoderControl * dc) {
i++;
}
if(i<data->highestFrame) {
- data->currentFrame = i;
- fillMp3InputBuffer(data,data->frameOffset[i]);
- data->muteFrame = 0;
+ if(fillMp3InputBuffer(data,
+ data->frameOffset[i]) == 0)
+ {
+ clearOutputBuffer(cb);
+ data->currentFrame = i;
+ data->muteFrame = 0;
+ }
+ else dc->seekError = 1;
dc->seek = 0;
}
}
diff --git a/src/mp4_decode.c b/src/mp4_decode.c
index 4705a6ed6..dccc7a846 100644
--- a/src/mp4_decode.c
+++ b/src/mp4_decode.c
@@ -220,8 +220,7 @@ int mp4_decode(OutputBuffer * cb, DecoderControl * dc) {
if(dc->seek && seekPositionFound) {
seekPositionFound = 0;
chunkLen = 0;
- cb->end = cb->begin;
- cb->wrap = 0;
+ clearOutputBuffer(cb);
dc->seek = 0;
}
diff --git a/src/ogg_decode.c b/src/ogg_decode.c
index 4014644af..d24d6158b 100644
--- a/src/ogg_decode.c
+++ b/src/ogg_decode.c
@@ -191,8 +191,7 @@ int ogg_decode(OutputBuffer * cb, DecoderControl * dc)
while(!eof) {
if(dc->seek) {
- cb->end = cb->begin;
- cb->wrap = 0;
+ clearOutputBuffer(cb);
chunkpos = 0;
ov_time_seek_page(&vf,dc->seekWhere);
dc->seek = 0;
diff --git a/src/outputBuffer.c b/src/outputBuffer.c
index 615139231..590b9a433 100644
--- a/src/outputBuffer.c
+++ b/src/outputBuffer.c
@@ -26,6 +26,12 @@
static mpd_sint16 currentChunk = -1;
+void clearOutputBuffer(OutputBuffer * cb) {
+ currentChunk = -1;
+ cb->end = cb->begin;
+ cb->wrap = 0;
+}
+
void flushOutputBuffer(OutputBuffer * cb) {
if(currentChunk == cb->end) {
cb->end++;
diff --git a/src/outputBuffer.h b/src/outputBuffer.h
index c00e8779b..d5bcb78c4 100644
--- a/src/outputBuffer.h
+++ b/src/outputBuffer.h
@@ -38,6 +38,8 @@ typedef struct _OutputBuffer {
AudioFormat audioFormat;
} OutputBuffer;
+void clearOutputBuffer(OutputBuffer * cb);
+
void flushOutputBuffer(OutputBuffer * cb);
int sendDataToOutputBuffer(OutputBuffer * cb, DecoderControl * dc,
diff --git a/src/player.c b/src/player.c
index f8d183baa..a764dd28a 100644
--- a/src/player.c
+++ b/src/player.c
@@ -161,22 +161,22 @@ int playerInit() {
}
int playerGetDecodeType(char * utf8file) {
- if(!isFile(utf8file,NULL));
+ if(!isRemoteUrl(utf8file) && !isFile(utf8file,NULL)) return -1;
#ifdef HAVE_MAD
- else if(hasMp3Suffix(utf8file)) return DECODE_TYPE_MP3;
+ if(hasMp3Suffix(utf8file)) return DECODE_TYPE_MP3;
#endif
#ifdef HAVE_OGG
- else if(hasOggSuffix(utf8file)) return DECODE_TYPE_OGG;
+ if(hasOggSuffix(utf8file)) return DECODE_TYPE_OGG;
#endif
#ifdef HAVE_FLAC
- else if(hasFlacSuffix(utf8file)) return DECODE_TYPE_FLAC;
+ if(hasFlacSuffix(utf8file)) return DECODE_TYPE_FLAC;
#endif
#ifdef HAVE_AUDIOFILE
- else if(hasWaveSuffix(utf8file)) return DECODE_TYPE_AUDIOFILE;
+ if(hasWaveSuffix(utf8file)) return DECODE_TYPE_AUDIOFILE;
#endif
#ifdef HAVE_FAAD
- else if(hasAacSuffix(utf8file)) return DECODE_TYPE_AAC;
- else if(hasMp4Suffix(utf8file)) return DECODE_TYPE_MP4;
+ if(hasAacSuffix(utf8file)) return DECODE_TYPE_AAC;
+ if(hasMp4Suffix(utf8file)) return DECODE_TYPE_MP4;
#endif
return -1;
}
@@ -189,7 +189,7 @@ int playerPlay(FILE * fp, char * utf8file) {
if(playerStop(fp)<0) return -1;
- {
+ /*{
struct stat st;
if(stat(rmp2amp(utf8ToFsCharset(utf8file)),&st)<0) {
strncpy(pc->erroredFile,pc->file,MAXPATHLEN);
@@ -197,7 +197,7 @@ int playerPlay(FILE * fp, char * utf8file) {
pc->error = PLAYER_ERROR_FILENOTFOUND;
return 0;
}
- }
+ }*/
decodeType = playerGetDecodeType(utf8file);
if(decodeType < 0) {
@@ -208,7 +208,10 @@ int playerPlay(FILE * fp, char * utf8file) {
}
pc->decodeType = decodeType;
- strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
+ if(isRemoteUrl(utf8file)) {
+ strncpy(pc->file,utf8file,MAXPATHLEN);
+ }
+ else strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
pc->file[MAXPATHLEN] = '\0';
pc->play = 1;
@@ -353,7 +356,10 @@ int queueSong(char * utf8file) {
int decodeType;
if(pc->queueState==PLAYER_QUEUE_BLANK) {
- strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
+ if(isRemoteUrl(utf8file)) {
+ strncpy(pc->file,utf8file,MAXPATHLEN);
+ }
+ else strncpy(pc->file,rmp2amp(utf8ToFsCharset(utf8file)),MAXPATHLEN);
pc->file[MAXPATHLEN] = '\0';
decodeType = playerGetDecodeType(utf8file);
@@ -410,7 +416,8 @@ int playerSeek(FILE * fp, char * utf8file, float time) {
return -1;
}
- file = rmp2amp(utf8ToFsCharset(utf8file));
+ if(isRemoteUrl(utf8file)) file = utf8file;
+ else file = rmp2amp(utf8ToFsCharset(utf8file));
if(strcmp(pc->file,file)!=0) {
decodeType = playerGetDecodeType(utf8file);
if(decodeType < 0) {