aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorPaweł Kołodziejski2002-09-02 07:53:43 +0000
committerPaweł Kołodziejski2002-09-02 07:53:43 +0000
commitca03c9b5fc58b6beb5dbc6c1307464ef9e2c9f45 (patch)
tree539f84d8edc7002ccb01278aa06a174ab53bda3d /sound
parent97ef7c2a34c4077d6d046f0aabce7e1dde04e092 (diff)
downloadscummvm-rg350-ca03c9b5fc58b6beb5dbc6c1307464ef9e2c9f45.tar.gz
scummvm-rg350-ca03c9b5fc58b6beb5dbc6c1307464ef9e2c9f45.tar.bz2
scummvm-rg350-ca03c9b5fc58b6beb5dbc6c1307464ef9e2c9f45.zip
changed file io in sounds to class File
svn-id: r4896
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp10
-rw-r--r--sound/mixer.h8
2 files changed, 10 insertions, 8 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 2158f949dd..150e5009e5 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -111,7 +111,7 @@ int SoundMixer::playMP3(PlayingSoundHandle * handle, void *sound, uint32 size, b
warning("SoundMixer::out of mixer slots");
return -1;
}
-int SoundMixer::playMP3CDTrack(PlayingSoundHandle * handle, FILE * file, mad_timer_t duration) {
+int SoundMixer::playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration) {
/* Stop the previously playing CD track (if any) */
for (int i = 0; i != NUM_CHANNELS; i++) {
if (_channels[i] == NULL) {
@@ -551,7 +551,7 @@ void SoundMixer::ChannelRaw::mix(int16 * data, uint len) {
if (s_org == NULL)
error("ChannelRaw::mix out of memory");
- uint num_read = fread(s_org, 1, num, (FILE *) _ptr);
+ uint num_read = ((File *)_ptr)->read(s_org, num);
if (num - num_read != 0)
memset(s_org + num_read, 0x80, num - num_read);
@@ -778,7 +778,7 @@ void SoundMixer::ChannelMP3::realDestroy() {
#define MP3CD_BUFFERING_SIZE 131072
-SoundMixer::ChannelMP3CDMusic::ChannelMP3CDMusic(SoundMixer * mixer, FILE * file,
+SoundMixer::ChannelMP3CDMusic::ChannelMP3CDMusic(SoundMixer * mixer, File * file,
mad_timer_t duration){
_mixer = mixer;
_file = file;
@@ -811,7 +811,7 @@ void SoundMixer::ChannelMP3CDMusic::mix(int16 * data, uint len) {
int skip_loop;
// just skipped
memset(_ptr, 0, _bufferSize);
- _size = fread(_ptr, 1, _bufferSize, _file);
+ _size = _file->read(_ptr, _bufferSize);
if (!_size) {
realDestroy();
return;
@@ -878,7 +878,7 @@ void SoundMixer::ChannelMP3CDMusic::mix(int16 * data, uint len) {
} else {
not_decoded = _stream.bufend - _stream.next_frame;
memcpy(_ptr, _stream.next_frame, not_decoded);
- _size = fread((unsigned char *)_ptr + not_decoded, 1, _bufferSize - not_decoded, _file);
+ _size = _file->read((unsigned char *)_ptr + not_decoded, _bufferSize - not_decoded);
}
_stream.error = (enum mad_error)0;
// Restream
diff --git a/sound/mixer.h b/sound/mixer.h
index 19c0414fcd..64ab0c7070 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -31,6 +31,8 @@
typedef uint32 PlayingSoundHandle;
+class File;
+
class SoundMixer {
private:
class Channel {
@@ -112,11 +114,11 @@ private:
uint32 _size;
uint32 _bufferSize;
mad_timer_t _duration;
- FILE * _file;
+ File * _file;
bool _initialized;
public:
- ChannelMP3CDMusic(SoundMixer * mixer, FILE * file, mad_timer_t duration);
+ ChannelMP3CDMusic(SoundMixer * mixer, File * file, mad_timer_t duration);
void mix(int16 * data, uint len);
void realDestroy();
bool soundFinished();
@@ -170,7 +172,7 @@ public:
byte flags);
#ifdef COMPRESSED_SOUND_FILE
int playMP3(PlayingSoundHandle * handle, void * sound, uint32 size, byte flags);
- int playMP3CDTrack(PlayingSoundHandle * handle, FILE * file, mad_timer_t duration);
+ int playMP3CDTrack(PlayingSoundHandle * handle, File * file, mad_timer_t duration);
#endif
/* Premix procedure, useful when using fmopl adlib */