diff options
author | Warren Dukes <warren.dukes@gmail.com> | 2004-05-04 19:49:29 +0000 |
---|---|---|
committer | Warren Dukes <warren.dukes@gmail.com> | 2004-05-04 19:49:29 +0000 |
commit | 659df586719c727204513c97c243c9f14dbfa5d9 (patch) | |
tree | 404a08b7c414feb0c1193fadd3ee146fa9bc8f95 /src/inputStream.c | |
parent | 638817fc5b2a537b21335d8f5e429559353602a5 (diff) | |
download | mpd-659df586719c727204513c97c243c9f14dbfa5d9.tar.gz mpd-659df586719c727204513c97c243c9f14dbfa5d9.tar.xz mpd-659df586719c727204513c97c243c9f14dbfa5d9.zip |
implement input abstraction for ogg and mp3
git-svn-id: https://svn.musicpd.org/mpd/trunk@904 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to '')
-rw-r--r-- | src/inputStream.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/inputStream.c b/src/inputStream.c index 0856dd125..9168e6aeb 100644 --- a/src/inputStream.c +++ b/src/inputStream.c @@ -23,7 +23,7 @@ #include <unistd.h> #include <errno.h> -int initInputStreamFromFile(InputStream * inStream, char * filename) { +int openInputStreamFromFile(InputStream * inStream, char * filename) { inStream->fp = fopen(filename,"r"); if(!inStream->fp) { inStream->error = errno; @@ -39,14 +39,9 @@ int initInputStreamFromFile(InputStream * inStream, char * filename) { return 0; } -int seekInputStream(InputStream * inStream, long offset) { - if(offset<0) { - inStream->error = EINVAL; - return -1; - } - - if(fseek(inStream->fp,offset,SEEK_SET)==0) { - inStream->offset = offset; +int seekInputStream(InputStream * inStream, long offset, int whence) { + if(fseek(inStream->fp,offset,whence)==0) { + inStream->offset = ftell(inStream->fp); } else { inStream->error = errno; @@ -56,19 +51,19 @@ int seekInputStream(InputStream * inStream, long offset) { return 0; } -size_t fillBufferFromInputStream(InputStream * inStream, char * buffer, - size_t buflen) +size_t readFromInputStream(InputStream * inStream, void * ptr, size_t size, + size_t nmemb) { size_t readSize; - readSize = fread(buffer,1,buflen,inStream->fp); + readSize = fread(ptr,size,nmemb,inStream->fp); if(readSize>0) inStream->offset+=readSize; return readSize; } -int finishInputStream(InputStream * inStream) { +int closeInputStream(InputStream * inStream) { if(fclose(inStream->fp)<0) { inStream->error = errno; } |