Fix for Windows semaphore problem in live streams
This commit is contained in:
parent
b6486878ca
commit
43e82f8c87
2 changed files with 17 additions and 15 deletions
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
namespace Mist {
|
namespace Mist {
|
||||||
inputBuffer::inputBuffer(Util::Config * cfg) : Input(cfg) {
|
inputBuffer::inputBuffer(Util::Config * cfg) : Input(cfg) {
|
||||||
|
liveMeta = 0;
|
||||||
capa["name"] = "Buffer";
|
capa["name"] = "Buffer";
|
||||||
JSON::Value option;
|
JSON::Value option;
|
||||||
option["arg"] = "integer";
|
option["arg"] = "integer";
|
||||||
|
@ -95,10 +96,11 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
if (liveMeta){
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
liveMeta->unlink();
|
||||||
IPC::semaphore liveMeta(pageName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
delete liveMeta;
|
||||||
liveMeta.unlink();
|
liveMeta = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,13 +122,9 @@ namespace Mist {
|
||||||
memset(tmp.mapped, 0xFF, size);
|
memset(tmp.mapped, 0xFF, size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Delete the live stream semaphore, if any.
|
||||||
|
if (liveMeta){liveMeta->unlink();}
|
||||||
{
|
{
|
||||||
//Delete the live stream semaphore, if any.
|
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
|
||||||
IPC::semaphore liveMeta(pageName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
|
||||||
liveMeta.unlink();
|
|
||||||
}{
|
|
||||||
//Delete the stream index metapage.
|
//Delete the stream index metapage.
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
||||||
IPC::sharedPage erasePage(pageName, DEFAULT_STRM_PAGE_SIZE, false, false);
|
IPC::sharedPage erasePage(pageName, DEFAULT_STRM_PAGE_SIZE, false, false);
|
||||||
|
@ -192,10 +190,13 @@ namespace Mist {
|
||||||
myMeta.bufferWindow = lastms - firstms;
|
myMeta.bufferWindow = lastms - firstms;
|
||||||
myMeta.vod = false;
|
myMeta.vod = false;
|
||||||
myMeta.live = true;
|
myMeta.live = true;
|
||||||
static char liveSemName[NAME_BUFFER_SIZE];
|
if (!liveMeta){
|
||||||
snprintf(liveSemName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
static char liveSemName[NAME_BUFFER_SIZE];
|
||||||
IPC::semaphore liveMeta(liveSemName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
snprintf(liveSemName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
||||||
liveMeta.wait();
|
liveMeta = new IPC::semaphore(liveSemName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||||
|
}
|
||||||
|
liveMeta->wait();
|
||||||
|
|
||||||
if (!nProxy.metaPages.count(0) || !nProxy.metaPages[0].mapped) {
|
if (!nProxy.metaPages.count(0) || !nProxy.metaPages[0].mapped) {
|
||||||
char pageName[NAME_BUFFER_SIZE];
|
char pageName[NAME_BUFFER_SIZE];
|
||||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
||||||
|
@ -204,7 +205,7 @@ namespace Mist {
|
||||||
}
|
}
|
||||||
myMeta.writeTo(nProxy.metaPages[0].mapped);
|
myMeta.writeTo(nProxy.metaPages[0].mapped);
|
||||||
memset(nProxy.metaPages[0].mapped + myMeta.getSendLen(), 0, (nProxy.metaPages[0].len > myMeta.getSendLen() ? std::min(nProxy.metaPages[0].len - myMeta.getSendLen(), 4ll) : 0));
|
memset(nProxy.metaPages[0].mapped + myMeta.getSendLen(), 0, (nProxy.metaPages[0].len > myMeta.getSendLen() ? std::min(nProxy.metaPages[0].len - myMeta.getSendLen(), 4ll) : 0));
|
||||||
liveMeta.post();
|
liveMeta->post();
|
||||||
}
|
}
|
||||||
|
|
||||||
///Checks if removing a key from this track is allowed/safe, and if so, removes it.
|
///Checks if removing a key from this track is allowed/safe, and if so, removes it.
|
||||||
|
|
|
@ -13,6 +13,7 @@ namespace Mist {
|
||||||
unsigned int cutTime;
|
unsigned int cutTime;
|
||||||
bool hasPush;
|
bool hasPush;
|
||||||
bool resumeMode;
|
bool resumeMode;
|
||||||
|
IPC::semaphore * liveMeta;
|
||||||
protected:
|
protected:
|
||||||
//Private Functions
|
//Private Functions
|
||||||
bool setup();
|
bool setup();
|
||||||
|
|
Loading…
Add table
Reference in a new issue