JunkBox_Win_Lib 1.5.3
Loading...
Searching...
No Matches
CWinAudioTool Class Reference

#include <WinAudioTool.h>

Collaboration diagram for CWinAudioTool:

Public Member Functions

 CWinAudioTool (void)
 
virtual ~CWinAudioTool (void)
 
BOOL init (void)
 
void free (void)
 
IStream * getIStream (void)
 
BOOL setMediaType (void)
 
BOOL startCapture (void)
 
void stopCapture (void)
 
Buffer getAudioData (void)
 
void getAudioData (Buffer *pbuf)
 
BOOL openOutput (void)
 
void closeOutput (void)
 
WAVEFORMATEX getAudioFormat (void)
 

Private Member Functions

CWinAudioTooloperator= (CWinAudioTool &rhs)
 

Private Attributes

CWinAudioStreamm_audioStream
 
IMediaObject * m_audioMedia
 
IPropertyStore * m_audioProperty
 
IStream * m_pStream
 

Detailed Description

Definition at line 40 of file WinAudioTool.h.

Constructor & Destructor Documentation

◆ CWinAudioTool()

CWinAudioTool ( void )

Definition at line 17 of file WinAudioTool.cpp.

18{
19 m_audioStream = NULL;
20 m_audioMedia = NULL;
21 m_audioProperty = NULL;
22 m_pStream = NULL;
23
24 //
25 init();
26}
IPropertyStore * m_audioProperty
CWinAudioStream * m_audioStream
IMediaObject * m_audioMedia

References CWinAudioTool::init(), CWinAudioTool::m_audioMedia, CWinAudioTool::m_audioProperty, CWinAudioTool::m_audioStream, and CWinAudioTool::m_pStream.

Here is the call graph for this function:

◆ ~CWinAudioTool()

~CWinAudioTool ( void )
virtual

Definition at line 30 of file WinAudioTool.cpp.

31{
32 DEBUG_INFO("DESTRUCTOR: CWinAudioTool: START\n");
33
34 free();
35
36 DEBUG_INFO("DESTRUCTOR: CWinAudioTool: END\n");
37}

References CWinAudioTool::free().

Here is the call graph for this function:

Member Function Documentation

◆ closeOutput()

void closeOutput ( void )
inline

Definition at line 62 of file WinAudioTool.h.

References CWinAudioStream::closeOutput(), and CWinAudioTool::m_audioStream.

Here is the call graph for this function:

◆ free()

void free ( void )

Definition at line 61 of file WinAudioTool.cpp.

62{
65
68}
void deleteNull(T *&ptr)
Definition WinTools.h:229
void releaseNull(T *&ptr)
Definition WinTools.h:220

References jbxwl::deleteNull(), CWinAudioTool::m_audioMedia, CWinAudioTool::m_audioProperty, CWinAudioTool::m_audioStream, CWinAudioTool::m_pStream, and jbxwl::releaseNull().

Referenced by CWinAudioTool::init(), and CWinAudioTool::~CWinAudioTool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAudioData() [1/2]

void getAudioData ( Buffer * pbuf)

Definition at line 101 of file WinAudioTool.cpp.

102{
103 if (m_pStream==NULL || pbuf==NULL) return;
104
105 ULONG len = 0;
106
107 m_pStream->Read((void*)pbuf->buf, (ULONG)pbuf->bufsz, &len);
108 pbuf->vldsz = (int)len;
109
110 return;
111}

References CWinAudioTool::m_pStream.

◆ getAudioData() [2/2]

Buffer getAudioData ( void )
inline

Definition at line 57 of file WinAudioTool.h.

57{ if (m_audioStream!=NULL) return m_audioStream->input(); else return init_Buffer();} // not free

References CWinAudioStream::input(), and CWinAudioTool::m_audioStream.

Here is the call graph for this function:

◆ getAudioFormat()

WAVEFORMATEX getAudioFormat ( void )

Definition at line 115 of file WinAudioTool.cpp.

116{
117 WORD blockAlign = ((WinAudioToolBitsPerSample+7)/8)*WinAudioToolChannels;
118 DWORD avgBytesPerSec = blockAlign*WinAudioToolSamplesPerSec;
119
120 WAVEFORMATEX format = {
122 avgBytesPerSec, blockAlign, WinAudioToolBitsPerSample, 0
123 };
124 return format;
125}
static const WORD WinAudioToolFormat
static const DWORD WinAudioToolSamplesPerSec
static const WORD WinAudioToolChannels
static const WORD WinAudioToolBitsPerSample

References jbxwl::WinAudioToolBitsPerSample, jbxwl::WinAudioToolChannels, jbxwl::WinAudioToolFormat, and jbxwl::WinAudioToolSamplesPerSec.

Referenced by CWinAudioTool::setMediaType().

Here is the caller graph for this function:

◆ getIStream()

IStream * getIStream ( void )
inline

Definition at line 49 of file WinAudioTool.h.

49{ return m_pStream;}

References CWinAudioTool::m_pStream.

◆ init()

BOOL init ( void )

Definition at line 41 of file WinAudioTool.cpp.

42{
43 free();
44
45// if (SUCCEEDED(hr)) hr = m_audioSource->QueryInterface(IID_IMediaObject, (void**)&m_audioMedia);
46// if (SUCCEEDED(hr)) hr = m_audioSource->QueryInterface(IID_IPropertyStore, (void**)&m_audioProperty);
47 //
48 //BOOL ret = setProperty(mode);
49 BOOL ret = setMediaType();
50 if (ret) {
52 m_audioStream->QueryInterface(IID_IStream, (void**)&m_pStream);
53 return TRUE;
54 }
55
56 return FALSE;
57}
STDMETHODIMP QueryInterface(REFIID riid, void **ppv)

References CWinAudioTool::free(), CWinAudioTool::m_audioMedia, CWinAudioTool::m_audioStream, CWinAudioTool::m_pStream, CWinAudioStream::QueryInterface(), and CWinAudioTool::setMediaType().

Referenced by CWinAudioTool::CWinAudioTool().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openOutput()

BOOL openOutput ( void )
inline

Definition at line 61 of file WinAudioTool.h.

61{ if (m_audioStream!=NULL) return m_audioStream->openOutput(); else return FALSE;}
BOOL openOutput(ULONG bufcount=100, WAVEFORMATEX *format=NULL)

References CWinAudioTool::m_audioStream, and CWinAudioStream::openOutput().

Here is the call graph for this function:

◆ operator=()

CWinAudioTool & operator= ( CWinAudioTool & rhs)
inlineprivate

Definition at line 78 of file WinAudioTool.h.

78{ return rhs;}

◆ setMediaType()

BOOL setMediaType ( void )

Definition at line 72 of file WinAudioTool.cpp.

73{
74 if (m_audioMedia==NULL) return FALSE;
75
76 DMO_MEDIA_TYPE mt = {0};
77 MoInitMediaType(&mt, sizeof(WAVEFORMATEX));
78 mt.majortype = MEDIATYPE_Audio;
79 mt.subtype = MEDIASUBTYPE_PCM;
80 mt.lSampleSize = 0;
81 mt.bFixedSizeSamples = TRUE;
82 mt.bTemporalCompression = FALSE;
83 mt.formattype = FORMAT_WaveFormatEx;
84 memcpy(mt.pbFormat, &getAudioFormat(), sizeof(WAVEFORMATEX));
85
86 HRESULT hr = m_audioMedia->SetOutputType(0, &mt, 0);
87 MoFreeMediaType(&mt);
88
89 if (FAILED(hr)) return FALSE;
90 return TRUE;
91
92 //
93 if (SUCCEEDED(hr)) {
95 m_audioStream->QueryInterface(IID_IStream, (void**)&m_pStream);
96 }
97}
WAVEFORMATEX getAudioFormat(void)

References CWinAudioTool::getAudioFormat(), CWinAudioTool::m_audioMedia, CWinAudioTool::m_audioStream, CWinAudioTool::m_pStream, and CWinAudioStream::QueryInterface().

Referenced by CWinAudioTool::init().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ startCapture()

BOOL startCapture ( void )
inline

Definition at line 54 of file WinAudioTool.h.

54{ if (m_audioStream!=NULL) return m_audioStream->startCapture(); else return FALSE;}
BOOL startCapture(WAVEFORMATEX *format=NULL)

References CWinAudioTool::m_audioStream, and CWinAudioStream::startCapture().

Here is the call graph for this function:

◆ stopCapture()

void stopCapture ( void )
inline

Definition at line 55 of file WinAudioTool.h.

References CWinAudioTool::m_audioStream, and CWinAudioStream::stopCapture().

Here is the call graph for this function:

Member Data Documentation

◆ m_audioMedia

IMediaObject* m_audioMedia
private

◆ m_audioProperty

IPropertyStore* m_audioProperty
private

Definition at line 73 of file WinAudioTool.h.

Referenced by CWinAudioTool::CWinAudioTool(), and CWinAudioTool::free().

◆ m_audioStream

◆ m_pStream


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