forked from mirror/openmw-tes3mp
More music changes, Makefile updates, minor changes
git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@31 ea6a568a-9f4f-0410-981a-c910a81bb256
This commit is contained in:
parent
eb642d3400
commit
33d11a733c
11 changed files with 129 additions and 110 deletions
67
Makefile
67
Makefile
|
@ -6,13 +6,15 @@ CXXFLAGS?= -Wall -g
|
||||||
DMD=gdmd -version=Posix
|
DMD=gdmd -version=Posix
|
||||||
|
|
||||||
# Some extra flags for niftool and bsatool
|
# Some extra flags for niftool and bsatool
|
||||||
NIFFLAGS=
|
NIFFLAGS=-debug=warnstd -debug=check -debug=statecheck -debug=strict -debug=verbose
|
||||||
|
|
||||||
# Compiler settings for Ogre + OIS. Change as needed.
|
# Compiler settings for Ogre + OIS. Change as needed.
|
||||||
OGCC=$(CXX) $(CXXFLAGS) `pkg-config --cflags OGRE OIS`
|
CF_OIS=$(shell pkg-config --cflags OGRE OIS)
|
||||||
|
OGCC=$(CXX) $(CXXFLAGS) $(CF_OIS)
|
||||||
|
|
||||||
# Compiler settings for ffmpeg. Change as needed.
|
# Compiler settings for ffmpeg. Change as needed.
|
||||||
AVGCC=$(CXX) $(CXXFLAGS) `pkg-config --cflags libavcodec libavformat`
|
CF_FFMPEG=$(shell pkg-config --cflags libavcodec libavformat)
|
||||||
|
AVGCC=$(CXX) $(CXXFLAGS) $(CF_FFMPEG)
|
||||||
|
|
||||||
# Ogre C++ files, on the form ogre/cpp_X.cpp. Only the first file is
|
# Ogre C++ files, on the form ogre/cpp_X.cpp. Only the first file is
|
||||||
# passed to the compiler, the rest are dependencies.
|
# passed to the compiler, the rest are dependencies.
|
||||||
|
@ -22,67 +24,56 @@ ogre_cpp=ogre framelistener interface overlay bsaarchive
|
||||||
# passed to the compiler, the rest are dependencies.
|
# passed to the compiler, the rest are dependencies.
|
||||||
avcodec_cpp=avcodec
|
avcodec_cpp=avcodec
|
||||||
|
|
||||||
## The rest of this file is automatic ##
|
## No modifications should be required below this line. ##
|
||||||
|
|
||||||
ogre_cpp_files=$(ogre_cpp:%=ogre/cpp_%.cpp)
|
ogre_cpp_files=$(ogre_cpp:%=ogre/cpp_%.cpp)
|
||||||
avcodec_cpp_files=$(avcodec_cpp:%=sound/cpp_%.cpp)
|
avcodec_cpp_files=$(avcodec_cpp:%=sound/cpp_%.cpp)
|
||||||
|
|
||||||
d_files=$(wildcard */*.d) $(wildcard monster/util/*.d)
|
# All object files needed by openmw and esmtool
|
||||||
d_files_nif=$(wildcard nif/*.d) $(wildcard util/*.d) $(wildcard core/memory.d) $(wildcard monster/util/*.d)
|
src := $(wildcard */*.d)
|
||||||
|
src := $(src) $(wildcard monster/util/*.d)
|
||||||
|
obj := $(src:%.d=objs/%.o)
|
||||||
|
|
||||||
# The NIF object files for niftool and bsatool are put in a separate
|
# The NIF object files for niftool and bsatool are put in a separate
|
||||||
# directory, since they are built with different flags.
|
# directory, since they are built with different flags.
|
||||||
d_objs=$(d_files:%.d=objs/%.o)
|
src_nif := $(wildcard nif/*.d)
|
||||||
d_objs_nif=$(d_files_nif:%.d=nifobjs/%.o)
|
src_nif := $(src_nif) $(wildcard util/*.d)
|
||||||
|
src_nif := $(src_nif) core/memory.d
|
||||||
|
src_nif := $(src_nif) $(wildcard monster/util/*.d)
|
||||||
|
obj_nif := $(src_nif:%.d=nifobjs/%.o)
|
||||||
|
|
||||||
.PHONY: cpp all clean makedirs
|
.PHONY: cpp all clean
|
||||||
|
|
||||||
# By default, make will only build the Ogre C++ sources.
|
# Build everything. Default when running 'make' directly.
|
||||||
|
all: openmw esmtool niftool bsatool bored
|
||||||
|
|
||||||
|
# Only build C++ sources. Used when building from DSSS.
|
||||||
cpp: cpp_ogre.o cpp_avcodec.o
|
cpp: cpp_ogre.o cpp_avcodec.o
|
||||||
|
|
||||||
all: makedirs openmw esmtool niftool bsatool bored
|
|
||||||
|
|
||||||
cpp_ogre.o: $(ogre_cpp_files)
|
cpp_ogre.o: $(ogre_cpp_files)
|
||||||
$(OGCC) -c $<
|
$(OGCC) -c $<
|
||||||
|
|
||||||
cpp_avcodec.o: $(avcodec_cpp_files)
|
cpp_avcodec.o: $(avcodec_cpp_files)
|
||||||
$(AVGCC) -c $<
|
$(AVGCC) -c $<
|
||||||
|
|
||||||
objs/%.o: %.d makedirs
|
objs/%.o: %.d
|
||||||
|
dirname $@ | xargs mkdir -p
|
||||||
$(DMD) -c $< -of$@
|
$(DMD) -c $< -of$@
|
||||||
|
|
||||||
nifobjs/%.o: %.d makedirs
|
nifobjs/%.o: %.d
|
||||||
$(DMD) -debug=warnstd -debug=check -debug=statecheck -debug=strict -debug=verbose -c $< -of$@
|
dirname $@ | xargs mkdir -p
|
||||||
|
$(DMD) $(NIFFLAGS) -c $< -of$@
|
||||||
|
|
||||||
# This is a hack for gdmd (dmd-like frontend to gdc), since it does
|
openmw: openmw.d cpp_ogre.o cpp_avcodec.o $(obj)
|
||||||
# not automatically create directories as it should.
|
|
||||||
makedirs:
|
|
||||||
mkdir -p objs/bsa
|
|
||||||
mkdir -p objs/core
|
|
||||||
mkdir -p objs/esm
|
|
||||||
mkdir -p objs/input
|
|
||||||
mkdir -p objs/monster/util
|
|
||||||
mkdir -p objs/nif
|
|
||||||
mkdir -p objs/ogre
|
|
||||||
mkdir -p objs/scene
|
|
||||||
mkdir -p objs/sound
|
|
||||||
mkdir -p objs/util
|
|
||||||
mkdir -p nifobjs/nif
|
|
||||||
mkdir -p nifobjs/util
|
|
||||||
mkdir -p nifobjs/core
|
|
||||||
mkdir -p nifobjs/monster/util
|
|
||||||
mkdir -p nifobjs/bsa
|
|
||||||
|
|
||||||
openmw: openmw.d cpp_ogre.o cpp_avcodec.o $(d_objs)
|
|
||||||
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat
|
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat
|
||||||
|
|
||||||
esmtool: esmtool.d cpp_ogre.o cpp_avcodec.o $(d_objs)
|
esmtool: esmtool.d cpp_ogre.o cpp_avcodec.o $(obj)
|
||||||
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat
|
$(DMD) $^ -of$@ -L-lopenal -L-lOgreMain -L-lOIS -L-lavcodec -L-lavformat
|
||||||
|
|
||||||
niftool: niftool.d $(d_objs_nif)
|
niftool: niftool.d $(obj_nif)
|
||||||
$(DMD) $^ -of$@
|
$(DMD) $^ -of$@
|
||||||
|
|
||||||
bsatool: bsatool.d $(d_objs_nif) bsa/bsafile.d
|
bsatool: bsatool.d $(obj_nif) objs/bsa/bsafile.o
|
||||||
$(DMD) $^ -of$@
|
$(DMD) $^ -of$@
|
||||||
|
|
||||||
bored: bored.d
|
bored: bored.d
|
||||||
|
|
17
README.txt
17
README.txt
|
@ -6,7 +6,7 @@ Email: korslund@gmail.com
|
||||||
WWW: http://openmw.snaptoad.com
|
WWW: http://openmw.snaptoad.com
|
||||||
License: See GPL3.txt
|
License: See GPL3.txt
|
||||||
Current version: 0.4 (still very pre-alpha)
|
Current version: 0.4 (still very pre-alpha)
|
||||||
Date: 2008 jul. 12
|
Date: 2008 jul. 20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -115,17 +115,26 @@ Thanks goes out to:
|
||||||
|
|
||||||
- Chris Robinson for OpenAL and MP3 support
|
- Chris Robinson for OpenAL and MP3 support
|
||||||
|
|
||||||
|
- Various others for testing, ideas and patches
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Changelog:
|
Changelog:
|
||||||
==========
|
==========
|
||||||
|
|
||||||
0.4 (Work in progress)
|
0.4 (2008 jul. 20) - work in progress
|
||||||
|
|
||||||
- switched from Audiere to OpenAL (BIG thanks to Chris Robinson)
|
- switched from Audiere to OpenAL (BIG thanks to Chris Robinson)
|
||||||
- added complete Makefile (again) as a alternative build tool
|
- added complete Makefile (again) as a alternative build tool
|
||||||
|
- much more realistic lighting (thanks again to Chris Robinson)
|
||||||
|
- should work with Russian version
|
||||||
|
- various bug-fixes
|
||||||
- cosmetic changes to placate gdc -Wall
|
- cosmetic changes to placate gdc -Wall
|
||||||
|
|
||||||
|
|
||||||
0.3 (2008 jul. 10) - latest release
|
0.3 (2008 jul. 10) - latest release
|
||||||
|
|
||||||
- built and tested on Windows XP
|
- built and tested on Windows XP
|
||||||
- partial support for FreeBSD (exceptions do not work)
|
- partial support for FreeBSD (exceptions do not work)
|
||||||
- temporarily dropped DSSS and Monster as necessary dependencies
|
- temporarily dropped DSSS and Monster as necessary dependencies
|
||||||
|
@ -138,10 +147,14 @@ Changelog:
|
||||||
Dmitry Marakasov.)
|
Dmitry Marakasov.)
|
||||||
- tested against OIS 1.0.0 (Ubuntu repository package)
|
- tested against OIS 1.0.0 (Ubuntu repository package)
|
||||||
|
|
||||||
|
|
||||||
0.2 (2008 jun. 17)
|
0.2 (2008 jun. 17)
|
||||||
|
|
||||||
- compiles with gdc
|
- compiles with gdc
|
||||||
- switched to DSSS for building D code
|
- switched to DSSS for building D code
|
||||||
- includes the program esmtool
|
- includes the program esmtool
|
||||||
|
|
||||||
|
|
||||||
0.1 (2008 jun. 03)
|
0.1 (2008 jun. 03)
|
||||||
|
|
||||||
- first release
|
- first release
|
||||||
|
|
6
bored.d
6
bored.d
|
@ -110,6 +110,12 @@ those plugins.");
|
||||||
play=false;
|
play=false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(rnd() < 0.02)
|
||||||
|
{
|
||||||
|
writefln("You were eaten by a grue.");
|
||||||
|
play=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
switch(rand(0,15))
|
switch(rand(0,15))
|
||||||
{
|
{
|
||||||
case 0: str = "Fjol the Outlaw"; goldinc = rand(0,70); lootinc = rand(10,120); break;
|
case 0: str = "Fjol the Outlaw"; goldinc = rand(0,70); lootinc = rand(10,120); break;
|
||||||
|
|
|
@ -192,6 +192,7 @@ struct ResourceManager
|
||||||
// Copy name and insert. We MUST copy here, since indices during
|
// Copy name and insert. We MUST copy here, since indices during
|
||||||
// load are put in a temporary buffer, and thus overwritten.
|
// load are put in a temporary buffer, and thus overwritten.
|
||||||
si.name = esmRegion.copyz(id);
|
si.name = esmRegion.copyz(id);
|
||||||
|
assert(si.name == id);
|
||||||
soundLookup[si.name] = si;
|
soundLookup[si.name] = si;
|
||||||
|
|
||||||
return si;
|
return si;
|
||||||
|
|
|
@ -11,7 +11,7 @@ version(Windows) {
|
||||||
prebuild = warn Not designed for Windows yet.
|
prebuild = warn Not designed for Windows yet.
|
||||||
}
|
}
|
||||||
version(Posix) {
|
version(Posix) {
|
||||||
prebuild = make ;
|
prebuild = make cpp;
|
||||||
}
|
}
|
||||||
# Make sure we recompile the nif files without the debug output
|
# Make sure we recompile the nif files without the debug output
|
||||||
prebuild += dsss clean niftool
|
prebuild += dsss clean niftool
|
||||||
|
|
|
@ -180,8 +180,6 @@ struct Dialogue
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO/FIXME: HACK suddenly needed with version 0.167 :(
|
|
||||||
// Haven't re-tested it with non-ancient compiler
|
|
||||||
typedef Dialogue.Type DialogueType;
|
typedef Dialogue.Type DialogueType;
|
||||||
|
|
||||||
/+
|
/+
|
||||||
|
|
|
@ -187,17 +187,26 @@ struct DialInfo
|
||||||
deleted = false;
|
deleted = false;
|
||||||
questStatus = Quest.None;
|
questStatus = Quest.None;
|
||||||
|
|
||||||
// Figure out how we check the owner's type
|
if(subName == "QSTN") questStatus = Quest.Name;
|
||||||
if(tp == Dialogue.Type.Journal)
|
else if(subName == "QSTF") questStatus = Quest.Finished;
|
||||||
{
|
else if(subName == "QSTR") questStatus = Quest.Restart;
|
||||||
if(subName == "QSTN") questStatus = Quest.Name;
|
|
||||||
else if(subName == "QSTF") questStatus = Quest.Finished;
|
|
||||||
else if(subName == "QSTR") questStatus = Quest.Restart;
|
|
||||||
|
|
||||||
if(questStatus != Quest.None) getHByte();
|
|
||||||
}
|
|
||||||
else if(subName == "DELE") {getHInt(); deleted = true;}
|
else if(subName == "DELE") {getHInt(); deleted = true;}
|
||||||
else fail("Don't know what to do with " ~ subName ~ " here.");
|
else
|
||||||
|
fail("Don't know what to do with " ~ subName ~ " in INFO " ~ id);
|
||||||
|
|
||||||
|
if(questStatus != Quest.None)
|
||||||
|
{
|
||||||
|
getHByte();
|
||||||
|
// The Quest markers should only appear in journal INFOs, but
|
||||||
|
// sometime the appear outside it. We could issue a warning,
|
||||||
|
// but lets just ignore it instead.
|
||||||
|
|
||||||
|
/*
|
||||||
|
if(tp != Dialogue.Type.Journal)
|
||||||
|
writefln("WARNING: Found INFO quest marker in INFO %s type %s",
|
||||||
|
id, cast(int)tp);
|
||||||
|
*/
|
||||||
|
}
|
||||||
}}
|
}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
30
openmw.d
30
openmw.d
|
@ -201,26 +201,6 @@ void main(char[][] args)
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
Sound *l = cast(Sound*) sounds.lookup("Fire 40");
|
|
||||||
if(l)
|
|
||||||
{
|
|
||||||
writefln("id: %s", l.id);
|
|
||||||
writefln("volume: ", l.data.volume);
|
|
||||||
writefln("range: %s-%s", l.data.minRange, l.data.maxRange);
|
|
||||||
writefln("sound file name: ", l.sound.getName);
|
|
||||||
writefln("playing... press enter to quit");
|
|
||||||
|
|
||||||
SoundInstance inst = SoundList.getInstance(l, true);
|
|
||||||
inst.setPos(0,0,0);
|
|
||||||
inst.setPlayerPos(0, 0, 0);
|
|
||||||
inst.play();
|
|
||||||
din.readLine();
|
|
||||||
inst.kill;
|
|
||||||
render = false;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
if(render)
|
if(render)
|
||||||
{
|
{
|
||||||
// Warm up OGRE
|
// Warm up OGRE
|
||||||
|
@ -287,11 +267,11 @@ void main(char[][] args)
|
||||||
if(s)
|
if(s)
|
||||||
{
|
{
|
||||||
writefln("Static light %s has sound %s", ls.m.id, s.id);
|
writefln("Static light %s has sound %s", ls.m.id, s.id);
|
||||||
ls.loopSound = soundScene.insert(s, true);
|
ls.loopSound = soundScene.insert(s, true);
|
||||||
if(ls.loopSound)
|
if(ls.loopSound)
|
||||||
ls.loopSound.setPos(ls.base.pos.position[0],
|
ls.loopSound.setPos(ls.base.pos.position[0],
|
||||||
ls.base.pos.position[1],
|
ls.base.pos.position[1],
|
||||||
ls.base.pos.position[2]);
|
ls.base.pos.position[2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Misc items
|
// Misc items
|
||||||
|
|
|
@ -44,6 +44,8 @@ struct SoundList
|
||||||
{
|
{
|
||||||
const distFactor = 40.0; // Just guessing, really.
|
const distFactor = 40.0; // Just guessing, really.
|
||||||
|
|
||||||
|
assert(!s.sound.isEmpty());
|
||||||
|
|
||||||
SoundInstance inst = s.sound.getInstance();
|
SoundInstance inst = s.sound.getInstance();
|
||||||
inst.setParams(s.data.volume/255.0,
|
inst.setParams(s.data.volume/255.0,
|
||||||
s.data.minRange*distFactor,
|
s.data.minRange*distFactor,
|
||||||
|
@ -54,6 +56,11 @@ struct SoundList
|
||||||
|
|
||||||
SoundInstance *insert(Sound *snd, bool loop=false)
|
SoundInstance *insert(Sound *snd, bool loop=false)
|
||||||
{
|
{
|
||||||
|
// For some reason, we get called with empty sound instances here
|
||||||
|
// if some files are missing, but not for others. Check into it
|
||||||
|
// later.
|
||||||
|
if(snd.sound.isEmpty) return null;
|
||||||
|
|
||||||
// Reuse a dead instance if one exists
|
// Reuse a dead instance if one exists
|
||||||
foreach(ref s; list)
|
foreach(ref s; list)
|
||||||
{
|
{
|
||||||
|
|
|
@ -128,7 +128,7 @@ extern "C" int cpp_getAVAudioInfo(MyFile::MyStream *stream,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getNextPacket(MyFile *file)
|
static void getNextPacket(MyFile *file, int streamidx)
|
||||||
{
|
{
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
while(av_read_frame(file->FmtCtx, &packet) >= 0)
|
while(av_read_frame(file->FmtCtx, &packet) >= 0)
|
||||||
|
@ -141,14 +141,16 @@ static int getNextPacket(MyFile *file)
|
||||||
size_t idx = (*i)->Data.size();
|
size_t idx = (*i)->Data.size();
|
||||||
(*i)->Data.resize(idx + packet.size);
|
(*i)->Data.resize(idx + packet.size);
|
||||||
memcpy(&(*i)->Data[idx], packet.data, packet.size);
|
memcpy(&(*i)->Data[idx], packet.data, packet.size);
|
||||||
av_free_packet(&packet);
|
if(streamidx == packet.stream_index)
|
||||||
return 0;
|
{
|
||||||
|
av_free_packet(&packet);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
av_free_packet(&packet);
|
av_free_packet(&packet);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" int cpp_getAVAudioData(MyFile::MyStream *stream, char *data, int length)
|
extern "C" int cpp_getAVAudioData(MyFile::MyStream *stream, char *data, int length)
|
||||||
|
@ -158,14 +160,25 @@ extern "C" int cpp_getAVAudioData(MyFile::MyStream *stream, char *data, int leng
|
||||||
int dec = 0;
|
int dec = 0;
|
||||||
while(dec < length)
|
while(dec < length)
|
||||||
{
|
{
|
||||||
|
if(stream->DecodedData.size() > 0)
|
||||||
|
{
|
||||||
|
size_t rem = length-dec;
|
||||||
|
if(rem > stream->DecodedData.size())
|
||||||
|
rem = stream->DecodedData.size();
|
||||||
|
|
||||||
|
memcpy(data, &stream->DecodedData[0], rem);
|
||||||
|
data += rem;
|
||||||
|
dec += rem;
|
||||||
|
if(rem < stream->DecodedData.size())
|
||||||
|
memmove(&stream->DecodedData[0], &stream->DecodedData[rem],
|
||||||
|
stream->DecodedData.size() - rem);
|
||||||
|
stream->DecodedData.resize(stream->DecodedData.size()-rem);
|
||||||
|
}
|
||||||
if(stream->DecodedData.size() == 0)
|
if(stream->DecodedData.size() == 0)
|
||||||
{
|
{
|
||||||
while(stream->Data.size() == 0)
|
// Must always get at least one more packet if possible, in case
|
||||||
{
|
// the previous one wasn't enough
|
||||||
if(getNextPacket(stream->parent) != 0)
|
getNextPacket(stream->parent, stream->StreamNum);
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
int insize = stream->Data.size();
|
int insize = stream->Data.size();
|
||||||
if(insize == 0)
|
if(insize == 0)
|
||||||
break;
|
break;
|
||||||
|
@ -174,6 +187,7 @@ extern "C" int cpp_getAVAudioData(MyFile::MyStream *stream, char *data, int leng
|
||||||
// codecs read in larger chunks and may accidently read
|
// codecs read in larger chunks and may accidently read
|
||||||
// past the end of the allocated buffer
|
// past the end of the allocated buffer
|
||||||
stream->Data.resize(insize + FF_INPUT_BUFFER_PADDING_SIZE);
|
stream->Data.resize(insize + FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
|
memset(&stream->Data[insize], 0, FF_INPUT_BUFFER_PADDING_SIZE);
|
||||||
stream->DecodedData.resize(AVCODEC_MAX_AUDIO_FRAME_SIZE);
|
stream->DecodedData.resize(AVCODEC_MAX_AUDIO_FRAME_SIZE);
|
||||||
|
|
||||||
int16_t *ptr = (int16_t*)&stream->DecodedData[0];
|
int16_t *ptr = (int16_t*)&stream->DecodedData[0];
|
||||||
|
@ -185,28 +199,16 @@ extern "C" int cpp_getAVAudioData(MyFile::MyStream *stream, char *data, int leng
|
||||||
stream->Data.resize(insize);
|
stream->Data.resize(insize);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if(len > 0)
|
||||||
int datarem = insize-len;
|
{
|
||||||
if(datarem)
|
int datarem = insize-len;
|
||||||
memmove(&stream->Data[0], &stream->Data[len], datarem);
|
if(datarem)
|
||||||
stream->Data.resize(datarem);
|
memmove(&stream->Data[0], &stream->Data[len], datarem);
|
||||||
|
stream->Data.resize(datarem);
|
||||||
|
}
|
||||||
|
|
||||||
stream->DecodedData.resize(size);
|
stream->DecodedData.resize(size);
|
||||||
if(stream->DecodedData.size() == 0)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t rem = length-dec;
|
|
||||||
if(rem > stream->DecodedData.size())
|
|
||||||
rem = stream->DecodedData.size();
|
|
||||||
|
|
||||||
memcpy(data, &stream->DecodedData[0], rem);
|
|
||||||
data += rem;
|
|
||||||
dec += rem;
|
|
||||||
if(rem < stream->DecodedData.size())
|
|
||||||
memmove(&stream->DecodedData[0], &stream->DecodedData[rem],
|
|
||||||
stream->DecodedData.size() - rem);
|
|
||||||
stream->DecodedData.resize(stream->DecodedData.size()-rem);
|
|
||||||
}
|
}
|
||||||
return dec;
|
return dec;
|
||||||
}
|
}
|
||||||
|
|
|
@ -183,6 +183,8 @@ struct MusicManager
|
||||||
// If something fails, clean everything up.
|
// If something fails, clean everything up.
|
||||||
scope(failure)
|
scope(failure)
|
||||||
{
|
{
|
||||||
|
// This block is only executed if an exception is thrown.
|
||||||
|
|
||||||
if(fileHandle) cpp_closeAVFile(fileHandle);
|
if(fileHandle) cpp_closeAVFile(fileHandle);
|
||||||
|
|
||||||
fileHandle = null;
|
fileHandle = null;
|
||||||
|
@ -199,6 +201,8 @@ struct MusicManager
|
||||||
|
|
||||||
// Try the next track if playNext is called again
|
// Try the next track if playNext is called again
|
||||||
index++;
|
index++;
|
||||||
|
|
||||||
|
// The function exits here.
|
||||||
}
|
}
|
||||||
|
|
||||||
if(checkALError())
|
if(checkALError())
|
||||||
|
@ -222,13 +226,21 @@ struct MusicManager
|
||||||
{
|
{
|
||||||
if(ch == 1) bufFormat = AL_FORMAT_MONO8;
|
if(ch == 1) bufFormat = AL_FORMAT_MONO8;
|
||||||
if(ch == 2) bufFormat = AL_FORMAT_STEREO8;
|
if(ch == 2) bufFormat = AL_FORMAT_STEREO8;
|
||||||
if(ch == 4) bufFormat = alGetEnumValue("AL_FORMAT_QUAD8");
|
if(alIsExtensionPresent("AL_EXT_MCFORMATS"))
|
||||||
|
{
|
||||||
|
if(ch == 4) bufFormat = alGetEnumValue("AL_FORMAT_QUAD8");
|
||||||
|
if(ch == 6) bufFormat = alGetEnumValue("AL_FORMAT_51CHN8");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(bits == 16)
|
if(bits == 16)
|
||||||
{
|
{
|
||||||
if(ch == 1) bufFormat = AL_FORMAT_MONO16;
|
if(ch == 1) bufFormat = AL_FORMAT_MONO16;
|
||||||
if(ch == 2) bufFormat = AL_FORMAT_STEREO16;
|
if(ch == 2) bufFormat = AL_FORMAT_STEREO16;
|
||||||
if(ch == 4) bufFormat = alGetEnumValue("AL_FORMAT_QUAD16");
|
if(alIsExtensionPresent("AL_EXT_MCFORMATS"))
|
||||||
|
{
|
||||||
|
if(ch == 4) bufFormat = alGetEnumValue("AL_FORMAT_QUAD16");
|
||||||
|
if(ch == 6) bufFormat = alGetEnumValue("AL_FORMAT_51CHN16");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(bufFormat == 0)
|
if(bufFormat == 0)
|
||||||
|
|
Loading…
Reference in a new issue