void KX_SoundActuator::play()
{
if(m_handle)
+ {
AUD_stop(m_handle);
+ m_handle = NULL;
+ }
if(!m_sound)
return;
break;
}
+ m_handle = AUD_play(sound, 0);
+
+ if(sound2)
+ AUD_unload(sound2);
+
+ if(!m_handle)
+ return;
+
if(m_is3d)
{
- // sound shall be played 3D
- m_handle = AUD_play(sound, 0);
-
AUD_setRelative(m_handle, false);
AUD_setVolumeMaximum(m_handle, m_3d.max_gain);
AUD_setVolumeMinimum(m_handle, m_3d.min_gain);
AUD_setConeAngleOuter(m_handle, m_3d.cone_outer_angle);
AUD_setConeVolumeOuter(m_handle, m_3d.cone_outer_gain);
}
- else
- m_handle = AUD_play(sound, 0);
if(loop)
AUD_setLoop(m_handle, -1);
AUD_setSoundPitch(m_handle, m_pitch);
AUD_setSoundVolume(m_handle, m_volume);
m_isplaying = true;
-
- if(sound2)
- AUD_unload(sound2);
}
CValue* KX_SoundActuator::GetReplica()
return false;
// actual audio device playing state
- bool isplaying = AUD_getStatus(m_handle) == AUD_STATUS_PLAYING;
+ bool isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
if (bNegativeEvent)
{
case KX_SOUNDACT_LOOPBIDIRECTIONAL_STOP:
{
// stop immediately
- AUD_stop(m_handle);
+ if(m_handle)
+ AUD_stop(m_handle);
+ m_handle = NULL;
break;
}
case KX_SOUNDACT_PLAYEND:
case KX_SOUNDACT_LOOPBIDIRECTIONAL:
{
// stop the looping so that the sound stops when it finished
- AUD_setLoop(m_handle, 0);
+ if(m_handle)
+ AUD_setLoop(m_handle, 0);
break;
}
default:
play();
}
// verify that the sound is still playing
- isplaying = AUD_getStatus(m_handle) == AUD_STATUS_PLAYING ? true : false;
+ isplaying = m_handle ? (AUD_getStatus(m_handle) == AUD_STATUS_PLAYING) : false;
if (isplaying)
{
"startSound()\n"
"\tStarts the sound.\n")
{
- switch(AUD_getStatus(m_handle))
+ if(m_handle)
{
- case AUD_STATUS_PLAYING:
- break;
- case AUD_STATUS_PAUSED:
- AUD_resume(m_handle);
- break;
- default:
- play();
+ switch(AUD_getStatus(m_handle))
+ {
+ case AUD_STATUS_PLAYING:
+ break;
+ case AUD_STATUS_PAUSED:
+ AUD_resume(m_handle);
+ break;
+ default:
+ play();
+ }
}
Py_RETURN_NONE;
}
"pauseSound()\n"
"\tPauses the sound.\n")
{
- AUD_pause(m_handle);
+ if(m_handle)
+ AUD_pause(m_handle);
Py_RETURN_NONE;
}
"stopSound()\n"
"\tStops the sound.\n")
{
- AUD_stop(m_handle);
+ if(m_handle)
+ AUD_stop(m_handle);
+ m_handle = NULL;
Py_RETURN_NONE;
}