コード例 #1
0
static void *start_record_alsa(char *file) {

    pthread_attr_t attr;
    const char *folder = 0;
    struct stat st;
    rec_ctx *ctx = 0;
#ifdef DEBUG_CONTEXTS
    int ctx_idx;
#endif
	pthread_mutex_lock(&mutty);
	log_info("start_record");

#ifdef DEBUG_CONTEXTS
	for(ctx_idx = 0; ctx_idx < MAX_CTX; ctx_idx++) if(!contexts[ctx_idx]) break;
	if(ctx_idx == MAX_CTX) {
	    log_err("no free contexts");
	    return 0;		
	}
#endif
	ctx = (rec_ctx *) calloc(sizeof(rec_ctx),1);
	if(!ctx) {
	    log_err("no memory!");
	    goto fail;
	}

	ctx->fd_out = -1; 

	ctx->cur_file = (char *) malloc(strlen(file)+1);
	if(!ctx->cur_file) {
            log_err("no memory!");
	    goto fail;	
        }
	strcpy(ctx->cur_file,file);

	/* Open/configure the device, and open output file */	

	if(!init_recording(ctx)) goto fail;
	
	pthread_attr_init(&attr);
	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);

	pthread_create(&ctx->rec,&attr,record,ctx);
	log_info("started recording to %s (ctx=%p)", file, ctx);

	pthread_attr_destroy(&attr);
	pthread_mutex_unlock(&mutty);
#ifdef DEBUG_CONTEXTS
	contexts[ctx_idx] = ctx;
#endif
	return ctx;

    fail:
	free_ctx(ctx);
	pthread_mutex_unlock(&mutty);

	return 0;
}
コード例 #2
0
ファイル: mmrecord.c プロジェクト: sfsy1989/j2me
/**
 * Start recording.
 * Allocate recording resources if there are no resources allocated now.
 */
static javacall_result recorder_start_recording(javacall_handle handle)
{
    recorder_handle* hRecord = (recorder_handle*)handle;
    MMRESULT mmReturn;

    /* Allocate all resources for recording if necessary */
    if (hRecord && JAVACALL_SUCCEEDED(init_recording(hRecord))) {
        /* Start recording */
        if (hRecord && hRecord->hWAVEIN) {
            mmReturn = waveInStart(hRecord->hWAVEIN);
            if (MMSYSERR_NOERROR == mmReturn) {
                hRecord->isRecording = TRUE;
                return JAVACALL_OK;
            }
        }
    }

    return JAVACALL_FAIL;
}
コード例 #3
0
int main(int argc, char** argv)
{
	openni::Status rc = openni::STATUS_OK;

	openni::Device device;
	openni::VideoStream depth, color;
	const char* deviceURI = openni::ANY_DEVICE;
	if (argc > 1)
	{
		deviceURI = argv[1];
	}

	rc = openni::OpenNI::initialize();

	printf("After initialization:\n%s\n", openni::OpenNI::getExtendedError());

	rc = device.open(deviceURI);
	if (rc != openni::STATUS_OK)
	{
		printf("SimpleViewer: Device open failed:\n%s\n", openni::OpenNI::getExtendedError());
		openni::OpenNI::shutdown();
		return 1;
	}

	rc = depth.create(device, openni::SENSOR_DEPTH);
	if (rc == openni::STATUS_OK)
	{
		rc = depth.start();
		if (rc != openni::STATUS_OK)
		{
			printf("SimpleViewer: Couldn't start depth stream:\n%s\n", openni::OpenNI::getExtendedError());
			depth.destroy();
		}
	}
	else
	{
		printf("SimpleViewer: Couldn't find depth stream:\n%s\n", openni::OpenNI::getExtendedError());
	}

	rc = color.create(device, openni::SENSOR_COLOR);
	if (rc == openni::STATUS_OK)
	{
		rc = color.start();
		if (rc != openni::STATUS_OK)
		{
			printf("SimpleViewer: Couldn't start color stream:\n%s\n", openni::OpenNI::getExtendedError());
			color.destroy();
		}
	}
	else
	{
		printf("SimpleViewer: Couldn't find color stream:\n%s\n", openni::OpenNI::getExtendedError());
	}

	if (!depth.isValid() || !color.isValid())
	{
		printf("SimpleViewer: No valid streams. Exiting\n");
		openni::OpenNI::shutdown();
		return 2;
	}

	/*Viewer class initialization. */
	Viewer Viewer("Simple Viewer", device, depth, color);

	rc = Viewer.init();
	if (rc != openni::STATUS_OK)
	{
		openni::OpenNI::shutdown();
		return 3;
	}

	rc = Viewer.initOpenCv();
	if (rc != openni::STATUS_OK)
	{
		openni::OpenNI::shutdown();
		return 4;
	}

	/*Hand processing initialization. */
	init_recording(&cvctx);
	//init_windows();
	init_ctx(&cvctx);

	/*loop program */
	while(1)
	{
		Viewer.run();
	}
}