]> icculus.org git repositories - btb/d2x.git/blob - arch/sdl/rbaudio.c
fix compiler warning
[btb/d2x.git] / arch / sdl / rbaudio.c
1 /* $Id: rbaudio.c,v 1.2 2002-08-04 23:19:37 btb 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         if (s_cd == NULL) {
51                 Warning("Could not open cdrom for redbook audio!\n");
52                 return;
53         }
54         atexit(RBAExit);
55         initialised = 1;
56 }
57
58 int RBAEnabled()
59 {
60  return 1;
61 }
62
63 void RBARegisterCD()
64 {
65
66 }
67
68 int RBAPlayTrack(int a)
69 {
70  if (!initialised) return -1;
71
72  if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
73          SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0);
74  }
75  return a;
76  
77 }
78
79 void RBAStop()
80 {
81   if (!initialised) return;
82   SDL_CDStop(s_cd);
83 }
84
85 void RBASetVolume(int a)
86 {
87
88 }
89
90 void RBAPause()
91 {
92   if (!initialised) return;
93   SDL_CDPause(s_cd);
94 }
95
96 int RBAResume()
97 {
98   if (!initialised) return -1;
99   SDL_CDResume(s_cd);
100   return 1;
101 }
102
103 int RBAGetNumberOfTracks()
104 {
105   if (!initialised) return -1;
106  SDL_CDStatus(s_cd);
107  return s_cd->numtracks;
108 }
109
110 int RBAPlayTracks(int tracknum,int something)
111 {
112   if (!initialised) return -1;
113  if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) {
114          SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0);
115  }
116  return tracknum;
117 }
118
119 int RBAGetTrackNum()
120 {
121   if (!initialised) return -1;
122  SDL_CDStatus(s_cd);
123  return s_cd->cur_track;
124 }
125
126 int RBAPeekPlayStatus()
127 {
128   return (SDL_CDStatus(s_cd) == CD_PLAYING);
129 }
130
131 int CD_blast_mixer()
132 {
133  return 0;
134 }