Leviathan  0.8.0.0
Leviathan game engine
Leviathan::AudioSource Class Reference

Small ReferenceCounted wrapper around a sound stream. More...

#include <AudioSource.h>

+ Inheritance diagram for Leviathan::AudioSource:

Public Member Functions

DLLEXPORT ~AudioSource ()
 
DLLEXPORT cAudio::IAudioSource * Get ()
 
DLLEXPORT bool HasInternalSource () const
 
DLLEXPORT bool Play2D ()
 
DLLEXPORT void Stop ()
 
DLLEXPORT void Pause ()
 
DLLEXPORT bool IsPlaying () const
 
DLLEXPORT void SetVolume (float volume)
 
 REFERENCE_COUNTED_PTR_TYPE (AudioSource)
 
- Public Member Functions inherited from Leviathan::GUI::JSProxyable
 JSProxyable (int id=IDFactory::GetID())
 
virtual ~JSProxyable ()
 
int GetID () const
 
- Public Member Functions inherited from Leviathan::ReferenceCounted
 ReferenceCounted (const ReferenceCounted &other)=delete
 
ReferenceCountedoperator= (const ReferenceCounted &other)=delete
 
FORCE_INLINE void AddRef ()
 
FORCE_INLINE void Release ()
 removes a reference and deletes the object if reference count reaches zero More...
 
int32_t GetRefCount () const
 Returns the reference count. More...
 

Protected Member Functions

DLLEXPORT AudioSource (cAudio::IAudioSource *sourcetowrap, SoundDevice *owner)
 
- Protected Member Functions inherited from Leviathan::ReferenceCounted
DLLEXPORT ReferenceCounted ()
 
virtual DLLEXPORT ~ReferenceCounted ()
 

Protected Attributes

friend ReferenceCounted
 
- Protected Attributes inherited from Leviathan::GUI::JSProxyable
const int ID
 

Additional Inherited Members

- Public Types inherited from Leviathan::GUI::JSProxyable
using pointer = boost::intrusive_ptr< JSProxyable >
 
- Public Types inherited from Leviathan::ReferenceCounted
using basepointer = boost::intrusive_ptr< ReferenceCounted >
 
using refcountedpointer = boost::intrusive_ptr< ReferenceCounted >
 
- Static Public Member Functions inherited from Leviathan::ReferenceCounted
template<class ActualType >
static boost::intrusive_ptr< ActualType > WrapPtr (ActualType *ptr)
 Creates an intrusive_ptr from raw pointer. More...
 
template<class ActualType , class... Args>
static boost::intrusive_ptr< ActualType > MakeShared (Args &&... args)
 Constructs a new instance and wraps it. More...
 

Detailed Description

Small ReferenceCounted wrapper around a sound stream.

Definition at line 20 of file AudioSource.h.

Constructor & Destructor Documentation

◆ AudioSource()

DLLEXPORT AudioSource::AudioSource ( cAudio::IAudioSource *  sourcetowrap,
SoundDevice owner 
)
protected

Definition at line 9 of file AudioSource.cpp.

9  :
10  Source(sourcetowrap), Owner(owner)
11 {
12 
13  LEVIATHAN_ASSERT(Owner, "AudioSource must be associated with a SoundDevice");
14 }

◆ ~AudioSource()

DLLEXPORT AudioSource::~AudioSource ( )

Definition at line 16 of file AudioSource.cpp.

17 {
18  // TODO: should this invoke if not called on the main thread
19  if(Source) {
20 
21  auto manager = Owner->GetAudioManager();
22  if(manager)
23  manager->release(Source);
24  }
25 }
DLLEXPORT cAudio::IAudioManager * GetAudioManager()
Definition: SoundDevice.h:73

Member Function Documentation

◆ Get()

DLLEXPORT cAudio::IAudioSource* Leviathan::AudioSource::Get ( )
inline

Definition at line 31 of file AudioSource.h.

32  {
33  return Source;
34  }

◆ HasInternalSource()

DLLEXPORT bool Leviathan::AudioSource::HasInternalSource ( ) const
inline

Definition at line 36 of file AudioSource.h.

37  {
38  return Source != nullptr;
39  }

◆ IsPlaying()

DLLEXPORT bool Leviathan::AudioSource::IsPlaying ( ) const
inline

Definition at line 62 of file AudioSource.h.

63  {
64  if(Source)
65  return Source->isPlaying();
66  return false;
67  }

◆ Pause()

DLLEXPORT void Leviathan::AudioSource::Pause ( )
inline

Definition at line 56 of file AudioSource.h.

57  {
58  if(Source)
59  Source->pause();
60  }

◆ Play2D()

DLLEXPORT bool Leviathan::AudioSource::Play2D ( )
inline

Definition at line 43 of file AudioSource.h.

44  {
45  if(Source)
46  return Source->play2d();
47  return false;
48  }

◆ REFERENCE_COUNTED_PTR_TYPE()

Leviathan::AudioSource::REFERENCE_COUNTED_PTR_TYPE ( AudioSource  )

◆ SetVolume()

DLLEXPORT void Leviathan::AudioSource::SetVolume ( float  volume)
inline
Parameters
volume0-1.f is normal range

Definition at line 70 of file AudioSource.h.

71  {
72  if(Source)
73  Source->setVolume(volume);
74  }

◆ Stop()

DLLEXPORT void Leviathan::AudioSource::Stop ( )
inline

Definition at line 50 of file AudioSource.h.

51  {
52  if(Source)
53  Source->stop();
54  }

Member Data Documentation

◆ ReferenceCounted

friend Leviathan::AudioSource::ReferenceCounted
protected

Definition at line 24 of file AudioSource.h.


The documentation for this class was generated from the following files: