summaryrefslogtreecommitdiffstats
path: root/kscd/libwm/include/wm_cdda.h
blob: 76a447eb42a2853b63908e8e0f9f69e87f9df91c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#ifndef WM_CDDA_H
#define WM_CDDA_H
/*
 * $Id$
 *
 * This file is part of WorkMan, the civilized CD player library
 * (c) 1991-1997 by Steven Grimm (original author)
 * (c) by Dirk Försterling (current 'author' = maintainer)
 * The maintainer can be contacted by his e-mail address:
 * milliByte@DeathsDoor.com 
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 *
 */

/*
 * Information about a particular block of CDDA data.
 */
struct cdda_block {
    unsigned char status;
    unsigned char track;
    unsigned char index;
    unsigned char reserved;

    int   frame;
    char *buf;
    long  buflen;
};

struct cdda_device {
    int        fd;
    const char *devname;
  
    unsigned char status;
    unsigned char track;
    unsigned char index;
    unsigned char command;
  
    int frame;
    int frames_at_once;

    /* Average volume levels, for level meters */
    unsigned char lev_chan0;
    unsigned char lev_chan1;

    /* Current volume setting (0-255) */
    unsigned char volume;

    /* Current balance setting (0-255, 128 = balanced) */
    unsigned char balance;
    
    struct cdda_block *blocks;
    int numblocks;
};

#include "wm_cdrom.h"
#include "wm_config.h"
#include "wm_struct.h"
/*
 * cdda_block status codes.
 */

/*
 * Enable or disable CDDA building depending on platform capabilities, and
 * determine endianness based on architecture.  (Gross!)
 *
 * For header-comfort, the macros LITTLE_ENDIAN and BIG_ENDIAN had to be
 * renamed. At least Linux does have bytesex.h and endian.h for easy
 * byte-order examination.
 */

#ifdef HAVE_MACHINE_ENDIAN_H
	#include <machine/endian.h>
	#if BYTE_ORDER == LITTLE_ENDIAN
		#define WM_LITTLE_ENDIAN 1
		#define WM_BIG_ENDIAN 0
	#else
		#define WM_LITTLE_ENDIAN 0
		#define WM_BIG_ENDIAN 1
	#endif
#elif defined(__sun) || defined(sun)
# ifdef SYSV
#  include <sys/types.h>
#  include <sys/cdio.h>
#  ifndef CDROMCDDA
#   undef BUILD_CDDA
#  endif
#  ifdef i386
#   define WM_LITTLE_ENDIAN 1
#   define WM_BIG_ENDIAN 0
#  else
#   define WM_BIG_ENDIAN 1
#   define WM_LITTLE_ENDIAN 0
#  endif
# else
#  undef BUILD_CDDA
# endif

/* Linux only allows definition of endianness, because there's no
 * standard interface for CDROM CDDA functions that aren't available
 * if there is no support.
 */
#elif defined(__linux__)
/*# include <bytesex.h>*/
# include <endian.h>
/*
 * XXX could this be a problem? The results are only 0 and 1 because
 * of the ! operator. How about other linux compilers than gcc ?
 */
# define WM_LITTLE_ENDIAN !(__BYTE_ORDER - __LITTLE_ENDIAN)
# define WM_BIG_ENDIAN !(__BYTE_ORDER - __BIG_ENDIAN)
#elif defined WORDS_BIGENDIAN
	#define WM_LITTLE_ENDIAN 0
	#define WM_BIG_ENDIAN 1
#else
	#define WM_LITTLE_ENDIAN 1
	#define WM_BIG_ENDIAN 0
#endif

/*
 * The following code shouldn't take effect now. 
 * In 1998, the WorkMan platforms don't support __PDP_ENDIAN
 * architectures.
 *
 */

#if !defined(WM_LITTLE_ENDIAN)
#  if !defined(WM_BIG_ENDIAN)
#    error yet unsupported architecture
	foo bar this is to stop the compiler. 
#  endif
#endif

#if defined(BUILD_CDDA)
/*
 * The following code support us by optimize cdda operations
 */
#define CDDARETURN(x) if(x && x->cdda == 1) return
#define IFCDDA(x) if(x && x->cdda == 1)
int cdda_get_drive_status(struct wm_drive *d, int oldmode,
	int *mode, int *pos, int *track, int *ind);
int cdda_play(struct wm_drive *d, int start, int end, int realstart);
int cdda_pause(struct wm_drive *d);
int cdda_stop(struct wm_drive *d);
int cdda_eject(struct wm_drive *d);
int cdda_set_volume(struct wm_drive *d, int left, int right);
int cdda_get_volume(struct wm_drive *d, int *left, int *right);
void cdda_kill(struct wm_drive *d);
void cdda_save(struct wm_drive *d, char *filename);
int cdda_get_ack(int);
int gen_cdda_init(struct wm_drive *d );

void cdda_set_direction(struct wm_drive *d, int newdir);
void cdda_set_speed(struct wm_drive *d, int speed);
void cdda_set_loudness(struct wm_drive *d, int loud);


int wmcdda_init(struct cdda_device*);
int wmcdda_open(const char*);
int wmcdda_close(struct cdda_device*);
int wmcdda_setup(int start, int end, int realstart);
long wmcdda_read(struct cdda_device*, struct cdda_block *block);
void wmcdda_speed(int speed);
void wmcdda_direction(int newdir);

#else
 #define CDDARETURN(x)
 #define IFCDDA(x)
 #define cdda_get_drive_status
 #define cdda_play
 #define cdda_pause
 #define cdda_resume
 #define cdda_stop
 #define cdda_eject
 #define cdda_set_volume
 #define cdda_get_volume
 #define cdda_kill
 #define cdda_save
 #define cdda_get_ack
#endif /* defined(BUILD_CDDA) */

#include <stdio.h>

#ifdef DEBUG
 #define DEBUGLOG(fmt, args...) fprintf(stderr, fmt, ##args)
#else
 #define DEBUGLOG(fmt, args...)
#endif
#define ERRORLOG(fmt, args...) fprintf(stderr, fmt, ##args)

#endif /* WM_CDDA_H */