ReactOS  0.4.14-dev-317-g96040ec
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 )

Definition at line 515 of file readers.c.

516 {
517  buffy_del_chain(bc->pool);
518  bc->pool = NULL;
519  bc->pool_fill = 0;
520 }
LPBATCH_CONTEXT bc
Definition: batch.c:66
smooth NULL
Definition: ftsmooth.c:416
static void buffy_del_chain(struct buffy *buf)
Definition: readers.c:486

◆ bc_fill()

size_t bc_fill ( struct bufferchain bc)

Definition at line 504 of file readers.c.

505 {
506  return (size_t)(bc->size - bc->pos);
507 }
LPBATCH_CONTEXT bc
Definition: batch.c:66

◆ bc_poolsize()

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

Definition at line 509 of file readers.c.

510 {
511  bc->pool_size = pool_size;
512  bc->bufblock = bufblock;
513 }
LPBATCH_CONTEXT bc
Definition: batch.c:66

Referenced by bc_prepare().

◆ bc_prepare()

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

Definition at line 496 of file readers.c.

497 {
498  bc_poolsize(bc, pool_size, bufblock);
499  bc->pool = NULL;
500  bc->pool_fill = 0;
501  bc_init(bc); /* Ensure that members are zeroed for read-only use. */
502 }
void bc_poolsize(struct bufferchain *bc, size_t pool_size, size_t bufblock)
Definition: readers.c:509
LPBATCH_CONTEXT bc
Definition: batch.c:66
smooth NULL
Definition: ftsmooth.c:416
static void bc_init(struct bufferchain *bc)
Definition: readers.c:584

◆ 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 760 of file readers.c.

761 {
762  int ret = 0;
763  if(VERBOSE3) debug("feed_more");
764  if((ret = bc_add(&fr->rdat.buffer, in, count)) != 0)
765  {
766  ret = READER_ERROR;
767  if(NOQUIET) error1("Failed to add buffer, return: %i", ret);
768  }
769  else /* Not talking about filelen... that stays at 0. */
770 
771  if(VERBOSE3) debug3("feed_more: %p %luB bufsize=%lu", fr->rdat.buffer.last->data,
772  (unsigned long)fr->rdat.buffer.last->size, (unsigned long)fr->rdat.buffer.size);
773  return ret;
774 }
#define error1(s, a)
Definition: debug.h:109
GLuint GLuint GLsizei count
Definition: gl.h:1545
struct reader_data rdat
Definition: frame.h:286
#define debug3(s, a, b, c)
Definition: debug.h:54
#define READER_ERROR
Definition: reader.h:134
#define VERBOSE3
#define NOQUIET
int ret
GLuint in
Definition: glext.h:9616
static int bc_add(struct bufferchain *bc, const unsigned char *data, ssize_t size)
Definition: readers.c:625
#define debug(msg)
Definition: key_call.c:71

◆ feed_set_pos()

off_t feed_set_pos ( mpg123_handle fr,
off_t  pos 
)

Definition at line 810 of file readers.c.

811 {
812  struct bufferchain *bc = &fr->rdat.buffer;
813  if(pos >= bc->fileoff && pos-bc->fileoff < bc->size)
814  { /* We have the position! */
815  bc->pos = (ssize_t)(pos - bc->fileoff);
816  debug1("feed_set_pos inside, next feed from %"OFF_P, (off_p)(bc->fileoff+bc->size));
817  return bc->fileoff+bc->size; /* Next input after end of buffer... */
818  }
819  else
820  { /* I expect to get the specific position on next feed. Forget what I have now. */
821  bc_reset(bc);
822  bc->fileoff = pos;
823  debug1("feed_set_pos outside, buffer reset, next feed from %"OFF_P, (off_p)pos);
824  return pos; /* Next input from exactly that position. */
825  }
826 }
LPBATCH_CONTEXT bc
Definition: batch.c:66
#define ssize_t
Definition: config.h:469
struct reader_data rdat
Definition: frame.h:286
static void bc_reset(struct bufferchain *bc)
Definition: readers.c:594
long off_p
Definition: compat.h:130
#define debug1(s, a)
Definition: debug.h:52
#define OFF_P
Definition: compat.h:129

◆ open_bad()

void open_bad ( mpg123_handle )

Definition at line 1104 of file readers.c.

1105 {
1106  debug("open_bad");
1107 #ifndef NO_ICY
1108  clear_icy(&mh->icy);
1109 #endif
1110  mh->rd = &bad_reader;
1111  mh->rdat.flags = 0;
1112 #ifndef NO_FEEDER
1113  bc_init(&mh->rdat.buffer);
1114 #endif
1115  mh->rdat.filelen = -1;
1116 }
static void bc_init(struct bufferchain *bc)
Definition: readers.c:584
static struct reader bad_reader
Definition: readers.c:1007
#define clear_icy
Definition: intsym.h:199
#define debug(msg)
Definition: key_call.c:71

◆ open_feed()

int open_feed ( mpg123_handle )

Definition at line 1118 of file readers.c.

1119 {
1120  debug("feed reader");
1121 #ifdef NO_FEEDER
1122  error("Buffered readers not supported in this build.");
1123  fr->err = MPG123_MISSING_FEATURE;
1124  return -1;
1125 #else
1126 #ifndef NO_ICY
1127  if(fr->p.icy_interval > 0)
1128  {
1129  if(NOQUIET) error("Feed reader cannot do ICY parsing!");
1130 
1131  return -1;
1132  }
1133  clear_icy(&fr->icy);
1134 #endif
1135  fr->rd = &readers[READER_FEED];
1136  fr->rdat.flags = 0;
1137  if(fr->rd->init(fr) < 0) return -1;
1138 
1139  debug("feed reader init successful");
1140  return 0;
1141 #endif /* NO_FEEDER */
1142 }
#define error(str)
Definition: mkdosfs.c:1605
#define READER_FEED
Definition: readers.c:905
static struct reader readers[]
Definition: readers.c:908
#define NOQUIET
#define clear_icy
Definition: intsym.h:199
#define debug(msg)
Definition: key_call.c:71

◆ open_stream()

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

Definition at line 1167 of file readers.c.

1168 {
1169  int filept_opened = 1;
1170  int filept; /* descriptor of opened file/stream */
1171 
1172  clear_icy(&fr->icy); /* can be done inside frame_clear ...? */
1173 
1174  if(!bs_filenam) /* no file to open, got a descriptor (stdin) */
1175  {
1176  filept = fd;
1177  filept_opened = 0; /* and don't try to close it... */
1178  }
1179  #ifndef O_BINARY
1180  #define O_BINARY (0)
1181  #endif
1182  else if((filept = compat_open(bs_filenam, O_RDONLY|O_BINARY)) < 0) /* a plain old file to open... */
1183  {
1184  if(NOQUIET) error2("Cannot open file %s: %s", bs_filenam, strerror(errno));
1185  fr->err = MPG123_BAD_FILE;
1186  return MPG123_ERR; /* error... */
1187  }
1188 
1189  /* now we have something behind filept and can init the reader */
1190  fr->rdat.filelen = -1;
1191  fr->rdat.filept = filept;
1192  fr->rdat.flags = 0;
1193  if(filept_opened) fr->rdat.flags |= READER_FD_OPENED;
1194 
1195  return open_finish(fr);
1196 }
static int open_finish(mpg123_handle *fr)
Definition: readers.c:1145
#define compat_open
Definition: intsym.h:12
#define O_BINARY
#define READER_FD_OPENED
Definition: reader.h:113
static int fd
Definition: io.c:51
int errno
const char * strerror(int err)
Definition: compat_str.c:23
#define error2(s, a, b)
Definition: debug.h:110
#define NOQUIET
#define clear_icy
Definition: intsym.h:199
#define O_RDONLY
Definition: acwin.h:108

◆ open_stream_handle()

int open_stream_handle ( mpg123_handle ,
void iohandle 
)

Definition at line 1198 of file readers.c.

1199 {
1200  clear_icy(&fr->icy); /* can be done inside frame_clear ...? */
1201  fr->rdat.filelen = -1;
1202  fr->rdat.filept = -1;
1203  fr->rdat.iohandle = iohandle;
1204  fr->rdat.flags = 0;
1205  fr->rdat.flags |= READER_HANDLEIO;
1206 
1207  return open_finish(fr);
1208 }
static int open_finish(mpg123_handle *fr)
Definition: readers.c:1145
#define READER_HANDLEIO
Definition: reader.h:118
#define clear_icy
Definition: intsym.h:199