try fixed crash on sample optimize

This commit is contained in:
Igor Korsukov 2020-03-19 13:37:36 +02:00
parent c0accef5c1
commit 5aea0ab5b5
3 changed files with 56 additions and 0 deletions

View file

@ -37,6 +37,10 @@ else (NOT MSVC)
set(_all_h_file "${PROJECT_SOURCE_DIR}/all.h")
endif (NOT MSVC)
include_directories (
${PROJECT_SOURCE_DIR}/global
)
add_library (fluid STATIC
${_all_h_file}
${PCH}

View file

@ -18,6 +18,8 @@
* 02111-1307, USA
*/
#include "log.h"
#include "conv.h"
#include "fluid.h"
#include "sfont.h"
@ -1810,6 +1812,14 @@ void Sample::optimize()
if (!s->valid())
return;
IF_ASSERT(s->loopstart >= s->start) {
s->loopstart = s->start;
}
IF_ASSERT(s->loopend <= s->end) {
s->loopend = s->end;
}
if (!s->amplitude_that_reaches_noise_floor_is_valid) { /* Only once */
/* Scan the loop */
for (size_t i = s->loopstart; i < s->loopend; i++) {

42
global/log.h Normal file
View file

@ -0,0 +1,42 @@
//=============================================================================
// MuseScore
// Music Composition & Notation
//
// Copyright (C) 2020 MuseScore BVBA and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
//=============================================================================
#ifndef MS_LOG_H
#define MS_LOG_H
#include <QDebug>
#define LOGD() qDebug()
#define LOGI() qInfo()
#define LOGW() qWarning()
#define LOGE() qCritical()
#define IF_ASSERT(cond) if (!(cond)) { \
LOGE() << "\"ASSERT FAILED!\":" << #cond << __FILE__ << __LINE__; \
Q_ASSERT(cond); \
} \
if (!(cond)) \
#define IF_FAILED(cond) if (!(cond)) { \
LOGE() << "\"FAILED!\":" << #cond << __FILE__ << __LINE__; \
} \
if (!(cond)) \
#endif // MS_LOG_H