diff options
Diffstat (limited to 'backends')
-rw-r--r-- | backends/PalmOS/Src/cd_msa.cpp | 39 | ||||
-rw-r--r-- | backends/PalmOS/Src/cd_msa.h | 22 | ||||
-rw-r--r-- | backends/PalmOS/Src/cdaudio.h | 10 |
3 files changed, 41 insertions, 30 deletions
diff --git a/backends/PalmOS/Src/cd_msa.cpp b/backends/PalmOS/Src/cd_msa.cpp index a91cd5eb9f..1afe41fd51 100644 --- a/backends/PalmOS/Src/cd_msa.cpp +++ b/backends/PalmOS/Src/cd_msa.cpp @@ -47,7 +47,7 @@ bool MsaCDPlayer::init() { if (!(error = FtrGet(sonySysFtrCreator, sonySysFtrNumSysInfoP, (UInt32*)&sonySysFtrSysInfoP))) { // not found with audio adapter ?! - //if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrMsa) { + //if (sonySysFtrSysInfoP->libr & sonySysFtrSysInfoLibrMsa) { if ((error = SysLibFind(sonySysLibNameMsa, &_msaRefNum))) if (error == sysErrLibNotFound) error = SysLibLoad(sonySysFileTMsaLib, sonySysFileCMsaLib, &_msaRefNum); @@ -57,11 +57,11 @@ bool MsaCDPlayer::init() { // this doesn't work the same way on build-in MP3 device and external MP3 devices if (!error) { //MsaLibClose(_msaRefNum, msaLibOpenModeAlbum); // close the lib if we previously let it open (?) Need to add Notify for sonySysNotifyMsaEnforceOpenEvent just in case ... - error = MsaLibOpen(_msaRefNum, msaLibOpenModeAlbum); + error = MsaLibOpen(_msaRefNum, msaLibOpenModeAlbum); //if (error == msaErrAlreadyOpen) // error = MsaLibEnforceOpen(_msaRefNum, msaLibOpenModeAlbum, appFileCreator); - + //error = (error != msaErrStillOpen) ? error : errNone; } //} @@ -93,8 +93,15 @@ void MsaCDPlayer::initInternal() { e = MsaSetAlbum(_msaRefNum, _msaAlbum.albumRefNum, &dummy); // TODO : use RMC to control volume - // move this to setSolume - MsaOutSetVolume(_msaRefNum, 20, 20); + MsaOutCapabilityType capability; + MsaOutGetCapability(_msaRefNum, &capability); + _volumeLLimit = capability.volumeLLimit; + _volumeRLimit = capability.volumeRLimit; +} + +void MsaCDPlayer::setVolume(int volume) { + _volumeLevel = volume; + MsaOutSetVolume(_msaRefNum, (_volumeLLimit * volume) / 100, (_volumeRLimit * volume) / 100); } void MsaCDPlayer::release() { @@ -147,7 +154,7 @@ void MsaCDPlayer::update() { } MsaStop(_msaRefNum, true); - + if (_msaLoops == 0) return; @@ -185,13 +192,13 @@ void MsaCDPlayer::play(int track, int num_loops, int start_frame, int duration) if (!num_loops && !start_frame) return; - + _msaTrack = track + gVars->CD.firstTrack - 1; // first track >= 1 ?, not 0 (0=album) _msaLoops = num_loops; _msaStartFrame = TO_MSECS(start_frame); _msaDuration = TO_MSECS(duration); - Err e; + Err e; MemHandle trackH; // stop current play if any @@ -206,19 +213,19 @@ void MsaCDPlayer::play(int track, int num_loops, int start_frame, int duration) MsaTime msaTime; MsaTrackInfo *trackP; UInt32 SU, fullLength; - + // FIXME (?) : this enable MsaSuToTime to return the right value in some cases MsaPlay(_msaRefNum, _msaTrack, 0, msa_PBRATE_SP); MsaStop(_msaRefNum, true); - - // get the msa time - trackP = (MsaTrackInfo *)MemHandleLock(trackH); + + // get the msa time + trackP = (MsaTrackInfo *)MemHandleLock(trackH); MsaSuToTime(_msaRefNum, trackP->totalsu, &msaTime); SU = trackP->totalsu; MemPtrUnlock(trackP); MemHandleFree(trackH); - - // MSA frame in milli-seconds + + // MSA frame in milli-seconds fullLength = FROM_MIN(msaTime.minute); fullLength += FROM_SEC(msaTime.second); fullLength += msaTime.frame; @@ -231,7 +238,7 @@ void MsaCDPlayer::play(int track, int num_loops, int start_frame, int duration) } else { _msaTrackLength = fullLength; } - + // try to play the track if (start_frame == 0 && duration == 0) { MsaPlay(_msaRefNum, _msaTrack, 0, msa_PBRATE_SP); @@ -241,7 +248,7 @@ void MsaCDPlayer::play(int track, int num_loops, int start_frame, int duration) _msaTrackStartSu = (UInt32) ((float)(_msaStartFrame) / ((float)fullLength / (float)SU)); _msaTrackEndSu = (UInt32) ((float)(_msaTrackLength) / ((float)fullLength / (float)SU)); _msaTrackEndSu += _msaTrackStartSu; - + if (_msaTrackEndSu > SU) _msaTrackEndSu = SU; diff --git a/backends/PalmOS/Src/cd_msa.h b/backends/PalmOS/Src/cd_msa.h index 10606f8753..8d553ec7a6 100644 --- a/backends/PalmOS/Src/cd_msa.h +++ b/backends/PalmOS/Src/cd_msa.h @@ -20,13 +20,13 @@ * */ - #ifndef CD_MSA_H - #define CD_MSA_H +#ifndef CD_MSA_H +#define CD_MSA_H - #include "cdaudio.h" +#include "cdaudio.h" - class MsaCDPlayer : public CDAudio { - public: +class MsaCDPlayer : public CDAudio { +public: MsaCDPlayer(OSystem *sys); bool init(); @@ -37,12 +37,17 @@ void play(int track, int num_loops, int start_frame, int duration); void stop(); + void setVolume(int volume); + private: void initInternal(); OSystem *_sys; UInt16 _msaRefNum; + UInt32 _volumeLLimit; + UInt32 _volumeRLimit; + // cdrom AlbumInfoType _msaAlbum; UInt16 _msaLoops; @@ -55,7 +60,6 @@ UInt16 _msaTrack; UInt32 _msaTrackStartSu, _msaTrackEndSu; UInt32 _msaTrackLength; - - }; - - #endif
\ No newline at end of file +}; + +#endif diff --git a/backends/PalmOS/Src/cdaudio.h b/backends/PalmOS/Src/cdaudio.h index 10c34b64d0..b644bee74b 100644 --- a/backends/PalmOS/Src/cdaudio.h +++ b/backends/PalmOS/Src/cdaudio.h @@ -19,7 +19,7 @@ * $Header$ * */ - + #ifndef CDAUDIO_H #define CDAUDIO_H @@ -34,7 +34,7 @@ #define FROM_SEC(secs) ((UInt32)((secs) * 1000)) class CDAudio { -public: +public: CDAudio() { _isInitialized = false; _volumeLevel = 100; @@ -42,7 +42,7 @@ public: virtual bool init() = 0; virtual void release() = 0; - + // OSystem functions virtual bool poll() = 0; virtual void play(int track, int num_loops, int start_frame, int duration) = 0; @@ -51,7 +51,7 @@ public: // volume in percent virtual void setVolume(int volume) { _volumeLevel = volume; } - virtual int getVolume() { return _volumeLevel; } + virtual int getVolume() const { return _volumeLevel; } virtual void upVolume(int value) {}; virtual void downVolume(int value) {}; @@ -61,4 +61,4 @@ protected: bool _isInitialized; }; -#endif
\ No newline at end of file +#endif |