// close the DirectSoundCapture system void dscap_close() { dscap_stop_record(); if (ds_capture_device != NULL) { OpenAL_C_ErrorPrint( alcCaptureCloseDevice(ds_capture_device) ); ds_capture_device = NULL; } }
// Stop a stream from recording void rtvoice_stop_recording() { if ( !Rtv_recording ) { return; } dscap_stop_record(); if ( Rtv_record_timer_id ) { #ifndef _WIN32 SDL_RemoveTimer(Rtv_record_timer_id); #else timeKillEvent(Rtv_record_timer_id); #endif Rtv_record_timer_id = 0; } Rtv_recording=0; }
// Open a stream for recording (recording begins immediately) // exit: 0 => success // !0 => failure int rtvoice_start_recording( void (*user_callback)(), int callback_time ) { if ( !dscap_supported() ) { return -1; } Assert(Rtv_recording_inited); if ( Rtv_recording ) { return -1; } if ( dscap_start_record() ) { return -1; } if ( user_callback ) { #ifndef _WIN32 Rtv_record_timer_id = SDL_AddTimer(callback_time, TimeProc, NULL); #else Rtv_record_timer_id = timeSetEvent(callback_time, callback_time, TimeProc, 0, TIME_PERIODIC); #endif if ( !Rtv_record_timer_id ) { dscap_stop_record(); return -1; } Rtv_callback = user_callback; Rtv_callback_time = callback_time; } else { Rtv_callback = NULL; Rtv_record_timer_id = 0; } Rtv_recording=1; return 0; }