diff --git a/haxelib.json b/haxelib.json
index e1dd7a4ca..30239766b 100644
--- a/haxelib.json
+++ b/haxelib.json
@@ -5,7 +5,7 @@
"tags": [ "cpp", "neko", "nme", "opengl", "sdl", "android", "ios" ],
"description": "NME provides a backend for native iOS, Android, Windows, Mac and Linux applications, using a Flash inspired API",
"version": "5.4.0",
- "binaryversion": "66",
+ "binaryversion": "67",
"releasenote": "see Changes.md",
"contributors": [ "gamehaxe" ],
"dependencies": {}
diff --git a/project/Build.xml b/project/Build.xml
index bd6094680..597ed68f4 100644
--- a/project/Build.xml
+++ b/project/Build.xml
@@ -170,11 +170,8 @@
-
-
+
@@ -211,7 +208,9 @@
-
+
+
+
diff --git a/project/include/Audio.h b/project/include/Audio.h
index 8f21dd2ca..783fe0588 100644
--- a/project/include/Audio.h
+++ b/project/include/Audio.h
@@ -22,7 +22,7 @@
#define LOG_SOUND(args,...) printf(args, ##__VA_ARGS__);
#endif
#else
- #define LOG_SOUND(args...) { }
+ #define LOG_SOUND(args,...) { }
#endif
@@ -35,7 +35,7 @@ namespace nme
virtual ~AudioStream() {}
virtual bool open(const std::string &path, int startTime)=0;
- virtual int getLength(const std::string &path) = 0;
+ virtual double getLength(const std::string &path) = 0;
virtual double getPosition() = 0;
virtual double setPosition(const float &inFloat) = 0;
virtual int fillBuffer(char *outBuffer, int inRequestBytes) = 0;
diff --git a/project/src/common/OggStream.cpp b/project/src/common/OggStream.cpp
index c4cd7c289..08e398892 100644
--- a/project/src/common/OggStream.cpp
+++ b/project/src/common/OggStream.cpp
@@ -105,7 +105,7 @@ class AudioStream_Ogg : public AudioStream
- int getLength(const std::string &path)
+ double getLength(const std::string &path)
{
int result;
mPath = std::string(path.c_str());
diff --git a/project/src/sdl/SDLSound.cpp b/project/src/sdl/SDLSound.cpp
index 1191ed2d2..d99d5d9ae 100644
--- a/project/src/sdl/SDLSound.cpp
+++ b/project/src/sdl/SDLSound.cpp
@@ -1,3 +1,4 @@
+#include
#include
#include
#include
@@ -6,6 +7,7 @@
#include
+using namespace nme::Audio;
namespace nme
{
@@ -412,12 +414,24 @@ class SDLSound : public Sound
}
double getLength()
{
- if (mChunk==0) return 0;
+ if (mChunk==0)
+ return 0;
#if defined(DYNAMIC_SDL) || defined(WEBOS)
- // ?
return 0.0;
#else
- return 0.0;
+
+
+ int freq = 0;
+ Uint16 format = 0;
+ int channels = 0;
+ Mix_QuerySpec(&freq, &format, &channels);
+
+ if (freq==0)
+ return 0;
+
+ int bytesPerSample = 2;
+ return (double)1000.0*mChunk->alen/(freq*channels*bytesPerSample);
+
#endif
}
// Will return with one ref...
@@ -537,6 +551,7 @@ class SDLMusic : public Sound
bool loaded;
std::string filename;
std::vector reso;
+ double duration;
public:
SDLMusic(const std::string &inFilename)
@@ -544,6 +559,7 @@ class SDLMusic : public Sound
filename = inFilename;
loaded = false;
mMusic = 0;
+ duration = 0;
IncRef();
if (gSDLAudioState!=sdaNotInit)
@@ -566,8 +582,17 @@ class SDLMusic : public Sound
#endif
mMusic = Mix_LoadMUS(name);
-
- if (!mMusic)
+ if (mMusic)
+ {
+ AudioFormat fmt = determineFormatFromFile(name);
+ if (fmt==eAF_ogg)
+ {
+ AudioStream *s = AudioStream::createOgg();
+ duration = s->getLength(name)*1000.0;
+ delete s;
+ }
+ }
+ else
{
ByteArray resource(filename.c_str());
if (resource.Ok())
@@ -582,6 +607,12 @@ class SDLMusic : public Sound
#else
mMusic = Mix_LoadMUS_RW(SDL_RWFromConstMem(&reso[0], resource.Size()));
#endif
+
+ if (mMusic)
+ {
+ // TODO
+ duration = 60000.0;
+ }
}
}
}
@@ -622,9 +653,7 @@ class SDLMusic : public Sound
}
double getLength()
{
- if (mMusic==0) return 0;
- // TODO:
- return 60000;
+ return duration;
}
// Will return with one ref...
SoundChannel *openChannel(double startTime, int loops, const SoundTransform &inTransform)
diff --git a/samples/06-Sound/Sample.hx b/samples/06-Sound/Sample.hx
index add64a094..4c1a18947 100644
--- a/samples/06-Sound/Sample.hx
+++ b/samples/06-Sound/Sample.hx
@@ -151,7 +151,7 @@ class Sample extends Sprite
}
}
- function doDelay(_) { Sys.sleep(1.0); }
+ //function doDelay(_) { Sys.sleep(1.0); }
function playMusic(inId:String)
{