Example #1
0
// Implementation of FilterThread
FilterThread::FilterThread(Filter* filter, int32 i, int32 n, bool runInCurrentThread)
	: fFilter(filter)
	, fI(i)
	, fN(n)
{
	if (runInCurrentThread) {
		Run();
	} else {
		thread_id tid;
		tid = spawn_thread(worker_thread, "filter", suggest_thread_priority(B_STATUS_RENDERING), this);
		if (tid >= 0) {
			resume_thread(tid);
		} else {
			delete this;
		}
	}
}
Example #2
0
status_t
TVideoPreviewView::Connected(
	const media_source & producer,
	const media_destination & where,
	const media_format & with_format,
	media_input* out_input)
{
	FUNCTION("TVideoPreviewView::Connected()\n");

	out_input->node = Node();
	out_input->source = mProducer = producer;
	out_input->destination = mDestination;
	out_input->format = with_format;
	sprintf(out_input->name, "TVideoPreviewView");

	mXSize          = with_format.u.raw_video.display.line_width;
	mYSize          = with_format.u.raw_video.display.line_count;
	mRowBytes       = with_format.u.raw_video.display.bytes_per_row;
	mColorspace = with_format.u.raw_video.display.format;

	mBufferAvailable = create_sem (0, "Video buffer available");
	if (mBufferAvailable < B_NO_ERROR) {
		ERROR("TVideoPreviewView: couldn't create semaphore\n");
		return B_ERROR;
	}

	mBufferQueue = new BTimedBufferQueue();

	//	Create offscreen
	if (m_Bitmap == NULL) {
		m_Bitmap = new BBitmap(BRect(0, 0, (mXSize-1), (mYSize - 1)), mColorspace, false, false);
	}

	if (vThread == 0) {
		mDisplayQuit = false;
		int drawPrio = suggest_thread_priority(B_VIDEO_PLAYBACK, 30, 1000, 5000);
		PROGRESS("Suggested draw thread priority: %d\n", drawPrio);
		vThread = spawn_thread(vRun, "TVideoPreviewView:draw", drawPrio, this);
		resume_thread(vThread);
	}

	mConnected = true;
	return B_OK;
}