CC-4370: Transitioning between two webstreams: a hiccup in the stream is audible

-fixed
This commit is contained in:
Martin Konecny 2012-09-13 16:10:17 -04:00
parent 14db5053b1
commit da72c00f28
2 changed files with 45 additions and 2 deletions

View File

@ -789,6 +789,30 @@ SQL;
}
}
/**
* Purpose of this function is to iterate through the entire
* schedule array that was just built and fix the data up a bit. For
* example, if we have two consecutive webstreams, we don't need the
* first webstream to shutdown the output, when the second one will
* just switch it back on. Preventing this behaviour stops hiccups
* in output sound.
*/
private static function filterData(&$data)
{
$previous_key = null;
$previous_val = null;
foreach ($data as $k => $v) {
if ($v["type"] == "stream_buffer_start"
&& !is_null($previous_val)
&& $previous_val["type"] == "stream_output_end") {
unset($data[$previous_key]);
}
$previous_key = $k;
$previous_val = $v;
}
}
public static function getSchedule($p_fromDateTime = null, $p_toDateTime = null)
{
list($range_start, $range_end) = self::getRangeStartAndEnd($p_fromDateTime, $p_toDateTime);
@ -799,6 +823,8 @@ SQL;
self::createInputHarborKickTimes($data, $range_start, $range_end);
self::createScheduledEvents($data, $range_start, $range_end);
self::filterData($data["media"]);
return $data;
}

View File

@ -434,7 +434,9 @@ class PypoPush(Thread):
self.start_web_stream_buffer(media_item)
self.start_web_stream(media_item)
elif media_item['type'] == "stream_buffer_end":
self.stop_web_stream(media_item)
self.stop_web_stream_buffer(media_item)
elif media_item['type'] == "stream_output_end":
self.stop_web_stream_output(media_item)
except Exception, e:
self.logger.error('Pypo Push Exception: %s', e)
@ -509,7 +511,7 @@ class PypoPush(Thread):
finally:
self.telnet_lock.release()
def stop_web_stream(self, media_item):
def stop_web_stream_buffer(self, media_item):
try:
self.telnet_lock.acquire()
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
@ -519,6 +521,21 @@ class PypoPush(Thread):
self.logger.debug(msg)
tn.write(msg)
tn.write("exit\n")
self.logger.debug(tn.read_all())
self.current_stream_info = None
except Exception, e:
self.logger.error(str(e))
finally:
self.telnet_lock.release()
def stop_web_stream_output(self, media_item):
try:
self.telnet_lock.acquire()
tn = telnetlib.Telnet(LS_HOST, LS_PORT)
#dynamic_source.stop http://87.230.101.24:80/top100station.mp3
msg = 'dynamic_source.output_stop\n'
self.logger.debug(msg)
tn.write(msg)