[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: =?utf-8?q?=5Bgluon=5D_/=3A_GluonAudio=3A=3ASound=3A_don=27t_crea?=
From: Guillaume Martres <smarter () ubuntu ! com>
Date: 2011-01-26 16:21:08
Message-ID: 20110126162108.69BCFA60AE () git ! kde ! org
[Download RAW message or body]
Git commit 599fbfb08c9d7e53fd0075b16efa4b8093c250f2 by Guillaume Martres.
Pushed by gmartres into branch 'master'.
GluonAudio::Sound: don't create a source if we don't have a file to load
GluonAudio::Engine: use the new GLUON_DEFINE_SINGLETON macro
M +1 -1 audio/engine.cpp
M +17 -7 audio/sound.cpp
M +2 -1 player/examples/invaders/Invaders.gluon
http://commits.kde.org/fad2ae7b/599fbfb08c9d7e53fd0075b16efa4b8093c250f2
diff --git a/audio/engine.cpp b/audio/engine.cpp
index 38e0c59..caee256 100644
--- a/audio/engine.cpp
+++ b/audio/engine.cpp
@@ -26,7 +26,7 @@
using namespace GluonAudio;
-template<> Engine* GluonCore::Singleton<Engine>::m_instance = 0;
+GLUON_DEFINE_SINGLETON(Engine)
class Engine::EnginePrivate {
public:
diff --git a/audio/sound.cpp b/audio/sound.cpp
index d967186..14d8d9c 100644
--- a/audio/sound.cpp
+++ b/audio/sound.cpp
@@ -53,7 +53,7 @@ class Sound::SoundPrivate
}
return false;
}
-
+
void init()
{
isValid = true;
@@ -68,10 +68,19 @@ class Sound::SoundPrivate
pitch = 1.0f;
radius = 10000.0f;
+ }
+
+ bool setupSource()
+ {
+ if (path.isEmpty()) {
+ return false;
+ }
+
alGenSources( 1, &source );
if (source == 0) {
DEBUG_BLOCK
DEBUG_TEXT2("Empty source, OpenAL error: %1", alGetError())
+ return false;
}
ALfloat sourcePosition[] = { position.x(), position.y() , position.z() };
@@ -80,8 +89,9 @@ class Sound::SoundPrivate
alSourcef( source, AL_PITCH, pitch );
alSourcef( source, AL_REFERENCE_DISTANCE, radius );
}
-
- void _k_deleteSource() {
+
+ void _k_deleteSource()
+ {
if (source != 0) {
alureStopSource(source, false);
alDeleteSources(1, &source);
@@ -94,10 +104,10 @@ class Sound::SoundPrivate
}
stream = 0;
}
-
+
QTimer *killTimer;
QString path;
-
+
bool isValid;
bool isStreamed;
bool isPaused;
@@ -109,7 +119,7 @@ class Sound::SoundPrivate
ALfloat volume;
ALfloat pitch;
ALfloat radius;
-
+
static const int maxInactivtyTime = 1000;
};
@@ -166,7 +176,6 @@ bool Sound::loadFile(const QString& fileName, bool toStream)
}
if (!d->path.isEmpty()) {
d->_k_deleteSource();
- d->init();
} else {
d->killTimer = new QTimer(this);
d->killTimer->setSingleShot(true);
@@ -174,6 +183,7 @@ bool Sound::loadFile(const QString& fileName, bool toStream)
connect(d->killTimer, SIGNAL(timeout()), SLOT(_k_deleteSource()));
}
d->path = fileName;
+ d->setupSource();
d->isStreamed = toStream;
if (d->isStreamed) {
alureStreamSizeIsMicroSec(true);
diff --git a/player/examples/invaders/Invaders.gluon b/player/examples/invaders/Invaders.gluon
index ee2992a..b912156 100644
--- a/player/examples/invaders/Invaders.gluon
+++ b/player/examples/invaders/Invaders.gluon
@@ -77,7 +77,7 @@
{ GluonEngine::MaterialAsset(Material)
file url(Assets/Invaders_Assets_Material.gml)
{ GluonGraphics::MaterialInstance(Menu Text)
- materialColor rgba(255;255;255;255)
+ materialColor rgba(74;74;74;255)
texture0 string(play.png)
}
{ GluonGraphics::MaterialInstance(Icon)
@@ -121,6 +121,7 @@
file url(Assets/Invaders_Assets_Material_1.gml)
{ GluonGraphics::MaterialInstance(Main)
materialColor rgba(255;255;255;255)
+ texture0 uint(40)
}
}
}
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic