From 3f1c47b7643f208747a1afa2a53ea6ae4aa5fc6e Mon Sep 17 00:00:00 2001 From: denise Date: Fri, 7 Jun 2013 13:47:12 -0400 Subject: [PATCH] CC-5215: Linked shows sometimes lose crossfades --- .../application/services/SchedulerService.php | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/services/SchedulerService.php b/airtime_mvc/application/services/SchedulerService.php index 1bbfbb471..7ab662c5c 100644 --- a/airtime_mvc/application/services/SchedulerService.php +++ b/airtime_mvc/application/services/SchedulerService.php @@ -148,6 +148,24 @@ class Application_Service_SchedulerService return $dt; } + private static function findTimeDifference($p_startDT, $p_seconds) + { + $startEpoch = $p_startDT->format("U.u"); + + //add two float numbers to 6 subsecond precision + //DateTime::createFromFormat("U.u") will have a problem if there is no decimal in the resulting number. + $newEpoch = bcsub($startEpoch , (string) $p_seconds, 6); + + $dt = DateTime::createFromFormat("U.u", $newEpoch, new DateTimeZone("UTC")); + + if ($dt === false) { + //PHP 5.3.2 problem + $dt = DateTime::createFromFormat("U", intval($newEpoch), new DateTimeZone("UTC")); + } + + return $dt; + } + public static function fillNewLinkedInstances($ccShow) { /* First check if any linked instances have content @@ -224,7 +242,8 @@ class Application_Service_SchedulerService "{$id}, ". "{$item["position"]})"; - $nextStartDT = $endTimeDT; + $nextStartDT = self::findTimeDifference($endTimeDT, + Application_Model_Preference::GetDefaultCrossfadeDuration()); } //foreach show item } } //foreach linked instance @@ -281,7 +300,8 @@ class Application_Service_SchedulerService ->setDbPosition($item->getDbPosition()) ->save(); - $nextStartDT = $endTimeDT; + $nextStartDT = self::findTimeDifference($endTimeDT, + Application_Model_Preference::GetDefaultCrossfadeDuration()); } //foreach show item $ccShowInstance