[Scummvm-cvs-logs] CVS: scummvm/backends/PalmOS/Src cd_msa.cpp,1.8,1.9 cd_msa.h,1.5,1.6 cdaudio.h,1.5,1.6

Chris Apers chrilith at users.sourceforge.net
Wed Oct 12 13:39:09 CEST 2005


Update of /cvsroot/scummvm/scummvm/backends/PalmOS/Src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2063

Modified Files:
	cd_msa.cpp cd_msa.h cdaudio.h 
Log Message:
Added getVolume()  (what the hell with these newlines :\ )

Index: cd_msa.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/cd_msa.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cd_msa.cpp	30 Jul 2005 21:10:48 -0000	1.8
+++ cd_msa.cpp	12 Oct 2005 20:36:40 -0000	1.9
@@ -47,7 +47,7 @@
 
 	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 @@
 			// 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 @@
 	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 @@
 	}
 
 	MsaStop(_msaRefNum, true);
-
+		
 	if (_msaLoops == 0)
 		return;
 
@@ -185,13 +192,13 @@
 
 	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 @@
 		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 @@
 		} 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 @@
 			_msaTrackStartSu = (UInt32) ((float)(_msaStartFrame)  / ((float)fullLength / (float)SU));
 			_msaTrackEndSu	 = (UInt32) ((float)(_msaTrackLength) / ((float)fullLength / (float)SU));
 			_msaTrackEndSu	+= _msaTrackStartSu;
-
+			
 			if (_msaTrackEndSu > SU)
 				_msaTrackEndSu = SU;
 

Index: cd_msa.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/cd_msa.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cd_msa.h	30 Jul 2005 21:10:48 -0000	1.5
+++ cd_msa.h	12 Oct 2005 20:36:40 -0000	1.6
@@ -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

Index: cdaudio.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/PalmOS/Src/cdaudio.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cdaudio.h	30 Jul 2005 21:10:48 -0000	1.5
+++ cdaudio.h	12 Oct 2005 20:36:40 -0000	1.6
@@ -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 @@
 
 	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 @@
 
 	// 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 @@
 	bool _isInitialized;
 };
 
-#endif
\ No newline at end of file
+#endif





More information about the Scummvm-git-logs mailing list