Free Electron
VoiceAL.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __openal_VoiceAL_h__
8 #define __openal_VoiceAL_h__
9 namespace fe
10 {
11 namespace ext
12 {
13 
14 /**************************************************************************//**
15  @brief Voice using OpenAL
16 
17  @ingroup openal
18 *//***************************************************************************/
19 class VoiceAL:
20  public Initialize<VoiceAL>,
21  virtual public VoiceI
22 {
23  public:
24  VoiceAL(void);
25 virtual ~VoiceAL(void);
26 
27  void initialize(void);
28 
29  //* As VoiceI
30 virtual Result setReferenceDistance(Real distance);
31 virtual Result setLocation(const SpatialVector& location);
32 virtual Result setDirection(const SpatialVector& direction);
33 virtual Result setVelocity(const SpatialVector& velocity);
34 virtual Result setPitch(F32 pitch);
35 virtual Result setVolume(F32 volume);
36 
37 virtual Result play(void);
38 virtual Result pause(void);
39 virtual Result stop(void);
40 virtual Result rewind(void);
41 
42 virtual Result queue(String name);
43 virtual Result loop(BWORD on);
44 virtual Result persist(BWORD on);
45 virtual I32 remaining(void);
46 
47  private:
48  Result checkError(String text);
49  I32 queued(void);
50  I32 processed(void);
51  Result prune(void);
52  Result clear(void);
53 
54  ALuint m_source;
55  hp<AudioAL> m_hpAudioAL;
56  sp<AudioAL> m_spAudioAL; // intermittent persistence lock
57  BWORD m_persistent;
58 };
59 
60 inline Result VoiceAL::checkError(String text)
61 {
62  return m_hpAudioAL.isValid()?
63  m_hpAudioAL->checkError("VoiceAL::~VoiceAL"): e_ok;
64 }
65 
66 } /* namespace ext */
67 } /* namespace fe */
68 
69 #endif /* __openal_VoiceAL_h__ */
70 
Sound producer.
Definition: VoiceI.h:19
virtual Result queue(String name)
Add another sound to be played in order.
Definition: VoiceAL.cc:120
kernel
Definition: namespace.dox:3
Per-class participation in the Initialized <> mechanism.
Definition: Initialized.h:117
virtual I32 remaining(void)
Return number of sounds playing or pending.
Definition: VoiceAL.cc:161
Safe handle for shared pointer.
Definition: Handled.h:61
Automatically reference-counted string container.
Definition: String.h:128
Result
Generalized return value indicating success or failure, and why.
Definition: Result.h:24
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
const String & name(void) const
Return the components chosen name.
Definition: Component.h:77
virtual Result persist(BWORD on)
Continue playing without external references.
Definition: VoiceAL.cc:142
Voice using OpenAL.
Definition: VoiceAL.h:19
virtual Result loop(BWORD on)
Play current sound repeatedly.
Definition: VoiceAL.cc:136