33 static ALCdevice *ds_capture_device = NULL;
48 if ( !rval || capture_dev_name.empty() ) {
61 if (ds_capture_device != NULL) {
63 ds_capture_device = NULL;
72 ALenum al_format = AL_FORMAT_MONO8;
73 ALsizei buf_size = freq * nseconds;
84 Assert( (nchannels == 1) || (nchannels == 2) );
85 Assert( (bits_per_sample == 8) || (bits_per_sample == 16) );
88 if (bits_per_sample == 8) {
89 al_format = AL_FORMAT_MONO8;
90 }
else if (bits_per_sample == 16) {
91 al_format = AL_FORMAT_MONO16;
93 }
else if (nchannels == 2) {
94 if (bits_per_sample == 8) {
95 al_format = AL_FORMAT_STEREO8;
96 }
else if (bits_per_sample == 16) {
97 al_format = AL_FORMAT_STEREO16;
101 const ALCchar *dev_name = (
const ALCchar*) capture_dev_name.c_str();
102 ds_capture_device = alcCaptureOpenDevice(dev_name, freq, al_format, buf_size);
104 if (ds_capture_device == NULL) {
108 if ( alcGetError(ds_capture_device) != ALC_NO_ERROR ) {
112 ALCaptureInfo.
format = al_format;
116 ALCaptureInfo.
block_align = (nchannels * bits_per_sample) / 8;
176 if (ds_capture_device != NULL) {
178 ds_capture_device = NULL;
194 ALCsizei num_samples = 0;
196 OpenAL_C_ErrorCheck( alcGetIntegerv(ds_capture_device, ALC_CAPTURE_SAMPLES,
sizeof(ALCsizei), &num_samples),
return -1 );
213 if (outbuf == NULL) {
217 ALCsizei num_samples = 0;
219 OpenAL_C_ErrorPrint( alcGetIntegerv(ds_capture_device, ALC_CAPTURE_SAMPLES,
sizeof(ALCsizei), &num_samples) );
221 if (num_samples <= 0) {
225 ALCsizei max_buf_size =
MIN(num_samples, ALsizei(max_size / ALCaptureInfo.
block_align));
227 OpenAL_C_ErrorCheck( alcCaptureSamples(ds_capture_device, outbuf, max_buf_size),
return 0 );
229 return (
int)max_buf_size * ALCaptureInfo.
block_align;
int dscap_max_buffersize()
struct ALcapture_t ALcapture_t
ALuint *typedef ALuint *typedef ALenum
std::basic_string< char, std::char_traits< char >, std::allocator< char > > SCP_string
void dscap_release_buffer()
int dscap_get_raw_data(unsigned char *outbuf, unsigned int max_size)
int dscap_create_buffer(int freq, int bits_per_sample, int nchannels, int nseconds)
#define OpenAL_C_ErrorCheck(x, y)
bool openal_init_device(SCP_string *playback, SCP_string *capture)
#define OpenAL_C_ErrorPrint(x)