ReactOS 0.4.15-dev-8145-ga541a46
reader.h File Reference
#include "config.h"
#include "mpg123.h"
Include dependency graph for reader.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  buffy
 
struct  bufferchain
 
struct  reader_data
 
struct  reader
 

Macros

#define READER_FD_OPENED   0x1
 
#define READER_ID3TAG   0x2
 
#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
 
#define READER_FEED   2
 
#define READER_BUF_STREAM   3
 
#define READER_BUF_ICY_STREAM   4
 
#define READERS   5
 
#define READER_ERROR   MPG123_ERR
 
#define READER_MORE   MPG123_NEED_MORE
 

Functions

void bc_prepare (struct bufferchain *, size_t pool_size, size_t bufblock)
 
void bc_cleanup (struct bufferchain *)
 
void bc_poolsize (struct bufferchain *, size_t pool_size, size_t bufblock)
 
size_t bc_fill (struct bufferchain *bc)
 
int open_stream (mpg123_handle *, const char *path, int fd)
 
int open_stream_handle (mpg123_handle *, void *iohandle)
 
int open_feed (mpg123_handle *)
 
int feed_more (mpg123_handle *fr, const unsigned char *in, long count)
 
void feed_forget (mpg123_handle *fr)
 
off_t feed_set_pos (mpg123_handle *fr, off_t pos)
 
void open_bad (mpg123_handle *)
 

Macro Definition Documentation

◆ READER_BUF_ICY_STREAM

#define READER_BUF_ICY_STREAM   4

Definition at line 125 of file reader.h.

◆ READER_BUF_STREAM

#define READER_BUF_STREAM   3

Definition at line 124 of file reader.h.

◆ READER_BUFFERED

#define READER_BUFFERED   0x8

Definition at line 116 of file reader.h.

◆ READER_ERROR

#define READER_ERROR   MPG123_ERR

Definition at line 134 of file reader.h.

◆ READER_FD_OPENED

#define READER_FD_OPENED   0x1

Definition at line 113 of file reader.h.

◆ READER_FEED

#define READER_FEED   2

Definition at line 122 of file reader.h.

◆ READER_HANDLEIO

#define READER_HANDLEIO   0x40

Definition at line 118 of file reader.h.

◆ READER_ICY_STREAM

#define READER_ICY_STREAM   1

Definition at line 121 of file reader.h.

◆ READER_ID3TAG

#define READER_ID3TAG   0x2

Definition at line 114 of file reader.h.

◆ READER_MORE

#define READER_MORE   MPG123_NEED_MORE

Definition at line 135 of file reader.h.

◆ READER_NONBLOCK

#define READER_NONBLOCK   0x20

Definition at line 117 of file reader.h.

◆ READER_SEEKABLE

#define READER_SEEKABLE   0x4

Definition at line 115 of file reader.h.

◆ READER_STREAM

#define READER_STREAM   0

Definition at line 120 of file reader.h.

◆ READERS

#define READERS   5

Definition at line 131 of file reader.h.

Function Documentation

◆ bc_cleanup()

void bc_cleanup ( struct bufferchain bc)

Definition at line 527 of file readers.c.

528{
529 buffy_del_chain(bc->pool);
530 bc->pool = NULL;
531 bc->pool_fill = 0;
532}
PBATCH_CONTEXT bc
Definition: batch.c:67
#define NULL
Definition: types.h:112
static void buffy_del_chain(struct buffy *buf)
Definition: readers.c:498

◆ bc_fill()

size_t bc_fill ( struct bufferchain bc)

Definition at line 516 of file readers.c.

517{
518 return (size_t)(bc->size - bc->pos);
519}

◆ bc_poolsize()

void bc_poolsize ( struct bufferchain bc,
size_t  pool_size,
size_t  bufblock 
)

Definition at line 521 of file readers.c.

522{
523 bc->pool_size = pool_size;
524 bc->bufblock = bufblock;
525}

◆ bc_prepare()

void bc_prepare ( struct bufferchain bc,
size_t  pool_size,
size_t  bufblock 
)

Definition at line 508 of file readers.c.

509{
510 bc_poolsize(bc, pool_size, bufblock);
511 bc->pool = NULL;
512 bc->pool_fill = 0;
513 bc_init(bc); /* Ensure that members are zeroed for read-only use. */
514}
#define bc_poolsize
Definition: intsym.h:249
static void bc_init(struct bufferchain *bc)
Definition: readers.c:596

◆ feed_forget()

void feed_forget ( mpg123_handle fr)

◆ feed_more()

int feed_more ( mpg123_handle fr,
const unsigned char in,
long  count 
)

Definition at line 772 of file readers.c.

773{
774 int ret = 0;
775 if(VERBOSE3) debug("feed_more");
776 if((ret = bc_add(&fr->rdat.buffer, in, count)) != 0)
777 {
779 if(NOQUIET) error1("Failed to add buffer, return: %i", ret);
780 }
781 else /* Not talking about filelen... that stays at 0. */
782
783 if(VERBOSE3) debug3("feed_more: %p %luB bufsize=%lu", fr->rdat.buffer.last->data,
784 (unsigned long)fr->rdat.buffer.last->size, (unsigned long)fr->rdat.buffer.size);
785 return ret;
786}
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint in
Definition: glext.h:9616
#define debug(msg)
Definition: key_call.c:71
#define NOQUIET
#define VERBOSE3
static int bc_add(struct bufferchain *bc, const unsigned char *data, ssize_t size)
Definition: readers.c:637
#define debug3(s, a, b, c)
Definition: debug.h:63
#define error1(s, a)
Definition: debug.h:125
#define READER_ERROR
Definition: reader.h:134
struct reader_data rdat
Definition: frame.h:288
int ret

◆ feed_set_pos()

off_t feed_set_pos ( mpg123_handle fr,
off_t  pos 
)

Definition at line 822 of file readers.c.

823{
824 struct bufferchain *bc = &fr->rdat.buffer;
825 if(pos >= bc->fileoff && pos-bc->fileoff < bc->size)
826 { /* We have the position! */
827 bc->pos = (ssize_t)(pos - bc->fileoff);
828 debug1("feed_set_pos inside, next feed from %"OFF_P, (off_p)(bc->fileoff+bc->size));
829 return bc->fileoff+bc->size; /* Next input after end of buffer... */
830 }
831 else
832 { /* I expect to get the specific position on next feed. Forget what I have now. */
833 bc_reset(bc);
834 bc->fileoff = pos;
835 debug1("feed_set_pos outside, buffer reset, next feed from %"OFF_P, (off_p)pos);
836 return pos; /* Next input from exactly that position. */
837 }
838}
static void bc_reset(struct bufferchain *bc)
Definition: readers.c:606
#define OFF_P
Definition: compat.h:131
long off_p
Definition: compat.h:132
#define ssize_t
Definition: config.h:517
#define debug1(s, a)
Definition: debug.h:61

◆ open_bad()

void open_bad ( mpg123_handle mh)

Definition at line 1123 of file readers.c.

1124{
1125 debug("open_bad");
1126#ifndef NO_ICY
1127 clear_icy(&mh->icy);
1128#endif
1129 mh->rd = &bad_reader;
1130 mh->rdat.flags = 0;
1131#ifndef NO_FEEDER
1132 bc_init(&mh->rdat.buffer);
1133#endif
1134 mh->rdat.filelen = -1;
1135}
#define clear_icy
Definition: intsym.h:209
static struct reader bad_reader
Definition: readers.c:1020
struct icy_meta icy
Definition: frame.h:303
struct reader * rd
Definition: frame.h:287

◆ open_feed()

int open_feed ( mpg123_handle fr)

Definition at line 1137 of file readers.c.

1138{
1139 debug("feed reader");
1140#ifdef NO_FEEDER
1141 if(NOQUIET)
1142 error("Buffered readers not supported in this build.");
1144 return -1;
1145#else
1146#ifndef NO_ICY
1147 if(fr->p.icy_interval > 0)
1148 {
1149 if(NOQUIET) error("Feed reader cannot do ICY parsing!");
1150
1151 return -1;
1152 }
1153 clear_icy(&fr->icy);
1154#endif
1155 fr->rd = &readers[READER_FEED];
1156 fr->rdat.flags = 0;
1157 if(fr->rd->init(fr) < 0) return -1;
1158
1159 debug("feed reader init successful");
1160 return 0;
1161#endif /* NO_FEEDER */
1162}
@ MPG123_MISSING_FEATURE
Definition: mpg123.h:421
#define error(str)
Definition: mkdosfs.c:1605
#define READER_FEED
Definition: readers.c:918
static struct reader readers[]
Definition: readers.c:921
struct mpg123_pars_struct p
Definition: frame.h:289

◆ open_stream()

int open_stream ( mpg123_handle fr,
const char path,
int  fd 
)

Definition at line 1187 of file readers.c.

1188{
1189 int filept_opened = 1;
1190 int filept; /* descriptor of opened file/stream */
1191
1192 clear_icy(&fr->icy); /* can be done inside frame_clear ...? */
1193
1194 if(!bs_filenam) /* no file to open, got a descriptor (stdin) */
1195 {
1196 filept = fd;
1197 filept_opened = 0; /* and don't try to close it... */
1198 }
1199 #ifndef O_BINARY
1200 #define O_BINARY (0)
1201 #endif
1202 else if((filept = compat_open(bs_filenam, O_RDONLY|O_BINARY)) < 0) /* a plain old file to open... */
1203 {
1204 if(NOQUIET) error2("Cannot open file %s: %s", bs_filenam, strerror(errno));
1205 fr->err = MPG123_BAD_FILE;
1206 return MPG123_ERR; /* error... */
1207 }
1208
1209 /* now we have something behind filept and can init the reader */
1210 fr->rdat.filelen = -1;
1211 fr->rdat.filept = filept;
1212 fr->rdat.flags = 0;
1213 if(filept_opened) fr->rdat.flags |= READER_FD_OPENED;
1214
1215 return open_finish(fr);
1216}
#define O_RDONLY
Definition: acwin.h:108
@ MPG123_ERR
Definition: mpg123.h:382
@ MPG123_BAD_FILE
Definition: mpg123.h:405
#define compat_open
Definition: intsym.h:13
const char * strerror(int err)
Definition: compat_str.c:23
#define O_BINARY
static int open_finish(mpg123_handle *fr)
Definition: readers.c:1165
#define errno
Definition: errno.h:18
#define error2(s, a, b)
Definition: debug.h:126
#define READER_FD_OPENED
Definition: reader.h:113
static int fd
Definition: io.c:51

◆ open_stream_handle()

int open_stream_handle ( mpg123_handle fr,
void iohandle 
)

Definition at line 1218 of file readers.c.

1219{
1220 clear_icy(&fr->icy); /* can be done inside frame_clear ...? */
1221 fr->rdat.filelen = -1;
1222 fr->rdat.filept = -1;
1223 fr->rdat.iohandle = iohandle;
1224 fr->rdat.flags = 0;
1225 fr->rdat.flags |= READER_HANDLEIO;
1226
1227 return open_finish(fr);
1228}
#define READER_HANDLEIO
Definition: reader.h:118