include/SDL_cdrom.h
author Ryan C. Gordon <icculus@icculus.org>
Tue, 27 Sep 2005 12:14:17 +0000
changeset 1147 b580f7201543
parent 1046 f09d5edfc7a3
child 1312 c9b51268668f
permissions -rw-r--r--
From: "Alex Volkov" <avcp-sdlmail@usa.net>
To: "'A list for developers using the SDL library. \(includesSDL-announce\)'" <sdl@libsdl.org>
Date: Mon, 19 Sep 2005 18:59:43 -0400
Subject: [SDL] [patch] Volume multiplier bug in

The volume multiplier in SDL_MixAudio_MMX_S8() is formed from the wrong
register.
slouken@0
     1
/*
slouken@0
     2
    SDL - Simple DirectMedia Layer
slouken@769
     3
    Copyright (C) 1997-2004 Sam Lantinga
slouken@0
     4
slouken@0
     5
    This library is free software; you can redistribute it and/or
slouken@0
     6
    modify it under the terms of the GNU Library General Public
slouken@0
     7
    License as published by the Free Software Foundation; either
slouken@0
     8
    version 2 of the License, or (at your option) any later version.
slouken@0
     9
slouken@0
    10
    This library is distributed in the hope that it will be useful,
slouken@0
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@0
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
slouken@0
    13
    Library General Public License for more details.
slouken@0
    14
slouken@0
    15
    You should have received a copy of the GNU Library General Public
slouken@0
    16
    License along with this library; if not, write to the Free
slouken@0
    17
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
slouken@0
    18
slouken@0
    19
    Sam Lantinga
slouken@251
    20
    slouken@libsdl.org
slouken@0
    21
*/
slouken@0
    22
slouken@0
    23
#ifdef SAVE_RCSID
slouken@0
    24
static char rcsid =
slouken@0
    25
 "@(#) $Id$";
slouken@0
    26
#endif
slouken@0
    27
slouken@0
    28
/* This is the CD-audio control API for Simple DirectMedia Layer */
slouken@0
    29
slouken@0
    30
#ifndef _SDL_cdrom_h
slouken@0
    31
#define _SDL_cdrom_h
slouken@0
    32
slouken@0
    33
#include "SDL_types.h"
slouken@0
    34
slouken@0
    35
#include "begin_code.h"
slouken@0
    36
/* Set up for C function definitions, even when using C++ */
slouken@0
    37
#ifdef __cplusplus
slouken@0
    38
extern "C" {
slouken@0
    39
#endif
slouken@0
    40
slouken@0
    41
/* In order to use these functions, SDL_Init() must have been called
slouken@0
    42
   with the SDL_INIT_CDROM flag.  This causes SDL to scan the system
slouken@0
    43
   for CD-ROM drives, and load appropriate drivers.
slouken@0
    44
*/
slouken@0
    45
slouken@0
    46
/* The maximum number of CD-ROM tracks on a disk */
slouken@0
    47
#define SDL_MAX_TRACKS	99
slouken@0
    48
slouken@0
    49
/* The types of CD-ROM track possible */
slouken@0
    50
#define SDL_AUDIO_TRACK	0x00
slouken@0
    51
#define SDL_DATA_TRACK	0x04
slouken@0
    52
slouken@0
    53
/* The possible states which a CD-ROM drive can be in. */
slouken@0
    54
typedef enum {
slouken@0
    55
	CD_TRAYEMPTY,
slouken@0
    56
	CD_STOPPED,
slouken@0
    57
	CD_PLAYING,
slouken@0
    58
	CD_PAUSED,
slouken@0
    59
	CD_ERROR = -1
slouken@0
    60
} CDstatus;
slouken@0
    61
slouken@0
    62
/* Given a status, returns true if there's a disk in the drive */
icculus@1046
    63
#define CD_INDRIVE(status)	((int)(status) > 0)
slouken@0
    64
slouken@911
    65
typedef struct SDL_CDtrack {
slouken@0
    66
	Uint8 id;		/* Track number */
slouken@0
    67
	Uint8 type;		/* Data or audio track */
slouken@0
    68
	Uint16 unused;
slouken@0
    69
	Uint32 length;		/* Length, in frames, of this track */
slouken@0
    70
	Uint32 offset;		/* Offset, in frames, from start of disk */
slouken@0
    71
} SDL_CDtrack;
slouken@0
    72
slouken@0
    73
/* This structure is only current as of the last call to SDL_CDStatus() */
slouken@0
    74
typedef struct SDL_CD {
slouken@0
    75
	int id;			/* Private drive identifier */
slouken@0
    76
	CDstatus status;	/* Current drive status */
slouken@0
    77
slouken@0
    78
	/* The rest of this structure is only valid if there's a CD in drive */
slouken@0
    79
	int numtracks;		/* Number of tracks on disk */
slouken@0
    80
	int cur_track;		/* Current track position */
slouken@0
    81
	int cur_frame;		/* Current frame offset within current track */
slouken@0
    82
	SDL_CDtrack track[SDL_MAX_TRACKS+1];
slouken@0
    83
} SDL_CD;
slouken@0
    84
slouken@0
    85
/* Conversion functions from frames to Minute/Second/Frames and vice versa */
slouken@0
    86
#define CD_FPS	75
slouken@0
    87
#define FRAMES_TO_MSF(f, M,S,F)	{					\
slouken@0
    88
	int value = f;							\
slouken@0
    89
	*(F) = value%CD_FPS;						\
slouken@0
    90
	value /= CD_FPS;						\
slouken@0
    91
	*(S) = value%60;						\
slouken@0
    92
	value /= 60;							\
slouken@0
    93
	*(M) = value;							\
slouken@0
    94
}
slouken@0
    95
#define MSF_TO_FRAMES(M, S, F)	((M)*60*CD_FPS+(S)*CD_FPS+(F))
slouken@0
    96
slouken@0
    97
/* CD-audio API functions: */
slouken@0
    98
slouken@0
    99
/* Returns the number of CD-ROM drives on the system, or -1 if
slouken@0
   100
   SDL_Init() has not been called with the SDL_INIT_CDROM flag.
slouken@0
   101
 */
slouken@337
   102
extern DECLSPEC int SDLCALL SDL_CDNumDrives(void);
slouken@0
   103
slouken@0
   104
/* Returns a human-readable, system-dependent identifier for the CD-ROM.
slouken@0
   105
   Example:
slouken@0
   106
	"/dev/cdrom"
slouken@0
   107
	"E:"
slouken@0
   108
	"/dev/disk/ide/1/master"
slouken@0
   109
*/
slouken@337
   110
extern DECLSPEC const char * SDLCALL SDL_CDName(int drive);
slouken@0
   111
slouken@0
   112
/* Opens a CD-ROM drive for access.  It returns a drive handle on success,
slouken@0
   113
   or NULL if the drive was invalid or busy.  This newly opened CD-ROM
slouken@0
   114
   becomes the default CD used when other CD functions are passed a NULL
slouken@0
   115
   CD-ROM handle.
slouken@0
   116
   Drives are numbered starting with 0.  Drive 0 is the system default CD-ROM.
slouken@0
   117
*/
slouken@337
   118
extern DECLSPEC SDL_CD * SDLCALL SDL_CDOpen(int drive);
slouken@0
   119
slouken@0
   120
/* This function returns the current status of the given drive.
slouken@0
   121
   If the drive has a CD in it, the table of contents of the CD and current
slouken@0
   122
   play position of the CD will be stored in the SDL_CD structure.
slouken@0
   123
*/
slouken@337
   124
extern DECLSPEC CDstatus SDLCALL SDL_CDStatus(SDL_CD *cdrom);
slouken@0
   125
slouken@0
   126
/* Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
slouken@0
   127
   tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play 
slouken@0
   128
   until the end of the CD.  This function will skip data tracks.
slouken@0
   129
   This function should only be called after calling SDL_CDStatus() to 
slouken@0
   130
   get track information about the CD.
slouken@0
   131
   For example:
slouken@0
   132
	// Play entire CD:
slouken@0
   133
	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
slouken@0
   134
		SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
slouken@0
   135
	// Play last track:
slouken@0
   136
	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
slouken@0
   137
		SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
slouken@0
   138
	}
slouken@0
   139
	// Play first and second track and 10 seconds of third track:
slouken@0
   140
	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
slouken@0
   141
		SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
slouken@0
   142
slouken@0
   143
   This function returns 0, or -1 if there was an error.
slouken@0
   144
*/
slouken@337
   145
extern DECLSPEC int SDLCALL SDL_CDPlayTracks(SDL_CD *cdrom,
slouken@0
   146
		int start_track, int start_frame, int ntracks, int nframes);
slouken@0
   147
slouken@0
   148
/* Play the given CD starting at 'start' frame for 'length' frames.
slouken@0
   149
   It returns 0, or -1 if there was an error.
slouken@0
   150
*/
slouken@337
   151
extern DECLSPEC int SDLCALL SDL_CDPlay(SDL_CD *cdrom, int start, int length);
slouken@0
   152
slouken@0
   153
/* Pause play -- returns 0, or -1 on error */
slouken@337
   154
extern DECLSPEC int SDLCALL SDL_CDPause(SDL_CD *cdrom);
slouken@0
   155
slouken@0
   156
/* Resume play -- returns 0, or -1 on error */
slouken@337
   157
extern DECLSPEC int SDLCALL SDL_CDResume(SDL_CD *cdrom);
slouken@0
   158
slouken@0
   159
/* Stop play -- returns 0, or -1 on error */
slouken@337
   160
extern DECLSPEC int SDLCALL SDL_CDStop(SDL_CD *cdrom);
slouken@0
   161
slouken@0
   162
/* Eject CD-ROM -- returns 0, or -1 on error */
slouken@337
   163
extern DECLSPEC int SDLCALL SDL_CDEject(SDL_CD *cdrom);
slouken@0
   164
slouken@0
   165
/* Closes the handle for the CD-ROM drive */
slouken@337
   166
extern DECLSPEC void SDLCALL SDL_CDClose(SDL_CD *cdrom);
slouken@0
   167
slouken@0
   168
slouken@0
   169
/* Ends C function definitions when using C++ */
slouken@0
   170
#ifdef __cplusplus
slouken@0
   171
}
slouken@0
   172
#endif
slouken@0
   173
#include "close_code.h"
slouken@0
   174
slouken@0
   175
#endif /* _SDL_video_h */