Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 3959 → Rev 3960

/programs/develop/libraries/libmpg123/reader.h
12,13 → 12,16
#include "config.h"
#include "mpg123.h"
 
#ifndef NO_FEEDER
struct buffy
{
unsigned char *data;
ssize_t size;
ssize_t realsize;
struct buffy *next;
};
 
 
struct bufferchain
{
struct buffy* first; /* The beginning of the chain. */
29,27 → 32,51
ssize_t firstpos; /* The point of return on non-forget() */
/* The "real" filepos is fileoff + pos. */
off_t fileoff; /* Beginning of chain is at this file offset. */
size_t bufblock; /* Default (minimal) size of buffers. */
size_t pool_size; /* Keep that many buffers in storage. */
size_t pool_fill; /* That many buffers are there. */
/* A pool of buffers to re-use, if activated. It's a linked list that is worked on from the front. */
struct buffy *pool;
};
 
/* Call this before any buffer chain use (even bc_init()). */
void bc_prepare(struct bufferchain *, size_t pool_size, size_t bufblock);
/* Free persistent data in the buffer chain, after bc_reset(). */
void bc_cleanup(struct bufferchain *);
/* Change pool size. This does not actually allocate/free anything on itself, just instructs later operations to free less / allocate more buffers. */
void bc_poolsize(struct bufferchain *, size_t pool_size, size_t bufblock);
/* Return available byte count in the buffer. */
size_t bc_fill(struct bufferchain *bc);
 
#endif
 
struct reader_data
{
off_t filelen; /* total file length or total buffer size */
off_t filepos; /* position in file or position in buffer chain */
int filept;
/* Custom opaque I/O handle from the client. */
void *iohandle;
int flags;
#ifndef WIN32
long timeout_sec;
#endif
ssize_t (*fdread) (mpg123_handle *, void *, size_t);
/* User can replace the read and lseek functions. The r_* are the stored replacement functions or NULL,
The second two pointers are the actual workers (default map to POSIX read/lseek). */
/* User can replace the read and lseek functions. The r_* are the stored replacement functions or NULL. */
ssize_t (*r_read) (int fd, void *buf, size_t count);
off_t (*r_lseek)(int fd, off_t offset, int whence);
/* These are custom I/O routines for opaque user handles.
They get picked if there's some iohandle set. */
ssize_t (*r_read_handle) (void *handle, void *buf, size_t count);
off_t (*r_lseek_handle)(void *handle, off_t offset, int whence);
/* An optional cleaner for the handle on closing the stream. */
void (*cleanup_handle)(void *handle);
/* These two pointers are the actual workers (default map to POSIX read/lseek). */
ssize_t (*read) (int fd, void *buf, size_t count);
off_t (*lseek)(int fd, off_t offset, int whence);
/* Buffered readers want that abstracted, set internally. */
ssize_t (*fullread)(mpg123_handle *, unsigned char *, ssize_t);
#ifndef NO_FEEDER
struct bufferchain buffer; /* Not dynamically allocated, these few struct bytes aren't worth the trouble. */
#endif
};
 
/* start to use off_t to properly do LFS in future ... used to be long */
71,6 → 98,8
 
/* Open a file by path or use an opened file descriptor. */
int open_stream(mpg123_handle *, const char *path, int fd);
/* Open an external handle. */
int open_stream_handle(mpg123_handle *, void *iohandle);
 
/* feed based operation has some specials */
int open_feed(mpg123_handle *);
86,6 → 115,7
#define READER_SEEKABLE 0x4
#define READER_BUFFERED 0x8
#define READER_NONBLOCK 0x20
#define READER_HANDLEIO 0x40
 
#define READER_STREAM 0
#define READER_ICY_STREAM 1