Added streamlock to disable refreshNextTimer() while streaming. Fixed bug in HLS Livestream Media Handler.
This commit is contained in:
parent
dd00a11b92
commit
a927b31919
2 changed files with 21 additions and 15 deletions
|
|
@ -49,6 +49,8 @@ module.exports = class{
|
|||
this.preSwitchTimer = null;
|
||||
//Create variable to hold currently playing media object
|
||||
this.nowPlaying = null;
|
||||
//Create variable to lock standard queuing functions during livestreams
|
||||
this.streamLock = false;
|
||||
|
||||
//create boolean to hold schedule lock
|
||||
this.locked = false;
|
||||
|
|
@ -302,6 +304,9 @@ module.exports = class{
|
|||
|
||||
//Broadcast new media object to users
|
||||
this.sendMedia();
|
||||
|
||||
//Throw stream lock
|
||||
this.streamLock = true;
|
||||
}catch(err){
|
||||
return loggerUtils.socketExceptionHandler(socket, err);
|
||||
}
|
||||
|
|
@ -359,13 +364,18 @@ module.exports = class{
|
|||
}
|
||||
|
||||
refreshNextTimer(volatile = false){
|
||||
//If we're streamlocked
|
||||
if(this.streamLock){
|
||||
//Stop while we're ahead since the stream hasn't ended yet
|
||||
return;
|
||||
}
|
||||
|
||||
//Grab the next item
|
||||
const nextItem = this.getNextItem();
|
||||
|
||||
//Get current item
|
||||
const currentItem = this.getItemAtEpoch()
|
||||
|
||||
|
||||
//Clear out any stale timers to prevent ghost queueing
|
||||
clearTimeout(this.nextTimer);
|
||||
clearTimeout(this.preSwitchTimer);
|
||||
|
|
@ -946,6 +956,9 @@ module.exports = class{
|
|||
|
||||
async endLivestream(chanDB){
|
||||
try{
|
||||
//Disable stream lock
|
||||
this.streamLock = false;
|
||||
|
||||
//Refresh next timer
|
||||
this.refreshNextTimer();
|
||||
|
||||
|
|
@ -960,19 +973,7 @@ module.exports = class{
|
|||
}
|
||||
}
|
||||
|
||||
async stop(chanDB){
|
||||
//If we wheren't handed a channel
|
||||
if(chanDB == null){
|
||||
//DO everything ourselves since we don't have a fance end() function to do it
|
||||
chanDB = await channelModel.findOne({name:this.channel.name});
|
||||
}
|
||||
|
||||
//If we wheren't handed a channel
|
||||
if(chanDB == null){
|
||||
//Complain about the lack of a channel
|
||||
throw loggerUtils.exceptionSmith(`Channel not found!`, "queue");
|
||||
}
|
||||
|
||||
stop(){
|
||||
//If we're not currently playing anything
|
||||
if(this.nowPlaying == null){
|
||||
//If an originating socket was provided for this request
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue