Guiliani  Version 2.6 revision 7293 (documentation build 12)
SndWrapLinux.h
1/*
2* Copyright (C) TES Electronic Solutions GmbH,
3* All Rights Reserved.
4* Contact: info@guiliani.de
5*
6* This file is part of the Guiliani HMI framework
7* for the development of graphical user interfaces on embedded systems.
8*/
9
10#ifndef __SNDWRAPLINUX_H__
11#define __SNDWRAPLINUX_H__
12
13#include "WaveLoader.h"
14#include "SndWrap.h"
15#include "eC_File.h"
16#include "GUIThread.h"
17
19
24{
25public:
26 virtual void LoadSnd(const eC_String &pkPath, const SoundResource_t &eID, eC_UInt uiDeviceID = 0);
27 virtual void UnloadSnd(const SoundResource_t &eID);
28 virtual eC_Bool SetVolume(eC_UByte ubVolume = 0xff) = 0;
29 virtual eC_UByte GetVolume() = 0;
30 virtual eC_Bool PauseSnd(const SoundResource_t &eID);
31 virtual eC_Bool PlaySnd(const SoundResource_t &eID, eC_UInt Flags = PLAY_ASYNC);
32 virtual eC_Bool ResumeSnd (const SoundResource_t &eID);
33 virtual eC_Bool StopSnd(const SoundResource_t &eID);
34
39 virtual eC_Bool IsSoundPlaying(const SoundResource_t &eID);
40
41protected:
44
46 virtual ~CSndWrapLinux();
47
51 class CSound
52 {
53 public:
54 CSound() :
55 m_pubData(NULL),
56 m_uiDataSize(0),
57 m_eSoundID(SND_START_TAG)
58 {
59 memset(&m_kWaveformat, 0, sizeof(m_kWaveformat));
60 }
61
66 {
67 m_kWaveformat = kWaveFormat;
68 }
69
74 {
75 return m_kWaveformat;
76 }
77
83 inline void SetData(
84 eC_UByte* pubData,
85 const eC_UInt& uiDataSize,
86 const eC_Bool& bAllocated)
87 {
88 if (pubData)
89 {
90 if (m_pubData)
92
93 if (bAllocated)
94 m_pubData = pubData;
95 else
96 {
97 m_pubData = new eC_UByte[uiDataSize];
98 memcpy(m_pubData, pubData, uiDataSize);
99 }
100 m_uiDataSize = uiDataSize;
101 m_bAllocated = bAllocated;
102 }
103 }
104
108 inline eC_UByte* GetData() const
109 {
110 return m_pubData;
111 }
112
116 inline eC_UInt GetDataSize() const
117 {
118 if (m_pubData)
119 return m_uiDataSize;
120 else
121 return 0;
122 }
123
126 inline void ReleaseData()
127 {
128 if (m_pubData && m_bAllocated)
129 delete[] m_pubData;
130 m_pubData = 0;
131 }
132
136 inline void SetSoundID(const SoundResource_t eSoundID)
137 {
138 m_eSoundID = eSoundID;
139 }
140
145 {
146 return m_eSoundID;
147 }
148
149 private:
150 eC_UByte* m_pubData;
151 eC_UInt m_uiDataSize;
152 eC_Bool m_bAllocated;
153 SoundResource_t m_eSoundID;
155 };
156
158
162 {
163 public:
168 CPlayThreadBase(const eC_UInt uiStackSize, const ThreadPriority_t kThreadPriority) :
169 CGUIThread(uiStackSize),
170 m_kThreadPriority(kThreadPriority)
171 {}
172
174 virtual ~CPlayThreadBase() {}
175
179 virtual void Play(const CSound& kSound) = 0;
180
182 virtual void Pause() = 0;
183
185 virtual void Resume() = 0;
186
188 virtual void Stop() = 0;
189
193 inline const CSound& GetSound() const {return m_kSound;}
194
198 inline const void SetSound(const CSound& kSound) {m_kSound = kSound;}
199
203 inline ThreadPriority_t GetThreadPriority() const {return m_kThreadPriority;}
204
205 private:
207 void Setup() {}
208
212 virtual void Execute(void *pArg) = 0;
213
215 void Cleanup() {}
216
220 eC_Int Start(void *pArg);
221
222 CSound m_kSound;
223 ThreadPriority_t m_kThreadPriority;
224 };
225
227 eC_TArray<CSound> m_aSoundFiles;
228
229private:
231 eC_Bool DeInit();
232
234 eC_Bool Init();
235
239 eC_Bool SetNOFSounds(eC_UInt uiNOFSounds);
240};
241#endif //#ifndef __SNDWRAPWAVBASE_H__
SoundResource_t
List of sound resource ids.
Definition: GUISoundResource.h:48
This is the base class for Guiliani threads.
Definition: GUIThread.h:85
This is the Sound-Wrapper base class.
Definition: SndWrap.h:48
This class handles the playing of sound files.
Definition: SndWrapLinux.h:162
virtual void Play(const CSound &kSound)=0
const CSound & GetSound() const
Definition: SndWrapLinux.h:193
const void SetSound(const CSound &kSound)
Definition: SndWrapLinux.h:198
virtual ~CPlayThreadBase()
Destructor.
Definition: SndWrapLinux.h:174
CPlayThreadBase(const eC_UInt uiStackSize, const ThreadPriority_t kThreadPriority)
Definition: SndWrapLinux.h:168
ThreadPriority_t GetThreadPriority() const
Definition: SndWrapLinux.h:203
This class represents a sound file with filepointer, WAVE header and Sound Resource ID.
Definition: SndWrapLinux.h:52
void SetData(eC_UByte *pubData, const eC_UInt &uiDataSize, const eC_Bool &bAllocated)
Definition: SndWrapLinux.h:83
eC_UByte * GetData() const
Definition: SndWrapLinux.h:108
void SetSoundID(const SoundResource_t eSoundID)
Definition: SndWrapLinux.h:136
eC_UInt GetDataSize() const
Definition: SndWrapLinux.h:116
const FileLoader::WaveLoader::FormatChunk_t & GetWaveFormat() const
Definition: SndWrapLinux.h:73
SoundResource_t GetSoundID() const
Definition: SndWrapLinux.h:144
void SetWaveFormat(const FileLoader::WaveLoader::FormatChunk_t &kWaveFormat)
Definition: SndWrapLinux.h:65
void ReleaseData()
Definition: SndWrapLinux.h:126
This class is the base implementation for playing WAV files using low-level interfaces.
Definition: SndWrapLinux.h:24
virtual void LoadSnd(const eC_String &pkPath, const SoundResource_t &eID, eC_UInt uiDeviceID=0)
virtual eC_Bool StopSnd(const SoundResource_t &eID)
virtual void UnloadSnd(const SoundResource_t &eID)
CPlayThreadBase * m_pPlayThread
The play thread.
Definition: SndWrapLinux.h:226
virtual eC_UByte GetVolume()=0
eC_TArray< CSound > m_aSoundFiles
The list of the loaded soundfiles.
Definition: SndWrapLinux.h:227
virtual eC_Bool PauseSnd(const SoundResource_t &eID)
virtual ~CSndWrapLinux()
Destructor.
CSndWrapLinux()
Constructor.
virtual eC_Bool IsSoundPlaying(const SoundResource_t &eID)
virtual eC_Bool SetVolume(eC_UByte ubVolume=0xff)=0
virtual eC_Bool PlaySnd(const SoundResource_t &eID, eC_UInt Flags=PLAY_ASYNC)
virtual eC_Bool ResumeSnd(const SoundResource_t &eID)
Structure of format chunk of wave-file.
Definition: WaveLoader.h:24