From 43d35cf29b62e6f3711a3508017bd6b915671b76 Mon Sep 17 00:00:00 2001 From: Thulinma Date: Tue, 27 Jan 2015 12:03:52 +0100 Subject: [PATCH] Converted previously hardcoded default sizes for shared memory pages to defines. --- src/controller/controller_storage.cpp | 3 ++- src/controller/controller_streams.cpp | 4 ++-- src/input/input.cpp | 10 +++++----- src/input/input_buffer.cpp | 2 +- src/output/output.cpp | 10 +++++----- src/output/output_http.cpp | 4 ++-- src/output/output_http_internal.cpp | 6 +++--- src/output/output_rtmp.cpp | 2 +- 8 files changed, 21 insertions(+), 20 deletions(-) diff --git a/src/controller/controller_storage.cpp b/src/controller/controller_storage.cpp index fa496c92..26a1c951 100644 --- a/src/controller/controller_storage.cpp +++ b/src/controller/controller_storage.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "controller_storage.h" #include "controller_capabilities.h" @@ -80,7 +81,7 @@ namespace Controller { writeConf["streams"] = Storage["streams"]; writeConf["capabilities"] = capabilities; - static IPC::sharedPage mistConfOut("!mistConfig", 4*1024*1024, true); + static IPC::sharedPage mistConfOut("!mistConfig", DEFAULT_CONF_PAGE_SIZE, true); IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); //lock semaphore configLock.wait(); diff --git a/src/controller/controller_streams.cpp b/src/controller/controller_streams.cpp index e503c3a5..d8520bfb 100644 --- a/src/controller/controller_streams.cpp +++ b/src/controller/controller_streams.cpp @@ -59,7 +59,7 @@ namespace Controller { //push-style stream if (hasViewers(name)){ data["meta"].null(); - IPC::sharedPage streamIndex(name,8 * 1024 * 1024,false,false); + IPC::sharedPage streamIndex(name, DEFAULT_META_PAGE_SIZE, false, false); if (!streamIndex.mapped){ return; } @@ -129,7 +129,7 @@ namespace Controller { DEBUG_MSG(DLVL_INSANE, "Waiting for stream %s to open...", name.c_str()); //wait for the stream { - IPC::sharedPage streamIndex(name, 8 * 1024 * 1024); + IPC::sharedPage streamIndex(name, DEFAULT_META_PAGE_SIZE); if (!streamIndex.mapped){ DEBUG_MSG(DLVL_INSANE, "Stream %s opening failed! Cancelling and marking as corrupt.", name.c_str()); data["meta"].null(); diff --git a/src/input/input.cpp b/src/input/input.cpp index 2e997665..fa4d7c1d 100644 --- a/src/input/input.cpp +++ b/src/input/input.cpp @@ -146,9 +146,9 @@ namespace Mist { //after this player functionality #ifdef __CYGWIN__ - metaPage.init(config->getString("streamname"), 8 * 1024 * 1024, true); + metaPage.init(config->getString("streamname"), DEFAULT_META_PAGE_SIZE, true); #else - metaPage.init(config->getString("streamname"), (isBuffer ? 8 * 1024 * 1024 : myMeta.getSendLen()), true); + metaPage.init(config->getString("streamname"), (isBuffer ? DEFAULT_META_PAGE_SIZE : myMeta.getSendLen()), true); #endif myMeta.writeTo(metaPage.mapped); userPage.init(config->getString("streamname") + "_users", 30, true); @@ -240,7 +240,7 @@ namespace Mist { pagesByTrack[it->first].rbegin()->second.keyNum++; pagesByTrack[it->first].rbegin()->second.partNum += it->second.keys[i].getParts(); pagesByTrack[it->first].rbegin()->second.dataSize += it->second.keySizes[i]; - if (pagesByTrack[it->first].rbegin()->second.dataSize > 8 * 1024 * 1024){ + if (pagesByTrack[it->first].rbegin()->second.dataSize > FLIP_DATA_PAGE_SIZE){ newData = true; } } @@ -275,7 +275,7 @@ namespace Mist { indexPages[tid].init(tmpId, 8 * 1024, true);//Pages of 8kb in size, room for 512 parts. } if (myMeta.tracks[tid].keys[bookKeeping[tid].curKey].getParts() + 1 == curData[tid].partNum){ - if (curData[tid].dataSize > 8 * 1024 * 1024) { + if (curData[tid].dataSize > FLIP_DATA_PAGE_SIZE) { pagesByTrack[tid][bookKeeping[tid].first] = curData[tid]; bookKeeping[tid].first += curData[tid].keyNum; curData[tid].keyNum = 0; @@ -331,7 +331,7 @@ namespace Mist { int pageIdLen = snprintf(pageId, 100, "%s%u_%u", config->getString("streamname").c_str(), track, pageNum); std::string tmpString(pageId, pageIdLen); #ifdef __CYGWIN__ - dataPages[track][pageNum].init(tmpString, 26 * 1024 * 1024, true); + dataPages[track][pageNum].init(tmpString, DEFAULT_DATA_PAGE_SIZE, true); #else dataPages[track][pageNum].init(tmpString, it->second.dataSize, true); #endif diff --git a/src/input/input_buffer.cpp b/src/input/input_buffer.cpp index 77208229..b3e28f9c 100644 --- a/src/input/input_buffer.cpp +++ b/src/input/input_buffer.cpp @@ -323,7 +323,7 @@ namespace Mist { std::string strName = config->getString("streamname"); Util::sanitizeName(strName); strName = strName.substr(0,(strName.find('+'))); - IPC::sharedPage serverCfg("!mistConfig", 4*1024*1024, false, false); ///< Contains server configuration and capabilities + IPC::sharedPage serverCfg("!mistConfig", DEFAULT_CONF_PAGE_SIZE, false, false); ///< Contains server configuration and capabilities IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); configLock.wait(); DTSC::Scan streamCfg = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("streams").getMember(strName); diff --git a/src/output/output.cpp b/src/output/output.cpp index 71af3c39..31e9cdb0 100644 --- a/src/output/output.cpp +++ b/src/output/output.cpp @@ -121,7 +121,7 @@ namespace Mist { char pageName[100]; sprintf(pageName, "liveStream_%s%d", streamName.c_str(), newTid); - metaPages[newTid].init(pageName, 8 * 1024 * 1024); + metaPages[newTid].init(pageName, DEFAULT_META_PAGE_SIZE); DTSC::Meta tmpMeta = meta_out; tmpMeta.tracks.clear(); tmpMeta.tracks[newTid] = meta_out.tracks[tid]; @@ -155,7 +155,7 @@ namespace Mist { INFO_MSG("Buffer has indicated that incoming track %d should start writing on track %d, page %d", tid, finalTid, firstPage); memset(pageName, 0, 100); sprintf(pageName, "%s%d_%d", streamName.c_str(), finalTid, firstPage); - curPages[finalTid].init(pageName, 25 * 1024 * 1024); + curPages[finalTid].init(pageName, DEFAULT_DATA_PAGE_SIZE); trackMap[tid] = finalTid; bookKeeping[finalTid] = DTSCPageData(); } @@ -203,7 +203,7 @@ namespace Mist { char nextPage[100]; sprintf(nextPage, "%s%llu_%d", streamName.c_str(), tNum, bookKeeping[tNum].pageNum + bookKeeping[tNum].keyNum); INFO_MSG("Continuing track %llu on page %d", tNum, bookKeeping[tNum].pageNum + bookKeeping[tNum].keyNum); - curPages[tNum].init(nextPage, 25 * 1024 * 1024); + curPages[tNum].init(nextPage, DEFAULT_DATA_PAGE_SIZE); bookKeeping[tNum].pageNum += bookKeeping[tNum].keyNum; bookKeeping[tNum].keyNum = 0; bookKeeping[tNum].curOffset = 0; @@ -236,7 +236,7 @@ namespace Mist { return; } isInitialized = true; - streamIndex.init(streamName, 8 * 1024 * 1024); + streamIndex.init(streamName, DEFAULT_META_PAGE_SIZE); if (!streamIndex.mapped){ DEBUG_MSG(DLVL_FAIL, "Could not connect to server for %s\n", streamName.c_str()); onFail(); @@ -439,7 +439,7 @@ namespace Mist { } char id[100]; snprintf(id, 100, "%s%lu_%d", streamName.c_str(), trackId, pageNum); - curPages[trackId].init(id, 26 * 1024 * 1024); + curPages[trackId].init(id, DEFAULT_DATA_PAGE_SIZE); if (!(curPages[trackId].mapped)){ DEBUG_MSG(DLVL_FAIL, "Initializing page %s failed", curPages[trackId].name.c_str()); return; diff --git a/src/output/output_http.cpp b/src/output/output_http.cpp index fc1159e9..1d175a7a 100644 --- a/src/output/output_http.cpp +++ b/src/output/output_http.cpp @@ -102,7 +102,7 @@ namespace Mist { //loop over the connectors IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); configLock.wait(); - IPC::sharedPage serverCfg("!mistConfig", 4*1024*1024); + IPC::sharedPage serverCfg("!mistConfig", DEFAULT_CONF_PAGE_SIZE); DTSC::Scan capa = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("capabilities").getMember("connectors"); unsigned int capa_ctr = capa.getSize(); for (unsigned int i = 0; i < capa_ctr; ++i){ @@ -249,7 +249,7 @@ namespace Mist { IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); configLock.wait(); - IPC::sharedPage serverCfg("!mistConfig", 4*1024*1024); + IPC::sharedPage serverCfg("!mistConfig", DEFAULT_CONF_PAGE_SIZE); DTSC::Scan prots = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("config").getMember("protocols"); unsigned int prots_ctr = prots.getSize(); diff --git a/src/output/output_http_internal.cpp b/src/output/output_http_internal.cpp index 2b5cb07a..9952aaea 100644 --- a/src/output/output_http_internal.cpp +++ b/src/output/output_http_internal.cpp @@ -194,7 +194,7 @@ namespace Mist { IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); configLock.wait(); - IPC::sharedPage serverCfg("!mistConfig", 4*1024*1024); + IPC::sharedPage serverCfg("!mistConfig", DEFAULT_CONF_PAGE_SIZE); DTSC::Scan prtcls = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("config").getMember("protocols"); DTSC::Scan capa = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("capabilities").getMember("connectors").getMember("RTMP"); unsigned int pro_cnt = prtcls.getSize(); @@ -254,14 +254,14 @@ namespace Mist { IPC::semaphore metaLocker(std::string("liveMeta@" + streamName).c_str(), O_CREAT | O_RDWR, ACCESSPERMS, 1); bool metaLock = false; configLock.wait(); - IPC::sharedPage serverCfg("!mistConfig", 4*1024*1024); + IPC::sharedPage serverCfg("!mistConfig", DEFAULT_CONF_PAGE_SIZE); DTSC::Scan strm = DTSC::Scan(serverCfg.mapped, serverCfg.len).getMember("streams").getMember(streamName).getMember("meta"); IPC::sharedPage streamIndex; if (!strm){ configLock.post(); //Stream metadata not found - attempt to start it if (Util::startInput(streamName)){ - streamIndex.init(streamName, 8 * 1024 * 1024); + streamIndex.init(streamName, DEFAULT_META_PAGE_SIZE); if (streamIndex.mapped){ metaLock = true; metaLocker.wait(); diff --git a/src/output/output_rtmp.cpp b/src/output/output_rtmp.cpp index b1cb9ee2..5622f2fe 100644 --- a/src/output/output_rtmp.cpp +++ b/src/output/output_rtmp.cpp @@ -449,7 +449,7 @@ namespace Mist { streamName = amfData.getContentP(3)->StrValue(); Util::sanitizeName(streamName); //pull the server configuration - IPC::sharedPage serverCfg("!mistConfig", 4*1024*1024); ///< Contains server configuration and capabilities + IPC::sharedPage serverCfg("!mistConfig", DEFAULT_CONF_PAGE_SIZE); ///< Contains server configuration and capabilities IPC::semaphore configLock("!mistConfLock", O_CREAT | O_RDWR, ACCESSPERMS, 1); configLock.wait();