]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/rbaudio.c
formatting
[btb/d2x.git] / arch / sdl / rbaudio.c
1 /* $Id: rbaudio.c,v 1.3 2003-01-15 02:42:41 btb Exp $ */
2 /*
3  *
4  * SDL CD Audio functions
5  *
6  *
7  */
8
9 #ifdef HAVE_CONFIG_H
10 #include <conf.h>
11 #endif
12
13 #include <stdio.h>
14 #include <stdlib.h>
15
16 #include <SDL.h>
17
18 #include "pstypes.h"
19 #include "error.h"
20 #include "args.h"
21 #include "rbaudio.h"
22
23 static SDL_CD *s_cd = NULL;
24 extern int Redbook_playing;
25 static int initialised = 0;
26
27 void RBAExit()
28 {
29   if (initialised)
30   {
31         SDL_CDClose(s_cd);
32   }
33 }
34
35 void RBAInit()
36 {
37         if (initialised) return;
38         if (FindArg("-nocdrom")) return; 
39
40         if (SDL_Init(SDL_INIT_CDROM) < 0)
41         {
42                 Warning("SDL library initialisation failed: %s.",SDL_GetError());
43                 return;
44         }
45
46         if (SDL_CDNumDrives() == 0)
47         {
48                 Warning("No cdrom drives found!\n");
49                 return;
50         }
51         s_cd = SDL_CDOpen(0);
52         if (s_cd == NULL) {
53                 Warning("Could not open cdrom for redbook audio!\n");
54                 return;
55         }
56         atexit(RBAExit);
57         initialised = 1;
58 }
59
60 int RBAEnabled()
61 {
62  return 1;
63 }
64
65 void RBARegisterCD()
66 {
67
68 }
69
70 int RBAPlayTrack(int a)
71 {
72  if (!initialised) return -1;
73
74  if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
75          SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0);
76  }
77  return a;
78  
79 }
80
81 void RBAStop()
82 {
83   if (!initialised) return;
84   SDL_CDStop(s_cd);
85 }
86
87 void RBASetVolume(int a)
88 {
89
90 }
91
92 void RBAPause()
93 {
94   if (!initialised) return;
95   SDL_CDPause(s_cd);
96 }
97
98 int RBAResume()
99 {
100   if (!initialised) return -1;
101   SDL_CDResume(s_cd);
102   return 1;
103 }
104
105 int RBAGetNumberOfTracks()
106 {
107   if (!initialised) return -1;
108  SDL_CDStatus(s_cd);
109  return s_cd->numtracks;
110 }
111
112 int RBAPlayTracks(int tracknum,int something)
113 {
114   if (!initialised) return -1;
115  if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
116          SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0);
117  }
118  return tracknum;
119 }
120
121 int RBAGetTrackNum()
122 {
123   if (!initialised) return -1;
124  SDL_CDStatus(s_cd);
125  return s_cd->cur_track;
126 }
127
128 int RBAPeekPlayStatus()
129 {
130   return (SDL_CDStatus(s_cd) == CD_PLAYING);
131 }
132
133 int CD_blast_mixer()
134 {
135  return 0;
136 }