*/
CIN_EXPORT(unsigned) Cin_StructSoundSize();
+/**
+ * @brief Causes a sound to play.
+ *
+ * This will trigger the sound to play without looping.
+ *
+ * Calling play on a sound that is already playing will do nothing. To restart
+ * a sound, use Cin_SoundStop first.
+ */
CIN_EXPORT(enum Cin_SoundError) Cin_SoundPlay(struct Cin_Sound *snd);
+/**
+ * @brief Causes a sound to play with optional looping.
+ *
+ * The sound will loop if the loop param is non-zero.
+ *
+ * Calling play on a sound that is already playing will do nothing. To restart
+ * a sound, use Cin_SoundStop first.
+ *
+ * @sa Cin_SoundPlay
+ */
+CIN_EXPORT(enum Cin_SoundError) Cin_SoundPlayLoop(struct Cin_Sound *snd,
+ int loop);
+
CIN_EXPORT(enum Cin_SoundError) Cin_SoundStop(struct Cin_Sound *snd);
CIN_EXPORT(void) Cin_DestroySound(struct Cin_Sound *snd);
\r
///////////////////////////////////////////////////////////////////////////////\r
\r
+CIN_EXPORT(enum Cin_SoundError) Cin_SoundPlayLoop(Cin_Sound *snd, int loop){\r
+ snd->play(!!loop);\r
+ return Cin_eSoundSuccess;\r
+}\r
+\r
+///////////////////////////////////////////////////////////////////////////////\r
+\r
CIN_EXPORT(enum Cin_SoundError) Cin_SoundStop(Cin_Sound *snd){\r
snd->stop();\r
return Cin_eSoundSuccess;\r
#include "cinnamon.h"\r
#include "cin_soft_loader.h"\r
\r
+#include <assert.h>\r
+\r
#include <mmreg.h>\r
#include <ks.h>\r
#include <ksmedia.h>\r
fmt.Format.wBitsPerSample = bytes_per_sample << 3;\r
\r
// Check the size of the loader data.\r
+\r
const unsigned byte_size = ld.bytes_placed;\r
#ifndef NDEBUG\r
{\r
assert(debug_byte_size == byte_size);\r
}\r
#endif\r
-\r
+ \r
+ \r
DSBUFFERDESC descriptor;\r
descriptor.dwSize = sizeof(DSBUFFERDESC);\r
descriptor.dwFlags = DSBCAPS_GLOBALFOCUS;\r
buffer_size == byte_size){\r
\r
Cin_LoaderMemcpy(ld.first, 0, buffer_data, byte_size);\r
- m_buffer->Unlock(buffer_data, byte_size, NULL, 0);\r
+ if(m_buffer->Unlock(buffer_data, byte_size, NULL, 0) != DS_OK){\r
+ m_dsound->Release();\r
+ m_buffer->Release();\r
+ m_buffer = NULL;\r
+ }\r
}\r
else{\r
m_dsound->Release();\r
/*****************************************************************************/
+enum Cin_SoundError Cin_SoundPlayLoop(struct Cin_Sound *snd, int loop){
+ alcMakeContextCurrent(snd->ctx);
+ alSourcei(snd->snd, AL_LOOPING, (loop==0) ? AL_FALSE : AL_TRUE);
+ alSourcePlay(snd->snd);
+ return Cin_eSoundSuccess;
+}
+
+/*****************************************************************************/
+
enum Cin_SoundError Cin_SoundStop(struct Cin_Sound *snd){
alcMakeContextCurrent(snd->ctx);
alSourceStop(snd->snd);