aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputStream.c
diff options
context:
space:
mode:
authorWarren Dukes <warren.dukes@gmail.com>2004-05-04 19:49:29 +0000
committerWarren Dukes <warren.dukes@gmail.com>2004-05-04 19:49:29 +0000
commit659df586719c727204513c97c243c9f14dbfa5d9 (patch)
tree404a08b7c414feb0c1193fadd3ee146fa9bc8f95 /src/inputStream.c
parent638817fc5b2a537b21335d8f5e429559353602a5 (diff)
downloadmpd-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.c21
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;
}