summaryrefslogtreecommitdiffstats
path: root/src/imports/audioengine/qaudioengine_openal_p.cpp
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2015-04-14 09:32:14 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-04-15 10:26:37 +0000
commit0f9a779f7214f22dfa4625b91dbc3e4d0fc1c122 (patch)
treead16041f0f4e614e6212cf4c2cae8e34c6896c77 /src/imports/audioengine/qaudioengine_openal_p.cpp
parent51d6b5c811c0e55888ae2e8404bd92f94d5a5aac (diff)
[QSoundBuffer] Replace isReady() with state() states
The two-state "isReady" is not enough for checking if loading was already requested. This also makes it abvious we're accepting load() after error. Change-Id: I8181f99e8b36be484ec791862941b5b2ec78eb1f Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
Diffstat (limited to 'src/imports/audioengine/qaudioengine_openal_p.cpp')
-rw-r--r--src/imports/audioengine/qaudioengine_openal_p.cpp23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/imports/audioengine/qaudioengine_openal_p.cpp b/src/imports/audioengine/qaudioengine_openal_p.cpp
index c71695ad0..839a584c5 100644
--- a/src/imports/audioengine/qaudioengine_openal_p.cpp
+++ b/src/imports/audioengine/qaudioengine_openal_p.cpp
@@ -58,7 +58,7 @@ StaticSoundBufferAL::StaticSoundBufferAL(QObject *parent, const QUrl &url, QSamp
m_ref(1),
m_url(url),
m_alBuffer(0),
- m_isReady(false),
+ m_state(Creating),
m_sample(0),
m_sampleLoader(sampleLoader)
{
@@ -79,10 +79,19 @@ StaticSoundBufferAL::~StaticSoundBufferAL()
}
}
+QSoundBuffer::State StaticSoundBufferAL::state() const
+{
+ return m_state;
+}
+
void StaticSoundBufferAL::load()
{
- if (m_sample)
+ if (m_state == Loading || m_state == Ready)
return;
+
+ m_state = Loading;
+ emit stateChanged(m_state);
+
m_sample = m_sampleLoader->requestSample(m_url);
connect(m_sample, SIGNAL(error()), this, SLOT(decoderError()));
connect(m_sample, SIGNAL(ready()), this, SLOT(sampleReady()));
@@ -98,11 +107,6 @@ void StaticSoundBufferAL::load()
}
}
-bool StaticSoundBufferAL::isReady() const
-{
- return m_isReady;
-}
-
void StaticSoundBufferAL::bindToSource(ALuint alSource)
{
Q_ASSERT(m_alBuffer != 0);
@@ -162,7 +166,8 @@ void StaticSoundBufferAL::sampleReady()
m_sample->release();
m_sample = 0;
- m_isReady = true;
+ m_state = Ready;
+ emit stateChanged(m_state);
emit ready();
}
@@ -176,6 +181,8 @@ void StaticSoundBufferAL::decoderError()
m_sample->release();
m_sample = 0;
+ m_state = Error;
+ emit stateChanged(m_state);
emit error();
}