// Given the capture hardware is working, fill a buffer with some data. This call is // asynchronous. When this buffer is filled, the function done will be called. // returns 0 for success, -1 for failure int HAE_StartAudioCapture(HAE_CaptureDone done, void *callbackContext) { long error = -1; //fprintf(stderr, ">> HAE_API_LinuxOS_Capture: HAE_StartAudioCapture()\n"); if (g_waveDevice && g_openForCapture) { // start capture g_captureDoneProc = done; // allocate the capture buffer // $$jb: 05.19.99: This is set in HAE_AquireAudioCapture //g_audioFramesToRead = HAE_LINUX_FRAMES_PER_BUFFER; // our read buffer will hold this many frames of sampled audio data // we're going to build this many buffers at a time if (g_bitSize == 8) { g_captureByteBufferSize = (sizeof(char) * g_audioFramesToRead); } else { g_captureByteBufferSize = (sizeof(short int) * g_audioFramesToRead); } g_captureByteBufferSize *= g_channels; // allocate read buffer g_captureBufferBlock = HAE_Allocate(g_captureByteBufferSize); if (g_captureBufferBlock) { // $$kk: 10.12.98: added this so we can restart capture // $$kk: 11.03.98: mark ourselves active *before* creating frame thread g_captureShutdown = FALSE; // create thread to manage audio capture error = HAE_CreateFrameThread(callbackContext, PV_AudioWaveInFrameThread); if (error == 0) { error = HAE_ResumeAudioCapture(); } } if (error != 0) { g_captureShutdown = TRUE; } } //fprintf(stderr, "<< HAE_API_LinuxOS_Capture: HAE_StartAudioCapture() returning %d\n", error); return (error == 0) ? 0 : -1; }
// Given the capture hardware is working, fill a buffer with some data. This call is // asynchronous. When this buffer is filled, the function done will be called. // returns 0 for success, -1 for failure int HAE_StartAudioCapture(HAE_CaptureDone done, void *callbackContext) { long error = 0; int i; // start capture g_captureDoneProc = done; g_captureDoneContext = callbackContext; // calculate the number of bytes per capture buffer if (g_bitSize == 8) { g_audioBytesPerBuffer = (sizeof(char) * g_audioFramesPerBuffer); } else { g_audioBytesPerBuffer = (sizeof(short int) * g_audioFramesPerBuffer); } g_audioBytesPerBuffer *= g_channels; // allocate the capture data buffers // this could really be done in initialiation...? for (i = 0; i < HAE_WAVEIN_NUM_BUFFERS; i++) { g_audioBufferBlock[i] = HAE_Allocate(g_audioBytesPerBuffer); if (g_audioBufferBlock[i] == NULL) { error = -1; // something is wrong break; } } // for if (error == 0) { // create thread to manage audio capture error = HAE_CreateFrameThread(callbackContext, PV_AudioWaveInFrameThread); if (error == 0) { error = HAE_ResumeAudioCapture(); } } if (error == 0) { // $$kk: 10.12.98: added this so we can restart capture g_captureShutdown = FALSE; } return (error == 0) ? 0 : -1; }