From 10ce807f6f0bf01e766b9659b29ae9c7e998b9d6 Mon Sep 17 00:00:00 2001 From: Erik Zandvliet Date: Wed, 23 Apr 2014 13:07:01 +0200 Subject: [PATCH] Edits to accomodate with abstracted semaphore class --- Doxyfile | 75 ++++++++++++++++++++++++-------------- src/input/input.cpp | 22 +++++++---- src/input/mist_in.cpp | 25 ++++++------- src/output/output.cpp | 6 +-- src/output/output_rtmp.cpp | 6 +-- 5 files changed, 80 insertions(+), 54 deletions(-) diff --git a/Doxyfile b/Doxyfile index 794b6cbc..c22c59df 100644 --- a/Doxyfile +++ b/Doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.8.6 +# Doxyfile 1.8.7 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. @@ -70,6 +70,14 @@ OUTPUT_DIRECTORY = ./docs CREATE_SUBDIRS = NO +# If the ALLOW_UNICODE_NAMES tag is set to YES, doxygen will allow non-ASCII +# characters to appear in the names of generated files. If set to NO, non-ASCII +# characters will be escaped, for example _xE3_x81_x84 will be used for Unicode +# U+3044. +# The default value is: NO. + +ALLOW_UNICODE_NAMES = NO + # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. @@ -261,9 +269,12 @@ OPTIMIZE_OUTPUT_VHDL = NO # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, and # language is one of the parsers supported by doxygen: IDL, Java, Javascript, -# C#, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL. For instance to make -# doxygen treat .inc files as Fortran files (default is PHP), and .f files as C -# (default is Fortran), use: inc=Fortran f=C. +# C#, C, C++, D, PHP, Objective-C, Python, Fortran (fixed format Fortran: +# FortranFixed, free formatted Fortran: FortranFree, unknown formatted Fortran: +# Fortran. In the later case the parser tries to guess whether the code is fixed +# or free formatted code, this is the default for Fortran type files), VHDL. For +# instance to make doxygen treat .inc files as Fortran files (default is PHP), +# and .f files as C (default is Fortran), use: inc=Fortran f=C. # # Note For files without extension you can use no_extension as a placeholder. # @@ -778,7 +789,8 @@ RECURSIVE = YES # Note that relative paths are relative to the directory from which doxygen is # run. -EXCLUDE = tinythread.cpp tinythread.h +EXCLUDE = tinythread.cpp \ + tinythread.h # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -794,7 +806,8 @@ EXCLUDE_SYMLINKS = NO # Note that the wildcards are matched against the file with absolute path, so to # exclude all test directories for example use the pattern */test/* -EXCLUDE_PATTERNS = */.git/* */tinythread.* +EXCLUDE_PATTERNS = */.git/* \ + */tinythread.* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the @@ -1230,7 +1243,8 @@ GENERATE_CHI = NO CHM_INDEX_ENCODING = # The BINARY_TOC flag controls whether a binary table of contents is generated ( -# YES) or a normal table of contents ( NO) in the .chm file. +# YES) or a normal table of contents ( NO) in the .chm file. Furthermore it +# enables the Previous and Next buttons. # The default value is: NO. # This tag requires that the tag GENERATE_HTMLHELP is set to YES. @@ -1470,11 +1484,11 @@ SEARCHENGINE = YES # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. There -# are two flavours of web server based searching depending on the -# EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for -# searching and an index file used by the script. When EXTERNAL_SEARCH is -# enabled the indexing and searching needs to be provided by external tools. See -# the section "External Indexing and Searching" for details. +# are two flavors of web server based searching depending on the EXTERNAL_SEARCH +# setting. When disabled, doxygen will generate a PHP script for searching and +# an index file used by the script. When EXTERNAL_SEARCH is enabled the indexing +# and searching needs to be provided by external tools. See the section +# "External Indexing and Searching" for details. # The default value is: NO. # This tag requires that the tag SEARCHENGINE is set to YES. @@ -1762,6 +1776,13 @@ MAN_OUTPUT = man MAN_EXTENSION = .3 +# The MAN_SUBDIR tag determines the name of the directory created within +# MAN_OUTPUT in which the man pages are placed. If defaults to man followed by +# MAN_EXTENSION with the initial . removed. +# This tag requires that the tag GENERATE_MAN is set to YES. + +MAN_SUBDIR = + # If the MAN_LINKS tag is set to YES and doxygen generates man output, then it # will generate one additional man file for each entity documented in the real # man page(s). These additional files only source the real man page, but without @@ -1789,18 +1810,6 @@ GENERATE_XML = NO XML_OUTPUT = xml -# The XML_SCHEMA tag can be used to specify a XML schema, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify a XML DTD, which can be used by a -# validating XML parser to check the syntax of the XML files. -# This tag requires that the tag GENERATE_XML is set to YES. - -XML_DTD = - # If the XML_PROGRAMLISTING tag is set to YES doxygen will dump the program # listings (including syntax highlighting and cross-referencing information) to # the XML output. Note that enabling this will significantly increase the size @@ -1947,9 +1956,9 @@ PREDEFINED = EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES then doxygen's preprocessor will -# remove all refrences to function-like macros that are alone on a line, have an -# all uppercase name, and do not end with a semicolon. Such function macros are -# typically used for boiler-plate code, and will confuse the parser if not +# remove all references to function-like macros that are alone on a line, have +# an all uppercase name, and do not end with a semicolon. Such function macros +# are typically used for boiler-plate code, and will confuse the parser if not # removed. # The default value is: YES. # This tag requires that the tag ENABLE_PREPROCESSING is set to YES. @@ -1969,7 +1978,7 @@ SKIP_FUNCTION_MACROS = YES # where loc1 and loc2 can be relative or absolute paths or URLs. See the # section "Linking to external documentation" for more information about the use # of tag files. -# Note: Each tag file must have an unique name (where the name does NOT include +# Note: Each tag file must have a unique name (where the name does NOT include # the path). If a tag file is not located in the directory in which doxygen is # run, you must also specify the path to the tagfile here. @@ -2061,6 +2070,16 @@ HAVE_DOT = NO DOT_NUM_THREADS = 0 +# When you want a differently looking font n the dot files that doxygen +# generates you can specify the font name using DOT_FONTNAME. You need to make +# sure dot is able to find the font, which can be done by putting it in a +# standard location or by setting the DOTFONTPATH environment variable or by +# setting DOT_FONTPATH to the directory containing the font. +# The default value is: Helvetica. +# This tag requires that the tag HAVE_DOT is set to YES. + +DOT_FONTNAME = Helvetica + # The DOT_FONTSIZE tag can be used to set the size (in points) of the font of # dot graphs. # Minimum value: 4, maximum value: 24, default value: 10. diff --git a/src/input/input.cpp b/src/input/input.cpp index e54acc93..1fedae88 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -114,7 +114,11 @@ namespace Mist { }else{ //after this player functionality - metaPage.init(config->getString("streamname"), (isBuffer ? 8388608 : myMeta.getSendLen()), true); +#ifdef __CYGWIN__ + metaPage.init(config->getString("streamname"), 8 * 1024 * 1024, true); +#else + metaPage.init(config->getString("streamname"), (isBuffer ? 8 * 1024 * 1024 : myMeta.getSendLen()), true); +#endif myMeta.writeTo(metaPage.mapped); userPage.init(config->getString("streamname") + "_users", 30, true); @@ -125,13 +129,13 @@ namespace Mist { } } - sem_t * waiting = sem_open(std::string("/wait_" + config->getString("streamname")).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 0); - if (waiting == SEM_FAILED){ + IPC::semaphore waiting(std::string("/wait_" + config->getString("streamname")).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 0); + if (!waiting){ DEBUG_MSG(DLVL_FAIL, "Failed to open semaphore - cancelling"); return -1; } - sem_post(waiting); - sem_close(waiting); + waiting.post(); + waiting.close(); DEBUG_MSG(DLVL_HIGH,"Pre-While"); @@ -213,10 +217,10 @@ namespace Mist { char tmpId[20]; sprintf(tmpId, "%d", tid); - indexPages[tid].init(config->getString("streamname") + tmpId, 8192, true);//Pages of 8kb in size, room for 512 parts. + indexPages[tid].init(config->getString("streamname") + tmpId, 8 * 1024, true);//Pages of 8kb in size, room for 512 parts. } if (myMeta.tracks[tid].keys[bookKeeping[tid].curKey].getParts() == curData[tid].partNum){ - if (curData[tid].dataSize > 8388608) { + if (curData[tid].dataSize > 8 * 1024 * 1024) { pagesByTrack[tid][bookKeeping[tid].first] = curData[tid]; bookKeeping[tid].first += curData[tid].keyNum; curData[tid].keyNum = 0; @@ -267,7 +271,11 @@ namespace Mist { char pageId[100]; int pageIdLen = sprintf(pageId, "%s%d_%d", config->getString("streamname").c_str(), track, pageNum); std::string tmpString(pageId, pageIdLen); +#ifdef __CYGWIN__ + dataPages[track][pageNum].init(tmpString, 26 * 1024 * 1024, true); +#else dataPages[track][pageNum].init(tmpString, it->second.dataSize, true); +#endif DEBUG_MSG(DLVL_DEVEL, "Buffering track %d page %d through %d", track, pageNum, pageNum-1 + it->second.keyNum); std::stringstream trackSpec; diff --git a/src/input/mist_in.cpp b/src/input/mist_in.cpp index 562b0243..eae8df8d 100644 --- a/src/input/mist_in.cpp +++ b/src/input/mist_in.cpp @@ -14,8 +14,8 @@ int main(int argc, char * argv[]) { Util::Config conf(argv[0], PACKAGE_VERSION); mistIn conv(&conf); if (conf.parseArgs(argc, argv)) { - sem_t * playerLock = sem_open(std::string("/lock_" + conf.getString("streamname")).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1); - if (sem_trywait(playerLock) == -1){ + IPC::semaphore playerLock(std::string("/lock_" + conf.getString("streamname")).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1); + if (!playerLock.tryWait()){ DEBUG_MSG(DLVL_DEVEL, "A player for stream %s is already running", conf.getString("streamname").c_str()); return 1; } @@ -23,30 +23,29 @@ int main(int argc, char * argv[]) { while (conf.is_active){ int pid = fork(); if (pid == 0){ - sem_close(playerLock); + playerLock.close(); return conv.run(); } if (pid == -1){ DEBUG_MSG(DLVL_FAIL, "Unable to spawn player process"); - sem_post(playerLock); + playerLock.post(); return 2; } //wait for the process to exit int status; while (waitpid(pid, &status, 0) != pid && errno == EINTR) continue; //clean up the semaphore by waiting for it, if it's non-zero - sem_t * waiting = sem_open(std::string("/wait_" + conf.getString("streamname")).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 0); - if (waiting == SEM_FAILED){ + IPC::semaphore waiting(std::string("/wait_" + conf.getString("streamname")).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 0); + if (!waiting){ DEBUG_MSG(DLVL_FAIL, "Failed to open semaphore - cancelling"); return -1; } - int sem_val = 0; - sem_getvalue(waiting, &sem_val); + int sem_val = waiting.getVal(); while (sem_val){ - while (sem_wait(waiting) == -1 && errno == EINTR) continue; - sem_getvalue(waiting, &sem_val); + waiting.wait(); + sem_val = waiting.getVal(); } - sem_close(waiting); + waiting.close(); //if the exit was clean, don't restart it if (WIFEXITED(status) && (WEXITSTATUS(status) == 0)){ DEBUG_MSG(DLVL_MEDIUM, "Finished player succesfully"); @@ -57,8 +56,8 @@ int main(int argc, char * argv[]) { break; } } - sem_post(playerLock); - sem_close(playerLock); + playerLock.post(); + playerLock.close(); } return 0; } diff --git a/src/output/output.cpp b/src/output/output.cpp index 73304260..d40d5ad5 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -82,7 +82,7 @@ namespace Mist { return; } isInitialized = true; - streamIndex.init(streamName,0); + streamIndex.init(streamName,8 * 1024 * 1024); if (!streamIndex.mapped){ DEBUG_MSG(DLVL_FAIL, "Could not connect to server for %s\n", streamName.c_str()); onFail(); @@ -239,7 +239,7 @@ namespace Mist { if (!indexPages.count(trackId)){ char id[100]; sprintf(id, "%s%lu", streamName.c_str(), trackId); - indexPages[trackId].init(id, 8192); + indexPages[trackId].init(id, 8 * 1024); } while (pageNum == -1 || keyAmount == -1){ for (int i = 0; i < indexPages[trackId].len / 8; i++){ @@ -285,7 +285,7 @@ namespace Mist { } char id[100]; sprintf(id, "%s%lu_%d", streamName.c_str(), trackId, pageNum); - curPages[trackId].init(std::string(id),0); + curPages[trackId].init(std::string(id),26 * 1024 * 1024); if (!(curPages[trackId].mapped)){ DEBUG_MSG(DLVL_FAIL, "Initializing page %s failed", curPages[trackId].name.c_str()); return; diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index 362d125f..e123f43e 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -609,7 +609,7 @@ namespace Mist { //open new page char nextPage[100]; sprintf(nextPage, "%s%llu_%d", streamName.c_str(), tNum, bookKeeping[tNum].pageNum + bookKeeping[tNum].keyNum); - curPages[tNum].init(nextPage, 0, false); + curPages[tNum].init(nextPage, 26 * 1024 * 1024); bookKeeping[tNum].pageNum += bookKeeping[tNum].keyNum; bookKeeping[tNum].keyNum = 0; bookKeeping[tNum].curOffset = 0; @@ -667,7 +667,7 @@ namespace Mist { for (std::map::iterator it = trackMap.begin(); it != trackMap.end(); it++){ char tmp[100]; sprintf( tmp, "liveStream_%s%d", streamName.c_str(), it->second); - metaPages[it->second].init(std::string(tmp), 0, false); + metaPages[it->second].init(std::string(tmp), 8 * 1024 * 1024); DTSC::Meta tmpMeta = meta_out; tmpMeta.tracks.clear(); tmpMeta.tracks[it->second] = meta_out.tracks[it->first]; @@ -719,7 +719,7 @@ namespace Mist { }else{ char firstPage[100]; sprintf(firstPage, "%s%lu_%d", streamName.c_str(), tNum, 0); - curPages[tNum].init(firstPage, 0, false); + curPages[tNum].init(firstPage, 8 * 1024 * 1024); bookKeeping[tNum] = DTSCPageData(); DEBUG_MSG(DLVL_WARN, "Buffer accepted track %lu", tNum); }