Skip to content

Commit

Permalink
TINSEL: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
fingolfin committed Apr 12, 2011
1 parent e2adf5b commit f5ff6e9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions engines/tinsel/music.cpp
Expand Up @@ -465,7 +465,6 @@ PCMMusicPlayer::PCMMusicPlayer() {
_silenceSamples = 0;

_curChunk = 0;
_fileName = 0;
_state = S_IDLE;
_mState = S_IDLE;
_scriptNum = -1;
Expand All @@ -488,15 +487,13 @@ PCMMusicPlayer::PCMMusicPlayer() {

PCMMusicPlayer::~PCMMusicPlayer() {
_vm->_mixer->stopHandle(_handle);

delete[] _fileName;
}

void PCMMusicPlayer::startPlay(int id) {
if (!_fileName)
if (_filename.empty())
return;

debugC(DEBUG_DETAILED, kTinselDebugMusic, "Playing PCM music %s, index %d", _fileName, id);
debugC(DEBUG_DETAILED, kTinselDebugMusic, "Playing PCM music %s, index %d", _filename.c_str(), id);

Common::StackLock slock(_mutex);

Expand Down Expand Up @@ -611,8 +608,7 @@ void PCMMusicPlayer::setMusicSceneDetails(SCNHANDLE hScript,

_hScript = hScript;
_hSegment = hSegment;
_fileName = new char[strlen(fileName) + 1];
strcpy(_fileName, fileName);
_filename = fileName;

// Start scene with music not dimmed
_dimmed = false;
Expand Down Expand Up @@ -768,19 +764,19 @@ bool PCMMusicPlayer::getNextChunk() {
sampleLength = FROM_LE_32(musicSegments[snum].sampleLength);
sampleCLength = (((sampleLength + 63) & ~63)*33)/64;

if (!file.open(_fileName))
error(CANNOT_FIND_FILE, _fileName);
if (!file.open(_filename))
error(CANNOT_FIND_FILE, _filename.c_str());

file.seek(sampleOffset);
if (file.eos() || file.err() || (uint32)file.pos() != sampleOffset)
error(FILE_IS_CORRUPT, _fileName);
error(FILE_IS_CORRUPT, _filename.c_str());

buffer = (byte *) malloc(sampleCLength);
assert(buffer);

// read all of the sample
if (file.read(buffer, sampleCLength) != sampleCLength)
error(FILE_IS_CORRUPT, _fileName);
error(FILE_IS_CORRUPT, _filename.c_str());

debugC(DEBUG_DETAILED, kTinselDebugMusic, "Creating ADPCM music chunk with size %d, "
"offset %d (script %d.%d)", sampleCLength, sampleOffset,
Expand Down
2 changes: 1 addition & 1 deletion engines/tinsel/music.h
Expand Up @@ -148,7 +148,7 @@ class PCMMusicPlayer : public Audio::AudioStream {
int32 _scriptIndex;
SCNHANDLE _hScript;
SCNHANDLE _hSegment;
char *_fileName;
Common::String _filename;

uint8 _volume;

Expand Down

0 comments on commit f5ff6e9

Please sign in to comment.