From ce5e5a2d3c7db1d3f933e5022e3b23c486132ea5 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Sat, 15 Mar 2003 13:12:07 +0000 Subject: [PATCH] formatting, enabled volume control under linux --- ChangeLog | 3 ++ arch/sdl/rbaudio.c | 89 ++++++++++++++++++++++++++++++---------------- 2 files changed, 61 insertions(+), 31 deletions(-) diff --git a/ChangeLog b/ChangeLog index 216c3faa..277217af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2003-03-15 Bradley Bell + * arch/sdl/rbaudio.c: formatting, enabled volume control under + linux + * arch/ogl/gr.c: fixed dark font bug by calling gr_set_mode from gr_init. don't really know why this works, though diff --git a/arch/sdl/rbaudio.c b/arch/sdl/rbaudio.c index 5974a29a..2d27e37b 100644 --- a/arch/sdl/rbaudio.c +++ b/arch/sdl/rbaudio.c @@ -1,4 +1,4 @@ -/* $Id: rbaudio.c,v 1.4 2003-03-15 01:28:19 btb Exp $ */ +/* $Id: rbaudio.c,v 1.5 2003-03-15 13:12:07 btb Exp $ */ /* * * SDL CD Audio functions @@ -15,6 +15,11 @@ #include +#ifdef __linux__ +#include +#include +#endif + #include "pstypes.h" #include "error.h" #include "args.h" @@ -49,18 +54,18 @@ void RBAInit() Warning("No cdrom drives found!\n"); return; } - s_cd = SDL_CDOpen(0); + s_cd = SDL_CDOpen(0); if (s_cd == NULL) { Warning("Could not open cdrom for redbook audio!\n"); return; } - atexit(RBAExit); + atexit(RBAExit); initialised = 1; } int RBAEnabled() { - return 1; + return 1; } void RBARegisterCD() @@ -70,68 +75,90 @@ void RBARegisterCD() int RBAPlayTrack(int a) { - if (!initialised) return -1; + if (!initialised) return -1; - if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { - SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0); - } - return a; - + if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { + SDL_CDPlayTracks(s_cd, a-1, 0, 0, 0); + } + return a; } void RBAStop() { - if (!initialised) return; - SDL_CDStop(s_cd); + if (!initialised) return; + SDL_CDStop(s_cd); } -void RBASetVolume(int a) +void RBASetVolume(int volume) { +#ifdef __linux__ + int cdfile, level; + struct cdrom_volctrl volctrl; + + if (!initialised) return; + + cdfile = s_cd->id; + level = volume * 3; + + if ((level<0) || (level>255)) { + fprintf(stderr, "illegal volume value (allowed values 0-255)\n"); + return; + } + volctrl.channel0 + = volctrl.channel1 + = volctrl.channel2 + = volctrl.channel3 + = level; + if ( ioctl(cdfile, CDROMVOLCTRL, &volctrl) == -1 ) { + fprintf(stderr, "CDROMVOLCTRL ioctl failed\n"); + return; + } +#endif } void RBAPause() { - if (!initialised) return; - SDL_CDPause(s_cd); + if (!initialised) return; + SDL_CDPause(s_cd); } int RBAResume() { - if (!initialised) return -1; - SDL_CDResume(s_cd); - return 1; + if (!initialised) return -1; + SDL_CDResume(s_cd); + return 1; } int RBAGetNumberOfTracks() { - if (!initialised) return -1; - SDL_CDStatus(s_cd); - return s_cd->numtracks; + if (!initialised) return -1; + SDL_CDStatus(s_cd); + return s_cd->numtracks; } int RBAPlayTracks(int tracknum,int something) { - if (!initialised) return -1; - if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { - SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0); - } - return tracknum; + if (!initialised) return -1; + if (CD_INDRIVE(SDL_CDStatus(s_cd)) ) { + SDL_CDPlayTracks(s_cd, tracknum-1, 0, 0, 0); + } + return tracknum; } int RBAGetTrackNum() { - if (!initialised) return -1; - SDL_CDStatus(s_cd); - return s_cd->cur_track; + if (!initialised) return -1; + SDL_CDStatus(s_cd); + return s_cd->cur_track; } int RBAPeekPlayStatus() { - return (SDL_CDStatus(s_cd) == CD_PLAYING); + return (SDL_CDStatus(s_cd) == CD_PLAYING); } int CD_blast_mixer() { - return 0; + return 0; } -- 2.39.2