File indexing completed on 2024-04-21 04:54:21

0001 #ifndef WM_CDDA_H
0002 #define WM_CDDA_H
0003 /*
0004  * This file is part of WorkMan, the civilized CD player library
0005  * Copyright (C) 1991-1997 by Steven Grimm <koreth@midwinter.com>
0006  * Copyright (C) by Dirk Försterling <milliByte@DeathsDoor.com>
0007  * Copyright (C) 2004-2006 Alexander Kern <alex.kern@gmx.de>
0008  *
0009  * This library is free software; you can redistribute it and/or
0010  * modify it under the terms of the GNU Library General Public
0011  * License as published by the Free Software Foundation; either
0012  * version 2 of the License, or (at your option) any later version.
0013  *
0014  * This library is distributed in the hope that it will be useful,
0015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0017  * Library General Public License for more details.
0018  *
0019  * You should have received a copy of the GNU Library General Public
0020  * License along with this library; if not, write to the Free
0021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
0022  *
0023  */
0024 
0025 #include "wm_cdrom.h"
0026 #include "wm_config.h"
0027 #include "wm_struct.h"
0028 /*
0029  * cdda_block status codes.
0030  */
0031 
0032 /*
0033  * Enable or disable CDDA building depending on platform capabilities, and
0034  * determine endianness based on architecture.  (Gross!)
0035  *
0036  * For header-comfort, the macros LITTLE_ENDIAN and BIG_ENDIAN had to be
0037  * renamed. At least Linux does have bytesex.h and endian.h for easy
0038  * byte-order examination.
0039  */
0040 
0041 #ifdef HAVE_MACHINE_ENDIAN_H
0042     #include <machine/endian.h>
0043     #if BYTE_ORDER == LITTLE_ENDIAN
0044         #define WM_LITTLE_ENDIAN 1
0045         #define WM_BIG_ENDIAN 0
0046     #else
0047         #define WM_LITTLE_ENDIAN 0
0048         #define WM_BIG_ENDIAN 1
0049     #endif
0050 #elif defined(__sun) || defined(sun)
0051 # ifdef SYSV
0052 #  include <sys/types.h>
0053 #  include <sys/cdio.h>
0054 #  ifndef CDROMCDDA
0055 #    error what to do?
0056 #  endif
0057 #  ifdef i386
0058 #   define WM_LITTLE_ENDIAN 1
0059 #   define WM_BIG_ENDIAN 0
0060 #  else
0061 #   define WM_BIG_ENDIAN 1
0062 #   define WM_LITTLE_ENDIAN 0
0063 #  endif
0064 # endif
0065 
0066 /* Linux only allows definition of endianness, because there's no
0067  * standard interface for CDROM CDDA functions that aren't available
0068  * if there is no support.
0069  */
0070 #elif defined(__linux__)
0071 /*# include <bytesex.h>*/
0072 # include <endian.h>
0073 /*
0074  * XXX could this be a problem? The results are only 0 and 1 because
0075  * of the ! operator. How about other linux compilers than gcc ?
0076  */
0077 # define WM_LITTLE_ENDIAN !(__BYTE_ORDER - __LITTLE_ENDIAN)
0078 # define WM_BIG_ENDIAN !(__BYTE_ORDER - __BIG_ENDIAN)
0079 #elif defined WORDS_BIGENDIAN
0080     #define WM_LITTLE_ENDIAN 0
0081     #define WM_BIG_ENDIAN 1
0082 #else
0083     #define WM_LITTLE_ENDIAN 1
0084     #define WM_BIG_ENDIAN 0
0085 #endif
0086 
0087 /*
0088  * The following code shouldn't take effect now.
0089  * In 1998, the WorkMan platforms don't support __PDP_ENDIAN
0090  * architectures.
0091  *
0092  */
0093 
0094 #if !defined(WM_LITTLE_ENDIAN)
0095 #  if !defined(WM_BIG_ENDIAN)
0096 #    error yet unsupported architecture
0097     foo bar this is to stop the compiler.
0098 #  endif
0099 #endif
0100 
0101 /*
0102  * Information about a particular block of CDDA data.
0103  */
0104 struct cdda_block {
0105     unsigned char status;
0106     unsigned char track;
0107     unsigned char index;
0108     unsigned char reserved;
0109 
0110     int   frame;
0111     char *buf;
0112     long  buflen;
0113 };
0114 
0115 struct cdda_device {
0116     int        fd;
0117     int        cdda_slave;
0118     const char *devname;
0119 
0120     unsigned char status;
0121     unsigned char track;
0122     unsigned char index;
0123     unsigned char command;
0124 
0125     int frame;
0126     int frames_at_once;
0127 
0128     /* Average volume levels, for level meters */
0129     unsigned char lev_chan0;
0130     unsigned char lev_chan1;
0131 
0132     /* Current volume setting (0-255) */
0133     unsigned char volume;
0134 
0135     /* Current balance setting (0-255, 128 = balanced) */
0136     unsigned char balance;
0137 
0138     struct cdda_block *blocks;
0139     int numblocks;
0140 
0141     struct cdda_proto *proto;
0142 };
0143 
0144 #endif /* WM_CDDA_H */