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