예제 #1
0
// stop the capture hardware
// returns 0 for success, -1 for failure
int HAE_StopAudioCapture(void* context) {
    audio_info_t sunAudioHeader;
    INT32 error = -1;

    //fprintf(stderr, ">> HAE_API_SolarisOS_Capture: HAE_StopAudioCapture()\n");
	
    if (g_captureSound) {
	g_captureShutdown = TRUE;

	// stop streaming data
	error = HAE_PauseAudioCapture();

	// wait for thread to complete
	while (g_activeWaveInThread) {
	    HAE_SleepFrameThread(context, 10);
	}
    }

    // $$kk: 04.13.99: should do this regardless of error value??
    if (error == 0) {
	// destroy the audio capture thread
	error = HAE_DestroyFrameThread(NULL);
    }

    //fprintf(stderr, "<< HAE_API_SolarisOS_Capture: HAE_StopAudioCapture() returning %d\n", error);
    return (error == 0) ? 0 : -1;
}
예제 #2
0
// stop the capture hardware
int HAE_StopAudioCapture(void* context) {
    MMRESULT	theErr;
    int i;

    TRACE0("> HAE_StopAudioCapture\n");
    if (g_captureSound) {
	    // tell the thread to die
	    // the thread will also reset the device
	    g_captureShutdown = TRUE;

	    // stop streaming data
	    theErr = HAE_PauseAudioCapture();

	    // destroy the audio capture thread. 
    
	    /* $$fb:
	     * this is a dummy operation! It wouldn't even
	     * distinguish between playback thread and capture thread...
	     */
	    HAE_DestroyFrameThread(NULL);

	    //printf("  waiting for thread to complete\n");
	    // wait for thread to complete
	    while (g_activeWaveInThread) {
		HAE_SleepFrameThread(context, 10);
	    }

	    // deallocate the capture data buffers
	    for (i = 0; i < HAE_WAVEIN_NUM_BUFFERS; i++) {
		HAE_Deallocate(g_audioBufferBlock[i]);
	    } // for
	}
    TRACE0("< HAE_StopAudioCapture\n");
    return 0;
}
예제 #3
0
// Release and free audio card.
// return 0 if ok, -1 if failed.
int HAE_ReleaseAudioCard(void *context) {
    int ctr = 50;
    g_shutDownDoubleBuffer = TRUE;	// signal thread to stop
    HAE_DestroyFrameThread(context);

    // $$fb 2002-04-17: wait until PV_AudioWaveOutFrameThread exits
    // fix for 4498848 Sound causes crashes on Linux
    ctr=50;
    while (g_activeDoubleBuffer && --ctr) {
	TRACE1("Waiting %d...\r", ctr);
	// the following call MUST allow the FrameThread to continue 
	// (i.e. to exit the PV_AudioWaveOutFrameThread function)
	HAE_SleepFrameThread(context, HAE_SOLARIS_SOUND_PERIOD);
    }
    if (!ctr) {
	ERROR0("Timed out waiting for frame thread to die!\n");
    }

    if (g_waveDevice) {
	close(g_waveDevice);
	g_waveDevice = 0;
    }

    if (g_audioBufferBlock) {
	HAE_Deallocate(g_audioBufferBlock);
	g_audioBufferBlock = NULL;
    }
#ifdef USE_RAWDATA_CHECK
    HAE_FileClose(debugrawfile); debugrawfile = 0;
#endif
    return 0;
}
예제 #4
0
// Release and free audio card.
// return 0 if ok, -1 if failed.
int HAE_ReleaseAudioCard(void *context)
{
    int ctr;
    g_shutDownDoubleBuffer = TRUE;	/* signal thread to stop */
    HAE_DestroyFrameThread(context);
    // $$fb 2002-04-17: wait until PV_AudioWaveOutFrameThread exits
    // fix for 4498848 Sound causes crashes on Linux
    ctr=50;
    while (g_activeDoubleBuffer && --ctr) {
        TRACE1("Waiting %d...\r", ctr);
        // the following call MUST allow the FrameThread to continue
        // (i.e. to exit the PV_AudioWaveOutFrameThread function)
        HAE_SleepFrameThread(context, HAE_LINUX_SOUND_PERIOD);
    }
    if (!ctr) {
        ERROR0("Timed out waiting for frame thread to die!\n");
    }

    HAE_CloseSoundCard(0); // Close for playback

    if (g_audioBufferBlock) {
        HAE_Deallocate(g_audioBufferBlock);
        g_audioBufferBlock = NULL;
    }

    return 0;
}