Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cSoundObject.h
Go to the documentation of this file.
1 //
4 //
5 #ifndef _INC_cSoundObject_H
6 #define _INC_cSoundObject_H
7 #ifndef NO_PRAGMA_ONCE
8 #pragma once
9 #endif
10 
11 #include "cAVSink.h"
12 #include "cSoundBase.h"
13 #include "cWaveFormat.h"
15 
16 namespace GrayLib
17 {
18  class GRAYLIB_LINK cSoundObject : public ISoundObject, public cAVSink
19  {
24 
25  public:
28 
29  public:
30  bool isSoundLoaded() const noexcept
31  {
32  return m_Data.isValidPtr();
33  }
35  {
36  m_Data.Free();
37  m_wf.SetFormatNull();
38  }
39 
40  // cAVSink
41  virtual HRESULT OnHeaderStream(const cAVHeaderStream& head, const void* pForm, size_t nSizeForm) override;
42  virtual HRESULT OnFrame(const cAVHeaderFrame& head, const void* pData, size_t nSizeData) override;
43 
44  // ISoundObject
45  virtual size_t get_WaveDataLength() override
46  {
48  return m_Data.get_DataSize();
49  }
50  virtual const void* get_WaveData() override
51  {
53  return m_Data.get_Data();
54  }
55  virtual const cWaveFormatEx* get_WaveFormat() override
56  {
58  return m_wf;
59  }
60 
61  // HRESULT SaveSoundObject(cAVSink* pSink);
62  HRESULT LoadSoundMP3(cStreamInput& stmIn);
63  HRESULT LoadSoundWAV(cStreamInput& stmIn);
64 
65 #ifdef _WIN32
66  HRESULT LoadSoundResource(const GChar_t* pszResourceName);
67 #endif
68  HRESULT LoadSoundFile(const FILECHAR_t* pszFilePath);
69  };
70 }
71 #endif
#define GRAYLIB_LINK
Definition: GrayLibBase.h:35
INT32 HRESULT
_WIN32 style error codes. INT32
Definition: SysTypes.h:465
Definition: cAVSink.h:80
Definition: cAVSink.h:60
Definition: cAVSink.h:130
Definition: cSoundObject.h:19
virtual const cWaveFormatEx * get_WaveFormat() override
Definition: cSoundObject.h:55
bool isSoundLoaded() const noexcept
Definition: cSoundObject.h:30
cHeapBlock m_Data
Read the full contents into memory as one block. PCM or compressed blocks.
Definition: cSoundObject.h:27
cWaveFormat m_wf
Sound/Wave format info.
Definition: cSoundObject.h:26
virtual size_t get_WaveDataLength() override
Definition: cSoundObject.h:45
virtual const void * get_WaveData() override
Definition: cSoundObject.h:50
void UnloadSoundObject()
Definition: cSoundObject.h:34
Definition: cWaveFormat.h:73
Definition: cWaveFormat.h:151
void SetFormatNull()
Definition: cWaveFormat.cpp:91
Definition: cHeap.h:156
void * get_Data() const noexcept
Definition: cHeap.h:363
void Free()
Definition: cHeap.h:249
bool isValidPtr() const noexcept
Definition: cMem.h:371
size_t get_DataSize() const noexcept
Definition: cMem.h:344
Definition: cStream.h:306
Definition: cMesh.h:22
char FILECHAR_t
a UTF8 char in a file name. like TCHAR
Definition: FileName.h:22
char GChar_t
My version of TCHAR, _TCHAR.
Definition: StrConst.h:26