void GrammarClose(Grammar *grammar) { FreeStr(&grammar->src); FreeStr(&grammar->errMsg); GrammarFreeDefinitions(grammar->defList); grammar->defList = NULL; }
void GrammarClose(Grammar *grammar) { FreeStr(&grammar->errMsg); GrammarFreeDefinitions(grammar->firstDef); grammar->firstDef = NULL; }
IDeckLinkDisplayMode *Player::GetDisplayModeByIndex(int selectedIndex) { // Populate the display mode combo with a list of display modes supported by the installed DeckLink card IDeckLinkDisplayModeIterator *displayModeIterator; IDeckLinkDisplayMode *deckLinkDisplayMode; IDeckLinkDisplayMode *selectedMode = NULL; int index = 0; if (m_deckLinkOutput->GetDisplayModeIterator(&displayModeIterator) != S_OK) goto bail; while (displayModeIterator->Next(&deckLinkDisplayMode) == S_OK) { BMDProbeString str; if (deckLinkDisplayMode->GetName(&str) == S_OK) { if (index == selectedIndex) { printf("Selected mode: %s\n\n\n", ToStr(str)); selectedMode = deckLinkDisplayMode; FreeStr(str); goto bail; } } index++; } bail: displayModeIterator->Release(); return selectedMode; }
void GrammarFreeItems(GrammarItem *item) { // Free it and all the following definitions. while (item != NULL) { GrammarItem *next = item->nextItem; FreeStr(&item->definitionName); FreeStr(&item->token); if (item->charSet) { free(item->charSet); } item = next; } }
void GrammarFreeDefinitions(GrammarDefinition *def) { // Free it and all the following definitions. while (def != NULL) { GrammarDefinition *next = def->nextDefinition; FreeStr(&def->name); GrammarFreeOptions(def->firstOption); def = next; } }
int WStrToScalar(PERL_CALL SV *string, PWSTR str) { if(!string) return 0; PSTR strPtr = str ? W2S(str) : NULL; if(strPtr) sv_setpv(string, strPtr); FreeStr(strPtr); return 1; }
/* ** GetBootFiles -- record list of files in current (boot) directory. ** ** Parameters: ** None. ** ** Returns: ** Number of boot files on success, 0 on failure. ** ** Side Effects: ** Strings in `BootFiles' are freed/allocated. ** ** Warnings: ** - After this routine is called, ParseConfig() must be ** called to re-order it's list of boot file pointers. */ int GetBootFiles(void) { DIR *dfd; struct stat statb; struct dirent *dp; int i; /* * Free the current list of boot files. */ for (i = 0; i < C_MAXFILE && BootFiles[i] != NULL; i++) { FreeStr(BootFiles[i]); BootFiles[i] = NULL; } /* * Open current directory to read boot file names. */ if ((dfd = opendir(".")) == NULL) { /* open BootDir */ syslog(LOG_ERR, "GetBootFiles: can't open directory (%s)\n", BootDir); return(0); } /* * Read each boot file name and allocate space for it in the * list of boot files (BootFiles). All boot files read after * C_MAXFILE will be ignored. */ i = 0; for (dp = readdir(dfd); dp != NULL; dp = readdir(dfd)) { if (stat(dp->d_name, &statb) < 0 || (statb.st_mode & S_IFMT) != S_IFREG) continue; if (i == C_MAXFILE) syslog(LOG_ERR, "GetBootFiles: too many boot files (%s ignored)", dp->d_name); else if ((BootFiles[i] = NewStr(dp->d_name)) != NULL) i++; } (void) closedir(dfd); /* close BootDir */ if (i == 0) /* can't find any boot files */ syslog(LOG_ERR, "GetBootFiles: no boot files (%s)\n", BootDir); return(i); }
int WStrToArray(PERL_CALL AV *array, PWSTR str) { if(!array) return 0; PSTR strPtr = str ? W2S(str) : NULL; if(strPtr) av_push(array, newSVpv(strPtr, strlen(strPtr))); FreeStr(strPtr); return 1; }
int WStrToHash(PERL_CALL HV *hash, PSTR idx, PWSTR str) { if(!hash || !idx) return 0; PSTR strPtr = str ? W2S(str) : NULL; if(strPtr) hv_store(hash, idx, strlen(idx), newSVpv(strPtr, strlen(strPtr)), 0); FreeStr(strPtr); return 1; }
int WNStrToArray(PERL_CALL AV *array, PWSTR str, DWORD strLen) { if(!array) return 0; PSTR strPtr = str ? W2S(str, strLen) : NULL; if(strPtr) { strPtr[strLen - 1] = 0; av_push(array, newSVpv(strPtr, strlen(strPtr))); } FreeStr(strPtr); return 1; }
int WNStrToHash(PERL_CALL HV *hash, PSTR idx, PWSTR str, DWORD strLen) { if(!hash || !idx) return 0; PSTR strPtr = str ? W2S(str, strLen) : NULL; if(strPtr) { strPtr[strLen - 1] = 0; hv_store(hash, idx, strlen(idx), newSVpv(strPtr, strlen(strPtr)), 0); } FreeStr(strPtr); return 1; }
bool CLog::AddString(__ulong Category, DEBUG_INFO_LEVEL Level, PTCHAR ptchLogString) { bool bClose = false; bool bRet = false; PWCHAR pwchLogStr; DWORD Len; DWORD dwWr; if (m_pParentLog) m_pParentLog->AddFormatedString(Category, Level, _T("%s"), ptchLogString); if ((Category & m_DbgFilterCat) && (Level <= m_DbgFilterLevel)) __DbPrintEx(Category, Level, _T("%s"), ptchLogString); //__DbPrintEx(DCB_SYSTEM, DL_INFO, L"m_FilterCat=%02X m_FilterLevel=%02X", m_FilterCat, m_FilterLevel); if ((Category & m_FilterCat)==0 || (Level > m_FilterLevel)) return true; CAutoLock auto_lock(&m_Sync); if (!IsValid()) { if (!OpenFile()) return false; bClose = true; } pwchLogStr = (PWCHAR) global_Alloc(_WSTR_LEN_B(ptchLogString) + 0x100); if (NULL != pwchLogStr) { CurrentTimeToString(pwchLogStr); lstrcat(pwchLogStr, ptchLogString); lstrcat(pwchLogStr, _T("\r\n")); Len = lstrlen(pwchLogStr); WriteFile(m_hFile, pwchLogStr, Len * sizeof(WCHAR), &dwWr, NULL); FreeStr(pwchLogStr); if (0 != dwWr) bRet = true; } if (bClose) ResetState(); return bRet; }
int usage(int status) { HRESULT result; IDeckLinkIterator *deckLinkIterator; IDeckLink *deckLink; int numDevices = 0; fprintf(stderr, "Usage: bmdcapture -m <mode id> [OPTIONS]\n" "\n" " -m <mode id>:\n" ); // Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system deckLinkIterator = CreateDeckLinkIteratorInstance(); if (deckLinkIterator == NULL) { fprintf( stderr, "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.\n"); return 1; } // Enumerate all cards in this system while (deckLinkIterator->Next(&deckLink) == S_OK) { BMDProbeString str; // Increment the total number of DeckLink cards found numDevices++; if (numDevices > 1) { printf("\n\n"); } // Print the model name of the DeckLink card result = deckLink->GetModelName(&str); if (result == S_OK) { printf("-> %s (-C %d )\n\n", ToStr(str), numDevices - 1); FreeStr(str); } print_input_modes(deckLink); // Release the IDeckLink instance when we've finished with it to prevent leaks deckLink->Release(); } deckLinkIterator->Release(); // If no DeckLink cards were found in the system, inform the user if (numDevices == 0) { printf("No Blackmagic Design devices were found.\n"); } printf("\n"); fprintf( stderr, " -v Be verbose (report each 25 frames)\n" " -f <filename> Filename raw video will be written to\n" " -F <format> Define the file format to be used\n" " -c <channels> Audio Channels (2, 8 or 16 - default is 2)\n" " -s <depth> Audio Sample Depth (16 or 32 - default is 16)\n" " -p <pixel> PixelFormat (yuv8, yuv10, rgb10)\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" " -S <serial_device> data input serial\n" " -A <audio-in> Audio input:\n" " 1: Analog (RCA or XLR)\n" " 2: Embedded Audio (HDMI/SDI)\n" " 3: Digital Audio (AES/EBU)\n" " -V <video-in> Video input:\n" " 1: Composite\n" " 2: Component\n" " 3: HDMI\n" " 4: SDI\n" " 5: Optical SDI\n" " 6: S-Video\n" " -o <optionstring> AVFormat options\n" " -w Embed a wallclock stream\n" " -d <filler> When the source is offline draw a black frame or color bars\n" " 0: black frame\n" " 1: color bars\n" "Capture video and audio to a file.\n" "Raw video and audio can be sent to a pipe to avconv or vlc e.g.:\n" "\n" " bmdcapture -m 2 -A 1 -V 1 -F nut -f pipe:1\n\n\n" ); exit(status); }
CLineProperty::~CLineProperty() { Free(); FreeStr(); }
int usage(int status) { HRESULT result; IDeckLinkIterator *deckLinkIterator; IDeckLink *deckLink; int numDevices = 0; fprintf(stderr, "Usage: bmdplay -m <mode id> [OPTIONS]\n" "\n" " -m <mode id>:\n" ); // Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system deckLinkIterator = CreateDeckLinkIteratorInstance(); if (deckLinkIterator == NULL) { fprintf( stderr, "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.\n"); return 1; } // Enumerate all cards in this system while (deckLinkIterator->Next(&deckLink) == S_OK) { BMDProbeString str; // Increment the total number of DeckLink cards found numDevices++; if (numDevices > 1) printf("\n\n"); // *** Print the model name of the DeckLink card result = deckLink->GetModelName(&str); if (result == S_OK) { printf("-> %s (-C %d )\n\n", ToStr(str), numDevices - 1); FreeStr(str); } print_output_modes(deckLink); // Release the IDeckLink instance when we've finished with it to prevent leaks deckLink->Release(); } deckLinkIterator->Release(); // If no DeckLink cards were found in the system, inform the user if (numDevices == 0) printf("No Blackmagic Design devices were found.\n"); printf("\n"); fprintf( stderr, " -f <filename> Filename raw video will be written to\n" " -C <num> Card number to be used\n" " -b <num> Milliseconds of pre-buffering before playback (default = 2000 ms)\n" " -p <pixel> PixelFormat Depth (8 or 10 - default is 8)\n" " -O <output> Output connection:\n" " 1: Composite video + analog audio\n" " 2: Components video + analog audio\n" " 3: HDMI video + audio\n" " 4: SDI video + audio\n\n"); return status; }
void print_output_modes(IDeckLink *deckLink) { IDeckLinkOutput *deckLinkOutput = NULL; IDeckLinkDisplayModeIterator *displayModeIterator = NULL; IDeckLinkDisplayMode *displayMode = NULL; HRESULT result; int displayModeCount = 0; // Query the DeckLink for its configuration interface result = deckLink->QueryInterface(IID_IDeckLinkOutput, (void **)&deckLinkOutput); if (result != S_OK) { fprintf( stderr, "Could not obtain the IDeckLinkOutput interface - result = %08x\n", result); goto bail; } // Obtain an IDeckLinkDisplayModeIterator to enumerate the display modes supported on output result = deckLinkOutput->GetDisplayModeIterator(&displayModeIterator); if (result != S_OK) { fprintf( stderr, "Could not obtain the video output display mode iterator - result = %08x\n", result); goto bail; } // List all supported output display modes printf("Supported video output display modes and pixel formats:\n"); while (displayModeIterator->Next(&displayMode) == S_OK) { BMDProbeString str; result = displayMode->GetName(&str); if (result == S_OK) { char modeName[64]; int modeWidth; int modeHeight; BMDTimeValue frameRateDuration; BMDTimeScale frameRateScale; int pixelFormatIndex = 0; // index into the gKnownPixelFormats / gKnownFormatNames arrays BMDDisplayModeSupport displayModeSupport; // Obtain the display mode's properties modeWidth = displayMode->GetWidth(); modeHeight = displayMode->GetHeight(); displayMode->GetFrameRate(&frameRateDuration, &frameRateScale); printf(" %2d: %-20s \t %d x %d \t %7g FPS\n", displayModeCount++, ToStr(str), modeWidth, modeHeight, (double)frameRateScale / (double)frameRateDuration); FreeStr(str); } // Release the IDeckLinkDisplayMode object to prevent a leak displayMode->Release(); } // printf("\n"); bail: // Ensure that the interfaces we obtained are released to prevent a memory leak if (displayModeIterator != NULL) displayModeIterator->Release(); if (deckLinkOutput != NULL) deckLinkOutput->Release(); }
int usage(int status) { HRESULT result; IDeckLinkIterator *deckLinkIterator; IDeckLink *deckLink; int numDevices = 0; // int displayModeCount = 0; fprintf(stderr, "Usage: bmdcapture -m <mode id> [OPTIONS]\n" "\n" " -m <mode id>:\n" ); // Create an IDeckLinkIterator object to enumerate all DeckLink cards in the system deckLinkIterator = CreateDeckLinkIteratorInstance(); if (deckLinkIterator == NULL) { fprintf( stderr, "A DeckLink iterator could not be created. The DeckLink drivers may not be installed.\n"); return 1; } // Enumerate all cards in this system while (deckLinkIterator->Next(&deckLink) == S_OK) { BMDProbeString str; // Increment the total number of DeckLink cards found numDevices++; if (numDevices > 1) { printf("\n\n"); } // *** Print the model name of the DeckLink card result = deckLink->GetModelName(&str); if (result == S_OK) { printf("-> %s (-C %d )\n\n", ToStr(str), numDevices - 1); FreeStr(str); } print_output_modes(deckLink); // Release the IDeckLink instance when we've finished with it to prevent leaks deckLink->Release(); } deckLinkIterator->Release(); // If no DeckLink cards were found in the system, inform the user if (numDevices == 0) { printf("No Blackmagic Design devices were found.\n"); } printf("\n"); /* * if (displayModeIterator) * { * // we try to print out some useful information about the chosen * // card, but this only works if a card has been selected successfully * * while (displayModeIterator->Next(&displayMode) == S_OK) * { * char * displayModeString = NULL; * * result = displayMode->GetName((const char **) &displayModeString); * if (result == S_OK) * { * BMDTimeValue frameRateDuration, frameRateScale; * displayMode->GetFrameRate(&frameRateDuration, &frameRateScale); * fprintf(stderr, " %2d: %-20s \t %li x %li \t %g FPS\n", * displayModeCount, displayModeString, displayMode->GetWidth(), displayMode->GetHeight(), (double)frameRateScale / (double)frameRateDuration); * free(displayModeString); * displayModeCount++; * } * * // Release the IDeckLinkDisplayMode object to prevent a leak * displayMode->Release(); * } * } */ fprintf( stderr, " -v Be verbose (report each 25 frames)\n" " -f <filename> Filename raw video will be written to\n" " -F <format> Define the file format to be used\n" " -c <channels> Audio Channels (2, 8 or 16 - default is 2)\n" " -s <depth> Audio Sample Depth (16 or 32 - default is 16)\n" " -p <pixel> PixelFormat Depth (8 or 10 - default is 8)\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" " -S <serial_device> data input serial\n" " -A <audio-in> Audio input:\n" " 1: Analog (RCA or XLR)\n" " 2: Embedded Audio (HDMI/SDI)\n" " 3: Digital Audio (AES/EBU)\n" " -V <video-in> Video input:\n" " 1: Composite\n" " 2: Component\n" " 3: HDMI\n" " 4: SDI\n" " 5: Optical SDI\n" " 6: S-Video\n" " -o <optionstring> AVFormat options\n" "Capture video and audio to a file. Raw video and audio can be sent to a pipe to avconv or vlc e.g.:\n" "\n" " bmdcapture -m 2 -A 1 -V 1 -F nut -f pipe:1\n\n\n" ); exit(status); }
CLog::~CLog() { FreeStr(m_pwchFileName); }