sfml-audio-0.7.0.1816/ 0000755 0000000 0000000 00000000000 11770572147 012355 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/sfml-audio.cabal 0000644 0000000 0000000 00000007252 11770572147 015407 0 ustar 00 0000000 0000000 Name: sfml-audio
Version: 0.7.0.1816
Synopsis: minimal bindings to the audio module of sfml
Description: Provides a very minimal interface to the audio module of sfml.
Currently, only the playing of sounds is covered.
Playing background music is not yet supported, but planned.
(sfml is a multimedia library: )
Homepage: http://patch-tag.com/r/shahn/sfml-audio
License: OtherLicense
License-file: LICENSE
Author: Sönke Hahn
Maintainer: shahn@joyridelabs.de
Stability: Beta
Category: Sound
Build-type: Simple
Cabal-version: >=1.6
-- headers used for compiling the cabal-package
extra-source-files:
-- sfml
dependencies/sfml2/include/SFML/*.hpp
dependencies/sfml2/include/SFML/Audio/*.hpp
dependencies/sfml2/include/SFML/System/*.hpp
dependencies/sfml2/include/SFML/System/*.inl
dependencies/sfml2/src/SFML/Audio/*.hpp
dependencies/sfml2/src/SFML/System/*.hpp
dependencies/sfml2/src/SFML/System/Unix/*.hpp
dependencies/sfml2/src/SFML/System/Win32/*.hpp
-- csfml
dependencies/sfml2/bindings/c/include/SFML/Audio/*.h
dependencies/sfml2/bindings/c/include/SFML/*.h
dependencies/sfml2/bindings/c/src/SFML/Audio/*.h
dependencies/sfml2/bindings/c/src/SFML/*.h
source-repository head
type: darcs
location: http://patch-tag.com/r/shahn/sfml-audio
Library
Exposed-modules: Sound.SFML, Sound.SFML.LowLevel
hs-source-dirs: src
-- Packages needed in order to build this package.
Build-depends:
base >= 4 && < 5
extra-libraries:
stdc++, sndfile
if os(linux)
extra-libraries:
openal, pthread
if os(mingw32)
extra-libraries:
openal32
if os(darwin)
frameworks:
OpenAL
includes:
al.h
sndfile.h
cc-options:
-O3
-DNDEBUG
-DSFML_EXPORTS
-DSFML_SYSTEM_EXPORTS
-DSFML_AUDIO_EXPORTS
-DCSFML_EXPORTS
if os(darwin)
cc-options:
-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5
ld-options:
-isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5
include-dirs:
dependencies/sfml2/include
dependencies/sfml2/src
dependencies/sfml2/bindings/c/include
dependencies/sfml2/bindings/c/src
-- sfml audio
c-sources:
dependencies/sfml2/src/SFML/Audio/ALCheck.cpp
dependencies/sfml2/src/SFML/Audio/AudioDevice.cpp
dependencies/sfml2/src/SFML/Audio/Music.cpp
dependencies/sfml2/src/SFML/Audio/SoundBuffer.cpp
dependencies/sfml2/src/SFML/Audio/Sound.cpp
dependencies/sfml2/src/SFML/Audio/SoundFile.cpp
dependencies/sfml2/src/SFML/Audio/SoundSource.cpp
dependencies/sfml2/src/SFML/Audio/SoundStream.cpp
-- sfml system
c-sources:
dependencies/sfml2/src/SFML/System/Err.cpp
dependencies/sfml2/src/SFML/System/Lock.cpp
dependencies/sfml2/src/SFML/System/Mutex.cpp
dependencies/sfml2/src/SFML/System/Sleep.cpp
dependencies/sfml2/src/SFML/System/Thread.cpp
if os(linux) || os(darwin)
c-sources:
dependencies/sfml2/src/SFML/System/Unix/MutexImpl.cpp
dependencies/sfml2/src/SFML/System/Unix/Platform.cpp
dependencies/sfml2/src/SFML/System/Unix/ThreadImpl.cpp
if os(mingw32)
c-sources:
dependencies/sfml2/src/SFML/System/Win32/MutexImpl.cpp
dependencies/sfml2/src/SFML/System/Win32/Platform.cpp
dependencies/sfml2/src/SFML/System/Win32/ThreadImpl.cpp
-- csfml audio
c-sources:
dependencies/sfml2/bindings/c/src/SFML/Audio/Music.cpp
dependencies/sfml2/bindings/c/src/SFML/Audio/SoundBuffer.cpp
dependencies/sfml2/bindings/c/src/SFML/Audio/Sound.cpp
sfml-audio-0.7.0.1816/LICENSE 0000644 0000000 0000000 00000002453 11770572147 013366 0 ustar 00 0000000 0000000 sfml-audio are haskell bindings to a small subset of the API of the audio
module of SFML2 (http://www.sfml-dev.org/). The source code (and other content)
of SFML2 (svn checkout, revision 1816, currently in
https://sfml.svn.sourceforge.net/svnroot/sfml/branches/sfml2)
is partially included in sfml-audio (in the "dependencies" directory).
sfml-audio is provided under the same terms as SFML2.
SFML's license:
==============
SFML - Copyright (c) 2007-2009 Laurent Gomila - laurent.gom@gmail.com
This software is provided 'as-is', without any express or
implied warranty. In no event will the authors be held
liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute
it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented;
you must not claim that you wrote the original software.
If you use this software in a product, an acknowledgment
in the product documentation would be appreciated but
is not required.
2. Altered source versions must be plainly marked as such,
and must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any
source distribution.
sfml-audio-0.7.0.1816/Setup.hs 0000644 0000000 0000000 00000000106 11770572147 014006 0 ustar 00 0000000 0000000 #!/usr/bin/runhaskell
import Distribution.Simple
main = defaultMain
sfml-audio-0.7.0.1816/src/ 0000755 0000000 0000000 00000000000 11770572147 013144 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/src/Sound/ 0000755 0000000 0000000 00000000000 11770572147 014234 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/src/Sound/SFML.hs 0000644 0000000 0000000 00000012260 11770572147 015332 0 ustar 00 0000000 0000000
-- High level api for playing sounds (and background music)
module Sound.SFML (
-- * PolySounds
PolySound,
newPolySound,
freePolySound,
triggerPolySound,
-- * LoopedSounds
LoopedSound,
newLoopedSound,
freeLoopedSound,
startLoopedSound,
stopLoopedSound,
-- * background music
playMusic,
playMusicLooped,
stopMusic,
pauseMusic,
) where
import Prelude hiding (mapM_)
import Data.Maybe
import Data.IORef
import Data.Foldable (forM_, mapM_)
import Data.Traversable (forM)
import Control.Monad (when)
import Control.Concurrent.MVar
import System.IO.Unsafe
import Foreign.Ptr
import Sound.SFML.LowLevel
-- * PolySounds
-- | A PolySound allows you to trigger one sound multiple times.
-- The played sounds will then overlap.
-- (Internally, there will be multiple sound instances, that will
-- be triggered one after the other. If there are not enough internal
-- instances, sounds will be cut.)
data PolySound = PolySound FilePath (Ptr SoundBuffer) [Ptr Sound] (IORef Int)
instance Show PolySound where
show (PolySound file _ _ _) = "PolySound " ++ show file
-- | Loads a sound into memory.
newPolySound ::
FilePath -- ^ soundfile
-> Int -- ^ number of internal sound instances.
-> IO PolySound
newPolySound path numberOfVoices = do
buffer <- sfSoundBuffer_CreateFromFile path
sounds <- forM [1 .. numberOfVoices] $ \ _ -> do
sound <- sfSound_Create
sfSound_SetBuffer sound buffer
return sound
ref <- newIORef 0
return $ PolySound path buffer sounds ref
-- | Frees the memory allocated by a sound. Don't use the PolySound afterwards.
freePolySound :: PolySound -> IO ()
freePolySound (PolySound _ buffer sounds _) = do
sfSoundBuffer_Destroy buffer
mapM_ sfSound_Destroy sounds
-- | Trigger a sound
triggerPolySound :: PolySound -> Maybe Float -> IO ()
triggerPolySound (PolySound _ _ sounds ref) volume = do
i <- readIORef ref
let sound = sounds !! i
status <- getSoundStatus sound
when (status == Stopped) $ do
writeIORef ref ((i + 1) `mod` length sounds)
sfSound_SetVolume sound ((fromMaybe 1 volume) * 100)
sfSound_Play sound
-- * LoopedSounds
-- | LoopedSounds are sounds that will always loop.
-- They can just be switched on and off.
newtype LoopedSound = LoopedSound (Ptr Sound)
deriving Show
-- | Loads a sound into memory.
newLoopedSound :: FilePath -> IO LoopedSound
newLoopedSound path = do
buffer <- sfSoundBuffer_CreateFromFile path
sound <- sfSound_Create
sfSound_SetBuffer sound buffer
sfSound_SetLoop sound True
return $ LoopedSound sound
-- | Releases the allocated memory of a LoopedSound.
-- Don't use the LoopedSound afterwards.
freeLoopedSound :: LoopedSound -> IO ()
freeLoopedSound (LoopedSound ptr) =
sfSound_Destroy ptr
-- | Starts a looped sound.
startLoopedSound :: Maybe Float -> LoopedSound -> IO ()
startLoopedSound volume (LoopedSound ptr) = do
sfSound_SetVolume ptr ((fromMaybe 1 volume) * 100)
sfSound_Play ptr
-- | Stops a looped sound.
stopLoopedSound :: LoopedSound -> IO ()
stopLoopedSound (LoopedSound ptr) =
sfSound_Stop ptr
-- * Music
-- There is always only one music being played at a single point in time.
-- | Loads and plays a music file once in a background thread.
-- Stops other music that is playing.
-- If the current music is Paused and the given file is the same as the one playing,
-- the music is continued.
-- The volume is set again in any case.
playMusic :: FilePath -> Maybe Float -> IO ()
playMusic = _playMusic False
-- |Like 'playMusic', but looping.
playMusicLooped :: FilePath -> Maybe Float -> IO ()
playMusicLooped = _playMusic True
_playMusic :: Bool -> FilePath -> Maybe Float -> IO ()
_playMusic looped file volume = modifyMVar_ _globalMusic $ \ mOldMusic -> do
case mOldMusic of
Just (oldFile, oldMusic) -> do
status <- getMusicStatus oldMusic
case status of
Paused | file == oldFile -> do
sfMusic_SetLoop oldMusic looped
sfMusic_SetVolume oldMusic ((fromMaybe 1 volume) * 100)
sfMusic_Play oldMusic
return $ Just (file, oldMusic)
_ -> do
sfMusic_Stop oldMusic
sfMusic_Destroy oldMusic
startNewMusic
Nothing -> startNewMusic
where
startNewMusic = do
music <- sfMusic_CreateFromFile file
sfMusic_SetLoop music looped
sfMusic_SetVolume music ((fromMaybe 1 volume) * 100)
sfMusic_Play music
return $ Just (file, music)
-- | Stops any background music that is playing.
stopMusic :: IO ()
stopMusic = modifyMVar_ _globalMusic $ \ mOldMusic -> do
forM_ mOldMusic $ \ (_, oldMusic) -> do
sfMusic_Stop oldMusic
sfMusic_Destroy oldMusic
return Nothing
-- | Pauses the current music.
pauseMusic :: IO ()
pauseMusic = modifyMVar_ _globalMusic $ \ mMusic -> do
mapM_ (sfMusic_Pause . snd) mMusic
return mMusic
{-# noinline _globalMusic #-}
-- all music-related functions are synchronized by this global MVar.
_globalMusic :: MVar (Maybe (FilePath, Ptr Music))
_globalMusic = unsafePerformIO $ newMVar Nothing
sfml-audio-0.7.0.1816/src/Sound/SFML/ 0000755 0000000 0000000 00000000000 11770572147 014775 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/src/Sound/SFML/LowLevel.hs 0000644 0000000 0000000 00000004050 11770572147 017061 0 ustar 00 0000000 0000000 {-# language ForeignFunctionInterface, EmptyDataDecls #-}
module Sound.SFML.LowLevel where
import Control.Applicative
import Foreign.Ptr
import Foreign.C.String
-- * Common
toStatus :: Int -> Status
toStatus = toEnum
data Status
= Stopped
| Paused
| Playing
deriving (Eq, Enum, Show)
-- * SoundBuffer
data SoundBuffer
sfSoundBuffer_CreateFromFile :: FilePath -> IO (Ptr SoundBuffer)
sfSoundBuffer_CreateFromFile path = withCString path c__sfSoundBuffer_CreateFromFile
foreign import ccall "sfSoundBuffer_CreateFromFile" c__sfSoundBuffer_CreateFromFile ::
CString -> IO (Ptr SoundBuffer)
foreign import ccall sfSoundBuffer_Destroy :: Ptr SoundBuffer -> IO ()
-- * Sound
data Sound
foreign import ccall sfSound_Create :: IO (Ptr Sound)
foreign import ccall sfSound_SetBuffer :: Ptr Sound -> Ptr SoundBuffer -> IO ()
foreign import ccall sfSound_Play :: Ptr Sound -> IO ()
foreign import ccall sfSound_Stop :: Ptr Sound -> IO ()
foreign import ccall sfSound_Destroy :: Ptr Sound -> IO ()
foreign import ccall sfSound_SetLoop :: Ptr Sound -> Bool -> IO ()
foreign import ccall sfSound_SetVolume :: Ptr Sound -> Float -> IO ()
foreign import ccall sfSound_GetStatus :: Ptr Sound -> IO Int
getSoundStatus s = toStatus <$> sfSound_GetStatus s
-- * Music
data Music
sfMusic_CreateFromFile :: FilePath -> IO (Ptr Music)
sfMusic_CreateFromFile path = withCString path c__sfMusic_CreateFromFile
foreign import ccall "sfMusic_CreateFromFile" c__sfMusic_CreateFromFile :: CString -> IO (Ptr Music)
foreign import ccall sfMusic_Destroy :: Ptr Music -> IO ()
foreign import ccall sfMusic_Play :: Ptr Music -> IO ()
foreign import ccall sfMusic_Stop :: Ptr Music -> IO ()
foreign import ccall sfMusic_Pause :: Ptr Music -> IO ()
foreign import ccall sfMusic_SetLoop :: Ptr Music -> Bool -> IO ()
foreign import ccall sfMusic_SetVolume :: Ptr Music -> Float -> IO ()
foreign import ccall sfMusic_GetDuration :: Ptr Music -> IO Float
foreign import ccall sfMusic_GetStatus :: Ptr Music -> IO Int
getMusicStatus s = toStatus <$> sfMusic_GetStatus s
sfml-audio-0.7.0.1816/dependencies/ 0000755 0000000 0000000 00000000000 11770572147 015003 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/ 0000755 0000000 0000000 00000000000 11770572147 016026 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/src/ 0000755 0000000 0000000 00000000000 11770572147 016615 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/ 0000755 0000000 0000000 00000000000 11770572147 017356 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/ 0000755 0000000 0000000 00000000000 11770572147 020642 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Thread.cpp 0000644 0000000 0000000 00000004360 11770572147 022560 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#if defined(SFML_SYSTEM_WINDOWS)
#include
#else
#include
#endif
namespace sf
{
////////////////////////////////////////////////////////////
Thread::~Thread()
{
Wait();
delete myFunction;
}
////////////////////////////////////////////////////////////
void Thread::Launch()
{
Wait();
myImpl = new priv::ThreadImpl(this);
}
////////////////////////////////////////////////////////////
void Thread::Wait()
{
if (myImpl)
{
myImpl->Wait();
delete myImpl;
myImpl = NULL;
}
}
////////////////////////////////////////////////////////////
void Thread::Terminate()
{
if (myImpl)
{
myImpl->Terminate();
delete myImpl;
myImpl = NULL;
}
}
////////////////////////////////////////////////////////////
void Thread::Run()
{
myFunction->Run();
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Sleep.cpp 0000644 0000000 0000000 00000003006 11770572147 022415 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
void Sleep(float duration)
{
if (duration >= 0)
priv::Platform::Sleep(duration);
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Mutex.cpp 0000644 0000000 0000000 00000003671 11770572147 022457 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#if defined(SFML_SYSTEM_WINDOWS)
#include
#else
#include
#endif
namespace sf
{
////////////////////////////////////////////////////////////
Mutex::Mutex()
{
myMutexImpl = new priv::MutexImpl;
}
////////////////////////////////////////////////////////////
Mutex::~Mutex()
{
delete myMutexImpl;
}
////////////////////////////////////////////////////////////
void Mutex::Lock()
{
myMutexImpl->Lock();
}
////////////////////////////////////////////////////////////
void Mutex::Unlock()
{
myMutexImpl->Unlock();
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Lock.cpp 0000644 0000000 0000000 00000003123 11770572147 022235 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
Lock::Lock(Mutex& mutex) :
myMutex(mutex)
{
myMutex.Lock();
}
////////////////////////////////////////////////////////////
Lock::~Lock()
{
myMutex.Unlock();
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Platform.hpp 0000644 0000000 0000000 00000003002 11770572147 023132 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_PLATFORM_HPP
#define SFML_PLATFORM_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#if defined(SFML_SYSTEM_WINDOWS)
#include
#else
#include
#endif
#endif // SFML_PLATFORM_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Err.cpp 0000644 0000000 0000000 00000006412 11770572147 022101 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
////////////////////////////////////////////////////////////
// Private data
////////////////////////////////////////////////////////////
namespace
{
// This class will be used as the default streambuf of sf::Err,
// it outputs to stderr by default (to keep the default beaviour)
class DefaultErrStreamBuf : public std::streambuf
{
public :
DefaultErrStreamBuf()
{
// Allocate the write buffer
static const int size = 64;
char* buffer = new char[size];
setp(buffer, buffer + size);
}
~DefaultErrStreamBuf()
{
// Synchronize
sync();
// Delete the write buffer
delete[] pbase();
}
private :
virtual int overflow(int character)
{
if ((character != EOF) && (pptr() != epptr()))
{
// Valid character
return sputc(static_cast(character));
}
else if (character != EOF)
{
// Not enough space in the buffer: synchronize output and try again
sync();
return overflow(character);
}
else
{
// Invalid character: synchronize output
return sync();
}
}
virtual int sync()
{
// Check if there is something into the write buffer
if (pbase() != pptr())
{
// Print the contents of the write buffer into the standard error output
std::size_t size = static_cast(pptr() - pbase());
fwrite(pbase(), 1, size, stderr);
// Reset the pointer position to the beginning of the write buffer
setp(pbase(), epptr());
}
return 0;
}
};
}
namespace sf
{
////////////////////////////////////////////////////////////
std::ostream& Err()
{
static DefaultErrStreamBuf buffer;
static std::ostream stream(&buffer);
return stream;
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/ 0000755 0000000 0000000 00000000000 11770572147 021565 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/MutexImpl.cpp 0000644 0000000 0000000 00000003610 11770572147 024215 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
MutexImpl::MutexImpl()
{
pthread_mutex_init(&myMutex, NULL);
}
////////////////////////////////////////////////////////////
MutexImpl::~MutexImpl()
{
pthread_mutex_destroy(&myMutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Lock()
{
pthread_mutex_lock(&myMutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Unlock()
{
pthread_mutex_unlock(&myMutex);
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/ThreadLocalImpl.hpp 0000644 0000000 0000000 00000005746 11770572147 025316 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_THREADLOCALIMPL_HPP
#define SFML_THREADLOCALIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Unix implementation of thread-local storage
////////////////////////////////////////////////////////////
class ThreadLocalImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor -- allocate the storage
///
////////////////////////////////////////////////////////////
ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// \brief Destructor -- free the storage
///
////////////////////////////////////////////////////////////
~ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// \brief Set the thread-specific value of the variable
///
/// \param value Value of the variable for this thread
///
////////////////////////////////////////////////////////////
void SetValue(void* value);
////////////////////////////////////////////////////////////
/// \brief Retrieve the thread-specific value of the variable
///
/// \return Value of the variable for this thread
///
////////////////////////////////////////////////////////////
void* GetValue() const;
private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
pthread_key_t myKey; ///< Index of our thread-local storage slot
};
} // namespace priv
} // namespace sf
#endif // SFML_THREADLOCALIMPL_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/Platform.cpp 0000644 0000000 0000000 00000003422 11770572147 024056 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
double Platform::GetSystemTime()
{
timeval time = {0, 0};
gettimeofday(&time, NULL);
return time.tv_sec + time.tv_usec / 1000000.;
}
////////////////////////////////////////////////////////////
void Platform::Sleep(float time)
{
usleep(static_cast(time * 1000000));
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/ThreadImpl.cpp 0000644 0000000 0000000 00000004671 11770572147 024332 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
ThreadImpl::ThreadImpl(Thread* owner) :
myIsActive(true)
{
myIsActive = pthread_create(&myThread, NULL, &ThreadImpl::EntryPoint, owner) == 0;
if (!myIsActive)
std::cerr << "Failed to create thread" << std::endl;
}
////////////////////////////////////////////////////////////
void ThreadImpl::Wait()
{
if (myIsActive)
pthread_join(myThread, NULL);
}
////////////////////////////////////////////////////////////
void ThreadImpl::Terminate()
{
if (myIsActive)
pthread_cancel(myThread);
}
////////////////////////////////////////////////////////////
void* ThreadImpl::EntryPoint(void* userData)
{
// The Thread instance is stored in the user data
Thread* owner = static_cast(userData);
// Tell the thread to handle cancel requests immediatly
pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
// Forward to the owner
owner->Run();
return NULL;
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/Platform.hpp 0000644 0000000 0000000 00000004404 11770572147 024064 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_PLATFORMUNIX_HPP
#define SFML_PLATFORMUNIX_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Give access to some system-specific low-level functions
////////////////////////////////////////////////////////////
class Platform
{
public :
////////////////////////////////////////////////////////////
/// \brief Get the current system time
///
/// \return System time, in seconds
///
////////////////////////////////////////////////////////////
static double GetSystemTime();
////////////////////////////////////////////////////////////
/// \brief Suspend the execution of the current thread for a specified time
///
/// \param time Time to sleep, in seconds
///
////////////////////////////////////////////////////////////
static void Sleep(float time);
};
} // namespace priv
} // namespace sf
#endif // SFML_PLATFORMUNIX_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/MutexImpl.hpp 0000644 0000000 0000000 00000005244 11770572147 024227 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_MUTEXIMPL_HPP
#define SFML_MUTEXIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Unix implementation of mutexes
////////////////////////////////////////////////////////////
class MutexImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
MutexImpl();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~MutexImpl();
////////////////////////////////////////////////////////////
/// \brief Lock the mutex
///
////////////////////////////////////////////////////////////
void Lock();
////////////////////////////////////////////////////////////
/// \brief Unlock the mutex
///
////////////////////////////////////////////////////////////
void Unlock();
private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
pthread_mutex_t myMutex; ///< pthread handle of the mutex
};
} // namespace priv
} // namespace sf
#endif // SFML_MUTEXIMPL_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Unix/ThreadImpl.hpp 0000644 0000000 0000000 00000006035 11770572147 024333 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_THREADIMPL_HPP
#define SFML_THREADIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
class Thread;
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Unix implementation of threads
////////////////////////////////////////////////////////////
class ThreadImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor, launch the thread
///
/// \param owner The Thread instance to run
///
////////////////////////////////////////////////////////////
ThreadImpl(Thread* owner);
////////////////////////////////////////////////////////////
/// \brief Wait until the thread finishes
///
////////////////////////////////////////////////////////////
void Wait();
////////////////////////////////////////////////////////////
/// \brief Terminate the thread
///
////////////////////////////////////////////////////////////
void Terminate();
private :
////////////////////////////////////////////////////////////
/// \brief Global entry point for all threads
///
/// \param userData User-defined data (contains the Thread instance)
///
/// \return Os specific error code
///
////////////////////////////////////////////////////////////
static void* EntryPoint(void* userData);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
pthread_t myThread; ///< pthread thread instance
bool myIsActive; ///< Thread state (active or inactive)
};
} // namespace priv
} // namespace sf
#endif // SFML_THREADIMPL_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/ 0000755 0000000 0000000 00000000000 11770572147 021544 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/MutexImpl.cpp 0000644 0000000 0000000 00000003614 11770572147 024200 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
MutexImpl::MutexImpl()
{
InitializeCriticalSection(&myMutex);
}
////////////////////////////////////////////////////////////
MutexImpl::~MutexImpl()
{
DeleteCriticalSection(&myMutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Lock()
{
EnterCriticalSection(&myMutex);
}
////////////////////////////////////////////////////////////
void MutexImpl::Unlock()
{
LeaveCriticalSection(&myMutex);
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/ThreadLocalImpl.hpp 0000644 0000000 0000000 00000005743 11770572147 025272 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_THREADLOCALIMPL_HPP
#define SFML_THREADLOCALIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Windows implementation of thread-local storage
////////////////////////////////////////////////////////////
class ThreadLocalImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor -- allocate the storage
///
////////////////////////////////////////////////////////////
ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// \brief Destructor -- free the storage
///
////////////////////////////////////////////////////////////
~ThreadLocalImpl();
////////////////////////////////////////////////////////////
/// \brief Set the thread-specific value of the variable
///
/// \param value Value of the variable for this thread
///
////////////////////////////////////////////////////////////
void SetValue(void* value);
////////////////////////////////////////////////////////////
/// \brief Retrieve the thread-specific value of the variable
///
/// \return Value of the variable for this thread
///
////////////////////////////////////////////////////////////
void* GetValue() const;
private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
DWORD myIndex; ///< Index of our thread-local storage slot
};
} // namespace priv
} // namespace sf
#endif // SFML_THREADLOCALIMPL_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/Platform.cpp 0000644 0000000 0000000 00000004254 11770572147 024041 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
double Platform::GetSystemTime()
{
static LARGE_INTEGER frequency;
static BOOL useHighPerformanceTimer = QueryPerformanceFrequency(&frequency);
if (useHighPerformanceTimer)
{
// High performance counter available : use it
LARGE_INTEGER currentTime;
QueryPerformanceCounter(¤tTime);
return static_cast(currentTime.QuadPart) / frequency.QuadPart;
}
else
{
// High performance counter not available: use GetTickCount (less accurate)
return GetTickCount() * 0.001;
}
}
////////////////////////////////////////////////////////////
void Platform::Sleep(float time)
{
::Sleep(static_cast(time * 1000));
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/ThreadImpl.cpp 0000644 0000000 0000000 00000005102 11770572147 024277 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
ThreadImpl::ThreadImpl(Thread* owner)
{
myThread = reinterpret_cast(_beginthreadex(NULL, 0, &ThreadImpl::EntryPoint, owner, 0, NULL));
if (!myThread)
Err() << "Failed to create thread" << std::endl;
}
////////////////////////////////////////////////////////////
ThreadImpl::~ThreadImpl()
{
if (myThread)
CloseHandle(myThread);
}
////////////////////////////////////////////////////////////
void ThreadImpl::Wait()
{
if (myThread)
WaitForSingleObject(myThread, INFINITE);
}
////////////////////////////////////////////////////////////
void ThreadImpl::Terminate()
{
if (myThread)
TerminateThread(myThread, 0);
}
////////////////////////////////////////////////////////////
unsigned int __stdcall ThreadImpl::EntryPoint(void* userData)
{
// The Thread instance is stored in the user data
Thread* owner = static_cast(userData);
// Forward to the owner
owner->Run();
// Optional, but it is cleaner
_endthreadex(0);
return 0;
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/Platform.hpp 0000644 0000000 0000000 00000004422 11770572147 024043 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_PLATFORMWIN32_HPP
#define SFML_PLATFORMWIN32_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Gives access to some system-specific low-level functions
///
////////////////////////////////////////////////////////////
class Platform
{
public :
////////////////////////////////////////////////////////////
/// \brief Get the current system time
///
/// \return System time, in seconds
///
////////////////////////////////////////////////////////////
static double GetSystemTime();
////////////////////////////////////////////////////////////
/// \brief Suspend the execution of the current thread for a specified time
///
/// \param time Time to sleep, in seconds
///
////////////////////////////////////////////////////////////
static void Sleep(float time);
};
} // namespace priv
} // namespace sf
#endif // SFML_PLATFORMWIN32_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/MutexImpl.hpp 0000644 0000000 0000000 00000005246 11770572147 024210 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_MUTEXIMPL_HPP
#define SFML_MUTEXIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Windows implementation of mutexes
////////////////////////////////////////////////////////////
class MutexImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
MutexImpl();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~MutexImpl();
////////////////////////////////////////////////////////////
/// \brief Lock the mutex
///
////////////////////////////////////////////////////////////
void Lock();
////////////////////////////////////////////////////////////
/// \brief Unlock the mutex
///
////////////////////////////////////////////////////////////
void Unlock();
private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
CRITICAL_SECTION myMutex; ///< Win32 handle of the mutex
};
} // namespace priv
} // namespace sf
#endif // SFML_MUTEXIMPL_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/System/Win32/ThreadImpl.hpp 0000644 0000000 0000000 00000006244 11770572147 024314 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_THREADIMPL_HPP
#define SFML_THREADIMPL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
class Thread;
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Windows implementation of threads
////////////////////////////////////////////////////////////
class ThreadImpl : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor, launch the thread
///
/// \param owner The Thread instance to run
///
////////////////////////////////////////////////////////////
ThreadImpl(Thread* owner);
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~ThreadImpl();
////////////////////////////////////////////////////////////
/// \brief Wait until the thread finishes
///
////////////////////////////////////////////////////////////
void Wait();
////////////////////////////////////////////////////////////
/// \brief Terminate the thread
///
////////////////////////////////////////////////////////////
void Terminate();
private :
////////////////////////////////////////////////////////////
/// \brief Global entry point for all threads
///
/// \param userData User-defined data (contains the Thread instance)
///
/// \return OS specific error code
///
////////////////////////////////////////////////////////////
static unsigned int __stdcall EntryPoint(void* userData);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
HANDLE myThread; ///< Win32 thread handle
};
} // namespace priv
} // namespace sf
#endif // SFML_THREADIMPL_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/ 0000755 0000000 0000000 00000000000 11770572147 020417 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/AudioDevice.cpp 0000644 0000000 0000000 00000007254 11770572147 023314 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
#include
////////////////////////////////////////////////////////////
// Private data
////////////////////////////////////////////////////////////
namespace
{
ALCdevice* audioDevice = NULL;
ALCcontext* audioContext = NULL;
}
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
AudioDevice::AudioDevice()
{
// Create the device
audioDevice = alcOpenDevice(NULL);
if (audioDevice)
{
// Create the context
audioContext = alcCreateContext(audioDevice, NULL);
if (audioContext)
{
// Set the context as the current one (we'll only need one)
alcMakeContextCurrent(audioContext);
}
else
{
Err() << "Failed to create the audio context" << std::endl;
}
}
else
{
Err() << "Failed to open the audio device" << std::endl;
}
}
////////////////////////////////////////////////////////////
AudioDevice::~AudioDevice()
{
// Destroy the context
alcMakeContextCurrent(NULL);
if (audioContext)
alcDestroyContext(audioContext);
// Destroy the device
if (audioDevice)
alcCloseDevice(audioDevice);
}
////////////////////////////////////////////////////////////
bool AudioDevice::IsExtensionSupported(const std::string& extension)
{
EnsureALInit();
if ((extension.length() > 2) && (extension.substr(0, 3) == "ALC"))
return alcIsExtensionPresent(audioDevice, extension.c_str()) != AL_FALSE;
else
return alIsExtensionPresent(extension.c_str()) != AL_FALSE;
}
////////////////////////////////////////////////////////////
int AudioDevice::GetFormatFromChannelsCount(unsigned int channelsCount)
{
EnsureALInit();
// Find the good format according to the number of channels
switch (channelsCount)
{
case 1 : return AL_FORMAT_MONO16;
case 2 : return AL_FORMAT_STEREO16;
case 4 : return alGetEnumValue("AL_FORMAT_QUAD16");
case 6 : return alGetEnumValue("AL_FORMAT_51CHN16");
case 7 : return alGetEnumValue("AL_FORMAT_61CHN16");
case 8 : return alGetEnumValue("AL_FORMAT_71CHN16");
default : return 0;
}
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/Sound.cpp 0000644 0000000 0000000 00000012074 11770572147 022217 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
Sound::Sound()
{
}
////////////////////////////////////////////////////////////
Sound::Sound(const SoundBuffer& buffer, bool loop, float pitch, float volume, const Vector3f& position) :
myBuffer(NULL)
{
SetBuffer(buffer);
SetLoop(loop);
SetPitch(pitch);
SetVolume(volume);
SetPosition(position);
}
////////////////////////////////////////////////////////////
Sound::Sound(const Sound& copy) :
SoundSource(copy),
myBuffer (NULL)
{
if (copy.myBuffer)
SetBuffer(*copy.myBuffer);
SetLoop(copy.GetLoop());
}
////////////////////////////////////////////////////////////
Sound::~Sound()
{
Stop();
if (myBuffer)
myBuffer->DetachSound(this);
}
////////////////////////////////////////////////////////////
void Sound::Play()
{
ALCheck(alSourcePlay(mySource));
}
////////////////////////////////////////////////////////////
void Sound::Pause()
{
ALCheck(alSourcePause(mySource));
}
////////////////////////////////////////////////////////////
void Sound::Stop()
{
ALCheck(alSourceStop(mySource));
}
////////////////////////////////////////////////////////////
void Sound::SetBuffer(const SoundBuffer& buffer)
{
// First detach from the previous buffer
if (myBuffer)
{
Stop();
myBuffer->DetachSound(this);
}
// Assign and use the new buffer
myBuffer = &buffer;
myBuffer->AttachSound(this);
ALCheck(alSourcei(mySource, AL_BUFFER, myBuffer->myBuffer));
}
////////////////////////////////////////////////////////////
void Sound::SetLoop(bool Loop)
{
ALCheck(alSourcei(mySource, AL_LOOPING, Loop));
}
////////////////////////////////////////////////////////////
void Sound::SetPlayingOffset(float timeOffset)
{
ALCheck(alSourcef(mySource, AL_SEC_OFFSET, timeOffset));
}
////////////////////////////////////////////////////////////
const SoundBuffer* Sound::GetBuffer() const
{
return myBuffer;
}
////////////////////////////////////////////////////////////
bool Sound::GetLoop() const
{
ALint loop;
ALCheck(alGetSourcei(mySource, AL_LOOPING, &loop));
return loop != 0;
}
////////////////////////////////////////////////////////////
float Sound::GetPlayingOffset() const
{
ALfloat seconds = 0.f;
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
return seconds;
}
////////////////////////////////////////////////////////////
Sound::Status Sound::GetStatus() const
{
return SoundSource::GetStatus();
}
////////////////////////////////////////////////////////////
Sound& Sound::operator =(const Sound& right)
{
// Here we don't use the copy-and-swap idiom, because it would mess up
// the list of sound instances contained in the buffers
// Detach the sound instance from the previous buffer (if any)
if (myBuffer)
{
Stop();
myBuffer->DetachSound(this);
myBuffer = NULL;
}
// Copy the sound attributes
if (right.myBuffer)
SetBuffer(*right.myBuffer);
SetLoop(right.GetLoop());
SetPitch(right.GetPitch());
SetVolume(right.GetVolume());
SetPosition(right.GetPosition());
SetRelativeToListener(right.IsRelativeToListener());
SetMinDistance(right.GetMinDistance());
SetAttenuation(right.GetAttenuation());
return *this;
}
////////////////////////////////////////////////////////////
void Sound::ResetBuffer()
{
// First stop the sound in case it is playing
Stop();
// Detach the buffer
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
myBuffer = NULL;
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/ALCheck.hpp 0000644 0000000 0000000 00000004755 11770572147 022375 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_ALCHECK_HPP
#define SFML_ALCHECK_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// Let's define a macro to quickly check every OpenAL
/// API calls
////////////////////////////////////////////////////////////
#ifdef SFML_DEBUG
// If in debug mode, perform a test on every call
#define ALCheck(Func) ((Func), priv::ALCheckError(__FILE__, __LINE__))
#else
// Else, we don't add any overhead
#define ALCheck(Func) (Func)
#endif
////////////////////////////////////////////////////////////
/// Check the last OpenAL error
///
/// \param file Source file where the call is located
/// \param line Line number of the source file where the call is located
///
////////////////////////////////////////////////////////////
void ALCheckError(const std::string& file, unsigned int line);
////////////////////////////////////////////////////////////
/// Make sure that OpenAL is initialized
///
////////////////////////////////////////////////////////////
void EnsureALInit();
} // namespace priv
} // namespace sf
#endif // SFML_ALCHECK_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundFile.cpp 0000644 0000000 0000000 00000025201 11770572147 023013 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
SoundFile::SoundFile() :
myFile (NULL),
myNbSamples (0),
myChannelsCount(0),
mySampleRate (0)
{
}
////////////////////////////////////////////////////////////
SoundFile::~SoundFile()
{
if (myFile)
sf_close(myFile);
}
////////////////////////////////////////////////////////////
std::size_t SoundFile::GetSamplesCount() const
{
return myNbSamples;
}
////////////////////////////////////////////////////////////
unsigned int SoundFile::GetChannelsCount() const
{
return myChannelsCount;
}
////////////////////////////////////////////////////////////
unsigned int SoundFile::GetSampleRate() const
{
return mySampleRate;
}
////////////////////////////////////////////////////////////
bool SoundFile::OpenRead(const std::string& filename)
{
// If the file is already opened, first close it
if (myFile)
sf_close(myFile);
// Open the sound file
SF_INFO fileInfos;
myFile = sf_open(filename.c_str(), SFM_READ, &fileInfos);
if (!myFile)
{
Err() << "Failed to read sound file \"" << filename << "\" (" << sf_strerror(myFile) << ")" << std::endl;
return false;
}
// Set the sound parameters
myChannelsCount = fileInfos.channels;
mySampleRate = fileInfos.samplerate;
myNbSamples = static_cast(fileInfos.frames) * myChannelsCount;
return true;
}
////////////////////////////////////////////////////////////
bool SoundFile::OpenRead(const void* data, std::size_t sizeInBytes)
{
// If the file is already opened, first close it
if (myFile)
sf_close(myFile);
// Prepare the memory I/O structure
SF_VIRTUAL_IO io = myMemoryIO.Prepare(data, sizeInBytes);
// Open the sound file
SF_INFO fileInfos;
myFile = sf_open_virtual(&io, SFM_READ, &fileInfos, &myMemoryIO);
if (!myFile)
{
Err() << "Failed to read sound file from memory (" << sf_strerror(myFile) << ")" << std::endl;
return false;
}
// Set the sound parameters
myChannelsCount = fileInfos.channels;
mySampleRate = fileInfos.samplerate;
myNbSamples = static_cast(fileInfos.frames) * myChannelsCount;
return true;
}
////////////////////////////////////////////////////////////
bool SoundFile::OpenWrite(const std::string& filename, unsigned int channelsCount, unsigned int sampleRate)
{
// If the file is already opened, first close it
if (myFile)
sf_close(myFile);
// Find the right format according to the file extension
int format = GetFormatFromFilename(filename);
if (format == -1)
{
// Error : unrecognized extension
Err() << "Failed to create sound file \"" << filename << "\" (unknown format)" << std::endl;
return false;
}
// Fill the sound infos with parameters
SF_INFO fileInfos;
fileInfos.channels = channelsCount;
fileInfos.samplerate = sampleRate;
fileInfos.format = format | (format == SF_FORMAT_OGG ? SF_FORMAT_VORBIS : SF_FORMAT_PCM_16);
// Open the sound file for writing
myFile = sf_open(filename.c_str(), SFM_WRITE, &fileInfos);
if (!myFile)
{
Err() << "Failed to create sound file \"" << filename << "\" (" << sf_strerror(myFile) << ")" << std::endl;
return false;
}
// Set the sound parameters
myChannelsCount = channelsCount;
mySampleRate = sampleRate;
myNbSamples = 0;
return true;
}
////////////////////////////////////////////////////////////
std::size_t SoundFile::Read(Int16* data, std::size_t nbSamples)
{
if (myFile && data && nbSamples)
return static_cast(sf_read_short(myFile, data, nbSamples));
else
return 0;
}
////////////////////////////////////////////////////////////
void SoundFile::Write(const Int16* data, std::size_t nbSamples)
{
if (myFile && data && nbSamples)
{
// Write small chunks instead of everything at once,
// to avoid a stack overflow in libsndfile (happens only with OGG format)
while (nbSamples > 0)
{
std::size_t count = nbSamples > 10000 ? 10000 : nbSamples;
sf_write_short(myFile, data, count);
data += count;
nbSamples -= count;
}
}
}
////////////////////////////////////////////////////////////
void SoundFile::Seek(float timeOffset)
{
if (myFile)
{
sf_count_t frameOffset = static_cast(timeOffset * mySampleRate);
sf_seek(myFile, frameOffset, SEEK_SET);
}
}
////////////////////////////////////////////////////////////
int SoundFile::GetFormatFromFilename(const std::string& filename)
{
// Extract the extension
std::string ext = "wav";
std::string::size_type pos = filename.find_last_of(".");
if (pos != std::string::npos)
ext = filename.substr(pos + 1);
// Match every supported extension with its format constant
if (ext == "wav" || ext == "WAV" ) return SF_FORMAT_WAV;
if (ext == "aif" || ext == "AIF" ) return SF_FORMAT_AIFF;
if (ext == "aiff" || ext == "AIFF") return SF_FORMAT_AIFF;
if (ext == "au" || ext == "AU" ) return SF_FORMAT_AU;
if (ext == "raw" || ext == "RAW" ) return SF_FORMAT_RAW;
if (ext == "paf" || ext == "PAF" ) return SF_FORMAT_PAF;
if (ext == "svx" || ext == "SVX" ) return SF_FORMAT_SVX;
if (ext == "nist" || ext == "NIST") return SF_FORMAT_NIST;
if (ext == "voc" || ext == "VOC" ) return SF_FORMAT_VOC;
if (ext == "sf" || ext == "SF" ) return SF_FORMAT_IRCAM;
if (ext == "w64" || ext == "W64" ) return SF_FORMAT_W64;
if (ext == "mat4" || ext == "MAT4") return SF_FORMAT_MAT4;
if (ext == "mat5" || ext == "MAT5") return SF_FORMAT_MAT5;
if (ext == "pvf" || ext == "PVF" ) return SF_FORMAT_PVF;
if (ext == "xi" || ext == "XI" ) return SF_FORMAT_XI;
if (ext == "htk" || ext == "HTK" ) return SF_FORMAT_HTK;
if (ext == "sds" || ext == "SDS" ) return SF_FORMAT_SDS;
if (ext == "avr" || ext == "AVR" ) return SF_FORMAT_AVR;
if (ext == "sd2" || ext == "SD2" ) return SF_FORMAT_SD2;
if (ext == "flac" || ext == "FLAC") return SF_FORMAT_FLAC;
if (ext == "caf" || ext == "CAF" ) return SF_FORMAT_CAF;
if (ext == "wve" || ext == "WVE" ) return SF_FORMAT_WVE;
if (ext == "ogg" || ext == "OGG") return SF_FORMAT_OGG;
if (ext == "mpc2k" || ext == "MPC2K") return SF_FORMAT_MPC2K;
if (ext == "rf64" || ext == "RF64") return SF_FORMAT_RF64;
return -1;
}
////////////////////////////////////////////////////////////
SF_VIRTUAL_IO SoundFile::MemoryIO::Prepare(const void* data, std::size_t sizeInBytes)
{
// Setup the I/O functions
SF_VIRTUAL_IO io;
io.get_filelen = &SoundFile::MemoryIO::GetLength;
io.read = &SoundFile::MemoryIO::Read;
io.seek = &SoundFile::MemoryIO::Seek;
io.tell = &SoundFile::MemoryIO::Tell;
io.write = &SoundFile::MemoryIO::Write;
// Initialize the memory data
myDataStart = static_cast(data);
myDataPtr = myDataStart;
myTotalSize = sizeInBytes;
return io;
}
////////////////////////////////////////////////////////////
sf_count_t SoundFile::MemoryIO::GetLength(void* userData)
{
MemoryIO* self = static_cast(userData);
return self->myTotalSize;
}
////////////////////////////////////////////////////////////
sf_count_t SoundFile::MemoryIO::Read(void* ptr, sf_count_t count, void* userData)
{
MemoryIO* self = static_cast(userData);
sf_count_t position = self->myDataPtr - self->myDataStart;
if (position + count >= self->myTotalSize)
count = self->myTotalSize - position;
std::memcpy(ptr, self->myDataPtr, static_cast(count));
self->myDataPtr += count;
return count;
}
////////////////////////////////////////////////////////////
sf_count_t SoundFile::MemoryIO::Seek(sf_count_t offset, int whence, void* userData)
{
MemoryIO* self = static_cast(userData);
sf_count_t position = 0;
switch (whence)
{
case SEEK_SET : position = offset; break;
case SEEK_CUR : position = self->myDataPtr - self->myDataStart + offset; break;
case SEEK_END : position = self->myTotalSize - offset; break;
default : position = 0; break;
}
if (position >= self->myTotalSize)
position = self->myTotalSize - 1;
else if (position < 0)
position = 0;
self->myDataPtr = self->myDataStart + position;
return position;
}
////////////////////////////////////////////////////////////
sf_count_t SoundFile::MemoryIO::Tell(void* userData)
{
MemoryIO* self = static_cast(userData);
return self->myDataPtr - self->myDataStart;
}
////////////////////////////////////////////////////////////
sf_count_t SoundFile::MemoryIO::Write(const void*, sf_count_t, void*)
{
return 0;
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundStream.cpp 0000644 0000000 0000000 00000023707 11770572147 023400 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
#include
#include
#ifdef _MSC_VER
#pragma warning(disable : 4355) // 'this' used in base member initializer list
#endif
namespace sf
{
////////////////////////////////////////////////////////////
SoundStream::SoundStream() :
myThread (&SoundStream::Stream, this),
myIsStreaming (false),
myChannelsCount (0),
mySampleRate (0),
myFormat (0),
myLoop (false),
mySamplesProcessed(0)
{
}
////////////////////////////////////////////////////////////
SoundStream::~SoundStream()
{
// Stop the sound if it was playing
Stop();
}
////////////////////////////////////////////////////////////
void SoundStream::Initialize(unsigned int channelsCount, unsigned int sampleRate)
{
myChannelsCount = channelsCount;
mySampleRate = sampleRate;
// Deduce the format from the number of channels
myFormat = priv::AudioDevice::GetFormatFromChannelsCount(channelsCount);
// Check if the format is valid
if (myFormat == 0)
{
myChannelsCount = 0;
mySampleRate = 0;
Err() << "Unsupported number of channels (" << myChannelsCount << ")" << std::endl;
}
}
////////////////////////////////////////////////////////////
void SoundStream::Play()
{
// Check if the sound parameters have been set
if (myFormat == 0)
{
Err() << "Failed to play audio stream: sound parameters have not been initialized (call Initialize first)" << std::endl;
return;
}
// If the sound is already playing (probably paused), just resume it
if (myIsStreaming)
{
ALCheck(alSourcePlay(mySource));
return;
}
// Move to the beginning
OnSeek(0);
// Start updating the stream in a separate thread to avoid blocking the application
mySamplesProcessed = 0;
myIsStreaming = true;
myThread.Launch();
}
////////////////////////////////////////////////////////////
void SoundStream::Pause()
{
ALCheck(alSourcePause(mySource));
}
////////////////////////////////////////////////////////////
void SoundStream::Stop()
{
// Wait for the thread to terminate
myIsStreaming = false;
myThread.Wait();
}
////////////////////////////////////////////////////////////
unsigned int SoundStream::GetChannelsCount() const
{
return myChannelsCount;
}
////////////////////////////////////////////////////////////
unsigned int SoundStream::GetSampleRate() const
{
return mySampleRate;
}
////////////////////////////////////////////////////////////
SoundStream::Status SoundStream::GetStatus() const
{
Status status = SoundSource::GetStatus();
// To compensate for the lag between Play() and alSourcePlay()
if ((status == Stopped) && myIsStreaming)
status = Playing;
return status;
}
////////////////////////////////////////////////////////////
void SoundStream::SetPlayingOffset(float timeOffset)
{
// Stop the stream
Stop();
// Let the derived class update the current position
OnSeek(timeOffset);
// Restart streaming
mySamplesProcessed = static_cast(timeOffset * mySampleRate * myChannelsCount);
myIsStreaming = true;
myThread.Launch();
}
////////////////////////////////////////////////////////////
float SoundStream::GetPlayingOffset() const
{
ALfloat seconds = 0.f;
ALCheck(alGetSourcef(mySource, AL_SEC_OFFSET, &seconds));
return seconds + static_cast(mySamplesProcessed) / mySampleRate / myChannelsCount;
}
////////////////////////////////////////////////////////////
void SoundStream::SetLoop(bool loop)
{
myLoop = loop;
}
////////////////////////////////////////////////////////////
bool SoundStream::GetLoop() const
{
return myLoop;
}
////////////////////////////////////////////////////////////
void SoundStream::Stream()
{
// Create the buffers
ALCheck(alGenBuffers(BuffersCount, myBuffers));
for (int i = 0; i < BuffersCount; ++i)
myEndBuffers[i] = false;
// Fill the queue
bool requestStop = FillQueue();
// Play the sound
ALCheck(alSourcePlay(mySource));
while (myIsStreaming)
{
// The stream has been interrupted!
if (SoundSource::GetStatus() == Stopped)
{
if (!requestStop)
{
// Just continue
ALCheck(alSourcePlay(mySource));
}
else
{
// End streaming
myIsStreaming = false;
}
}
// Get the number of buffers that have been processed (ie. ready for reuse)
ALint nbProcessed = 0;
ALCheck(alGetSourcei(mySource, AL_BUFFERS_PROCESSED, &nbProcessed));
while (nbProcessed--)
{
// Pop the first unused buffer from the queue
ALuint buffer;
ALCheck(alSourceUnqueueBuffers(mySource, 1, &buffer));
// Find its number
unsigned int bufferNum = 0;
for (int i = 0; i < BuffersCount; ++i)
if (myBuffers[i] == buffer)
{
bufferNum = i;
break;
}
// Retrieve its size and add it to the samples count
if (myEndBuffers[bufferNum])
{
// This was the last buffer: reset the sample count
mySamplesProcessed = 0;
myEndBuffers[bufferNum] = false;
}
else
{
ALint size, bits;
ALCheck(alGetBufferi(buffer, AL_SIZE, &size));
ALCheck(alGetBufferi(buffer, AL_BITS, &bits));
mySamplesProcessed += size / (bits / 8);
}
// Fill it and push it back into the playing queue
if (!requestStop)
{
if (FillAndPushBuffer(bufferNum))
requestStop = true;
}
}
// Leave some time for the other threads if the stream is still playing
if (SoundSource::GetStatus() != Stopped)
Sleep(0.01f);
}
// Stop the playback
ALCheck(alSourceStop(mySource));
// Unqueue any buffer left in the queue
ClearQueue();
// Delete the buffers
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
ALCheck(alDeleteBuffers(BuffersCount, myBuffers));
}
////////////////////////////////////////////////////////////
bool SoundStream::FillAndPushBuffer(unsigned int bufferNum)
{
bool requestStop = false;
// Acquire audio data
Chunk data = {NULL, 0};
if (!OnGetData(data))
{
// Mark the buffer as the last one (so that we know when to reset the playing position)
myEndBuffers[bufferNum] = true;
// Check if the stream must loop or stop
if (myLoop)
{
// Return to the beginning of the stream source
OnSeek(0);
// If we previously had no data, try to fill the buffer once again
if (!data.Samples || (data.NbSamples == 0))
{
return FillAndPushBuffer(bufferNum);
}
}
else
{
// Not looping: request stop
requestStop = true;
}
}
// Fill the buffer if some data was returned
if (data.Samples && data.NbSamples)
{
unsigned int buffer = myBuffers[bufferNum];
// Fill the buffer
ALsizei size = static_cast(data.NbSamples) * sizeof(Int16);
ALCheck(alBufferData(buffer, myFormat, data.Samples, size, mySampleRate));
// Push it into the sound queue
ALCheck(alSourceQueueBuffers(mySource, 1, &buffer));
}
return requestStop;
}
////////////////////////////////////////////////////////////
bool SoundStream::FillQueue()
{
// Fill and enqueue all the available buffers
bool requestStop = false;
for (int i = 0; (i < BuffersCount) && !requestStop; ++i)
{
if (FillAndPushBuffer(i))
requestStop = true;
}
return requestStop;
}
////////////////////////////////////////////////////////////
void SoundStream::ClearQueue()
{
// Get the number of buffers still in the queue
ALint nbQueued;
ALCheck(alGetSourcei(mySource, AL_BUFFERS_QUEUED, &nbQueued));
// Unqueue them all
ALuint buffer;
for (ALint i = 0; i < nbQueued; ++i)
ALCheck(alSourceUnqueueBuffers(mySource, 1, &buffer));
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/AudioDevice.hpp 0000644 0000000 0000000 00000006154 11770572147 023317 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_AUDIODEVICE_HPP
#define SFML_AUDIODEVICE_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief High-level wrapper around the audio API, it manages
/// the creation and destruction of the audio device and
/// context and stores the device capabilities
///
////////////////////////////////////////////////////////////
class AudioDevice
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
AudioDevice();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~AudioDevice();
////////////////////////////////////////////////////////////
/// \brief Check if an OpenAL extension is supported
///
/// This functions automatically finds whether it
/// is an AL or ALC extension, and calls the corresponding
/// function.
///
/// \param extension Name of the extension to test
///
/// \return True if the extension is supported, false if not
///
////////////////////////////////////////////////////////////
static bool IsExtensionSupported(const std::string& extension);
////////////////////////////////////////////////////////////
/// \brief Get the OpenAL format that matches the given number of channels
///
/// \param channelsCount Number of channels
///
/// \return Corresponding format
///
////////////////////////////////////////////////////////////
static int GetFormatFromChannelsCount(unsigned int channelsCount);
};
} // namespace priv
} // namespace sf
#endif // SFML_AUDIODEVICE_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundFile.hpp 0000644 0000000 0000000 00000016270 11770572147 023026 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_SOUNDFILE_HPP
#define SFML_SOUNDFILE_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
/// \brief Provide read and write access to sound files
///
////////////////////////////////////////////////////////////
class SoundFile : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
////////////////////////////////////////////////////////////
SoundFile();
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~SoundFile();
////////////////////////////////////////////////////////////
/// \brief Get the total number of audio samples in the file
///
/// \return Number of samples
///
////////////////////////////////////////////////////////////
std::size_t GetSamplesCount() const;
////////////////////////////////////////////////////////////
/// \brief Get the number of channels used by the sound
///
/// \return Number of channels (1 = mono, 2 = stereo)
///
////////////////////////////////////////////////////////////
unsigned int GetChannelsCount() const;
////////////////////////////////////////////////////////////
/// \brief Get the sample rate of the sound
///
/// \return Sample rate, in samples per second
///
////////////////////////////////////////////////////////////
unsigned int GetSampleRate() const;
////////////////////////////////////////////////////////////
/// \brief Open a sound file for reading
///
/// \param filename Path of the sound file to load
///
/// \return True if the file was successfully opened
///
////////////////////////////////////////////////////////////
bool OpenRead(const std::string& filename);
////////////////////////////////////////////////////////////
/// \brief Open a sound file in memory for reading
///
/// \param data Pointer to the file data in memory
/// \param sizeInBytes Size of the data to load, in bytes
///
/// \return True if the file was successfully opened
///
////////////////////////////////////////////////////////////
bool OpenRead(const void* data, std::size_t sizeInBytes);
////////////////////////////////////////////////////////////
/// \brief a the sound file for writing
///
/// \param filename Path of the sound file to write
/// \param channelsCount Number of channels in the sound
/// \param sampleRate Sample rate of the sound
///
/// \return True if the file was successfully opened
///
////////////////////////////////////////////////////////////
bool OpenWrite(const std::string& filename, unsigned int channelsCount, unsigned int sampleRate);
////////////////////////////////////////////////////////////
/// \brief Read audio samples from the loaded sound
///
/// \param data Pointer to the samples array to fill
/// \param nbSamples Number of samples to read
///
/// \return Number of samples actually read (may be less than \a nbSamples)
///
////////////////////////////////////////////////////////////
std::size_t Read(Int16* data, std::size_t nbSamples);
////////////////////////////////////////////////////////////
/// \brief Write audio samples to the file
///
/// \param data Pointer to the samples array to write
/// \param nbSamples Number of samples to write
///
////////////////////////////////////////////////////////////
void Write(const Int16* data, std::size_t nbSamples);
////////////////////////////////////////////////////////////
/// \brief Change the current read position in the file
///
/// \param timeOffset New read position, in seconds
///
////////////////////////////////////////////////////////////
void Seek(float timeOffset);
private :
////////////////////////////////////////////////////////////
/// \brief Get the internal format of an audio file according to
/// its filename extension
///
/// \param filename Filename to check
///
/// \return Internal format matching the filename (-1 if no match)
///
////////////////////////////////////////////////////////////
static int GetFormatFromFilename(const std::string& filename);
////////////////////////////////////////////////////////////
/// \brief Provide I/O functions for manipulating files in memory
///
////////////////////////////////////////////////////////////
class MemoryIO
{
public :
SF_VIRTUAL_IO Prepare(const void* data, std::size_t sizeInBytes);
private :
static sf_count_t GetLength(void* userData);
static sf_count_t Read(void* ptr, sf_count_t count, void* userData);
static sf_count_t Seek(sf_count_t offset, int whence, void* userData);
static sf_count_t Tell(void* userData);
static sf_count_t Write(const void* ptr, sf_count_t count, void* userData);
const char* myDataStart;
const char* myDataPtr;
sf_count_t myTotalSize;
};
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
SNDFILE* myFile; ///< File descriptor
MemoryIO myMemoryIO; ///< Memory read / write data
std::size_t myNbSamples; ///< Total number of samples in the file
unsigned int myChannelsCount; ///< Number of channels used by the sound
unsigned int mySampleRate; ///< Number of samples per second
};
} // namespace priv
} // namespace sf
#endif // SFML_SOUNDFILE_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/Music.cpp 0000644 0000000 0000000 00000010372 11770572147 022206 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
#include
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
Music::Music() :
myFile (new priv::SoundFile),
myDuration(0.f)
{
}
////////////////////////////////////////////////////////////
Music::~Music()
{
// We must stop before destroying the file :)
Stop();
delete myFile;
}
////////////////////////////////////////////////////////////
bool Music::OpenFromFile(const std::string& filename)
{
// First stop the music if it was already running
Stop();
// Create the sound file implementation, and open it in read mode
if (!myFile->OpenRead(filename))
{
Err() << "Failed to open \"" << filename << "\" for reading" << std::endl;
return false;
}
// Compute the duration
myDuration = static_cast(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
// Resize the internal buffer so that it can contain 1 second of audio samples
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount());
// Initialize the stream
Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate());
return true;
}
////////////////////////////////////////////////////////////
bool Music::OpenFromMemory(const void* data, std::size_t sizeInBytes)
{
// First stop the music if it was already running
Stop();
// Create the sound file implementation, and open it in read mode
if (!myFile->OpenRead(data, sizeInBytes))
{
Err() << "Failed to open music from memory for reading" << std::endl;
return false;
}
// Compute the duration
myDuration = static_cast(myFile->GetSamplesCount()) / myFile->GetSampleRate() / myFile->GetChannelsCount();
// Resize the internal buffer so that it can contain 1 second of audio samples
mySamples.resize(myFile->GetSampleRate() * myFile->GetChannelsCount());
// Initialize the stream
Initialize(myFile->GetChannelsCount(), myFile->GetSampleRate());
return true;
}
////////////////////////////////////////////////////////////
float Music::GetDuration() const
{
return myDuration;
}
////////////////////////////////////////////////////////////
bool Music::OnGetData(SoundStream::Chunk& data)
{
Lock lock(myMutex);
// Fill the chunk parameters
data.Samples = &mySamples[0];
data.NbSamples = myFile->Read(&mySamples[0], mySamples.size());
// Check if we have reached the end of the audio file
return data.NbSamples == mySamples.size();
}
////////////////////////////////////////////////////////////
/// /see SoundStream::OnSeek
////////////////////////////////////////////////////////////
void Music::OnSeek(float timeOffset)
{
Lock lock(myMutex);
myFile->Seek(timeOffset);
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundSource.cpp 0000644 0000000 0000000 00000012401 11770572147 023372 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
SoundSource::SoundSource()
{
priv::EnsureALInit();
ALCheck(alGenSources(1, &mySource));
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
}
////////////////////////////////////////////////////////////
SoundSource::SoundSource(const SoundSource& copy)
{
priv::EnsureALInit();
ALCheck(alGenSources(1, &mySource));
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
SetPitch(copy.GetPitch());
SetVolume(copy.GetVolume());
SetPosition(copy.GetPosition());
SetRelativeToListener(copy.IsRelativeToListener());
SetMinDistance(copy.GetMinDistance());
SetAttenuation(copy.GetAttenuation());
}
////////////////////////////////////////////////////////////
SoundSource::~SoundSource()
{
ALCheck(alSourcei(mySource, AL_BUFFER, 0));
ALCheck(alDeleteSources(1, &mySource));
}
////////////////////////////////////////////////////////////
void SoundSource::SetPitch(float pitch)
{
ALCheck(alSourcef(mySource, AL_PITCH, pitch));
}
////////////////////////////////////////////////////////////
void SoundSource::SetVolume(float volume)
{
ALCheck(alSourcef(mySource, AL_GAIN, volume * 0.01f));
}
////////////////////////////////////////////////////////////
void SoundSource::SetPosition(float x, float y, float z)
{
ALCheck(alSource3f(mySource, AL_POSITION, x, y, z));
}
////////////////////////////////////////////////////////////
void SoundSource::SetPosition(const Vector3f& position)
{
SetPosition(position.x, position.y, position.z);
}
////////////////////////////////////////////////////////////
void SoundSource::SetRelativeToListener(bool relative)
{
ALCheck(alSourcei(mySource, AL_SOURCE_RELATIVE, relative));
}
////////////////////////////////////////////////////////////
void SoundSource::SetMinDistance(float distance)
{
ALCheck(alSourcef(mySource, AL_REFERENCE_DISTANCE, distance));
}
////////////////////////////////////////////////////////////
void SoundSource::SetAttenuation(float attenuation)
{
ALCheck(alSourcef(mySource, AL_ROLLOFF_FACTOR, attenuation));
}
////////////////////////////////////////////////////////////
float SoundSource::GetPitch() const
{
ALfloat pitch;
ALCheck(alGetSourcef(mySource, AL_PITCH, &pitch));
return pitch;
}
////////////////////////////////////////////////////////////
float SoundSource::GetVolume() const
{
ALfloat gain;
ALCheck(alGetSourcef(mySource, AL_GAIN, &gain));
return gain * 100.f;
}
////////////////////////////////////////////////////////////
Vector3f SoundSource::GetPosition() const
{
Vector3f position;
ALCheck(alGetSource3f(mySource, AL_POSITION, &position.x, &position.y, &position.z));
return position;
}
////////////////////////////////////////////////////////////
bool SoundSource::IsRelativeToListener() const
{
ALint relative;
ALCheck(alGetSourcei(mySource, AL_SOURCE_RELATIVE, &relative));
return relative != 0;
}
////////////////////////////////////////////////////////////
float SoundSource::GetMinDistance() const
{
ALfloat distance;
ALCheck(alGetSourcef(mySource, AL_REFERENCE_DISTANCE, &distance));
return distance;
}
////////////////////////////////////////////////////////////
float SoundSource::GetAttenuation() const
{
ALfloat attenuation;
ALCheck(alGetSourcef(mySource, AL_ROLLOFF_FACTOR, &attenuation));
return attenuation;
}
////////////////////////////////////////////////////////////
SoundSource::Status SoundSource::GetStatus() const
{
ALint status;
ALCheck(alGetSourcei(mySource, AL_SOURCE_STATE, &status));
switch (status)
{
case AL_INITIAL :
case AL_STOPPED : return Stopped;
case AL_PAUSED : return Paused;
case AL_PLAYING : return Playing;
}
return Stopped;
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/ALCheck.cpp 0000644 0000000 0000000 00000007051 11770572147 022360 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
namespace priv
{
////////////////////////////////////////////////////////////
void ALCheckError(const std::string& file, unsigned int line)
{
// Get the last error
ALenum errorCode = alGetError();
if (errorCode != AL_NO_ERROR)
{
std::string error, description;
// Decode the error code
switch (errorCode)
{
case AL_INVALID_NAME :
{
error = "AL_INVALID_NAME";
description = "an unacceptable name has been specified";
break;
}
case AL_INVALID_ENUM :
{
error = "AL_INVALID_ENUM";
description = "an unacceptable value has been specified for an enumerated argument";
break;
}
case AL_INVALID_VALUE :
{
error = "AL_INVALID_VALUE";
description = "a numeric argument is out of range";
break;
}
case AL_INVALID_OPERATION :
{
error = "AL_INVALID_OPERATION";
description = "the specified operation is not allowed in the current state";
break;
}
case AL_OUT_OF_MEMORY :
{
error = "AL_OUT_OF_MEMORY";
description = "there is not enough memory left to execute the command";
break;
}
}
// Log the error
Err() << "An internal OpenAL call failed in "
<< file.substr(file.find_last_of("\\/") + 1) << " (" << line << ") : "
<< error << ", " << description
<< std::endl;
}
}
////////////////////////////////////////////////////////////
/// Make sure that OpenAL is initialized
////////////////////////////////////////////////////////////
void EnsureALInit()
{
// The audio device is instanciated on demand rather than at global startup,
// which solves a lot of weird crashes and errors.
// It is destroyed at global exit which is fine.
static AudioDevice globalDevice;
}
} // namespace priv
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/src/SFML/Audio/SoundBuffer.cpp 0000644 0000000 0000000 00000020315 11770572147 023346 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
#include
#include
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
SoundBuffer::SoundBuffer() :
myBuffer (0),
myDuration(0.f)
{
priv::EnsureALInit();
// Create the buffer
ALCheck(alGenBuffers(1, &myBuffer));
}
////////////////////////////////////////////////////////////
SoundBuffer::SoundBuffer(const SoundBuffer& copy) :
Resource(),
myBuffer (0),
mySamples (copy.mySamples),
myDuration (copy.myDuration),
mySounds () // don't copy the attached sounds
{
// Create the buffer
ALCheck(alGenBuffers(1, &myBuffer));
// Update the internal buffer with the new samples
Update(copy.GetChannelsCount(), copy.GetSampleRate());
}
////////////////////////////////////////////////////////////
SoundBuffer::~SoundBuffer()
{
// First detach the buffer from the sounds that use it (to avoid OpenAL errors)
for (SoundList::const_iterator it = mySounds.begin(); it != mySounds.end(); ++it)
(*it)->ResetBuffer();
// Destroy the buffer
if (myBuffer)
ALCheck(alDeleteBuffers(1, &myBuffer));
}
////////////////////////////////////////////////////////////
bool SoundBuffer::LoadFromFile(const std::string& filename)
{
// Open the sound file
priv::SoundFile file;
if (file.OpenRead(filename))
{
// Get the sound parameters
std::size_t nbSamples = file.GetSamplesCount();
unsigned int channelsCount = file.GetChannelsCount();
unsigned int sampleRate = file.GetSampleRate();
// Read the samples from the opened file
mySamples.resize(nbSamples);
if (file.Read(&mySamples[0], nbSamples) == nbSamples)
{
// Update the internal buffer with the new samples
return Update(channelsCount, sampleRate);
}
else
{
return false;
}
}
else
{
return false;
}
}
////////////////////////////////////////////////////////////
bool SoundBuffer::LoadFromMemory(const void* data, std::size_t sizeInBytes)
{
// Open the sound file
priv::SoundFile file;
if (file.OpenRead(data, sizeInBytes))
{
// Get the sound parameters
std::size_t nbSamples = file.GetSamplesCount();
unsigned int channelsCount = file.GetChannelsCount();
unsigned int sampleRate = file.GetSampleRate();
// Read the samples from the opened file
mySamples.resize(nbSamples);
if (file.Read(&mySamples[0], nbSamples) == nbSamples)
{
// Update the internal buffer with the new samples
return Update(channelsCount, sampleRate);
}
else
{
return false;
}
}
else
{
return false;
}
}
////////////////////////////////////////////////////////////
bool SoundBuffer::LoadFromSamples(const Int16* samples, std::size_t samplesCount, unsigned int channelsCount, unsigned int sampleRate)
{
if (samples && samplesCount && channelsCount && sampleRate)
{
// Copy the new audio samples
mySamples.assign(samples, samples + samplesCount);
// Update the internal buffer with the new samples
return Update(channelsCount, sampleRate);
}
else
{
// Error...
Err() << "Failed to load sound buffer from memory ("
<< "Samples : " << samples << ", "
<< "Samples count : " << samplesCount << ", "
<< "Channels count : " << channelsCount << ", "
<< "Sample rate : " << sampleRate << ")"
<< std::endl;
return false;
}
}
////////////////////////////////////////////////////////////
bool SoundBuffer::SaveToFile(const std::string& filename) const
{
// Create the sound file in write mode
priv::SoundFile file;
if (file.OpenWrite(filename, GetChannelsCount(), GetSampleRate()))
{
// Write the samples to the opened file
file.Write(&mySamples[0], mySamples.size());
return true;
}
else
{
return false;
}
}
////////////////////////////////////////////////////////////
const Int16* SoundBuffer::GetSamples() const
{
return mySamples.empty() ? NULL : &mySamples[0];
}
////////////////////////////////////////////////////////////
std::size_t SoundBuffer::GetSamplesCount() const
{
return mySamples.size();
}
////////////////////////////////////////////////////////////
unsigned int SoundBuffer::GetSampleRate() const
{
ALint sampleRate;
ALCheck(alGetBufferi(myBuffer, AL_FREQUENCY, &sampleRate));
return sampleRate;
}
////////////////////////////////////////////////////////////
unsigned int SoundBuffer::GetChannelsCount() const
{
ALint channelsCount;
ALCheck(alGetBufferi(myBuffer, AL_CHANNELS, &channelsCount));
return channelsCount;
}
////////////////////////////////////////////////////////////
float SoundBuffer::GetDuration() const
{
return myDuration;
}
////////////////////////////////////////////////////////////
SoundBuffer& SoundBuffer::operator =(const SoundBuffer& right)
{
SoundBuffer temp(right);
std::swap(mySamples, temp.mySamples);
std::swap(myBuffer, temp.myBuffer);
std::swap(myDuration, temp.myDuration);
std::swap(mySounds, temp.mySounds); // swap sounds too, so that they are detached when temp is destroyed
return *this;
}
////////////////////////////////////////////////////////////
bool SoundBuffer::Update(unsigned int channelsCount, unsigned int sampleRate)
{
// Check parameters
if (!channelsCount || !sampleRate || mySamples.empty())
return false;
// Find the good format according to the number of channels
ALenum format = priv::AudioDevice::GetFormatFromChannelsCount(channelsCount);
// Check if the format is valid
if (format == 0)
{
Err() << "Unsupported number of channels (" << channelsCount << ")" << std::endl;
return false;
}
// Fill the buffer
ALsizei size = static_cast(mySamples.size()) * sizeof(Int16);
ALCheck(alBufferData(myBuffer, format, &mySamples[0], size, sampleRate));
// Compute the duration
myDuration = static_cast(mySamples.size()) / sampleRate / channelsCount;
return true;
}
////////////////////////////////////////////////////////////
void SoundBuffer::AttachSound(Sound* sound) const
{
mySounds.insert(sound);
}
////////////////////////////////////////////////////////////
void SoundBuffer::DetachSound(Sound* sound) const
{
mySounds.erase(sound);
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/include/ 0000755 0000000 0000000 00000000000 11770572147 017451 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/ 0000755 0000000 0000000 00000000000 11770572147 020212 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/Config.hpp 0000644 0000000 0000000 00000012221 11770572147 022126 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_CONFIG_HPP
#define SFML_CONFIG_HPP
////////////////////////////////////////////////////////////
// Define the SFML version
////////////////////////////////////////////////////////////
#define SFML_VERSION_MAJOR 2
#define SFML_VERSION_MINOR 0
////////////////////////////////////////////////////////////
// Identify the operating system
////////////////////////////////////////////////////////////
#if defined(_WIN32) || defined(__WIN32__)
// Windows
#define SFML_SYSTEM_WINDOWS
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#ifndef NOMINMAX
#define NOMINMAX
#endif
#elif defined(linux) || defined(__linux)
// Linux
#define SFML_SYSTEM_LINUX
#elif defined(__APPLE__) || defined(MACOSX) || defined(macintosh) || defined(Macintosh)
// MacOS
#define SFML_SYSTEM_MACOS
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
// FreeBSD
#define SFML_SYSTEM_FREEBSD
#else
// Unsupported system
#error This operating system is not supported by SFML library
#endif
////////////////////////////////////////////////////////////
// Identify the endianess
////////////////////////////////////////////////////////////
#if defined(__m68k__) || defined(mc68000) || defined(_M_M68K) || (defined(__MIPS__) && defined(__MISPEB__)) || \
defined(__ppc__) || defined(__POWERPC__) || defined(_M_PPC) || defined(__sparc__) || defined(__hppa__)
// Big endian
#define SFML_ENDIAN_BIG
#else
// Little endian
#define SFML_ENDIAN_LITTLE
#endif
////////////////////////////////////////////////////////////
// Define a portable debug macro
////////////////////////////////////////////////////////////
#if !defined(NDEBUG)
#define SFML_DEBUG
#endif
////////////////////////////////////////////////////////////
// Define portable import / export macros
////////////////////////////////////////////////////////////
#if defined(SFML_SYSTEM_WINDOWS) && !defined(SFML_STATIC)
#ifdef SFML_EXPORTS
// From DLL side, we must export
#define SFML_API __declspec(dllexport)
#else
// From client application side, we must import
#define SFML_API __declspec(dllimport)
#endif
// For Visual C++ compilers, we also need to turn off this annoying C4251 warning.
// You can read lots ot different things about it, but the point is the code will
// just work fine, and so the simplest way to get rid of this warning is to disable it
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#endif
#else
// Other platforms and static build don't need these export macros
#define SFML_API
#endif
////////////////////////////////////////////////////////////
// Define portable fixed-size types
////////////////////////////////////////////////////////////
#include
namespace sf
{
// 8 bits integer types
#if UCHAR_MAX == 0xFF
typedef signed char Int8;
typedef unsigned char Uint8;
#else
#error No 8 bits integer type for this platform
#endif
// 16 bits integer types
#if USHRT_MAX == 0xFFFF
typedef signed short Int16;
typedef unsigned short Uint16;
#elif UINT_MAX == 0xFFFF
typedef signed int Int16;
typedef unsigned int Uint16;
#elif ULONG_MAX == 0xFFFF
typedef signed long Int16;
typedef unsigned long Uint16;
#else
#error No 16 bits integer type for this platform
#endif
// 32 bits integer types
#if USHRT_MAX == 0xFFFFFFFF
typedef signed short Int32;
typedef unsigned short Uint32;
#elif UINT_MAX == 0xFFFFFFFF
typedef signed int Int32;
typedef unsigned int Uint32;
#elif ULONG_MAX == 0xFFFFFFFF
typedef signed long Int32;
typedef unsigned long Uint32;
#else
#error No 32 bits integer type for this platform
#endif
} // namespace sf
#endif // SFML_CONFIG_HPP
sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ 0000755 0000000 0000000 00000000000 11770572147 021476 5 ustar 00 0000000 0000000 sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ThreadLocalPtr.inl 0000644 0000000 0000000 00000004360 11770572147 025055 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
namespace sf
{
////////////////////////////////////////////////////////////
template
ThreadLocalPtr::ThreadLocalPtr(T* value) :
ThreadLocal(value)
{
}
////////////////////////////////////////////////////////////
template
T& ThreadLocalPtr::operator *() const
{
return *static_cast(GetValue());
}
////////////////////////////////////////////////////////////
template
T* ThreadLocalPtr::operator ->() const
{
return static_cast(GetValue());
}
////////////////////////////////////////////////////////////
template
ThreadLocalPtr::operator T*() const
{
return static_cast(GetValue());
}
////////////////////////////////////////////////////////////
template
ThreadLocalPtr& ThreadLocalPtr::operator =(T* value)
{
SetValue(value);
return *this;
}
////////////////////////////////////////////////////////////
template
ThreadLocalPtr& ThreadLocalPtr::operator =(const ThreadLocalPtr& right)
{
SetValue(right.GetValue());
return *this;
}
} // namespace sf
sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/String.hpp 0000644 0000000 0000000 00000050340 11770572147 023457 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_STRING_HPP
#define SFML_STRING_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
/// \brief Utility string class that automatically handles
/// conversions between types and encodings
///
////////////////////////////////////////////////////////////
class SFML_API String
{
public :
////////////////////////////////////////////////////////////
// Types
////////////////////////////////////////////////////////////
typedef std::basic_string::iterator Iterator; ///< Iterator type
typedef std::basic_string::const_iterator ConstIterator; ///< Constant iterator type
////////////////////////////////////////////////////////////
// Static member data
////////////////////////////////////////////////////////////
static const std::size_t InvalidPos; ///< Represents an invalid position in the string
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// This constructor creates an empty string.
///
////////////////////////////////////////////////////////////
String();
////////////////////////////////////////////////////////////
/// \brief Construct from a single ANSI character and a locale
///
/// The source character is converted to UTF-32 according
/// to the given locale.
///
/// \param ansiChar ANSI character to convert
/// \param locale Locale to use for conversion
///
////////////////////////////////////////////////////////////
String(char ansiChar, const std::locale& locale = std::locale());
////////////////////////////////////////////////////////////
/// \brief Construct from single wide character
///
/// \param wideChar Wide character to convert
///
////////////////////////////////////////////////////////////
String(wchar_t wideChar);
////////////////////////////////////////////////////////////
/// \brief Construct from single UTF-32 character
///
/// \param utf32Char UTF-32 character to convert
///
////////////////////////////////////////////////////////////
String(Uint32 utf32Char);
////////////////////////////////////////////////////////////
/// \brief Construct from a null-terminated C-style ANSI string and a locale
///
/// The source string is converted to UTF-32 according
/// to the given locale.
///
/// \param ansiString ANSI string to convert
/// \param locale Locale to use for conversion
///
////////////////////////////////////////////////////////////
String(const char* ansiString, const std::locale& locale = std::locale());
////////////////////////////////////////////////////////////
/// \brief Construct from an ANSI string and a locale
///
/// The source string is converted to UTF-32 according
/// to the given locale.
///
/// \param ansiString ANSI string to convert
/// \param locale Locale to use for conversion
///
////////////////////////////////////////////////////////////
String(const std::string& ansiString, const std::locale& locale = std::locale());
////////////////////////////////////////////////////////////
/// \brief Construct from null-terminated C-style wide string
///
/// \param wideString Wide string to convert
///
////////////////////////////////////////////////////////////
String(const wchar_t* wideString);
////////////////////////////////////////////////////////////
/// \brief Construct from a wide string
///
/// \param wideString Wide string to convert
///
////////////////////////////////////////////////////////////
String(const std::wstring& wideString);
////////////////////////////////////////////////////////////
/// \brief Construct from a null-terminated C-style UTF-32 string
///
/// \param utf32String UTF-32 string to assign
///
////////////////////////////////////////////////////////////
String(const Uint32* utf32String);
////////////////////////////////////////////////////////////
/// \brief Construct from an UTF-32 string
///
/// \param utf32String UTF-32 string to assign
///
////////////////////////////////////////////////////////////
String(const std::basic_string& utf32String);
////////////////////////////////////////////////////////////
/// \brief Copy constructor
///
/// \param copy Instance to copy
///
////////////////////////////////////////////////////////////
String(const String& copy);
////////////////////////////////////////////////////////////
/// \brief Implicit cast operator to std::string (ANSI string)
///
/// The current global locale is used for conversion. If you
/// want to explicitely specify a locale, see ToAnsiString.
/// Characters that do not fit in the target encoding are
/// discarded from the returned string.
/// This operator is defined for convenience, and is equivalent
/// to calling ToAnsiString().
///
/// \return Converted ANSI string
///
/// \see ToAnsiString, operator std::wstring
///
////////////////////////////////////////////////////////////
operator std::string() const;
////////////////////////////////////////////////////////////
/// \brief Implicit cast operator to std::wstring (wide string)
///
/// Characters that do not fit in the target encoding are
/// discarded from the returned string.
/// This operator is defined for convenience, and is equivalent
/// to calling ToWideString().
///
/// \return Converted wide string
///
/// \see ToWideString, operator std::string
///
////////////////////////////////////////////////////////////
operator std::wstring() const;
////////////////////////////////////////////////////////////
/// \brief Convert the unicode string to an ANSI string
///
/// The UTF-32 string is converted to an ANSI string in
/// the encoding defined by \a locale.
/// Characters that do not fit in the target encoding are
/// discarded from the returned string.
///
/// \param locale Locale to use for conversion
///
/// \return Converted ANSI string
///
/// \see ToWideString, operator std::string
///
////////////////////////////////////////////////////////////
std::string ToAnsiString(const std::locale& locale = std::locale()) const;
////////////////////////////////////////////////////////////
/// \brief Convert the unicode string to a wide string
///
/// Characters that do not fit in the target encoding are
/// discarded from the returned string.
///
/// \return Converted wide string
///
/// \see ToAnsiString, operator std::wstring
///
////////////////////////////////////////////////////////////
std::wstring ToWideString() const;
////////////////////////////////////////////////////////////
/// \brief Overload of assignment operator
///
/// \param right Instance to assign
///
/// \return Reference to self
///
////////////////////////////////////////////////////////////
String& operator =(const String& right);
////////////////////////////////////////////////////////////
/// \brief Overload of += operator to append an UTF-32 string
///
/// \param right String to append
///
/// \return Reference to self
///
////////////////////////////////////////////////////////////
String& operator +=(const String& right);
////////////////////////////////////////////////////////////
/// \brief Overload of [] operator to access a character by its position
///
/// This function provides read-only access to characters.
/// Note: this function doesn't throw if \a index is out of range.
///
/// \param index Index of the character to get
///
/// \return Character at position \a index
///
////////////////////////////////////////////////////////////
Uint32 operator [](std::size_t index) const;
////////////////////////////////////////////////////////////
/// \brief Overload of [] operator to access a character by its position
///
/// This function provides read and write access to characters.
/// Note: this function doesn't throw if \a index is out of range.
///
/// \param index Index of the character to get
///
/// \return Reference to the character at position \a index
///
////////////////////////////////////////////////////////////
Uint32& operator [](std::size_t index);
////////////////////////////////////////////////////////////
/// \brief Clear the string
///
/// This function removes all the characters from the string.
///
/// \see IsEmpty, Erase
///
////////////////////////////////////////////////////////////
void Clear();
////////////////////////////////////////////////////////////
/// \brief Get the size of the string
///
/// \return Number of characters in the string
///
/// \see IsEmpty
///
////////////////////////////////////////////////////////////
std::size_t GetSize() const;
////////////////////////////////////////////////////////////
/// \brief Check whether the string is empty or not
///
/// \return True if the string is empty (i.e. contains no character)
///
/// \see Clear, GetSize
///
////////////////////////////////////////////////////////////
bool IsEmpty() const;
////////////////////////////////////////////////////////////
/// \brief Erase one or more characters from the string
///
/// This function removes a sequence of \a count characters
/// starting from \a position.
///
/// \param position Position of the first character to erase
/// \param count Number of characters to erase
///
////////////////////////////////////////////////////////////
void Erase(std::size_t position, std::size_t count = 1);
////////////////////////////////////////////////////////////
/// \brief Insert one or more characters into the string
///
/// This function inserts the characters of \a str
/// into the string, starting from \a position.
///
/// \param position Position of insertion
/// \param str Characters to insert
///
////////////////////////////////////////////////////////////
void Insert(std::size_t position, const String& str);
////////////////////////////////////////////////////////////
/// \brief Find a sequence of one or more characters in the string
///
/// This function searches for the characters of \a str
/// into the string, starting from \a start.
///
/// \param str Characters to find
/// \param start Where to begin searching
///
/// \return Position of \a str in the string, or String::InvalidPos if not found
///
////////////////////////////////////////////////////////////
std::size_t Find(const String& str, std::size_t start = 0) const;
////////////////////////////////////////////////////////////
/// \brief Get a pointer to the C-style array of characters
///
/// This functions provides a read-only access to a
/// null-terminated C-style representation of the string.
/// The returned pointer is temporary and is meant only for
/// immediate use, thus it is not recommended to store it.
///
/// \return Read-only pointer to the array of characters
///
////////////////////////////////////////////////////////////
const Uint32* GetData() const;
////////////////////////////////////////////////////////////
/// \brief Return an iterator to the beginning of the string
///
/// \return Read-write iterator to the beginning of the string characters
///
/// \see End
///
////////////////////////////////////////////////////////////
Iterator Begin();
////////////////////////////////////////////////////////////
/// \brief Return an iterator to the beginning of the string
///
/// \return Read-only iterator to the beginning of the string characters
///
/// \see End
///
////////////////////////////////////////////////////////////
ConstIterator Begin() const;
////////////////////////////////////////////////////////////
/// \brief Return an iterator to the beginning of the string
///
/// The end iterator refers to 1 position past the last character;
/// thus it represents an invalid character and should never be
/// accessed.
///
/// \return Read-write iterator to the end of the string characters
///
/// \see Begin
///
////////////////////////////////////////////////////////////
Iterator End();
////////////////////////////////////////////////////////////
/// \brief Return an iterator to the beginning of the string
///
/// The end iterator refers to 1 position past the last character;
/// thus it represents an invalid character and should never be
/// accessed.
///
/// \return Read-only iterator to the end of the string characters
///
/// \see Begin
///
////////////////////////////////////////////////////////////
ConstIterator End() const;
private :
friend SFML_API bool operator ==(const String& left, const String& right);
friend SFML_API bool operator <(const String& left, const String& right);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
std::basic_string myString; ///< Internal string of UTF-32 characters
};
////////////////////////////////////////////////////////////
/// \relates String
/// \brief Overload of == operator to compare two UTF-32 strings
///
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if both strings are equal
///
////////////////////////////////////////////////////////////
SFML_API bool operator ==(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
/// \brief Overload of != operator to compare two UTF-32 strings
///
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if both strings are different
///
////////////////////////////////////////////////////////////
SFML_API bool operator !=(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
/// \brief Overload of < operator to compare two UTF-32 strings
///
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically lesser than \a right
///
////////////////////////////////////////////////////////////
SFML_API bool operator <(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
/// \brief Overload of > operator to compare two UTF-32 strings
///
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically greater than \a right
///
////////////////////////////////////////////////////////////
SFML_API bool operator >(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
/// \brief Overload of <= operator to compare two UTF-32 strings
///
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically lesser or equal than \a right
///
////////////////////////////////////////////////////////////
SFML_API bool operator <=(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
/// \brief Overload of >= operator to compare two UTF-32 strings
///
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return True if \a left is alphabetically greater or equal than \a right
///
////////////////////////////////////////////////////////////
SFML_API bool operator >=(const String& left, const String& right);
////////////////////////////////////////////////////////////
/// \relates String
/// \brief Overload of binary + operator to concatenate two strings
///
/// \param left Left operand (a string)
/// \param right Right operand (a string)
///
/// \return Concatenated string
///
////////////////////////////////////////////////////////////
SFML_API String operator +(const String& left, const String& right);
} // namespace sf
#endif // SFML_STRING_HPP
////////////////////////////////////////////////////////////
/// \class sf::String
/// \ingroup system
///
/// sf::String is a utility string class defined mainly for
/// convenience. It is a Unicode string (implemented using
/// UTF-32), thus it can store any character in the world
/// (european, chinese, arabic, hebrew, etc.).
///
/// It automatically handles conversions from/to ANSI and
/// wide strings, so that you can work with standard string
/// classes and still be compatible with functions taking a
/// sf::String.
///
/// \code
/// sf::String s;
///
/// std::string s1 = s; // automatically converted to ANSI string
/// std::wstring s2 = s; // automatically converted to wide string
/// s = "hello"; // automatically converted from ANSI string
/// s = L"hello"; // automatically converted from wide string
/// s += 'a'; // automatically converted from ANSI string
/// s += L'a'; // automatically converted from wide string
/// \endcode
///
/// Conversions involving ANSI strings use the default user locale. However
/// it is possible to use a custom locale if necessary:
/// \code
/// std::locale locale;
/// sf::String s;
/// ...
/// std::string s1 = s.ToAnsiString(locale);
/// s = sf::String("hello", locale);
/// \endcode
///
/// sf::String defines the most important functions of the
/// standard std::string class: removing, random access, iterating,
/// appending, comparing, etc. However it is a simple class
/// provided for convenience, and you may have to consider using
/// a more optimized class if your program requires complex string
/// handling. The automatic conversion functions will then take
/// care of converting your string to sf::String whenever SFML
/// requires it.
///
/// Please note that SFML also defines a low-level, generic
/// interface for Unicode handling, see the sf::Utf classes.
///
////////////////////////////////////////////////////////////
sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ThreadLocal.hpp 0000644 0000000 0000000 00000006662 11770572147 024403 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_THREADLOCAL_HPP
#define SFML_THREADLOCAL_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
#include
namespace sf
{
namespace priv
{
class ThreadLocalImpl;
}
////////////////////////////////////////////////////////////
/// \brief Defines variables with thread-local storage
///
////////////////////////////////////////////////////////////
class SFML_API ThreadLocal : NonCopyable
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// \param value Optional value to initalize the variable
///
////////////////////////////////////////////////////////////
ThreadLocal(void* value = NULL);
////////////////////////////////////////////////////////////
/// \brief Destructor
///
////////////////////////////////////////////////////////////
~ThreadLocal();
////////////////////////////////////////////////////////////
/// \brief Set the thread-specific value of the variable
///
/// \param value Value of the variable for the current thread
///
////////////////////////////////////////////////////////////
void SetValue(void* value);
////////////////////////////////////////////////////////////
/// \brief Retrieve the thread-specific value of the variable
///
/// \return Value of the variable for the current thread
///
////////////////////////////////////////////////////////////
void* GetValue() const;
private :
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
priv::ThreadLocalImpl* myImpl; ///< Pointer to the OS specific implementation
};
} // namespace sf
#endif // SFML_THREADLOCAL_HPP
////////////////////////////////////////////////////////////
/// \class sf::ThreadLocal
/// \ingroup system
///
/// This class manipulates void* parameters and thus is not
/// appropriate for strongly-typed variables. You should rather
/// use the sf::ThreadLocalPtr template class.
///
////////////////////////////////////////////////////////////
sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Vector3.hpp 0000644 0000000 0000000 00000022515 11770572147 023541 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_VECTOR3_HPP
#define SFML_VECTOR3_HPP
namespace sf
{
////////////////////////////////////////////////////////////
/// \brief Utility template class for manipulating
/// 3-dimensional vectors
///
////////////////////////////////////////////////////////////
template
class Vector3
{
public :
////////////////////////////////////////////////////////////
/// \brief Default constructor
///
/// Creates a Vector3(0, 0, 0).
///
////////////////////////////////////////////////////////////
Vector3();
////////////////////////////////////////////////////////////
/// \brief Construct the vector from its coordinates
///
/// \param X X coordinate
/// \param Y Y coordinate
/// \param Z Z coordinate
///
////////////////////////////////////////////////////////////
Vector3(T X, T Y, T Z);
////////////////////////////////////////////////////////////
// Member data
////////////////////////////////////////////////////////////
T x; ///< X coordinate of the vector
T y; ///< Y coordinate of the vector
T z; ///< Z coordinate of the vector
};
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of unary operator -
///
/// \param right Vector to negate
///
/// \return Memberwise opposite of the vector
///
////////////////////////////////////////////////////////////
template
Vector3 operator -(const Vector3& left);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator +=
///
/// This operator performs a memberwise addition of both vectors,
/// and assigns the result to \a left.
///
/// \param left Left operand (a vector)
/// \param right Right operand (a vector)
///
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
template
Vector3& operator +=(Vector3& left, const Vector3& right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator -=
///
/// This operator performs a memberwise subtraction of both vectors,
/// and assigns the result to \a left.
///
/// \param left Left operand (a vector)
/// \param right Right operand (a vector)
///
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
template
Vector3& operator -=(Vector3& left, const Vector3& right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator +
///
/// \param left Left operand (a vector)
/// \param right Right operand (a vector)
///
/// \return Memberwise addition of both vectors
///
////////////////////////////////////////////////////////////
template
Vector3 operator +(const Vector3& left, const Vector3& right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator -
///
/// \param left Left operand (a vector)
/// \param right Right operand (a vector)
///
/// \return Memberwise subtraction of both vectors
///
////////////////////////////////////////////////////////////
template
Vector3 operator -(const Vector3& left, const Vector3& right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator *
///
/// \param left Left operand (a vector)
/// \param right Right operand (a scalar value)
///
/// \return Memberwise multiplication by \a right
///
////////////////////////////////////////////////////////////
template
Vector3 operator *(const Vector3& left, T right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator *
///
/// \param left Left operand (a scalar value)
/// \param right Right operand (a vector)
///
/// \return Memberwise multiplication by \a left
///
////////////////////////////////////////////////////////////
template
Vector3 operator *(T left, const Vector3& right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator *=
///
/// This operator performs a memberwise multiplication by \a right,
/// and assigns the result to \a left.
///
/// \param left Left operand (a vector)
/// \param right Right operand (a scalar value)
///
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
template
Vector3& operator *=(Vector3& left, T right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator /
///
/// \param left Left operand (a scalar value)
/// \param right Right operand (a vector)
///
/// \return Memberwise division by \a right
///
////////////////////////////////////////////////////////////
template
Vector3 operator /(const Vector3& left, T right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator /=
///
/// This operator performs a memberwise division by \a right,
/// and assigns the result to \a left.
///
/// \param left Left operand (a vector)
/// \param right Right operand (a scalar value)
///
/// \return Reference to \a left
///
////////////////////////////////////////////////////////////
template
Vector3& operator /=(Vector3& left, T right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator ==
///
/// This operator compares strict equality between two vectors.
///
/// \param left Left operand (a vector)
/// \param right Right operand (a vector)
///
/// \return True if \a left is equal to \a right
///
////////////////////////////////////////////////////////////
template
bool operator ==(const Vector3& left, const Vector3& right);
////////////////////////////////////////////////////////////
/// \relates Vector3
/// \brief Overload of binary operator !=
///
/// This operator compares strict difference between two vectors.
///
/// \param left Left operand (a vector)
/// \param right Right operand (a vector)
///
/// \return True if \a left is not equal to \a right
///
////////////////////////////////////////////////////////////
template
bool operator !=(const Vector3& left, const Vector3& right);
#include
// Define the most common types
typedef Vector3 Vector3i;
typedef Vector3 Vector3f;
} // namespace sf
#endif // SFML_VECTOR3_HPP
////////////////////////////////////////////////////////////
/// \class sf::Vector3
/// \ingroup system
///
/// sf::Vector3 is a simple class that defines a mathematical
/// vector with three coordinates (x, y and z). It can be used to
/// represent anything that has three dimensions: a size, a point,
/// a velocity, etc.
///
/// The template parameter T is the type of the coordinates. It
/// can be any type that supports arithmetic operations (+, -, /, *)
/// and comparisons (==, !=), for example int or float.
///
/// You generally don't have to care about the templated form (sf::Vector3),
/// the two most common specializations have special typedefs:
/// \li sf::Vector3 is sf::Vector3f
/// \li sf::Vector3 is sf::Vector3i
///
/// The sf::Vector3 class has a small and simple interface, its x and y members
/// can be accessed directly (there's no accessor like SetX(), GetX()) and it
/// contains no mathematical function like dot product, cross product, length, etc.
///
/// Usage example:
/// \code
/// sf::Vector3f v1(16.5f, 24.f, -8.2f);
/// v1.x = 18.2f;
/// float y = v1.y;
/// float z = v1.z;
///
/// sf::Vector3f v2 = v1 * 5.f;
/// sf::Vector3f v3;
/// v3 = v1 + v2;
///
/// bool different = (v2 != v3);
/// \endcode
///
/// Note: for 2-dimensional vectors, see sf::Vector2.
///
////////////////////////////////////////////////////////////
sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/ResourcePtr.inl 0000644 0000000 0000000 00000006273 11770572147 024467 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
template
ResourcePtr::ResourcePtr() :
myResource(NULL)
{
}
////////////////////////////////////////////////////////////
template
ResourcePtr::ResourcePtr(const T* resource) :
myResource(resource)
{
if (myResource)
myResource->Connect(*this);
}
////////////////////////////////////////////////////////////
template
ResourcePtr::ResourcePtr(const ResourcePtr& copy) :
myResource(copy.myResource)
{
if (myResource)
myResource->Connect(*this);
}
////////////////////////////////////////////////////////////
template
ResourcePtr::~ResourcePtr()
{
if (myResource)
myResource->Disconnect(*this);
}
////////////////////////////////////////////////////////////
template
ResourcePtr& ResourcePtr::operator =(const ResourcePtr& right)
{
if (myResource)
myResource->Disconnect(*this);
myResource = right.myResource;
if (myResource)
myResource->Connect(*this);
return *this;
}
////////////////////////////////////////////////////////////
template
ResourcePtr& ResourcePtr::operator =(const T* resource)
{
if (myResource)
myResource->Disconnect(*this);
myResource = resource;
if (myResource)
myResource->Connect(*this);
return *this;
}
////////////////////////////////////////////////////////////
template
ResourcePtr::operator const T*() const
{
return myResource;
}
////////////////////////////////////////////////////////////
template
const T& ResourcePtr::operator *() const
{
return *myResource;
}
////////////////////////////////////////////////////////////
template
const T* ResourcePtr::operator ->() const
{
return myResource;
}
////////////////////////////////////////////////////////////
template
void ResourcePtr::OnResourceDestroyed()
{
myResource = NULL;
}
sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Err.hpp 0000644 0000000 0000000 00000005105 11770572147 022740 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
#ifndef SFML_ERR_HPP
#define SFML_ERR_HPP
////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include
#include
namespace sf
{
////////////////////////////////////////////////////////////
/// \brief Standard stream used by SFML to output warnings and errors
///
////////////////////////////////////////////////////////////
SFML_API std::ostream& Err();
} // namespace sf
#endif // SFML_ERR_HPP
////////////////////////////////////////////////////////////
/// \fn sf::Err
/// \ingroup system
///
/// By default, sf::Err() outputs to the same location as std::cerr,
/// (-> the stderr descriptor) which is the console if there's
/// one available.
///
/// It is a standard std::ostream instance, so it supports all the
/// insertion operations defined by the STL
/// (operator <<, manipulators, etc.).
///
/// sf::Err() can be redirected to write to another output, independantly
/// of std::cerr, by using the rdbuf() function provided by the
/// std::ostream class.
///
/// Example:
/// \code
/// // Redirect to a file
/// std::ofstream file("sfml-log.txt");
/// std::streambuf* previous = sf::Err().rdbuf(file.rdbuf());
///
/// // Redirect to nothing
/// sf::Err().rdbuf(NULL);
///
/// // Restore the original output
/// sf::Err().rdbuf(previous);
/// \endcode
///
////////////////////////////////////////////////////////////
sfml-audio-0.7.0.1816/dependencies/sfml2/include/SFML/System/Vector2.inl 0000644 0000000 0000000 00000007767 11770572147 023547 0 ustar 00 0000000 0000000 ////////////////////////////////////////////////////////////
//
// SFML - Simple and Fast Multimedia Library
// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
//
// This software is provided 'as-is', without any express or implied warranty.
// In no event will the authors be held liable for any damages arising from the use of this software.
//
// Permission is granted to anyone to use this software for any purpose,
// including commercial applications, and to alter it and redistribute it freely,
// subject to the following restrictions:
//
// 1. The origin of this software must not be misrepresented;
// you must not claim that you wrote the original software.
// If you use this software in a product, an acknowledgment
// in the product documentation would be appreciated but is not required.
//
// 2. Altered source versions must be plainly marked as such,
// and must not be misrepresented as being the original software.
//
// 3. This notice may not be removed or altered from any source distribution.
//
////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////
template
inline Vector2::Vector2() :
x(0),
y(0)
{
}
////////////////////////////////////////////////////////////
template
inline Vector2::Vector2(T X, T Y) :
x(X),
y(Y)
{
}
////////////////////////////////////////////////////////////
template
inline Vector2 operator -(const Vector2& right)
{
return Vector2(-right.x, -right.y);
}
////////////////////////////////////////////////////////////
template
inline Vector2& operator +=(Vector2& left, const Vector2& right)
{
left.x += right.x;
left.y += right.y;
return left;
}
////////////////////////////////////////////////////////////
template
inline Vector2& operator -=(Vector2& left, const Vector2& right)
{
left.x -= right.x;
left.y -= right.y;
return left;
}
////////////////////////////////////////////////////////////
template
inline Vector2 operator +(const Vector2& left, const Vector2& right)
{
return Vector2(left.x + right.x, left.y + right.y);
}
////////////////////////////////////////////////////////////
template
inline Vector2 operator -(const Vector2& left, const Vector2& right)
{
return Vector2(left.x - right.x, left.y - right.y);
}
////////////////////////////////////////////////////////////
template
inline Vector2 operator *(const Vector2& left, T right)
{
return Vector2(left.x * right, left.y * right);
}
////////////////////////////////////////////////////////////
template
inline Vector2 operator *(T left, const Vector2& right)
{
return Vector2(right.x * left, right.y * left);
}
////////////////////////////////////////////////////////////
template
inline Vector2& operator *=(Vector2& left, T right)
{
left.x *= right;
left.y *= right;
return left;
}
////////////////////////////////////////////////////////////
template