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 {
|
||||
inputBuffer::inputBuffer(Util::Config * cfg) : Input(cfg) {
|
||||
liveMeta = 0;
|
||||
capa["name"] = "Buffer";
|
||||
JSON::Value option;
|
||||
option["arg"] = "integer";
|
||||
|
@ -95,10 +96,11 @@ namespace Mist {
|
|||
}
|
||||
}
|
||||
}
|
||||
char pageName[NAME_BUFFER_SIZE];
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
||||
IPC::semaphore liveMeta(pageName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
liveMeta.unlink();
|
||||
if (liveMeta){
|
||||
liveMeta->unlink();
|
||||
delete liveMeta;
|
||||
liveMeta = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -120,13 +122,9 @@ namespace Mist {
|
|||
memset(tmp.mapped, 0xFF, size);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
//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();
|
||||
}{
|
||||
if (liveMeta){liveMeta->unlink();}
|
||||
{
|
||||
//Delete the stream index metapage.
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
||||
IPC::sharedPage erasePage(pageName, DEFAULT_STRM_PAGE_SIZE, false, false);
|
||||
|
@ -192,10 +190,13 @@ namespace Mist {
|
|||
myMeta.bufferWindow = lastms - firstms;
|
||||
myMeta.vod = false;
|
||||
myMeta.live = true;
|
||||
if (!liveMeta){
|
||||
static char liveSemName[NAME_BUFFER_SIZE];
|
||||
snprintf(liveSemName, NAME_BUFFER_SIZE, SEM_LIVE, streamName.c_str());
|
||||
IPC::semaphore liveMeta(liveSemName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
liveMeta.wait();
|
||||
liveMeta = new IPC::semaphore(liveSemName, O_CREAT | O_RDWR, ACCESSPERMS, 1);
|
||||
}
|
||||
liveMeta->wait();
|
||||
|
||||
if (!nProxy.metaPages.count(0) || !nProxy.metaPages[0].mapped) {
|
||||
char pageName[NAME_BUFFER_SIZE];
|
||||
snprintf(pageName, NAME_BUFFER_SIZE, SHM_STREAM_INDEX, streamName.c_str());
|
||||
|
@ -204,7 +205,7 @@ namespace Mist {
|
|||
}
|
||||
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));
|
||||
liveMeta.post();
|
||||
liveMeta->post();
|
||||
}
|
||||
|
||||
///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;
|
||||
bool hasPush;
|
||||
bool resumeMode;
|
||||
IPC::semaphore * liveMeta;
|
||||
protected:
|
||||
//Private Functions
|
||||
bool setup();
|
||||
|
|
Loading…
Add table
Reference in a new issue