// // tank // // Import and Playlist Daemon for autoradio project // // // Copyright (C) 2017-2018 Christian Pointner <equinox@helsinki.at> // // This file is part of tank. // // tank is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // any later version. // // tank is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with tank. If not, see <http://www.gnu.org/licenses/>. // package importer import ( "time" ) const ( DEBUG_NORMALIZE_TIME = 150 ) func (job *Job) normalize() error { job.Progress.set(StepNormalizing, 0) // TODO: actually normalize the file t := time.NewTicker(100 * time.Millisecond) defer t.Stop() cnt := 0 normalizeLoop: for { select { case <-job.ctx.Done(): return job.ctx.Err() case <-t.C: cnt++ if cnt > DEBUG_NORMALIZE_TIME { break normalizeLoop } job.Progress.set(StepNormalizing, float32(cnt)/DEBUG_NORMALIZE_TIME) } } job.Progress.set(StepNormalizing, 1) return nil }