mirror of
https://github.com/scummvm/scummvm.git
synced 2026-05-21 05:40:43 +00:00
AUDIO: Move API to Path
This commit is contained in:
committed by
Eugene Sandulenko
parent
226de788c8
commit
4ecccceca6
@@ -65,12 +65,12 @@ static const StreamFileFormat STREAM_FILEFORMATS[] = {
|
||||
{ "WAV", ".wav", makeWAVStream },
|
||||
};
|
||||
|
||||
SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &basename) {
|
||||
SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::Path &basename) {
|
||||
SeekableAudioStream *stream = nullptr;
|
||||
Common::File *fileHandle = new Common::File();
|
||||
|
||||
for (int i = 0; i < ARRAYSIZE(STREAM_FILEFORMATS); ++i) {
|
||||
Common::String filename = basename + STREAM_FILEFORMATS[i].fileExtension;
|
||||
Common::Path filename = basename.append(STREAM_FILEFORMATS[i].fileExtension);
|
||||
fileHandle->open(filename);
|
||||
if (fileHandle->isOpen()) {
|
||||
// Create the stream object
|
||||
@@ -83,7 +83,7 @@ SeekableAudioStream *SeekableAudioStream::openStreamFile(const Common::String &b
|
||||
delete fileHandle;
|
||||
|
||||
if (stream == nullptr)
|
||||
debug(1, "SeekableAudioStream::openStreamFile: Could not open compressed AudioFile %s", basename.c_str());
|
||||
debug(1, "SeekableAudioStream::openStreamFile: Could not open compressed AudioFile %s", basename.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
+2
-2
@@ -24,12 +24,12 @@
|
||||
|
||||
#include "common/ptr.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
#include "common/types.h"
|
||||
|
||||
#include "audio/timestamp.h"
|
||||
|
||||
namespace Common {
|
||||
class Path;
|
||||
class SeekableReadStream;
|
||||
}
|
||||
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
* @return A SeekableAudioStream ready to use in case of success.
|
||||
* NULL in case of an error (e.g. invalid/non-existing file).
|
||||
*/
|
||||
static SeekableAudioStream *openStreamFile(const Common::String &basename);
|
||||
static SeekableAudioStream *openStreamFile(const Common::Path &basename);
|
||||
|
||||
/**
|
||||
* Seek to a given offset in the stream.
|
||||
|
||||
@@ -85,7 +85,7 @@ QuickTimeAudioDecoder::~QuickTimeAudioDecoder() {
|
||||
delete _audioTracks[i];
|
||||
}
|
||||
|
||||
bool QuickTimeAudioDecoder::loadAudioFile(const Common::String &filename) {
|
||||
bool QuickTimeAudioDecoder::loadAudioFile(const Common::Path &filename) {
|
||||
if (!Common::QuickTimeParser::parseFile(filename))
|
||||
return false;
|
||||
|
||||
@@ -657,7 +657,7 @@ public:
|
||||
QuickTimeAudioStream() {}
|
||||
~QuickTimeAudioStream() {}
|
||||
|
||||
bool openFromFile(const Common::String &filename) {
|
||||
bool openFromFile(const Common::Path &filename) {
|
||||
return QuickTimeAudioDecoder::loadAudioFile(filename) && !_audioTracks.empty();
|
||||
}
|
||||
|
||||
@@ -687,7 +687,7 @@ public:
|
||||
Timestamp getLength() const override { return _audioTracks[0]->getLength(); }
|
||||
};
|
||||
|
||||
SeekableAudioStream *makeQuickTimeStream(const Common::String &filename) {
|
||||
SeekableAudioStream *makeQuickTimeStream(const Common::Path &filename) {
|
||||
QuickTimeAudioStream *audioStream = new QuickTimeAudioStream();
|
||||
|
||||
if (!audioStream->openFromFile(filename)) {
|
||||
|
||||
@@ -50,7 +50,7 @@ class SeekableAudioStream;
|
||||
* @param filename the filename of the file from which to read the data
|
||||
* @return a new SeekableAudioStream, or NULL, if an error occurred
|
||||
*/
|
||||
SeekableAudioStream *makeQuickTimeStream(const Common::String &filename);
|
||||
SeekableAudioStream *makeQuickTimeStream(const Common::Path &filename);
|
||||
|
||||
/**
|
||||
* Try to load a QuickTime sound file from the given seekable stream and create a SeekableAudioStream
|
||||
|
||||
@@ -53,7 +53,7 @@ public:
|
||||
* Load a QuickTime audio file
|
||||
* @param filename the filename to load
|
||||
*/
|
||||
bool loadAudioFile(const Common::String &filename);
|
||||
bool loadAudioFile(const Common::Path &filename);
|
||||
|
||||
/**
|
||||
* Load a QuickTime audio file from a SeekableReadStream
|
||||
|
||||
@@ -95,7 +95,7 @@ bool MidiParser_QT::loadFromContainerStream(Common::SeekableReadStream *stream,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool MidiParser_QT::loadFromContainerFile(const Common::String &fileName) {
|
||||
bool MidiParser_QT::loadFromContainerFile(const Common::Path &fileName) {
|
||||
unloadMusic();
|
||||
|
||||
if (!parseFile(fileName))
|
||||
|
||||
@@ -74,7 +74,7 @@ public:
|
||||
/**
|
||||
* Load the MIDI from a QuickTime file
|
||||
*/
|
||||
bool loadFromContainerFile(const Common::String &fileName);
|
||||
bool loadFromContainerFile(const Common::Path &fileName);
|
||||
|
||||
protected:
|
||||
// MidiParser
|
||||
|
||||
+3
-3
@@ -304,11 +304,11 @@ private:
|
||||
MilesMT32SysExQueueEntry _milesSysExQueues[MILES_CONTROLLER_SYSEX_QUEUE_COUNT];
|
||||
};
|
||||
|
||||
extern MidiDriver_Multisource *MidiDriver_Miles_AdLib_create(const Common::String &filenameAdLib, const Common::String &filenameOPL3, Common::SeekableReadStream *streamAdLib = nullptr, Common::SeekableReadStream *streamOPL3 = nullptr);
|
||||
extern MidiDriver_Multisource *MidiDriver_Miles_AdLib_create(const Common::Path &filenameAdLib, const Common::Path &filenameOPL3, Common::SeekableReadStream *streamAdLib = nullptr, Common::SeekableReadStream *streamOPL3 = nullptr);
|
||||
|
||||
extern MidiDriver_Miles_Midi *MidiDriver_Miles_MT32_create(const Common::String &instrumentDataFilename);
|
||||
extern MidiDriver_Miles_Midi *MidiDriver_Miles_MT32_create(const Common::Path &instrumentDataFilename);
|
||||
|
||||
extern MidiDriver_Miles_Midi *MidiDriver_Miles_MIDI_create(MusicType midiType, const Common::String &instrumentDataFilename);
|
||||
extern MidiDriver_Miles_Midi *MidiDriver_Miles_MIDI_create(MusicType midiType, const Common::Path &instrumentDataFilename);
|
||||
/** @} */
|
||||
} // End of namespace Audio
|
||||
|
||||
|
||||
@@ -1271,9 +1271,9 @@ void MidiDriver_Miles_AdLib::setRegisterStereo(uint8 reg, uint8 valueLeft, uint8
|
||||
_opl->write(0x223, valueRight);
|
||||
}
|
||||
|
||||
MidiDriver_Multisource *MidiDriver_Miles_AdLib_create(const Common::String &filenameAdLib, const Common::String &filenameOPL3, Common::SeekableReadStream *streamAdLib, Common::SeekableReadStream *streamOPL3) {
|
||||
MidiDriver_Multisource *MidiDriver_Miles_AdLib_create(const Common::Path &filenameAdLib, const Common::Path &filenameOPL3, Common::SeekableReadStream *streamAdLib, Common::SeekableReadStream *streamOPL3) {
|
||||
// Load adlib instrument data from file SAMPLE.AD (OPL3: SAMPLE.OPL)
|
||||
Common::String timbreFilename;
|
||||
Common::Path timbreFilename;
|
||||
Common::SeekableReadStream *timbreStream = nullptr;
|
||||
|
||||
bool preferOPL3 = false;
|
||||
@@ -1374,12 +1374,12 @@ MidiDriver_Multisource *MidiDriver_Miles_AdLib_create(const Common::String &file
|
||||
// If none of them exists and also no stream was passed, we can't do anything about it
|
||||
if (!filenameAdLib.empty()) {
|
||||
if (!filenameOPL3.empty()) {
|
||||
error("MILES-ADLIB: could not open timbre file (%s or %s)", filenameAdLib.c_str(), filenameOPL3.c_str());
|
||||
error("MILES-ADLIB: could not open timbre file (%s or %s)", filenameAdLib.toString(Common::Path::kNativeSeparator).c_str(), filenameOPL3.toString(Common::Path::kNativeSeparator).c_str());
|
||||
} else {
|
||||
error("MILES-ADLIB: could not open timbre file (%s)", filenameAdLib.c_str());
|
||||
error("MILES-ADLIB: could not open timbre file (%s)", filenameAdLib.toString(Common::Path::kNativeSeparator).c_str());
|
||||
}
|
||||
} else {
|
||||
error("MILES-ADLIB: could not open timbre file (%s)", filenameOPL3.c_str());
|
||||
error("MILES-ADLIB: could not open timbre file (%s)", filenameOPL3.toString(Common::Path::kNativeSeparator).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1389,14 +1389,14 @@ MidiDriver_Multisource *MidiDriver_Miles_AdLib_create(const Common::String &file
|
||||
// We prefer this situation
|
||||
|
||||
if (!fileStream->open(timbreFilename))
|
||||
error("MILES-ADLIB: could not open timbre file (%s)", timbreFilename.c_str());
|
||||
error("MILES-ADLIB: could not open timbre file (%s)", timbreFilename.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
streamSize = fileStream->size();
|
||||
|
||||
streamDataPtr = new byte[streamSize];
|
||||
|
||||
if (fileStream->read(streamDataPtr, streamSize) != streamSize)
|
||||
error("MILES-ADLIB: error while reading timbre file (%s)", timbreFilename.c_str());
|
||||
error("MILES-ADLIB: error while reading timbre file (%s)", timbreFilename.toString(Common::Path::kNativeSeparator).c_str());
|
||||
fileStream->close();
|
||||
|
||||
} else if (timbreStream) {
|
||||
|
||||
@@ -794,11 +794,11 @@ void MidiDriver_Miles_Midi::writeToSystemArea(byte index, byte value) {
|
||||
sysExMT32(sysExData, 1, targetAddress);
|
||||
}
|
||||
|
||||
MidiDriver_Miles_Midi *MidiDriver_Miles_MT32_create(const Common::String &instrumentDataFilename) {
|
||||
MidiDriver_Miles_Midi *MidiDriver_Miles_MT32_create(const Common::Path &instrumentDataFilename) {
|
||||
return MidiDriver_Miles_MIDI_create(MT_MT32, instrumentDataFilename);
|
||||
}
|
||||
|
||||
MidiDriver_Miles_Midi *MidiDriver_Miles_MIDI_create(MusicType midiType, const Common::String &instrumentDataFilename) {
|
||||
MidiDriver_Miles_Midi *MidiDriver_Miles_MIDI_create(MusicType midiType, const Common::Path &instrumentDataFilename) {
|
||||
assert(midiType == MT_MT32 || midiType == MT_GM || midiType == MT_GS);
|
||||
|
||||
MilesMT32InstrumentEntry *instrumentTablePtr = nullptr;
|
||||
@@ -820,7 +820,7 @@ MidiDriver_Miles_Midi *MidiDriver_Miles_MIDI_create(MusicType midiType, const Co
|
||||
uint16 instrumentDataSize;
|
||||
|
||||
if (!fileStream->open(instrumentDataFilename))
|
||||
error("MILES-MIDI: could not open instrument file '%s'", instrumentDataFilename.c_str());
|
||||
error("MILES-MIDI: could not open instrument file '%s'", instrumentDataFilename.toString(Common::Path::kNativeSeparator).c_str());
|
||||
|
||||
fileSize = fileStream->size();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user