ReactOS 0.4.15-dev-7918-g2a2556c
audio_resampler_acm Class Reference

#include <audio_resampler_acm.hpp>

Inheritance diagram for audio_resampler_acm:
Collaboration diagram for audio_resampler_acm:

Public Member Functions

 audio_resampler_acm (audio_format fmt_in, audio_format fmt_out)
 
 ~audio_resampler_acm (void)
 
void open (void)
 
void close (void)
 
void audio_receive (unsigned char *, unsigned int)
 
- Public Member Functions inherited from audio_receiver
 audio_receiver (void)
 
virtual ~audio_receiver (void)
 
virtual void audio_receive (unsigned char *, unsigned int)=0
 
void set_b_received (unsigned int r)
 

Protected Attributes

HACMSTREAM acm_stream
 
ACMSTREAMHEADER acm_header
 
DWORD src_buflen
 
DWORD dst_buflen
 
bool stream_opened
 
audio_format audfmt_in
 
audio_format audfmt_out
 
float buf_secs
 
WAVEFORMATEX wformat_src
 
WAVEFORMATEX wformat_dst
 
- Protected Attributes inherited from audio_receiver
unsigned int bytes_received
 

Private Member Functions

void init_ (void)
 

Detailed Description

Definition at line 17 of file audio_resampler_acm.hpp.

Constructor & Destructor Documentation

◆ audio_resampler_acm()

audio_resampler_acm::audio_resampler_acm ( audio_format  fmt_in,
audio_format  fmt_out 
)
inline

Definition at line 39 of file audio_resampler_acm.hpp.

◆ ~audio_resampler_acm()

audio_resampler_acm::~audio_resampler_acm ( void  )
inline

Definition at line 52 of file audio_resampler_acm.hpp.

53 {
54 }

Member Function Documentation

◆ audio_receive()

void audio_resampler_acm::audio_receive ( unsigned char data,
unsigned int  size 
)
virtual

Implements audio_receiver.

Definition at line 193 of file audio_resampler_acm.cpp.

194{
196
197 /* Checking for acm stream opened */
198 if (stream_opened)
199 {
200 /* Copy audio data from extern to internal source buffer */
202
205
207
208 if (err != MMSYSERR_NOERROR)
209 {
210 /* TODO: throw error */
211 MessageBox(0, _T("acmStreamConvert error"), _T("ERROR"), MB_ICONERROR);
212 }
213
214 /* Wait for sound conversion */
216
217 /* Copy resampled audio, to destination buffer */
218 //memcpy(pbOutputData, acm_header.pbDst, acm_header.cbDstLengthUsed);
219 }
220}
ACMSTREAMHEADER acm_header
MMRESULT WINAPI acmStreamConvert(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwConvert)
Definition: stream.c:89
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
UINT MMRESULT
Definition: mmsystem.h:962
#define MMSYSERR_NOERROR
Definition: mmsystem.h:96
#define ACM_STREAMCONVERTF_BLOCKALIGN
Definition: msacm.h:205
#define ACMSTREAMHEADER_STATUSF_DONE
Definition: msacm.h:209
#define err(...)
DWORD fdwStatus
Definition: msacm.h:551
DWORD cbSrcLength
Definition: msacm.h:554
DWORD cbDstLengthUsed
Definition: msacm.h:559
LPBYTE pbSrc
Definition: msacm.h:553
#define _T(x)
Definition: vfdio.h:22
#define MB_ICONERROR
Definition: winuser.h:787
#define MessageBox
Definition: winuser.h:5822

◆ close()

void audio_resampler_acm::close ( void  )

Definition at line 113 of file audio_resampler_acm.cpp.

114{
116
117 if (acm_stream)
118 {
120 {
123
125 if (err != MMSYSERR_NOERROR)
126 {
127 /* Free buffer memory */
128 if (acm_header.pbSrc != 0)
129 {
130 delete[] acm_header.pbSrc;
131 acm_header.pbSrc = 0;
132 }
133
134 if (acm_header.pbDst != 0)
135 {
136 delete[] acm_header.pbDst;
137 acm_header.pbDst = 0;
138 }
139
140 /* Re-init structures */
141 init_();
142 /* Updating status */
143 stream_opened = false;
144 /* TODO: throw error */
145 MessageBox(0, _T("acmStreamUnPrepareHeader error"), _T("ERROR"), MB_ICONERROR);
146 }
147 }
148
150 acm_stream = 0;
151
152 if (err != MMSYSERR_NOERROR)
153 {
154 /* Free buffer memory */
155 if (acm_header.pbSrc != 0)
156 {
157 delete[] acm_header.pbSrc;
158 acm_header.pbSrc = 0;
159 }
160
161 if (acm_header.pbDst != 0)
162 {
163 delete[] acm_header.pbDst;
164 acm_header.pbDst = 0;
165 }
166
167 /* Re-init structures */
168 init_();
169 /* Updating status */
170 stream_opened = false;
171 /* TODO: throw error! */
172 MessageBox(0, _T("acmStreamClose error"), _T("ERROR"), MB_ICONERROR);
173 }
174
175 } /* if acm_stream != 0 */
176
177 /* Free buffer memory */
178 if (acm_header.pbSrc != 0)
179 delete[] acm_header.pbSrc;
180
181 if (acm_header.pbDst != 0)
182 delete[] acm_header.pbDst;
183
184 /* Re-init structures */
185 init_();
186 /* Updating status */
187 stream_opened = false;
188
189 /* ACM sream successfully closed */
190}
MMRESULT WINAPI acmStreamClose(HACMSTREAM has, DWORD fdwClose)
Definition: stream.c:65
MMRESULT WINAPI acmStreamUnprepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwUnprepare)
Definition: stream.c:449
#define ACMSTREAMHEADER_STATUSF_PREPARED
Definition: msacm.h:210
#define L(x)
Definition: ntvdm.h:50
LPBYTE pbDst
Definition: msacm.h:557
DWORD cbDstLength
Definition: msacm.h:558

◆ init_()

_AUDIO_NAMESPACE_START_ void audio_resampler_acm::init_ ( void  )
private

Definition at line 16 of file audio_resampler_acm.cpp.

17{
18 /* Zeroing structures */
22
23 /* Setting structures sizes */
27
28 /* Setting WAVEFORMATEX structure parameters
29 according to `audio_format' in/out classes */
30
37
44
45 /* Init acm structures completed successful */
46}
#define WAVE_FORMAT_PCM
Definition: constants.h:425
unsigned short int bits(void) const
unsigned int byte_rate(void) const
unsigned int sample_rate(void) const
unsigned short int channels(void) const
unsigned int block_align(void) const
struct _ACMSTREAMHEADER ACMSTREAMHEADER
DWORD nAvgBytesPerSec
Definition: audioclient.idl:43
WORD wBitsPerSample
Definition: audioclient.idl:45
DWORD nSamplesPerSec
Definition: audioclient.idl:42
DWORD cbStruct
Definition: msacm.h:550
#define ZeroMemory
Definition: winbase.h:1712

Referenced by audio_resampler_acm(), and close().

◆ open()

void audio_resampler_acm::open ( void  )

Definition at line 51 of file audio_resampler_acm.cpp.

52{
54
55 /* Opens ACM stream */
57 0,
60 0, 0, 0,
62
63 if (err != MMSYSERR_NOERROR)
64 {
65 /* TODO: throw error */
66 MessageBox(0, _T("acmOpen error: %i"), _T("ERROR"), MB_ICONERROR);
67 }
68
69 /* Calcs source buffer length */
70 src_buflen = (unsigned int)((float)audfmt_in.byte_rate() * (float)buf_secs);
71
72 /* Calcs destination source buffer length with help of ACM apis */
77
78 if (err != MMSYSERR_NOERROR)
79 {
80 /* TODO: throw error */
81 MessageBox(0, _T("acmStreamSize error"), _T("ERROR"), MB_ICONERROR);
82 }
83
84 /* Initialize ACMSTREAMHEADER structure,
85 and alloc memory for source and destination buffers */
86
89
94
99
100 /* Give ACMSTREAMHEADER initialized correctly to the driver */
102 if (err != MMSYSERR_NOERROR)
103 {
104 /* TODO: throw error */
105 MessageBox(0, _T("acmStreamPrepareHeader error"), _T("ERROR"), MB_ICONERROR);
106 }
107
108 /* ACM stream successfully opened */
109 stream_opened = true;
110}
MMRESULT WINAPI acmStreamPrepareHeader(HACMSTREAM has, PACMSTREAMHEADER pash, DWORD fdwPrepare)
Definition: stream.c:299
MMRESULT WINAPI acmStreamSize(HACMSTREAM has, DWORD cbInput, LPDWORD pdwOutputBytes, DWORD fdwSize)
Definition: stream.c:394
MMRESULT WINAPI acmStreamOpen(PHACMSTREAM phas, HACMDRIVER had, PWAVEFORMATEX pwfxSrc, PWAVEFORMATEX pwfxDst, PWAVEFILTER pwfltr, DWORD_PTR dwCallback, DWORD_PTR dwInstance, DWORD fdwOpen)
Definition: stream.c:149
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
static float(__cdecl *square_half_float)(float x
#define ACM_STREAMOPENF_NONREALTIME
Definition: msacm.h:215
#define ACM_STREAMSIZEF_SOURCE
Definition: msacm.h:217
DWORD cbSrcLengthUsed
Definition: msacm.h:555
DWORD_PTR dwUser
Definition: msacm.h:552
DWORD_PTR dwDstUser
Definition: msacm.h:560
DWORD_PTR dwSrcUser
Definition: msacm.h:556
unsigned char * LPBYTE
Definition: typedefs.h:53
unsigned char BYTE
Definition: xxhash.c:193

Member Data Documentation

◆ acm_header

ACMSTREAMHEADER audio_resampler_acm::acm_header
protected

Definition at line 24 of file audio_resampler_acm.hpp.

Referenced by audio_receive(), close(), init_(), and open().

◆ acm_stream

HACMSTREAM audio_resampler_acm::acm_stream
protected

Definition at line 23 of file audio_resampler_acm.hpp.

Referenced by audio_receive(), close(), and open().

◆ audfmt_in

audio_format audio_resampler_acm::audfmt_in
protected

Definition at line 29 of file audio_resampler_acm.hpp.

Referenced by init_(), and open().

◆ audfmt_out

audio_format audio_resampler_acm::audfmt_out
protected

Definition at line 30 of file audio_resampler_acm.hpp.

Referenced by init_().

◆ buf_secs

float audio_resampler_acm::buf_secs
protected

Definition at line 32 of file audio_resampler_acm.hpp.

Referenced by open().

◆ dst_buflen

DWORD audio_resampler_acm::dst_buflen
protected

Definition at line 26 of file audio_resampler_acm.hpp.

Referenced by close(), and open().

◆ src_buflen

DWORD audio_resampler_acm::src_buflen
protected

Definition at line 25 of file audio_resampler_acm.hpp.

Referenced by close(), and open().

◆ stream_opened

bool audio_resampler_acm::stream_opened
protected

Definition at line 27 of file audio_resampler_acm.hpp.

Referenced by audio_receive(), close(), and open().

◆ wformat_dst

WAVEFORMATEX audio_resampler_acm::wformat_dst
protected

Definition at line 35 of file audio_resampler_acm.hpp.

Referenced by init_(), and open().

◆ wformat_src

WAVEFORMATEX audio_resampler_acm::wformat_src
protected

Definition at line 34 of file audio_resampler_acm.hpp.

Referenced by init_(), and open().


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