本文整理汇总了C++中BBitmap::LockBits方法的典型用法代码示例。如果您正苦于以下问题:C++ BBitmap::LockBits方法的具体用法?C++ BBitmap::LockBits怎么用?C++ BBitmap::LockBits使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BBitmap
的用法示例。
在下文中一共展示了BBitmap::LockBits方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
int32
MediaView::MediaPlayer(
void *arg)
{
MediaView* view = (MediaView *)arg;
BWindow* window = view->Window();
BBitmap* bitmap = view->fBitmap;
BMediaTrack* videoTrack = view->fVideoTrack;
BMediaTrack* audioTrack = view->fAudioTrack;
BMediaTrack* counterTrack = (videoTrack != NULL) ? videoTrack : audioTrack;
AudioOutput* audioOutput = view->fAudioOutput;
void* adBuffer = view->fAudioDumpingBuffer;
int64 numFrames = counterTrack->CountFrames();
int64 numFramesToSkip = 0;
int64 numSkippedFrames = 0;
bool scrubbing = false;
bool seekNeeded = false;
int64 dummy;
media_header mh;
bigtime_t vStartTime, aStartTime, seekTime, snoozeTime, startTime;
bigtime_t curScrubbing, lastScrubbing, lastTime;
curScrubbing = lastScrubbing = system_time();
seekTime = 0LL;
// Main processing loop (handle stop->start->stop)
while (acquire_sem(view->fPlaySem) == B_OK) {
release_sem(view->fPlaySem);
// as we are doing stop->start, restart audio if needed.
if (audioTrack != NULL)
audioOutput->Play();
startTime = system_time()-counterTrack->CurrentTime();
// This will loop until the end of the stream
while ((counterTrack->CurrentFrame() < numFrames) || scrubbing) {
// We are in scrub mode
if (acquire_sem(view->fScrubSem) == B_OK) {
curScrubbing = system_time();
// We are entering scrub mode
if (!scrubbing) {
if (audioTrack != NULL)
audioOutput->Stop();
scrubbing = true;
}
// Do a seek.
seekNeeded = true;
seekTime = view->fScrubTime;
}
// We are not scrubbing
else if (scrubbing) {
if (audioTrack != NULL)
audioOutput->Play();
scrubbing = false;
}
// Handle seeking
if (seekNeeded) {
if (videoTrack) {
// Seek the seekTime as close as possible
vStartTime = seekTime;
videoTrack->SeekToTime(&vStartTime);
// Read frames until we get less than 50ms ahead.
lastTime = vStartTime;
do {
bitmap->LockBits();
status_t err = videoTrack->ReadFrames((char*)bitmap->Bits(), &dummy, &mh);
bitmap->UnlockBits();
if (err != B_OK) break;
vStartTime = mh.start_time;
if ((dummy == 0) || (vStartTime <= lastTime))
break;
lastTime = vStartTime;
} while (seekTime - vStartTime > 50000);
}
if (audioTrack) {
// Seek the extractor as close as possible
aStartTime = seekTime;
audioOutput->SeekToTime(&aStartTime);
// Read frames until we get less than 50ms ahead.
lastTime = aStartTime;
while (seekTime - aStartTime > 50000) {
if (audioTrack->ReadFrames((char *)adBuffer, &dummy, &mh) != B_OK)
break;
aStartTime = mh.start_time;
if ((dummy == 0) || (aStartTime <= lastTime))
break;
lastTime = aStartTime;
}
}
else startTime = system_time() - vStartTime;
// Set the current time
view->fCurTime = seekTime;
//.........这里部分代码省略.........