Robustified disconnect/reconnect functions in Output
This commit is contained in:
parent
a7218bc2f8
commit
72cfc82a9f
1 changed files with 19 additions and 12 deletions
|
@ -336,10 +336,11 @@ namespace Mist{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Disconnects from all stat/user-related shared structures.
|
/// Disconnects from all stat/user/metadata-related shared structures.
|
||||||
void Output::disconnect(){
|
void Output::disconnect(){
|
||||||
MEDIUM_MSG("disconnect");
|
MEDIUM_MSG("disconnect");
|
||||||
if (statComm){
|
if (statComm){
|
||||||
|
stats(true);
|
||||||
statComm.unload();
|
statComm.unload();
|
||||||
myConn.resetCounter();
|
myConn.resetCounter();
|
||||||
}
|
}
|
||||||
|
@ -351,8 +352,6 @@ namespace Mist{
|
||||||
/// Connects or reconnects to the stream.
|
/// Connects or reconnects to the stream.
|
||||||
/// Assumes streamName class member has been set already.
|
/// Assumes streamName class member has been set already.
|
||||||
/// Will start input if not currently active, calls onFail() if this does not succeed.
|
/// Will start input if not currently active, calls onFail() if this does not succeed.
|
||||||
/// After assuring stream is online, clears metaPages, then sets metaPages[0], statistics and
|
|
||||||
/// userClient to (hopefully) valid handles.
|
|
||||||
void Output::reconnect(){
|
void Output::reconnect(){
|
||||||
thisPacket.null();
|
thisPacket.null();
|
||||||
if (config->hasOption("noinput") && config->getBool("noinput")){
|
if (config->hasOption("noinput") && config->getBool("noinput")){
|
||||||
|
@ -409,18 +408,30 @@ namespace Mist{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
disconnect();
|
//Wipe currently selected tracks; metadata unload coming up
|
||||||
|
userSelect.clear();
|
||||||
|
|
||||||
|
//Connect to stream metadata
|
||||||
meta.reInit(streamName, false);
|
meta.reInit(streamName, false);
|
||||||
unsigned int attempts = 0;
|
unsigned int attempts = 0;
|
||||||
while (!meta && ++attempts < 20 && Util::streamAlive(streamName)){
|
while (!meta && ++attempts < 20 && Util::streamAlive(streamName)){
|
||||||
meta.reInit(streamName, false);
|
meta.reInit(streamName, false);
|
||||||
}
|
}
|
||||||
|
//Abort if this step failed
|
||||||
if (!meta){return;}
|
if (!meta){return;}
|
||||||
|
|
||||||
isInitialized = true;
|
isInitialized = true;
|
||||||
statComm.reload();
|
|
||||||
stats(true);
|
//Connect to stats reporting, if not connected already
|
||||||
|
if (!statComm){
|
||||||
|
statComm.reload();
|
||||||
|
stats(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//push inputs do not need to wait for stream to be ready for playback
|
||||||
if (isPushing()){return;}
|
if (isPushing()){return;}
|
||||||
|
|
||||||
|
//live streams that are no push outputs (recordings), wait for stream to be ready
|
||||||
if (!isRecording() && M.getLive() && !isReadyForPlay()){
|
if (!isRecording() && M.getLive() && !isReadyForPlay()){
|
||||||
uint64_t waitUntil = Util::bootSecs() + 45;
|
uint64_t waitUntil = Util::bootSecs() + 45;
|
||||||
while (M.getLive() && !isReadyForPlay()){
|
while (M.getLive() && !isReadyForPlay()){
|
||||||
|
@ -433,6 +444,7 @@ namespace Mist{
|
||||||
stats();
|
stats();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//Finally, select the default tracks
|
||||||
selectDefaultTracks();
|
selectDefaultTracks();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1451,11 +1463,7 @@ namespace Mist{
|
||||||
}
|
}
|
||||||
/*LTS-END*/
|
/*LTS-END*/
|
||||||
|
|
||||||
stats(true);
|
disconnect();
|
||||||
if (statComm){statComm.setStatus(COMM_STATUS_DISCONNECT | statComm.getStatus());}
|
|
||||||
|
|
||||||
userSelect.clear();
|
|
||||||
|
|
||||||
myConn.close();
|
myConn.close();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -2010,7 +2018,6 @@ namespace Mist{
|
||||||
while (((streamStatus != STRMSTAT_WAIT && streamStatus != STRMSTAT_READY) || !meta) && keepGoing()){
|
while (((streamStatus != STRMSTAT_WAIT && streamStatus != STRMSTAT_READY) || !meta) && keepGoing()){
|
||||||
INFO_MSG("Waiting for %s buffer to be ready... (%u)", streamName.c_str(), streamStatus);
|
INFO_MSG("Waiting for %s buffer to be ready... (%u)", streamName.c_str(), streamStatus);
|
||||||
disconnect();
|
disconnect();
|
||||||
userSelect.clear();
|
|
||||||
Util::wait(1000);
|
Util::wait(1000);
|
||||||
streamStatus = Util::getStreamStatus(streamName);
|
streamStatus = Util::getStreamStatus(streamName);
|
||||||
if (streamStatus == STRMSTAT_OFF || streamStatus == STRMSTAT_WAIT || streamStatus == STRMSTAT_READY){
|
if (streamStatus == STRMSTAT_OFF || streamStatus == STRMSTAT_WAIT || streamStatus == STRMSTAT_READY){
|
||||||
|
|
Loading…
Add table
Reference in a new issue