From 792366e1f5dc47e7886e24267cb2e609fb41fd5c Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 23 May 2013 11:35:56 -0400 Subject: [PATCH 001/136] CC-5100: Now Playing: Editing schedule on-the-fly will cause 2 tracks mixed at the same time. --- airtime_mvc/application/models/Scheduler.php | 1 + 1 file changed, 1 insertion(+) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 7cfe72908..371fbf07e 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -577,6 +577,7 @@ class Application_Model_Scheduler $linkCcSchedule = CcScheduleQuery::create() ->filterByDbInstanceId($instanceId) ->filterByDbPosition($pos) + ->filterByDbPlayoutStatus(-1, Criteria::NOT_EQUAL) ->findOne(); $schedItemEndDT = $linkCcSchedule->getDbEnds(null); From 0107f36206b75d106bda72eb123d68583bc610dc Mon Sep 17 00:00:00 2001 From: denise Date: Wed, 22 May 2013 16:10:10 -0400 Subject: [PATCH 002/136] Changed propel to prepared statements --- airtime_mvc/application/models/Scheduler.php | 216 ++++++++++++------ .../application/services/SchedulerService.php | 137 +++++++---- 2 files changed, 237 insertions(+), 116 deletions(-) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 371fbf07e..25b01fa01 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -388,7 +388,7 @@ class Application_Model_Scheduler return $dt; } - private function findNextStartTime($DT, $instance) + private function findNextStartTime($DT, $instanceId) { $sEpoch = $DT->format("U.u"); $nEpoch = $this->epochNow; @@ -410,7 +410,7 @@ class Application_Model_Scheduler ->setDbCueIn('00:00:00') ->setDbCueOut('00:00:00') ->setDbPlayoutStatus(-1) - ->setDbInstanceId($instance->getDbId()) + ->setDbInstanceId($instanceId) ->save($this->con); } else { $nextDT = $DT; @@ -521,7 +521,12 @@ class Application_Model_Scheduler $linked = false; + $dropIndex_sql = "DROP INDEX cc_schedule_instance_id_idx"; + Application_Common_Database::prepareAndExecute( + $dropIndex_sql, array(), Application_Common_Database::EXECUTE); + foreach ($scheduleItems as $schedule) { + Logging::info($schedule); $id = intval($schedule["id"]); /* Find out if the show where the cursor position (where an item will @@ -531,12 +536,18 @@ class Application_Model_Scheduler * of inserted items */ if ($id != 0) { - $ccSchedule = CcScheduleQuery::create()->findPk($id); - $ccShowInstance = CcShowInstancesQuery::create()->findPk($ccSchedule->getDbInstanceId()); - $ccShow = $ccShowInstance->getCcShow(); - $linked = $ccShow->isLinked(); + $schedule_sql = "SELECT * FROM cc_schedule WHERE id = ".$id; + $ccSchedule = Application_Common_Database::prepareAndExecute( + $schedule_sql, array(), Application_Common_Database::SINGLE); + + $show_sql = "SELECT * FROM cc_show WHERE id IN (". + "SELECT show_id FROM cc_show_instances WHERE id = ".$ccSchedule["instance_id"].")"; + $ccShow = Application_Common_Database::prepareAndExecute( + $show_sql, array(), Application_Common_Database::SINGLE); + + $linked = $ccShow["linked"]; if ($linked) { - $unique = $ccShow->getDbId() . $ccSchedule->getDbPosition(); + $unique = $ccShow["id"] . $ccSchedule["position"]; if (!in_array($unique, $temp)) { $temp[] = $unique; } else { @@ -544,11 +555,14 @@ class Application_Model_Scheduler } } } else { - $ccShowInstance = CcShowInstancesQuery::create()->findPk($schedule["instance"]); - $ccShow = $ccShowInstance->getccShow(); - $linked = $ccShow->isLinked(); + $show_sql = "SELECT * FROM cc_show WHERE id IN (". + "SELECT show_id FROM cc_show_instances WHERE id = ".$schedule["instance"].")"; + $ccShow = Application_Common_Database::prepareAndExecute( + $show_sql, array(), Application_Common_Database::SINGLE); + + $linked = $ccShow["linked"]; if ($linked) { - $unique = $ccShow->getDbId() . "a"; + $unique = $ccShow["id"] . "a"; if (!in_array($unique, $temp)) { $temp[] = $unique; } else { @@ -562,39 +576,47 @@ class Application_Model_Scheduler * to that show */ if ($linked) { - $instances = $ccShow->getCcShowInstancess(); + $instance_sql = "SELECT * FROM cc_show_instances ". + "WHERE show_id = ".$ccShow["id"]; + $instances = Application_Common_Database::prepareAndExecute( + $instance_sql); } else { - $instances = array($ccShowInstance); + $instance_sql = "SELECT * FROM cc_show_instances ". + "WHERE id = ".$schedule["instance"]; + $instances = Application_Common_Database::prepareAndExecute( + $instance_sql); } foreach($instances as &$instance) { - $instanceId = $instance->getDbId(); + $instanceId = $instance["id"]; if ($id !== 0) { /* We use the selected cursor's position to find the same * positions in every other linked instance */ - $pos = $ccSchedule->getDbPosition(); + $pos = $ccSchedule["position"]; - $linkCcSchedule = CcScheduleQuery::create() - ->filterByDbInstanceId($instanceId) - ->filterByDbPosition($pos) - ->filterByDbPlayoutStatus(-1, Criteria::NOT_EQUAL) - ->findOne(); + $linkedItem_sql = "SELECT ends FROM cc_schedule ". + "WHERE instance_id = {$instanceId} ". + "AND position = {$pos} ". + "AND playout_status IS NOT -1"; + $linkedItemEnds = Application_Common_Database::prepareAndExecute( + $linkedItem_sql, array(), Application_Common_Database::COLUMN); - $schedItemEndDT = $linkCcSchedule->getDbEnds(null); - $nextStartDT = $this->findNextStartTime($schedItemEndDT, $instance); + $nextStartDT = $this->findNextStartTime( + new DateTime($linkedItemEnds, new DateTimeZone("UTC")), + $instanceId); $pos++; } //selected empty row to add after else { - $showStartDT = $instance->getDbStarts(null); - $nextStartDT = $this->findNextStartTime($showStartDT, $instance); + $showStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC")); + $nextStartDT = $this->findNextStartTime($showStartDT, $instanceId); //show is empty so start position counter at 0 $pos = 0; } - if (!in_array($instance->getDbId(), $affectedShowInstances)) { + if (!in_array($instanceId, $affectedShowInstances)) { $affectedShowInstances[] = $instanceId; } @@ -621,39 +643,50 @@ class Application_Model_Scheduler } } + $doInsert = false; + $doUpdate = false; + $values = array(); foreach ($filesToInsert as &$file) { //item existed previously and is being moved. //need to keep same id for resources if we want REST. if (isset($file['sched_id'])) { - $sched = CcScheduleQuery::create()->findPk($file["sched_id"]); + $doUpdate = true; + + $movedItem_sql = "SELECT * FROM cc_schedule ". + "WHERE id = ".$file["sched_id"]; + $sched = Application_Common_Database::prepareAndExecute( + $movedItem_sql, array(), Application_Common_Database::SINGLE); /* We need to keep a record of the original positon a track * is being moved from so we can use it to retrieve the correct * items in linked instances */ if (!isset($originalPosition)) { - $originalPosition = $sched->getDbPosition(); + $originalPosition = $sched["position"]; } /* If we are moving an item in a linked show we need to get * the relative item to move in each instance. We know what the * relative item is by its position */ - if ($linked && $moveAction) { - $sched = CcScheduleQuery::create() - ->filterByDbInstanceId($instanceId) - ->filterByDbPosition($originalPosition) - ->findOne(); - } - $excludeIds[] = intval($sched->getDbId()); + if ($linked) { + $movedItem_sql = "SELECT * FROM cc_schedule ". + "WHERE position = {$originalPosition} ". + "AND instance_id = {$instanceId}"; - $file["cliplength"] = $sched->getDbClipLength(); - $file["cuein"] = $sched->getDbCueIn(); - $file["cueout"] = $sched->getDbCueOut(); - $file["fadein"] = $sched->getDbFadeIn(); - $file["fadeout"] = $sched->getDbFadeOut(); + $sched = Application_Common_Database::prepareAndExecute( + $movedItem_sql, array(), Application_Common_Database::SINGLE); + } + $excludeIds[] = intval($sched["id"]); + + $file["cliplength"] = $sched["clip_length"]; + $file["cuein"] = $sched["cue_in"]; + $file["cueout"] = $sched["cue_out"]; + $file["fadein"] = $sched["fade_in"]; + $file["fadeout"] = $sched["fade_out"]; } else { - $sched = new CcSchedule(); + //$sched = new CcSchedule(); + $doInsert = true; } $endTimeDT = $this->findEndTime($nextStartDT, $file['cliplength']); @@ -662,30 +695,47 @@ class Application_Model_Scheduler $file['fadein'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadein']); $file['fadeout'] = Application_Common_DateHelper::secondsToPlaylistTime($file['fadeout']); - $sched->setDbStarts($nextStartDT) - ->setDbEnds($endTimeDT) - ->setDbCueIn($file['cuein']) - ->setDbCueOut($file['cueout']) - ->setDbFadeIn($file['fadein']) - ->setDbFadeOut($file['fadeout']) - ->setDbClipLength($file['cliplength']) - ->setDbPosition($pos); - - if (!$moveAction) { - $sched->setDbInstanceId($instanceId); - } - switch ($file["type"]) { case 0: - $sched->setDbFileId($file['id']); + $fileId = $file["id"]; + $streamId = "null"; break; case 1: - $sched->setDbStreamId($file['id']); + $streamId = $file["id"]; + $fileId = "null"; break; default: break; } - $sched->save($this->con); + if ($doInsert) { + $values[] = "(". + "'{$nextStartDT->format("Y-m-d H:i:s")}', ". + "'{$endTimeDT->format("Y-m-d H:i:s")}', ". + "'{$file["cuein"]}', ". + "'{$file["cueout"]}', ". + "'{$file["fadein"]}', ". + "'{$file["fadeout"]}', ". + "'{$file["cliplength"]}', ". + "{$pos}, ". + "{$instanceId}, ". + "{$fileId}, ". + "{$streamId})"; + + } elseif ($doUpdate) { + $update_sql = "UPDATE cc_schedule SET ". + "starts = '{$nextStartDT->format("Y-m-d H:i:s")}', ". + "ends = '{$endTimeDT->format("Y-m-d H:i:s")}', ". + "cue_in = '{$file["cuein"]}', ". + "cue_out = '{$file["cueout"]}', ". + "fade_in = '{$file["fadein"]}', ". + "fade_out = '{$file["fadeout"]}', ". + "clip_length = '{$file["cliplength"]}', ". + "position = {$pos} ". + "WHERE id = {$sched["id"]}"; + + Application_Common_Database::prepareAndExecute( + $update_sql, array(), Application_Common_Database::EXECUTE); + } $nextStartDT = $endTimeDT; $pos++; @@ -694,9 +744,18 @@ class Application_Model_Scheduler * after the insert location, we need to exclude the * schedule item we just inserted because it has correct * start and end times*/ - $excludeIds[] = $sched->getDbId(); + //$excludeIds[] = $lastInsertId; }//all files have been inserted/moved + if ($doInsert) { + $insert_sql = "INSERT INTO cc_schedule ". + "(starts, ends, cue_in, cue_out, fade_in, fade_out, ". + "clip_length, position, instance_id, file_id, stream_id) VALUES ". + implode($values, ","); + + Application_Common_Database::prepareAndExecute( + $insert_sql, array(), Application_Common_Database::EXECUTE); + } // update is_scheduled flag for each cc_file $fileIds = array(); @@ -718,22 +777,30 @@ class Application_Model_Scheduler } if ($adjustSched === true) { - $followingSchedItems = CcScheduleQuery::create() - ->filterByDBStarts($initalStartDT->format("Y-m-d H:i:s.u"), Criteria::GREATER_EQUAL) - ->filterByDbInstanceId($instance->getDbId()) - ->filterByDbId($excludeIds, Criteria::NOT_IN) - ->orderByDbStarts() - ->find($this->con); + $followingItems_sql = "SELECT * FROM cc_schedule ". + "WHERE starts >= '{$initalStartDT->format("Y-m-d H:i:s.u")}' ". + "AND instance_id = {$instanceId} "; + if (count($excludeIds) > 0) { + $followingItems_sql .= "AND id NOT IN (". implode($excludeIds, ",").") "; + } + $followingItems_sql .= "ORDER BY starts"; + + $followingSchedItems = Application_Common_Database::prepareAndExecute( + $followingItems_sql); $pstart = microtime(true); //recalculate the start/end times after the inserted items. foreach ($followingSchedItems as $item) { - $endTimeDT = $this->findEndTime($nextStartDT, $item->getDbClipLength()); - $item->setDbStarts($nextStartDT); - $item->setDbEnds($endTimeDT); - $item->setDbPosition($pos); - $item->save($this->con); + $endTimeDT = $this->findEndTime($nextStartDT, $item["clip_length"]); + $update_sql = "UPDATE cc_schedule SET ". + "starts = '{$nextStartDT->format("Y-m-d H:i:s")}', ". + "ends = '{$endTimeDT->format("Y-m-d H:i:s")}', ". + "position = {$pos} ". + "WHERE id = {$item["id"]}"; + Application_Common_Database::prepareAndExecute( + $update_sql, array(), Application_Common_Database::EXECUTE); + $nextStartDT = $endTimeDT; $pos++; } @@ -742,12 +809,16 @@ class Application_Model_Scheduler Logging::debug("adjusting all following items."); Logging::debug(floatval($pend) - floatval($pstart)); - $this->calculateCrossfades($instance->getDbId()); + $this->calculateCrossfades($instanceId); } }//for each instance - }//for each schedule location + $createIndex_sql = "CREATE INDEX cc_schedule_instance_id_idx ". + "ON cc_schedule USING btree(instance_id)"; + Application_Common_Database::prepareAndExecute( + $createIndex_sql, array(), Application_Common_Database::EXECUTE); + $endProfile = microtime(true); Logging::debug("finished adding scheduled items."); Logging::debug(floatval($endProfile) - floatval($startProfile)); @@ -783,6 +854,11 @@ class Application_Model_Scheduler } } + private function updateMovedItem() + { + + } + private function getInstances($instanceId) { $ccShowInstance = CcShowInstancesQuery::create()->findPk($instanceId); diff --git a/airtime_mvc/application/services/SchedulerService.php b/airtime_mvc/application/services/SchedulerService.php index 7cfac160d..1d9c5e244 100644 --- a/airtime_mvc/application/services/SchedulerService.php +++ b/airtime_mvc/application/services/SchedulerService.php @@ -155,64 +155,105 @@ class Application_Service_SchedulerService * any other instances with content */ $instanceIds = $ccShow->getInstanceIds(); - $ccSchedules = CcScheduleQuery::create() - ->filterByDbInstanceId($instanceIds, Criteria::IN) - ->find(); - if (!$ccSchedules->isEmpty()) { + $schedule_sql = "SELECT * FROM cc_schedule ". + "WHERE instance_id IN (".implode($instanceIds, ",").")"; + $ccSchedules = Application_Common_Database::prepareAndExecute( + $schedule_sql); + + if (count($ccSchedules) > 0) { /* Find the show contents of just one of the instances. It doesn't * matter which instance we use since all the content is the same */ - $ccSchedule = $ccSchedules->getFirst(); - $showStamp = CcScheduleQuery::create() - ->filterByDbInstanceId($ccSchedule->getDbInstanceId()) - ->orderByDbStarts() - ->find(); + $ccSchedule = $ccSchedules[0]; + $showStamp_sql = "SELECT * FROM cc_schedule ". + "WHERE instance_id = {$ccSchedule["instance_id"]} ". + "ORDER BY starts"; + $showStamp = Application_Common_Database::prepareAndExecute( + $showStamp_sql); //get time_filled so we can update cc_show_instances - $timeFilled = $ccSchedule->getCcShowInstances()->getDbTimeFilled(); + $timeFilled_sql = "SELECT time_filled FROM cc_show_instances ". + "WHERE id = {$ccSchedule["instance_id"]}"; + $timeFilled = Application_Common_Database::prepareAndExecute( + $timeFilled_sql, array(), Application_Common_Database::COLUMN); + + $dropIndex_sql = "DROP INDEX cc_schedule_instance_id_idx"; + Application_Common_Database::prepareAndExecute( + $dropIndex_sql, array(), Application_Common_Database::EXECUTE); //need to find out which linked instances are empty - foreach ($ccShow->getCcShowInstancess() as $ccShowInstance) { - $ccSchedules = CcScheduleQuery::create() - ->filterByDbInstanceId($ccShowInstance->getDbId()) - ->find(); + $values = array(); + foreach ($instanceIds as $id) { + $instanceSched_sql = "SELECT * FROM cc_schedule ". + "WHERE instance_id = {$id} ". + "ORDER by starts"; + $ccSchedules = Application_Common_Database::prepareAndExecute( + $instanceSched_sql); + /* If the show instance is empty OR it has different content than - * the first instance, we cant to fill/replace with the show stamp + * the first instance, we need to fill/replace with the show stamp * (The show stamp is taken from the first show instance's content) */ - if ($ccSchedules->isEmpty() || - self::replaceInstanceContentCheck($ccShowInstance, $showStamp)) { + if (count($ccSchedules) < 1 || + self::replaceInstanceContentCheck($ccSchedules, $showStamp)) { - $nextStartDT = $ccShowInstance->getDbStarts(null); + //$nextStartDT = $ccShowInstance->getDbStarts(null); + $instanceStart_sql = "SELECT starts FROM cc_show_instances ". + "WHERE id = {$id}"; + $nextStartDT = new DateTime( + Application_Common_Database::prepareAndExecute( + $instanceStart_sql, array(), Application_Common_Database::EXECUTE), + new DateTimeZone("UTC")); foreach ($showStamp as $item) { - $endTimeDT = self::findEndTime($nextStartDT, $item->getDbClipLength()); + $endTimeDT = self::findEndTime($nextStartDT, $item["clip_length"]); - $ccSchedule = new CcSchedule(); - $ccSchedule - ->setDbStarts($nextStartDT) - ->setDbEnds($endTimeDT) - ->setDbFileId($item->getDbFileId()) - ->setDbStreamId($item->getDbStreamId()) - ->setDbClipLength($item->getDbClipLength()) - ->setDbFadeIn($item->getDbFadeIn()) - ->setDbFadeOut($item->getDbFadeOut()) - ->setDbCuein($item->getDbCueIn()) - ->setDbCueOut($item->getDbCueOut()) - ->setDbInstanceId($ccShowInstance->getDbId()) - ->setDbPosition($item->getDbPosition()) - ->save(); + if (is_null($item["file_id"])) { + $item["file_id"] = "null"; + } elseif (is_null($item["stream_id"])) { + $item["stream_id"] = "null"; + } + + $values[] = "(". + "'{$nextStartDT->format("Y-m-d H:i:s")}', ". + "'{$endTimeDT->format("Y-m-d H:i:s")}', ". + "'{$item["clip_length"]}', ". + "'{$item["fade_in"]}', ". + "'{$item["fade_out"]}', ". + "'{$item["cue_in"]}', ". + "'{$item["cue_out"]}', ". + "{$item["file_id"]}, ". + "{$item["stream_id"]}, ". + "{$id}, ". + "{$item["position"]})"; $nextStartDT = $endTimeDT; } //foreach show item - - //update time_filled in cc_show_instances - $ccShowInstance - ->setDbTimeFilled($timeFilled) - ->setDbLastScheduled(gmdate("Y-m-d H:i:s")) - ->save(); } } //foreach linked instance + + $insert_sql = "INSERT INTO cc_schedule (starts, ends, ". + "clip_length, fade_in, fade_out, cue_in, cue_out, ". + "file_id, stream_id, instance_id, position) VALUES ". + implode($values, ","); + + Application_Common_Database::prepareAndExecute( + $insert_sql, array(), Application_Common_Database::EXECUTE); + + $createIndex_sql = "CREATE INDEX cc_schedule_instance_id_idx ". + "ON cc_schedule USING btree(instance_id)"; + Application_Common_Database::prepareAndExecute( + $createIndex_sql, array(), Application_Common_Database::EXECUTE); + + //update time_filled in cc_show_instances + $now = gmdate("Y-m-d H:i:s"); + $update_sql = "UPDATE cc_show_instances SET ". + "time_filled = '{$timeFilled}', ". + "last_scheduled = '{$now}' ". + "WHERE show_id = {$ccShow->getDbId()}"; + Application_Common_Database::prepareAndExecute( + $update_sql, array(), Application_Common_Database::EXECUTE); + } //if at least one linked instance has content } @@ -259,20 +300,24 @@ class Application_Service_SchedulerService } } - private static function replaceInstanceContentCheck($ccShowInstance, $showStamp) + private static function replaceInstanceContentCheck($currentShowStamp, $showStamp) { - $currentShowStamp = CcScheduleQuery::create() + /*$currentShowStamp = CcScheduleQuery::create() ->filterByDbInstanceId($ccShowInstance->getDbId()) ->orderByDbStarts() - ->find(); + ->find();*/ $counter = 0; foreach ($showStamp as $item) { - if ($item->getDbFileId() != $currentShowStamp[$counter]->getDbFileId() || - $item->getDbStreamId() != $currentShowStamp[$counter]->getDbStreamId()) { - CcScheduleQuery::create() + if ($item["file_id"] != $currentShowStamp[$counter]["file_id"] || + $item["stream_id"] != $currentShowStamp[$counter]["stream_id"]) { + /*CcScheduleQuery::create() ->filterByDbInstanceId($ccShowInstance->getDbId()) - ->delete(); + ->delete();*/ + $delete_sql = "DELETE FROM cc_schedule ". + "WHERE instance_id = {$currentShowStamp[$counter]["instance_id"]}"; + Application_Common_Database::prepareAndExecute( + $delete_sql, array(), Application_Common_Database::EXECUTE); return true; } } From 02292569f9118ef82e25482b2046369384769db7 Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 22 May 2013 17:52:02 -0400 Subject: [PATCH 003/136] CC-5172 : errors from setting cues in waveform editor not handled properly Conflicts: airtime_mvc/application/models/Playlist.php --- airtime_mvc/application/models/Playlist.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index aa74c78c4..b4e48d1bd 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -10,6 +10,10 @@ require_once 'formatters/LengthFormatter.php'; */ class Application_Model_Playlist implements Application_Model_LibraryEditable { + const CUE_ALL_ERROR = 0; + const CUE_IN_ERROR = 1; + const CUE_OUT_ERROR = 2; + /** * propel connection object. */ From c57de650e8a1a53a6399ae9ffba145b6ce4e3ba4 Mon Sep 17 00:00:00 2001 From: Naomi Date: Wed, 22 May 2013 17:50:34 -0400 Subject: [PATCH 004/136] CC-5172 : errors from setting cues in waveform editor not handled properly Conflicts: airtime_mvc/application/models/Playlist.php --- .../controllers/PlaylistController.php | 1 + airtime_mvc/application/models/Playlist.php | 6 +++++ airtime_mvc/public/js/airtime/library/spl.js | 25 +++++++++++++++++-- 3 files changed, 30 insertions(+), 2 deletions(-) diff --git a/airtime_mvc/application/controllers/PlaylistController.php b/airtime_mvc/application/controllers/PlaylistController.php index 2b48b40b7..1826bde3b 100644 --- a/airtime_mvc/application/controllers/PlaylistController.php +++ b/airtime_mvc/application/controllers/PlaylistController.php @@ -383,6 +383,7 @@ class PlaylistController extends Zend_Controller_Action $this->createUpdateResponse($obj); } else { $this->view->cue_error = $response["error"]; + $this->view->code = $response["type"]; } } catch (PlaylistOutDatedException $e) { $this->playlistOutdated($e); diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index b4e48d1bd..74b1b62c7 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -796,6 +796,7 @@ SQL; try { if (is_null($cueIn) && is_null($cueOut)) { $errArray["error"] = _("Cue in and cue out are null."); + $errArray["type"] = self::CUE_ALL_ERROR; return $errArray; } @@ -826,6 +827,7 @@ SQL; $sql = "SELECT :cueIn::INTERVAL > :cueOut::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':cueOut'=>$cueOut), 'column')) { $errArray["error"] = _("Can't set cue in to be larger than cue out."); + $errArray["type"] = self::CUE_IN_ERROR; return $errArray; } @@ -833,6 +835,7 @@ SQL; $sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) { $errArray["error"] = _("Can't set cue out to be greater than file length."); + $errArray["type"] = self::CUE_OUT_ERROR; return $errArray; } @@ -849,6 +852,7 @@ SQL; $sql = "SELECT :cueIn::INTERVAL > :oldCueOut::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueIn'=>$cueIn, ':oldCueOut'=>$oldCueOut), 'column')) { $errArray["error"] = _("Can't set cue in to be larger than cue out."); + $errArray["type"] = self::CUE_IN_ERROR; return $errArray; } @@ -867,6 +871,7 @@ SQL; $sql = "SELECT :cueOut::INTERVAL < :oldCueIn::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':oldCueIn'=>$oldCueIn), 'column')) { $errArray["error"] = _("Can't set cue out to be smaller than cue in."); + $errArray["type"] = self::CUE_OUT_ERROR; return $errArray; } @@ -874,6 +879,7 @@ SQL; $sql = "SELECT :cueOut::INTERVAL > :origLength::INTERVAL"; if (Application_Common_Database::prepareAndExecute($sql, array(':cueOut'=>$cueOut, ':origLength'=>$origLength), 'column')) { $errArray["error"] = _("Can't set cue out to be greater than file length."); + $errArray["type"] = self::CUE_OUT_ERROR; return $errArray; } diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index a50684131..00f899f9c 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -144,7 +144,8 @@ var AIRTIME = (function(AIRTIME){ var url = baseUrl+"Playlist/set-cue", lastMod = getModified(), type = $('#obj_type').val(), - li; + li, + span; if (!isTimeValid(cueIn)){ $el.find('.cue-in-error').val($.i18n._("please put in a time '00:00:00 (.0)'")).show(); @@ -174,7 +175,27 @@ var AIRTIME = (function(AIRTIME){ return; } if (json.cue_error !== undefined) { - showError(span, json.cue_error); + + li = $('#side_playlist li[unqid='+id+']'); + + if (json.code === 0) { + + span = $('#spl_cue_in_'+id).find('span'); + showError(span, json.cue_error); + span = $('#spl_cue_out_'+id).find('span'); + showError(span, json.cue_error); + } + else if (json.code === 1) { + + span = $('#spl_cue_in_'+id).find('span'); + showError(span, json.cue_error); + } + else if (json.code === 2) { + + span = $('#spl_cue_out_'+id).find('span'); + showError(span, json.cue_error); + } + return; } From 2a897414a4ec39dcd071be8db4d04dc2d07dd017 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Wed, 22 May 2013 18:07:12 -0400 Subject: [PATCH 005/136] make operators more local to each queue source Conflicts: python_apps/pypo/liquidsoap_scripts/ls_script.liq --- python_apps/pypo/liquidsoap_scripts/ls_script.liq | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/python_apps/pypo/liquidsoap_scripts/ls_script.liq b/python_apps/pypo/liquidsoap_scripts/ls_script.liq index 97dc544c5..c2b898f3a 100644 --- a/python_apps/pypo/liquidsoap_scripts/ls_script.liq +++ b/python_apps/pypo/liquidsoap_scripts/ls_script.liq @@ -40,6 +40,14 @@ source_id = ref 0 def create_source() l = request.equeue(id="s#{!source_id}", length=0.5) l = cue_cut(l) + + l = audio_to_stereo(id="queue_src", l) + l = amplify(1., override="replay_gain", l) + + # the crossfade function controls fade in/out + l = crossfade_airtime(l) + + l = on_metadata(notify, l) sources := list.append([l], !sources) server.register(namespace="queues", "s#{!source_id}_skip", @@ -62,12 +70,6 @@ create_source() queue = add(!sources, normalize=false) -queue = audio_to_stereo(id="queue_src", queue) -queue = amplify(1., override="replay_gain", queue) - -# the crossfade function controls fade in/out -queue = crossfade_airtime(queue) -queue = on_metadata(notify, queue) output.dummy(fallible=true, queue) http = input.http_restart(id="http") From e104146b9ad5ba5a8d93d369522ec47dfff919ce Mon Sep 17 00:00:00 2001 From: denise Date: Thu, 23 May 2013 16:10:00 -0400 Subject: [PATCH 007/136] CC-5138: Linked Show: Time limitation exceeds when adding 24 hours smart block into daily repeating & linked shows Removed propel from calculateCrossfades function and used prepared statements instead --- airtime_mvc/application/models/Scheduler.php | 56 +++++++++++--------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/airtime_mvc/application/models/Scheduler.php b/airtime_mvc/application/models/Scheduler.php index 25b01fa01..efaa8e682 100644 --- a/airtime_mvc/application/models/Scheduler.php +++ b/airtime_mvc/application/models/Scheduler.php @@ -424,33 +424,39 @@ class Application_Model_Scheduler * This function recalculates the start/end times of items in a gapless show to * account for crossfade durations. */ - private function calculateCrossfades($showInstance) + private function calculateCrossfades($instanceId) { - Logging::info("adjusting start, end times of scheduled items to account for crossfades show instance #".$showInstance); - - $instance = CcShowInstancesQuery::create()->findPK($showInstance, $this->con); - if (is_null($instance)) { - throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!")); - } - - $itemStartDT = $instance->getDbStarts(null); - $itemEndDT = null; - - $schedule = CcScheduleQuery::create() - ->filterByDbInstanceId($showInstance) - ->orderByDbStarts() - ->find($this->con); - - foreach ($schedule as $item) { - $itemEndDT = $this->findEndTime($itemStartDT, $item->getDbClipLength()); + Logging::info("adjusting start, end times of scheduled items to account for crossfades show instance #".$instanceId); - $item->setDbStarts($itemStartDT) - ->setDbEnds($itemEndDT); + $sql = "SELECT * FROM cc_show_instances ". + "WHERE id = {$instanceId}"; + $instance = Application_Common_Database::prepareAndExecute( + $sql, array(), Application_Common_Database::SINGLE); - $itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration); - } - - $schedule->save($this->con); + if (is_null($instance)) { + throw new OutDatedScheduleException(_("The schedule you're viewing is out of date!")); + } + + $itemStartDT = new DateTime($instance["starts"], new DateTimeZone("UTC")); + $itemEndDT = null; + + $schedule_sql = "SELECT * FROM cc_schedule ". + "WHERE instance_id = {$instanceId} ". + "ORDER BY starts"; + $schedule = Application_Common_Database::prepareAndExecute($schedule_sql); + + foreach ($schedule as $item) { + $itemEndDT = $this->findEndTime($itemStartDT, $item["clip_length"]); + + $update_sql = "UPDATE cc_schedule SET ". + "starts = '{$itemStartDT->format("Y-m-d H:i:s")}', ". + "ends = '{$itemEndDT->format("Y-m-d H:i:s")}' ". + "WHERE id = {$item["id"]}"; + Application_Common_Database::prepareAndExecute( + $update_sql, array(), Application_Common_Database::EXECUTE); + + $itemStartDT = $this->findTimeDifference($itemEndDT, $this->crossfadeDuration); + } } /* @@ -526,7 +532,6 @@ class Application_Model_Scheduler $dropIndex_sql, array(), Application_Common_Database::EXECUTE); foreach ($scheduleItems as $schedule) { - Logging::info($schedule); $id = intval($schedule["id"]); /* Find out if the show where the cursor position (where an item will @@ -737,6 +742,7 @@ class Application_Model_Scheduler $update_sql, array(), Application_Common_Database::EXECUTE); } + //$nextStartDT = $this->findTimeDifference($endTimeDT, $this->crossfadeDuration); $nextStartDT = $endTimeDT; $pos++; From ca37ec3affde33412838eef9865c90003ce69950 Mon Sep 17 00:00:00 2001 From: Martin Konecny Date: Thu, 23 May 2013 17:17:00 -0400 Subject: [PATCH 008/136] CC-5049: Error messages on Liquidsoap start up/shut down after Airtime install Suppress global warning messages. Clients should decide whether to print or not. --- python_apps/api_clients/api_client.py | 8 ++++---- .../liquidsoap_scripts/generate_liquidsoap_cfg.py | 11 +++++++---- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/python_apps/api_clients/api_client.py b/python_apps/api_clients/api_client.py index be3cc53b5..16348c156 100644 --- a/python_apps/api_clients/api_client.py +++ b/python_apps/api_clients/api_client.py @@ -138,8 +138,8 @@ class ApiRequest(object): content_type = f.info().getheader('Content-Type') response = f.read() except Exception, e: - self.logger.error('Exception: %s', e) - self.logger.error("traceback: %s", traceback.format_exc()) + #self.logger.error('Exception: %s', e) + #self.logger.error("traceback: %s", traceback.format_exc()) raise try: @@ -149,8 +149,8 @@ class ApiRequest(object): else: raise InvalidContentType() except Exception: - self.logger.error(response) - self.logger.error("traceback: %s", traceback.format_exc()) + #self.logger.error(response) + #self.logger.error("traceback: %s", traceback.format_exc()) raise def req(self, *args, **kwargs): diff --git a/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py b/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py index 6144058e0..e0160181b 100644 --- a/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py +++ b/python_apps/pypo/liquidsoap_scripts/generate_liquidsoap_cfg.py @@ -1,6 +1,7 @@ import logging import sys import time +import traceback from api_clients.api_client import AirtimeApiClient def generate_liquidsoap_config(ss): @@ -26,19 +27,21 @@ def generate_liquidsoap_config(ss): fh.close() logging.basicConfig(format='%(message)s') -ac = AirtimeApiClient(logging.getLogger()) attempts = 0 -max_attempts = 5 +max_attempts = 10 +successful = False -while True: +while not successful: try: + ac = AirtimeApiClient(logging.getLogger()) ss = ac.get_stream_setting() generate_liquidsoap_config(ss) - break + successful = True except Exception, e: if attempts == max_attempts: print "Unable to connect to the Airtime server." logging.error(str(e)) + logging.error("traceback: %s", traceback.format_exc()) sys.exit(1) else: time.sleep(3) From 75e6f21ce06cd3a3c890d722ce9c69f1df82f877 Mon Sep 17 00:00:00 2001 From: Naomi Date: Thu, 23 May 2013 18:33:40 -0400 Subject: [PATCH 009/136] CC-5108 : Waveform Editor UI putting on the timescale for time reference. fade editor now has cursor playback info. --- .../application/layouts/scripts/layout.phtml | 3 ++ airtime_mvc/application/models/Block.php | 4 ++ airtime_mvc/application/models/Playlist.php | 4 ++ airtime_mvc/application/models/StoredFile.php | 2 - airtime_mvc/public/css/waveform.css | 39 +++++++++++++++++-- airtime_mvc/public/js/airtime/library/spl.js | 18 +++++++-- .../public/js/waveformplaylist/playlist.js | 32 ++++++++++++++- .../public/js/waveformplaylist/playout.js | 3 +- .../public/js/waveformplaylist/time_scale.js | 21 +++++++++- .../public/js/waveformplaylist/track.js | 29 +++++++++++++- 10 files changed, 141 insertions(+), 14 deletions(-) diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml index f7c029ba5..fc46df5c4 100644 --- a/airtime_mvc/application/layouts/scripts/layout.phtml +++ b/airtime_mvc/application/layouts/scripts/layout.phtml @@ -36,6 +36,7 @@