2 Cafu Engine, http://www.cafu.de/
3 Copyright (c) Carsten Fuchs and other contributors.
4 This project is licensed under the terms of the MIT license.
7 #include "StreamingBuffer.hpp"
9 #include "fmod.h" // FMOD
11 #include "fmod_errors.h" // FMOD Error Messages
17 StreamingBufferT::StreamingBufferT(const std::string
& AudioFile
, bool Is3DSound
)
19 m_Stream(FSOUND_Stream_Open(AudioFile
.c_str(), Is3DSound
? FSOUND_HW3D
| FSOUND_FORCEMONO
: FSOUND_HW2D
, 0, 0))
21 if (m_Stream
==NULL
) std::cout
<< "FMOD3: Error creating stream from '" << AudioFile
<< "'\n";
25 StreamingBufferT::~StreamingBufferT()
27 if (m_Stream
==NULL
) return;
29 FSOUND_Stream_Close(m_Stream
);
33 int StreamingBufferT::AttachToChannel(unsigned int Priority
)
35 if (m_Stream
==NULL
) return -1;
37 // Note: Streams have always a priority of 256 in FMOD and can never be rejected.
38 // The only thing we can do is set the custom priority after a channel has been set.
39 int ChannelHandle
=FSOUND_Stream_PlayEx(FSOUND_FREE
, m_Stream
, NULL
, true);
41 if(FSOUND_SetPriority(ChannelHandle
, Priority
)==false)
42 std::cout
<< "FMOD3: [Warning] Couldn't set channel priority for '" << FileName
<< "'\n";
48 void StreamingBufferT::Rewind()
50 FSOUND_Stream_SetPosition(m_Stream
, 0);