ReactOS 0.4.15-dev-8222-g9164419
reader.h
Go to the documentation of this file.
1/*
2 reader: reading input data
3
4 copyright ?-2007 by the mpg123 project - free software under the terms of the LGPL 2.1
5 see COPYING and AUTHORS files in distribution or http://mpg123.org
6 initially written by Thomas Orgis (after code from Michael Hipp)
7*/
8
9#ifndef MPG123_READER_H
10#define MPG123_READER_H
11
12#include "config.h"
13#include "mpg123.h"
14
15#ifndef NO_FEEDER
16struct buffy
17{
18 unsigned char *data;
21 struct buffy *next;
22};
23
24
26{
27 struct buffy* first; /* The beginning of the chain. */
28 struct buffy* last; /* The end... of the chain. */
29 ssize_t size; /* Aggregated size of all buffies. */
30 /* These positions are relative to buffer chain beginning. */
31 ssize_t pos; /* Position in whole chain. */
32 ssize_t firstpos; /* The point of return on non-forget() */
33 /* The "real" filepos is fileoff + pos. */
34 off_t fileoff; /* Beginning of chain is at this file offset. */
35 size_t bufblock; /* Default (minimal) size of buffers. */
36 size_t pool_size; /* Keep that many buffers in storage. */
37 size_t pool_fill; /* That many buffers are there. */
38 /* A pool of buffers to re-use, if activated. It's a linked list that is worked on from the front. */
39 struct buffy *pool;
40};
41
42/* Call this before any buffer chain use (even bc_init()). */
43void bc_prepare(struct bufferchain *, size_t pool_size, size_t bufblock);
44/* Free persistent data in the buffer chain, after bc_reset(). */
45void bc_cleanup(struct bufferchain *);
46/* Change pool size. This does not actually allocate/free anything on itself, just instructs later operations to free less / allocate more buffers. */
47void bc_poolsize(struct bufferchain *, size_t pool_size, size_t bufblock);
48/* Return available byte count in the buffer. */
49size_t bc_fill(struct bufferchain *bc);
50
51#endif
52
54{
55 off_t filelen; /* total file length or total buffer size */
56 off_t filepos; /* position in file or position in buffer chain */
57 int filept;
58 /* Custom opaque I/O handle from the client. */
59 void *iohandle;
60 int flags;
63 /* User can replace the read and lseek functions. The r_* are the stored replacement functions or NULL. */
64 ssize_t (*r_read) (int fd, void *buf, size_t count);
65 off_t (*r_lseek)(int fd, off_t offset, int whence);
66 /* These are custom I/O routines for opaque user handles.
67 They get picked if there's some iohandle set. */
68 ssize_t (*r_read_handle) (void *handle, void *buf, size_t count);
69 off_t (*r_lseek_handle)(void *handle, off_t offset, int whence);
70 /* An optional cleaner for the handle on closing the stream. */
72 /* These two pointers are the actual workers (default map to POSIX read/lseek). */
73 ssize_t (*read) (int fd, void *buf, size_t count);
74 off_t (*lseek)(int fd, off_t offset, int whence);
75 /* Buffered readers want that abstracted, set internally. */
76 ssize_t (*fullread)(mpg123_handle *, unsigned char *, ssize_t);
77#ifndef NO_FEEDER
78 struct bufferchain buffer; /* Not dynamically allocated, these few struct bytes aren't worth the trouble. */
79#endif
80};
81
82/* start to use off_t to properly do LFS in future ... used to be long */
83struct reader
84{
87 ssize_t (*fullread) (mpg123_handle *, unsigned char *, ssize_t);
88 int (*head_read) (mpg123_handle *, unsigned long *newhead); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */
89 int (*head_shift) (mpg123_handle *, unsigned long *head); /* succ: TRUE, else <= 0 (FALSE or READER_MORE) */
90 off_t (*skip_bytes) (mpg123_handle *, off_t len); /* succ: >=0, else error or READER_MORE */
91 int (*read_frame_body)(mpg123_handle *, unsigned char *, int size);
97};
98
99/* Open a file by path or use an opened file descriptor. */
100int open_stream(mpg123_handle *, const char *path, int fd);
101/* Open an external handle. */
102int open_stream_handle(mpg123_handle *, void *iohandle);
103
104/* feed based operation has some specials */
106/* externally called function, returns 0 on success, -1 on error */
107int feed_more(mpg123_handle *fr, const unsigned char *in, long count);
108void feed_forget(mpg123_handle *fr); /* forget the data that has been read (free some buffers) */
109off_t feed_set_pos(mpg123_handle *fr, off_t pos); /* Set position (inside available data if possible), return wanted byte offset of next feed. */
110
111void open_bad(mpg123_handle *);
112
113#define READER_FD_OPENED 0x1
114#define READER_ID3TAG 0x2
115#define READER_SEEKABLE 0x4
116#define READER_BUFFERED 0x8
117#define READER_NONBLOCK 0x20
118#define READER_HANDLEIO 0x40
119
120#define READER_STREAM 0
121#define READER_ICY_STREAM 1
122#define READER_FEED 2
123/* These two add a little buffering to enable small seeks for peek ahead. */
124#define READER_BUF_STREAM 3
125#define READER_BUF_ICY_STREAM 4
126
127#ifdef READ_SYSTEM
128#define READER_SYSTEM 5
129#define READERS 6
130#else
131#define READERS 5
132#endif
133
134#define READER_ERROR MPG123_ERR
135#define READER_MORE MPG123_NEED_MORE
136
137#endif
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
struct outqueuenode * head
Definition: adnsresfilter.c:66
PBATCH_CONTEXT bc
Definition: batch.c:67
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
#define off_t
Definition: dosfsck.h:5
__kernel_size_t size_t
Definition: linux.h:237
__kernel_off_t off_t
Definition: linux.h:201
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLuint buffer
Definition: glext.h:5915
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLuint in
Definition: glext.h:9616
GLuint GLuint num
Definition: glext.h:9618
GLenum GLsizei len
Definition: glext.h:6722
GLintptr offset
Definition: glext.h:5920
#define open_stream_handle
Definition: intsym.h:252
#define bc_fill
Definition: intsym.h:250
#define bc_cleanup
Definition: intsym.h:248
#define open_feed
Definition: intsym.h:253
#define bc_prepare
Definition: intsym.h:247
#define feed_forget
Definition: intsym.h:255
#define bc_poolsize
Definition: intsym.h:249
#define open_bad
Definition: intsym.h:257
#define open_stream
Definition: intsym.h:251
#define feed_set_pos
Definition: intsym.h:256
#define feed_more
Definition: intsym.h:254
int ssize_t
Definition: rosdhcp.h:48
#define ssize_t
Definition: config.h:517
static int fd
Definition: io.c:51
struct buffy * last
Definition: reader.h:28
ssize_t size
Definition: reader.h:29
ssize_t pos
Definition: reader.h:31
ssize_t firstpos
Definition: reader.h:32
off_t fileoff
Definition: reader.h:34
size_t pool_size
Definition: reader.h:36
struct buffy * first
Definition: reader.h:27
size_t pool_fill
Definition: reader.h:37
struct buffy * pool
Definition: reader.h:39
size_t bufblock
Definition: reader.h:35
Definition: reader.h:17
struct buffy * next
Definition: reader.h:21
ssize_t realsize
Definition: reader.h:20
unsigned char * data
Definition: reader.h:18
ssize_t size
Definition: reader.h:19
ssize_t(* r_read)(int fd, void *buf, size_t count)
Definition: reader.h:64
ssize_t(* r_read_handle)(void *handle, void *buf, size_t count)
Definition: reader.h:68
off_t filepos
Definition: reader.h:56
ssize_t(* fdread)(mpg123_handle *, void *, size_t)
Definition: reader.h:62
ssize_t(* read)(int fd, void *buf, size_t count)
Definition: reader.h:73
ssize_t(* fullread)(mpg123_handle *, unsigned char *, ssize_t)
Definition: reader.h:76
long timeout_sec
Definition: reader.h:61
int flags
Definition: reader.h:60
off_t filelen
Definition: reader.h:55
int filept
Definition: reader.h:57
off_t(* lseek)(int fd, off_t offset, int whence)
Definition: reader.h:74
void * iohandle
Definition: reader.h:59
off_t(* r_lseek)(int fd, off_t offset, int whence)
Definition: reader.h:65
void(* cleanup_handle)(void *handle)
Definition: reader.h:71
off_t(* r_lseek_handle)(void *handle, off_t offset, int whence)
Definition: reader.h:69
Definition: reader.h:84
int(* head_shift)(mpg123_handle *, unsigned long *head)
Definition: reader.h:89
int(* seek_frame)(mpg123_handle *, off_t num)
Definition: reader.h:93
off_t(* skip_bytes)(mpg123_handle *, off_t len)
Definition: reader.h:90
int(* init)(mpg123_handle *)
Definition: reader.h:85
void(* close)(mpg123_handle *)
Definition: reader.h:86
ssize_t(* fullread)(mpg123_handle *, unsigned char *, ssize_t)
Definition: reader.h:87
void(* rewind)(mpg123_handle *)
Definition: reader.h:95
int(* read_frame_body)(mpg123_handle *, unsigned char *, int size)
Definition: reader.h:91
void(* forget)(mpg123_handle *)
Definition: reader.h:96
int(* back_bytes)(mpg123_handle *, off_t bytes)
Definition: reader.h:92
int(* head_read)(mpg123_handle *, unsigned long *newhead)
Definition: reader.h:88
off_t(* tell)(mpg123_handle *)
Definition: reader.h:94