Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Command line-configurable memory limit #2

Merged
merged 2 commits into from
Mar 11, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions bmdcapture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ extern "C" {

pthread_mutex_t sleepMutex;
pthread_cond_t sleepCond;
unsigned long long memory_limit = 1024*1024*1024; // 1GByte(>50 sec)
int videoOutputFile = -1;
int audioOutputFile = -1;

Expand All @@ -59,6 +58,7 @@ const char *g_videoOutputFile = NULL;
const char *g_audioOutputFile = NULL;
static int g_maxFrames = -1;
bool g_verbose = false;
unsigned long long g_memoryLimit = 1024*1024*1024; // 1GByte(>50 sec)

static unsigned long frameCount = 0;
static unsigned int dropped = 0, totaldropped = 0;
Expand Down Expand Up @@ -381,7 +381,7 @@ HRESULT DeckLinkCaptureDelegate::VideoInputFrameArrived(IDeckLinkVideoInputFrame
// frameCount++;

if (g_maxFrames > 0 && frameCount >= g_maxFrames ||
avpacket_queue_size(&queue) > memory_limit)
avpacket_queue_size(&queue) > g_memoryLimit)
{
pthread_cond_signal(&sleepCond);
}
Expand Down Expand Up @@ -575,6 +575,7 @@ int usage(int status)
" -c <channels> Audio Channels (2, 8 or 16 - default is 2)\n"
" -s <depth> Audio Sample Depth (16 or 32 - default is 16)\n"
" -n <frames> Number of frames to capture (default is unlimited)\n"
" -M <memlimit> Maximum queue size in GB (default is 1 GB)\n"
" -C <num> number of card to be used\n"
" -A <audio-in> Audio input:\n"
" 1: Analog (RCA)\n"
Expand Down Expand Up @@ -631,7 +632,7 @@ int main(int argc, char *argv[])
}

// Parse command line options
while ((ch = getopt(argc, argv, "?hvc:s:f:a:m:n:F:C:A:V:")) != -1)
while ((ch = getopt(argc, argv, "?hvc:s:f:a:m:n:M:F:C:A:V:")) != -1)
{
switch (ch)
{
Expand Down Expand Up @@ -665,6 +666,9 @@ int main(int argc, char *argv[])
case 'n':
g_maxFrames = atoi(optarg);
break;
case 'M':
g_memoryLimit = atoi(optarg) * 1024*1024*1024L;
break;
case 'F':
fmt = av_guess_format(optarg, NULL, NULL);
break;
Expand Down Expand Up @@ -871,7 +875,9 @@ int main(int argc, char *argv[])
}

if (deckLinkIterator != NULL)
{
deckLinkIterator->Release();
}

if (oc != NULL)
{
Expand Down