ReactOS 0.4.15-dev-8344-g0574987
audio_wavein.hpp
Go to the documentation of this file.
1/* PROJECT: ReactOS sndrec32
2 * LICENSE: GPL - See COPYING in the top level directory
3 * FILE: base/applications/sndrec32/audio_wavein.hpp
4 * PURPOSE: Windows MM wave in abstraction
5 * PROGRAMMERS: Marco Pagliaricci (irc: rendar)
6 */
7
8#ifndef _AUDIOWAVEIN_H_
9#define _AUDIOWAVEIN_H_
10
11#include "audio_format.hpp"
12#include "audio_receiver.hpp"
13
15
17{
24};
25
27{
28 private:
29 /* The new recording thread sends message to this procedure
30 about open recording, close, and sound data recorded */
32
33 /* When this event is signaled, then the previously created
34 recording thread will wake up and start recording audio
35 and will pass audio data to an `audio_receiver' object. */
38
39 protected:
40 /* TODO: puts these structs in private?! */
41
42 /* Audio wavein device stuff */
46
49
50 /* Audio Recorder Thread id */
52
53 /* Object status */
55
56 /* How many seconds of audio can record the internal buffer before
57 flushing audio data to the `audio_receiver' class? */
58 float buf_secs;
59
60 /* The temporary buffers for the audio data incoming from the wavein
61 device and its size, and its total number */
63 unsigned int mb_size;
64 unsigned int buffers;
65
66 /* Protected Functions */
67
68 /* initialize all structures and variables */
69 void init_(void);
70
71 void alloc_buffers_mem_(unsigned int, float);
72 void free_buffers_mem_(void);
73
74 void init_headers_(void);
75 void prep_headers_(void);
76 void unprep_headers_(void);
77 void add_buffers_to_driver_(void);
78
79 public:
80 /* Ctors */
82 audio_receiver &a_receiver) : wave_headers(0),
83 aud_info(a_info),
84 audio_rcvd(a_receiver),
86 main_buffer(0),
87 mb_size(0),
89 {
90 /* Initializing internal wavein data */
91 init_();
92 aud_info = a_info;
93 }
94
95 /* Dtor */
97 {
98 //close(); TODO!
99 }
100
101 /* Public functions */
102
103 void open(void);
104 void close(void);
105
106 void start_recording(void);
107 void stop_recording(void);
108
110 {
111 return status;
112 }
113
114 float buffer_secs(void) const
115 {
116 return buf_secs;
117 }
118
119 void buffer_secs(float bsecs)
120 {
121 /* Some checking */
122 if (bsecs <= 0)
123 return;
124
125 /* Set seconds length for each buffer */
126 buf_secs = bsecs;
127 }
128
129 unsigned int total_buffers(void) const
130 {
131 return buffers;
132 }
133
134 void total_buffers(unsigned int tot_bufs)
135 {
136 /* Some checking */
137 if (tot_bufs == 0)
138 return;
139
140 /* Sets the number of total buffers */
141 buffers = tot_bufs;
142 }
143
145 {
146 return aud_info;
147 }
148
149 BYTE *buf(void)
150 {
151 return main_buffer;
152 }
153
154 unsigned int bufsz(void)
155 {
156 return mb_size;
157 }
158
159 unsigned int samplevalue_max(void)
160 {
161 if (aud_info.bits() == 16)
162 return (unsigned int)65535;
163
164 else if (aud_info.bits() == 8)
165 return (unsigned int)255;
166
167 else
168 return 0;
169 }
170
171 unsigned tot_samples_buf(void)
172 {
174 }
175
176 unsigned int nsample(unsigned int nsamp)
177 {
178 unsigned int svalue;
179
180 if (aud_info.bits() == 16)
181 svalue = (unsigned int)abs(*((short *)(main_buffer + aud_info.bytes_in_samples(nsamp))));
182 else if (aud_info.bits() == 8)
183 svalue = (unsigned int)((ptrdiff_t) *(main_buffer + aud_info.bytes_in_samples(nsamp)));
184 else
185 svalue = 0;
186
187 return svalue;
188 }
189};
190
192
193#endif /* _AUDIOWAVEIN_H_ */
#define _AUDIO_NAMESPACE_START_
Definition: audio_def.hpp:24
#define _AUDIO_DEFAULT_WAVEINBUFFERS
Definition: audio_def.hpp:15
#define _AUDIO_NAMESPACE_END_
Definition: audio_def.hpp:25
audio_wavein_status
@ WAVEIN_NOTREADY
@ WAVEIN_STOP
@ WAVEIN_RECORDING
@ WAVEIN_READY
@ WAVEIN_FLUSHING
@ WAVEIN_ERR
unsigned short int bits(void) const
unsigned int bytes_in_samples(unsigned int samples) const
unsigned int samples_in_bytes(unsigned int bytes) const
void buffer_secs(float bsecs)
HANDLE data_flushed_event
BYTE * main_buffer
void open(void)
void start_recording(void)
WAVEFORMATEX wave_format
void init_(void)
audio_wavein(const audio_format &a_info, audio_receiver &a_receiver)
void prep_headers_(void)
audio_wavein_status status
float buffer_secs(void) const
DWORD recthread_id
void stop_recording(void)
void init_headers_(void)
void unprep_headers_(void)
~audio_wavein(void)
unsigned int samplevalue_max(void)
HANDLE wakeup_recthread
audio_format format(void) const
audio_wavein_status current_status(void) const
unsigned int bufsz(void)
unsigned int nsample(unsigned int nsamp)
unsigned int total_buffers(void) const
void total_buffers(unsigned int tot_bufs)
void add_buffers_to_driver_(void)
void alloc_buffers_mem_(unsigned int, float)
audio_format aud_info
unsigned tot_samples_buf(void)
WAVEHDR * wave_headers
BYTE * buf(void)
HWAVEIN wavein_handle
audio_receiver & audio_rcvd
void free_buffers_mem_(void)
unsigned int buffers
unsigned int mb_size
static DWORD WINAPI recording_procedure(LPVOID)
void close(void)
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
__kernel_ptrdiff_t ptrdiff_t
Definition: linux.h:247
#define abs(i)
Definition: fconv.c:206
unsigned long DWORD
Definition: ntddk_ex.h:95
const GLuint * buffers
Definition: glext.h:5916
Definition: ps.c:97
#define WINAPI
Definition: msvc.h:6
unsigned char BYTE
Definition: xxhash.c:193