"Fossies" - the Fresh Open Source Software Archive

Member "xorriso-1.5.4/libburn/libdax_audioxtr.h" (30 Jan 2021, 7763 Bytes) of package /linux/misc/xorriso-1.5.4.pl02.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "libdax_audioxtr.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.5.2_vs_1.5.4.

    1 
    2 /* libdax_audioxtr
    3    Audio track data extraction facility of libdax and libburn.
    4    Copyright (C) 2006 Thomas Schmitt <scdbackup@gmx.net>, provided under GPLv2+
    5 */
    6 
    7 #ifndef LIBDAX_AUDIOXTR_H_INCLUDED
    8 #define LIBDAX_AUDIOXTR_H_INCLUDED 1
    9 
   10 
   11 /* Normally this public API is defined in <libburn/libburn.h>
   12    Macro LIBDAX_AUDIOXTR_H_PUBLIC enables the definition for programs
   13    which only include this file.
   14 */
   15 #ifdef LIBDAX_AUDIOXTR_H_PUBLIC
   16 
   17                             /* Public Macros */
   18 
   19 /* Maximum size for address paths and fmt_info strings */
   20 #define LIBDAX_AUDIOXTR_STRLEN 4096
   21 
   22 
   23                           /* Public Opaque Handles */
   24 
   25 /** Extractor object encapsulating intermediate states of extraction.
   26     The clients of libdax_audioxtr shall only allocate pointers to this
   27     struct and get a storage object via libdax_audioxtr_new().
   28     Appropriate initial value for the pointer is NULL.
   29 */
   30 struct libdax_audioxtr;
   31 
   32 
   33                             /* Public Functions */
   34 
   35                /* Calls initiated from inside libdax/libburn */
   36 
   37 
   38      /* Calls from applications (to be forwarded by libdax/libburn) */
   39 
   40 
   41 /** Open an audio file, check whether suitable, create extractor object.
   42     @param xtr Opaque handle to extractor. Gets attached extractor object.
   43     @param path Address of the audio file to extract. "-" is stdin (but might
   44                 be not suitable for all futurely supported formats).
   45     @param flag Bitfield for control purposes (unused yet, submit 0)
   46     @return >0 success
   47              0 unsuitable format
   48             -1 severe error
   49             -2 path not found
   50 */
   51 int libdax_audioxtr_new(struct libdax_audioxtr **xtr, char *path, int flag);
   52 
   53 
   54 /** Obtain identification parameters of opened audio source.
   55     @param xtr Opaque handle to extractor
   56     @param fmt Gets pointed to the audio file format id text: ".wav" , ".au"
   57     @param fmt_info Gets pointed to a format info text telling parameters
   58     @param num_channels     e.g. 1=mono, 2=stereo, etc
   59     @param sample_rate      e.g. 11025, 44100 
   60     @param bits_per_sample  e.g. 8= 8 bits per sample, 16= 16 bits ...
   61     @param msb_first Byte order of samples: 0=Intel 1=Motorola 
   62     @param flag Bitfield for control purposes (unused yet, submit 0)
   63     @return >0 success, <=0 failure
   64 */
   65 int libdax_audioxtr_get_id(struct libdax_audioxtr *xtr,
   66                            char **fmt, char **fmt_info,
   67                            int *num_channels, int *sample_rate,
   68                            int *bits_per_sample, int *msb_first, int flag);
   69 
   70 
   71 /** Obtain a prediction about the extracted size based on internal information
   72     of the formatted file.
   73     @param xtr Opaque handle to extractor
   74     @param size Gets filled with the predicted size
   75     @param flag Bitfield for control purposes (unused yet, submit 0)
   76     @return 1 prediction was possible , 0 no prediction could be made
   77 */
   78 int libdax_audioxtr_get_size(struct libdax_audioxtr *o, off_t *size, int flag);
   79 
   80 
   81 /** Obtain next buffer full of extracted data in desired format (only raw audio
   82     for now).
   83     @param xtr Opaque handle to extractor
   84     @param buffer Gets filled with extracted data
   85     @param buffer_size Maximum number of bytes to be filled into buffer
   86     @param flag Bitfield for control purposes
   87                 bit0= do not stop at predicted end of data
   88     @return >0 number of valid buffer bytes,
   89              0 End of file
   90             -1 operating system reports error
   91             -2 usage error by application
   92 */
   93 int libdax_audioxtr_read(struct libdax_audioxtr *xtr,
   94                          char buffer[], int buffer_size, int flag);
   95 
   96 
   97 /** Try to obtain a file descriptor which will deliver extracted data
   98     to normal calls of read(2). This may fail because the format is
   99     unsuitable for that, but ".wav" is ok. If this call succeeds the xtr
  100     object will have forgotten its file descriptor and libdax_audioxtr_read()
  101     will return a usage error. One may use *fd after libdax_audioxtr_destroy()
  102     and will have to close it via close(2) when done with it.
  103     @param xtr Opaque handle to extractor
  104     @param fd Eventually returns the file descriptor number
  105     @param flag Bitfield for control purposes
  106                 bit0= do not dup(2) and close(2) but hand out original fd
  107     @return 1 success, 0 cannot hand out fd , -1 severe error
  108 */
  109 int libdax_audioxtr_detach_fd(struct libdax_audioxtr *o, int *fd, int flag);
  110 
  111 
  112 /** Clean up after extraction and destroy extractor object.
  113     @param xtr Opaque handle to extractor, *xtr is allowed to be NULL,
  114                *xtr is set to NULL by this function
  115     @param flag Bitfield for control purposes (unused yet, submit 0)
  116     @return 1 = destroyed object, 0 = was already destroyed
  117 */
  118 int libdax_audioxtr_destroy(struct libdax_audioxtr **xtr, int flag);
  119 
  120 #endif /* LIBDAX_AUDIOXTR_H_PUBLIC */
  121 
  122 
  123 #ifdef LIBDAX_AUDIOXTR________________
  124 
  125 
  126 -- place documentation text here ---
  127 
  128 
  129 #endif /* LIBDAX_AUDIOXTR_________________ */
  130 
  131 
  132 
  133 /*
  134   *Never* set this macro outside libdax_audioxtr.c !
  135   The entrails of this facility are not to be seen by
  136   the other library components or the applications.
  137 */
  138 #ifdef LIBDAX_AUDIOXTR_H_INTERNAL
  139 
  140                        /* Internal Structures */
  141 
  142 /** Extractor object encapsulating intermediate states of extraction */
  143 struct libdax_audioxtr {
  144 
  145  /* Source of the encoded audio data */
  146  char path[LIBDAX_AUDIOXTR_STRLEN];
  147 
  148  /* File descriptor to path. Anything else than 0 must be lseek-able */
  149  int fd;
  150 
  151  /* Format identifier. E.g. ".wav" */
  152  char fmt[80];
  153 
  154  /* Format parameter info text */
  155  char fmt_info[LIBDAX_AUDIOXTR_STRLEN];
  156 
  157  /* 1= mono, 2= stereo, etc. */
  158  int num_channels;
  159 
  160  /* 8000, 44100, etc. */
  161  int sample_rate;
  162 
  163  /* 8 bits = 8, 16 bits = 16, etc. */
  164  int bits_per_sample;
  165 
  166  /* Byte order of samples: 0=Intel 1=Motorola */
  167  int msb_first;
  168 
  169  /* Number of bytes to extract (0= unknown/unlimited) */
  170  off_t data_size;
  171 
  172  /* Number of extracted data bytes */
  173  off_t extract_count;
  174 
  175 
  176  /* Format dependent parameters */
  177 
  178  /* MS WAVE Format */
  179  /* see description in: doc/waveformat.txt */
  180 
  181  /* Offset to "data" subchunk */
  182  unsigned int wav_data_location;
  183 
  184  /* == NumSamples * NumChannels * BitsPerSample/8
  185     This is the number of bytes in the data. */
  186  unsigned wav_subchunk2_size;
  187 
  188 
  189  /* Sun Audio, .au */
  190  /* info used: http://www.opengroup.org/public/pubs/external/auformat.html */
  191 
  192  /* Number of bytes in non-payload header part */
  193  unsigned au_data_location;
  194 
  195  /* Number of payload bytes or 0xffffffff */
  196  unsigned au_data_size;
  197 
  198 };
  199 
  200 
  201                              /* Internal Functions */
  202 
  203 /** Open the audio source pointed to by .path and evaluate suitability.
  204     @return -1 failure to open, 0 unsuitable format, 1 success
  205 */
  206 static int libdax_audioxtr_open(struct libdax_audioxtr *o, int flag);
  207 
  208 
  209 /** Identify format and evaluate suitability.
  210     @return 0 unsuitable format, 1 format is suitable
  211 */
  212 static int libdax_audioxtr_identify(struct libdax_audioxtr *o, int flag);
  213 
  214 /** Specialized identifier for .wav */
  215 static int libdax_audioxtr_identify_wav(struct libdax_audioxtr *o, int flag);
  216 /** Specialized identifier for .au */
  217 static int libdax_audioxtr_identify_au(struct libdax_audioxtr *o, int flag);
  218 
  219 
  220 /** Convert a byte string into a number (currently only little endian)
  221     @param flag Bitfield for control purposes
  222                 bit0=msb_first
  223     @return The resulting number
  224 */
  225 static unsigned libdax_audioxtr_to_int(struct libdax_audioxtr *o,
  226                                       unsigned char *bytes, int len, int flag);
  227 
  228 
  229 /** Prepare for reading of first buffer.
  230     @return 0 error, 1 success
  231 */
  232 static int libdax_audioxtr_init_reading(struct libdax_audioxtr *o, int flag);
  233 
  234 
  235 
  236 #endif /* LIBDAX_AUDIOXTR_H_INTERNAL */
  237 
  238 
  239 #endif /* ! LIBDAX_AUDIOXTR_H_INCLUDED */
  240