Compare commits

..
Author SHA1 Message Date
Torsten Dreyer 6d89cc6c1d new version: 2018.4.0 2018-09-21 17:18:46 +02:00
43 changed files with 144 additions and 670 deletions
+12 -22
View File
@@ -10,15 +10,6 @@ if(COMMAND cmake_policy)
if(POLICY CMP0067)
cmake_policy(SET CMP0067 NEW)
endif()
# OpenGL VND policy : use the old definition for now, until we can audit this
if(POLICY CMP0072)
cmake_policy(SET CMP0072 OLD)
endif()
if(POLICY CMP0093)
cmake_policy(SET CMP0093 NEW)
endif()
endif()
@@ -41,7 +32,6 @@ include (GenerateExportHeader)
# only relevant for building shared libs but let's set it regardless
set(CMAKE_OSX_RPATH 1)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
# let's use & require C++11 - note these are only functional with CMake 3.1
# we do manual fallbacks for CMake 3.0 in the compilers section
@@ -54,7 +44,12 @@ string(STRIP ${versionFile} SIMGEAR_VERSION)
project(SimGear VERSION ${SIMGEAR_VERSION} LANGUAGES C CXX)
# add a dependency on the version file
# using 10.7 because boost requires libc++ and 10.6 doesn't include it
# Cmake documentation says we must set this before calling project(), but
# it only seems to be picked up setting it /after/ the call to project()
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.7")
# add a dependency on the versino file
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS version)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
@@ -134,14 +129,9 @@ option(ENABLE_SOUND "Set to OFF to disable building SimGear's sound support"
option(USE_AEONWAVE "Set to ON to use AeonWave instead of OpenAL" ON)
option(ENABLE_PKGUTIL "Set to ON to build the sg_pkgutil application (default)" ON)
option(ENABLE_DNS "Set to ON to use udns library and DNS service resolver" ON)
option(ENABLE_SIMD "Enable SSE/SSE2 support for compilers" ON)
option(ENABLE_SIMD_CODE "Enable SSE/SSE2 support code for compilers" OFF)
option(ENABLE_SIMD "Enable SSE/SSE2 support for x86 compilers" ON)
option(ENABLE_OPENMP "Enable OpenMP compiler support" OFF)
if (NOT ENABLE_SIMD AND ENABLE_SIMD_CODE)
set(ENABLE_SIMD_CODE OFF)
endif()
include (DetectArch)
# until the fstream fix is applied and generally available in OSG,
@@ -225,7 +215,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux" OR ${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD
endif()
find_package(Boost REQUIRED)
set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION -DBOOST_NO_STDLIB_CONFIG")
set (BOOST_CXX_FLAGS "-DBOOST_BIMAP_DISABLE_SERIALIZATION")
include(BoostTestTargets)
if(SIMGEAR_HEADLESS)
@@ -426,8 +416,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
"${CMAKE_CXX_FLAGS} -O0 -fno-omit-frame-pointer -fno-inline")
elseif (ENABLE_SIMD)
if (X86 OR X86_64)
set(CMAKE_C_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse -ftree-vectorize -ftree-slp-vectorize")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse -ftree-vectorize -ftree-slp-vectorize")
set(CMAKE_C_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse")
endif()
endif()
@@ -454,8 +444,8 @@ if (CLANG)
"${CMAKE_CXX_FLAGS} -O0 -fno-omit-frame-pointer -fno-inline-functions")
elseif (ENABLE_SIMD)
if (X86 OR X86_64)
set(CMAKE_C_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse -ftree-vectorize -ftree-slp-vectorize")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse -ftree-vectorize -ftree-slp-vectorize")
set(CMAKE_C_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse")
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -msse2 -mfpmath=sse")
endif()
endif()
endif()
+5 -11
View File
@@ -46,17 +46,11 @@ set(BOOST_TEST_TARGET_PREFIX "test")
if(NOT Boost_FOUND)
find_package(Boost 1.34.0 QUIET)
endif()
if (NOT Boost_VERSION_MACRO)
# Compatibility with pre CMP0093 (CMake 3.15)
set(Boost_VERSION_MACRO ${Boost_VERSION})
endif()
if("${Boost_VERSION_MACRO}0" LESS "1034000")
if("${Boost_VERSION}0" LESS "1034000")
set(_shared_msg
"NOTE: boost::test-based targets and tests cannot "
"be added: boost >= 1.34.0 required but not found. "
"(found: '${Boost_VERSION_MACRO}'; want >=103400) ")
"(found: '${Boost_VERSION}'; want >=103400) ")
if(ENABLE_TESTS)
message(FATAL_ERROR
${_shared_msg}
@@ -72,7 +66,7 @@ endif()
include(GetForceIncludeDefinitions)
include(CopyResourcesToBuildTree)
if(Boost_FOUND AND NOT "${Boost_VERSION_MACRO}0" LESS "1034000")
if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000")
set(_boosttesttargets_libs)
set(_boostConfig "BoostTestTargetsIncluded.h")
if(NOT Boost_UNIT_TEST_FRAMEWORK_LIBRARY)
@@ -135,7 +129,7 @@ function(add_boost_test _name)
"Syntax error in use of add_boost_test: at least one source file required!")
endif()
if(Boost_FOUND AND NOT "${Boost_VERSION_MACRO}0" LESS "1034000")
if(Boost_FOUND AND NOT "${Boost_VERSION}0" LESS "1034000")
include_directories(${Boost_INCLUDE_DIRS})
@@ -227,7 +221,7 @@ function(add_boost_test _name)
set(_test_command ${_target_name})
endif()
if(TESTS AND ( "${Boost_VERSION_MACRO}" VERSION_GREATER "103799" ))
if(TESTS AND ( "${Boost_VERSION}" VERSION_GREATER "103799" ))
foreach(_test ${TESTS})
add_test(
${_name}-${_test}
-23
View File
@@ -107,8 +107,6 @@ public:
unsigned int bytesTransferred;
unsigned int lastTransferRate;
uint64_t totalBytesDownloaded;
SGPath tlsCertificatePath;
};
Client::Client() :
@@ -124,8 +122,6 @@ Client::Client() :
d->maxPipelineDepth = 5;
setUserAgent("SimGear-" SG_STRINGIZE(SIMGEAR_VERSION));
d->tlsCertificatePath = SGPath::fromEnv("SIMGEAR_TLS_CERT_PATH");
static bool didInitCurlGlobal = false;
if (!didInitCurlGlobal) {
curl_global_init(CURL_GLOBAL_ALL);
@@ -279,11 +275,6 @@ void Client::makeRequest(const Request_ptr& r)
curl_easy_setopt(curlRequest, CURLOPT_FOLLOWLOCATION, 1);
if (!d->tlsCertificatePath.isNull()) {
const auto utf8 = d->tlsCertificatePath.utf8Str();
curl_easy_setopt(curlRequest, CURLOPT_CAINFO, utf8.c_str());
}
if (!d->proxy.empty()) {
curl_easy_setopt(curlRequest, CURLOPT_PROXY, d->proxy.c_str());
curl_easy_setopt(curlRequest, CURLOPT_PROXYPORT, d->proxyPort);
@@ -481,26 +472,12 @@ size_t Client::requestReadCallback(char *ptr, size_t size, size_t nmemb, void *u
return actualBytes;
}
bool isRedirectStatus(int code)
{
return ((code >= 300) && (code < 400));
}
size_t Client::requestHeaderCallback(char *rawBuffer, size_t size, size_t nitems, void *userdata)
{
size_t byteSize = size * nitems;
Request* req = static_cast<Request*>(userdata);
std::string h = strutils::simplify(std::string(rawBuffer, byteSize));
if (req->readyState() >= HTTP::Request::HEADERS_RECEIVED) {
// this can happen with chunked transfers (secondary chunks)
// or redirects
if (isRedirectStatus(req->responseCode())) {
req->responseStart(h);
return byteSize;
}
}
if (req->readyState() == HTTP::Request::OPENED) {
req->responseStart(h);
return byteSize;
+3
View File
@@ -1049,6 +1049,9 @@ HTTPRepository::failure() const
entry.lengthBytes = strtol(sizeData.c_str(), NULL, 10);
hashes.push_back(entry);
}
SG_LOG(SG_TERRASYNC, SG_INFO, "restored hashes:" << hashes.size());
}
class DirectoryWithPath
-10
View File
@@ -328,16 +328,6 @@ unsigned int Request::responseLength() const
return _responseLength;
}
//------------------------------------------------------------------------------
void Request::setSuccess(int code)
{
_responseStatus = code;
_responseReason.clear();
if( !isComplete() ) {
setReadyState(DONE);
}
}
//------------------------------------------------------------------------------
void Request::setFailure(int code, const std::string& reason)
{
+1 -1
View File
@@ -224,7 +224,7 @@ protected:
virtual void onAlways();
void setFailure(int code, const std::string& reason);
void setSuccess(int code);
private:
friend class Client;
friend class Connection;
+1 -35
View File
@@ -273,23 +273,7 @@ public:
d << "\r\n"; // final CRLF to terminate the headers
d << contentStr;
push(d.str().c_str());
} else if (path == "/test_redirect") {
string contentStr("<html>See <a href=\"wibble\">Here</a></html>");
stringstream d;
d << "HTTP/1.1 " << 302 << " " << "Found" << "\r\n";
d << "Location:" << " http://localhost:2000/was_redirected" << "\r\n";
d << "Content-Length:" << contentStr.size() << "\r\n";
d << "\r\n"; // final CRLF to terminate the headers
d << contentStr;
push(d.str().c_str());
} else if (path == "/was_redirected") {
string contentStr(BODY1);
stringstream d;
d << "HTTP/1.1 " << 200 << " " << reasonForCode(200) << "\r\n";
d << "Content-Length:" << contentStr.size() << "\r\n";
d << "\r\n"; // final CRLF to terminate the headers
d << contentStr;
push(d.str().c_str());
} else {
TestServerChannel::processRequestHeaders();
}
@@ -789,24 +773,6 @@ cout << "testing proxy close" << endl;
SG_CHECK_EQUAL(tr2->bodyData, string(BODY1));
SG_CHECK_EQUAL(tr2->responseBytesReceived(), strlen(BODY1));
}
{
cout << "redirect test" << endl;
// redirect test
testServer.disconnectAll();
cl.clearAllConnections();
TestRequest* tr = new TestRequest("http://localhost:2000/test_redirect");
HTTP::Request_ptr own(tr);
cl.makeRequest(tr);
waitForComplete(&cl, tr);
SG_CHECK_EQUAL(tr->responseCode(), 200);
SG_CHECK_EQUAL(tr->responseReason(), string("OK"));
SG_CHECK_EQUAL(tr->responseLength(), strlen(BODY1));
SG_CHECK_EQUAL(tr->responseBytesReceived(), strlen(BODY1));
SG_CHECK_EQUAL(tr->bodyData, string(BODY1));
}
cout << "all tests passed ok" << endl;
return EXIT_SUCCESS;
+4 -2
View File
@@ -30,6 +30,7 @@ public:
virtual ~TestServerChannel()
{
std::cerr << "dtor test server channel" << std::endl;
}
virtual void collectIncomingData(const char* s, int n)
@@ -138,8 +139,8 @@ public:
void sendErrorResponse(int code, bool close, std::string content)
{
// std::cerr << "sending error " << code << " for " << path << std::endl;
// std::cerr << "\tcontent:" << content << std::endl;
std::cerr << "sending error " << code << " for " << path << std::endl;
std::cerr << "\tcontent:" << content << std::endl;
std::stringstream headerData;
headerData << "HTTP/1.1 " << code << " " << reasonForCode(code) << "\r\n";
@@ -167,6 +168,7 @@ public:
virtual void handleClose (void)
{
std::cerr << "channel close" << std::endl;
NetBufferChannel::handleClose();
}
+1 -1
View File
@@ -635,7 +635,7 @@ void ArchiveExtractor::extractBytes(const uint8_t* bytes, size_t count)
d.reset(new ZipExtractorPrivate(this));
}
else {
SG_LOG(SG_IO, SG_WARN, "Invalid archive type");
SG_LOG(SG_IO, SG_ALERT, "Invcalid archive type");
_invalidDataType = true;
return;
}
+2 -2
View File
@@ -309,7 +309,7 @@ inline simd4_t<T,N> operator*(simd4_t<T,N> v, T f) {
return v;
}
#ifdef ENABLE_SIMD_CODE
#ifdef ENABLE_SIMD
# ifdef __SSE__
namespace simd4
@@ -1305,7 +1305,7 @@ inline simd4_t<int,N> max(simd4_t<int,N> v1, const simd4_t<int,N>& v2) {
# endif
#endif /* ENABLE_SIMD_CODE */
#endif /* ENABLE_SIMD */
#endif /* __SIMD_H__ */
+2 -2
View File
@@ -289,7 +289,7 @@ inline simd4x4_t<T,N> operator*(const simd4x4_t<T,N>& m1, const simd4x4_t<T,N>&
}
#ifdef ENABLE_SIMD_CODE
#ifdef ENABLE_SIMD
# ifdef __SSE__
template<>
@@ -1191,7 +1191,7 @@ inline simd4_t<int,3> transform<int>(const simd4x4_t<int,4>& m, const simd4_t<in
} /* namespace simd4x */
# endif
#endif /* ENABLE_SIMD_CODE */
#endif /* ENABLE_SIMD */
#endif /* __SIMD4X4_H__ */
-1
View File
@@ -21,7 +21,6 @@
#include "NasalString.hxx"
#include <cassert>
#include <stdexcept> // for std::runtime_error
namespace nasal
{
-5
View File
@@ -24,11 +24,6 @@
#include <simgear/structure/map.hxx>
#include <boost/iterator/iterator_facade.hpp>
#if BOOST_VERSION >= 105600
#include <boost/core/enable_if.hpp>
#else
#include <boost/utility/enable_if.hpp>
#endif
namespace nasal
{
+3 -6
View File
@@ -302,18 +302,15 @@ static char* dosprintf(char* f, ...)
char* buf;
va_list va;
int olen, len = 16;
va_start(va, f);
while(1) {
buf = naAlloc(len);
va_list vaCopy;
va_copy(vaCopy, va);
olen = vsnprintf(buf, len, f, vaCopy);
va_start(va, f);
olen = vsnprintf(buf, len, f, va);
if(olen >= 0 && olen < len) {
va_end(va);
va_end(vaCopy);
return buf;
}
va_end(vaCopy);
va_end(va);
naFree(buf);
len *= 2;
}
+19 -69
View File
@@ -81,27 +81,17 @@ bool checkVersion(const std::string& aVersion, SGPropertyNode_ptr props)
}
return false;
}
SGPropertyNode_ptr alternateForVersion(const std::string& aVersion, SGPropertyNode_ptr props)
{
for (auto v : props->getChildren("alternate-version")) {
for (auto versionSpec : v->getChildren("version")) {
if (checkVersionString(aVersion, versionSpec->getStringValue())) {
return v;
}
}
}
return {};
}
std::string redirectUrlForVersion(const std::string& aVersion, SGPropertyNode_ptr props)
{
auto node = alternateForVersion(aVersion, props);
if (node)
return node->getStringValue("url");;
for (SGPropertyNode* v : props->getChildren("alternate-version")) {
std::string s(v->getStringValue("version"));
if (checkVersionString(aVersion, s)) {
return v->getStringValue("url");;
}
}
return {};
return std::string();
}
//////////////////////////////////////////////////////////////////////////////
@@ -149,15 +139,19 @@ protected:
std::string ver(m_owner->root()->applicationVersion());
if (!checkVersion(ver, props)) {
SG_LOG(SG_GENERAL, SG_WARN, "downloaded catalog " << m_owner->url() << ", but version required " << ver);
// check for a version redirect entry
auto alt = alternateForVersion(ver, props);
if (alt) {
SG_LOG(SG_GENERAL, SG_WARN, "have alternate version of package at:"
<< alt->getStringValue("url"));
m_owner->processAlternate(alt);
std::string url = redirectUrlForVersion(ver, props);
if (!url.empty()) {
SG_LOG(SG_GENERAL, SG_WARN, "redirecting from " << m_owner->url() <<
" to \n\t" << url);
// update the URL and kick off a new request
m_owner->setUrl(url);
Downloader* dl = new Downloader(m_owner, url);
m_owner->root()->makeHTTPRequest(dl);
} else {
SG_LOG(SG_GENERAL, SG_WARN, "downloaded catalog " << m_owner->url()
<< ", but app version " << ver << " is not comaptible");
m_owner->refreshComplete(Delegate::FAIL_VERSION);
}
@@ -234,7 +228,7 @@ CatalogRef Catalog::createFromPath(Root* aRoot, const SGPath& aPath)
bool versionCheckOk = checkVersion(aRoot->applicationVersion(), props);
if (!versionCheckOk) {
SG_LOG(SG_GENERAL, SG_INFO, "catalog at:" << aPath << " failed version check: app version: "
SG_LOG(SG_GENERAL, SG_INFO, "catalog at:" << aPath << " failed version check: need version: "
<< aRoot->applicationVersion());
// keep the catalog but mark it as needing an update
} else {
@@ -604,50 +598,6 @@ bool Catalog::isEnabled() const
}
}
void Catalog::processAlternate(SGPropertyNode_ptr alt)
{
std::string altId;
const auto idPtr = alt->getStringValue("id");
if (idPtr) {
altId = std::string(idPtr);
}
std::string altUrl;
if (alt->getStringValue("url")) {
altUrl = std::string(alt->getStringValue("url"));
}
CatalogRef existing;
if (!altId.empty()) {
existing = root()->getCatalogById(altId);
} else {
existing = root()->getCatalogByUrl(altUrl);
}
if (existing && (existing != this)) {
// we already have the alternate, so just go quiet here
changeStatus(Delegate::FAIL_VERSION);
return;
}
// we have an alternate ID, and it's differnt from our ID, so let's
// define a new catalog
if (!altId.empty()) {
SG_LOG(SG_GENERAL, SG_INFO, "Adding new catalog:" << altId << " as version alternate for " << id());
// new catalog being added
createFromUrl(root(), altUrl);
// and we can go idle now
changeStatus(Delegate::FAIL_VERSION);
return;
}
SG_LOG(SG_GENERAL, SG_INFO, "Migrating catalog " << id() << " to new URL:" << altUrl);
setUrl(altUrl);
Downloader* dl = new Downloader(this, altUrl);
root()->makeHTTPRequest(dl);
}
} // of namespace pkg
} // of namespace simgear
-2
View File
@@ -179,8 +179,6 @@ private:
void changeStatus(Delegate::StatusCode newStatus);
void processAlternate(SGPropertyNode_ptr alt);
Root* m_root;
SGPropertyNode_ptr m_props;
SGPath m_installRoot;
-126
View File
@@ -723,130 +723,6 @@ void testVersionMigrate(HTTP::Client* cl)
}
}
void testVersionMigrateToId(HTTP::Client* cl)
{
global_catalogVersion = 2; // version which has migration info
SGPath rootPath(simgear::Dir::current().path());
rootPath.append("cat_migrate_version_id");
simgear::Dir pd(rootPath);
pd.removeChildren();
{
pkg::RootRef root(new pkg::Root(rootPath, "8.1.2"));
root->setHTTPClient(cl);
pkg::CatalogRef c = pkg::Catalog::createFromUrl(root.ptr(), "http://localhost:2000/catalogTest1/catalog.xml");
waitForUpdateComplete(cl, root);
SG_VERIFY(c->isEnabled());
// install a package
pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG");
SG_CHECK_EQUAL(p1->id(), "b737-NG");
pkg::InstallRef ins = p1->install();
SG_VERIFY(ins->isQueued());
waitForUpdateComplete(cl, root);
SG_VERIFY(p1->isInstalled());
}
// change version to an alternate one
{
pkg::RootRef root(new pkg::Root(rootPath, "7.5"));
root->setHTTPClient(cl);
// this should cause the alternate package to be loaded
root->refresh(true);
waitForUpdateComplete(cl, root);
pkg::CatalogRef cat = root->getCatalogById("org.flightgear.test.catalog1");
SG_VERIFY(!cat->isEnabled());
SG_CHECK_EQUAL(cat->status(), pkg::Delegate::FAIL_VERSION);
SG_CHECK_EQUAL(cat->id(), "org.flightgear.test.catalog1");
SG_CHECK_EQUAL(cat->url(), "http://localhost:2000/catalogTest1/catalog.xml");
auto enabledCats = root->catalogs();
auto it = std::find(enabledCats.begin(), enabledCats.end(), cat);
SG_VERIFY(it == enabledCats.end());
// ensure existing package is still installed
pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG");
SG_VERIFY(p1 != pkg::PackageRef());
SG_CHECK_EQUAL(p1->id(), "b737-NG");
// but not listed
auto packs = root->allPackages();
auto k = std::find(packs.begin(), packs.end(), p1);
SG_VERIFY(k == packs.end());
// check the new catalog
auto altCat = root->getCatalogById("org.flightgear.test.catalog-alt");
SG_VERIFY(altCat->isEnabled());
SG_CHECK_EQUAL(altCat->status(), pkg::Delegate::STATUS_REFRESHED);
SG_CHECK_EQUAL(altCat->id(), "org.flightgear.test.catalog-alt");
SG_CHECK_EQUAL(altCat->url(), "http://localhost:2000/catalogTest1/catalog-alt.xml");
it = std::find(enabledCats.begin(), enabledCats.end(), altCat);
SG_VERIFY(it != enabledCats.end());
// install a parallel package from the new catalog
pkg::PackageRef p2 = root->getPackageById("org.flightgear.test.catalog-alt.b737-NG");
SG_CHECK_EQUAL(p2->id(), "b737-NG");
pkg::InstallRef ins = p2->install();
SG_VERIFY(ins->isQueued());
waitForUpdateComplete(cl, root);
SG_VERIFY(p2->isInstalled());
// do a non-scoped lookup, we should get the new one
pkg::PackageRef p3 = root->getPackageById("b737-NG");
SG_CHECK_EQUAL(p2, p3);
}
// test that re-init-ing doesn't mirgate again
{
pkg::RootRef root(new pkg::Root(rootPath, "7.5"));
root->setHTTPClient(cl);
root->refresh(true);
waitForUpdateComplete(cl, root);
pkg::CatalogRef cat = root->getCatalogById("org.flightgear.test.catalog1");
SG_VERIFY(!cat->isEnabled());
SG_CHECK_EQUAL(cat->status(), pkg::Delegate::FAIL_VERSION);
auto altCat = root->getCatalogById("org.flightgear.test.catalog-alt");
SG_VERIFY(altCat->isEnabled());
auto packs = root->allPackages();
SG_CHECK_EQUAL(packs.size(), 4);
}
// and now switch back to the older version
{
pkg::RootRef root(new pkg::Root(rootPath, "8.1.0"));
root->setHTTPClient(cl);
root->refresh(true);
waitForUpdateComplete(cl, root);
pkg::CatalogRef cat = root->getCatalogById("org.flightgear.test.catalog1");
SG_VERIFY(cat->isEnabled());
SG_CHECK_EQUAL(cat->status(), pkg::Delegate::STATUS_REFRESHED);
auto altCat = root->getCatalogById("org.flightgear.test.catalog-alt");
SG_VERIFY(!altCat->isEnabled());
// verify the original aircraft is still installed and available
pkg::PackageRef p1 = root->getPackageById("org.flightgear.test.catalog1.b737-NG");
SG_VERIFY(p1 != pkg::PackageRef());
SG_CHECK_EQUAL(p1->id(), "b737-NG");
SG_VERIFY(p1->isInstalled());
// verify the alt package is still installed,
pkg::PackageRef p2 = root->getPackageById("org.flightgear.test.catalog-alt.b737-NG");
SG_VERIFY(p2 != pkg::PackageRef());
SG_CHECK_EQUAL(p2->id(), "b737-NG");
SG_VERIFY(p2->isInstalled());
}
}
void testOfflineMode(HTTP::Client* cl)
{
global_catalogVersion = 0;
@@ -1096,8 +972,6 @@ int main(int argc, char* argv[])
removeInvalidCatalog(&cl);
testVersionMigrateToId(&cl);
SG_LOG(SG_GENERAL, SG_INFO, "Successfully passed all tests!");
return EXIT_SUCCESS;
}
+22 -51
View File
@@ -18,8 +18,8 @@
#include <simgear_config.h>
#include <simgear/package/Install.hxx>
#include <boost/foreach.hpp>
#include <fstream>
#include <cstdlib>
#include <simgear/package/unzip.h>
#include <simgear/package/md5.h>
@@ -43,21 +43,25 @@ namespace pkg {
class Install::PackageArchiveDownloader : public HTTP::Request
{
public:
PackageArchiveDownloader(InstallRef aOwner, const string_list& urls) :
PackageArchiveDownloader(InstallRef aOwner) :
HTTP::Request("" /* dummy URL */),
m_owner(aOwner)
{
m_urls = urls;
if (urls.empty()) {
m_urls = m_owner->package()->downloadUrls();
m_urls = m_owner->package()->downloadUrls();
if (m_urls.empty()) {
throw sg_exception("no package download URLs");
}
selectMirrorUrl();
// if (m_owner->package()->properties()->hasChild("archive-type")) {
// setArchiveTypeFromExtension(m_owner->package()->properties()->getStringValue("archive-type"));
//}
// TODO randomise order of m_urls
m_extractPath = aOwner->path().dir();
m_extractPath.append("_extract_" + aOwner->package()->md5());
// clean up any existing files (eg from previous failed download)
// clean up any existing files
Dir d(m_extractPath);
if (d.exists()) {
d.remove(true /* recursive */);
@@ -89,54 +93,36 @@ public:
return (m_downloaded * 100) / responseLength();
}
protected:
void selectMirrorUrl()
virtual std::string url() const
{
const int randomizedIndex = rand() % m_urls.size();
m_activeURL = m_urls.at(randomizedIndex);
m_urls.erase(m_urls.begin() + randomizedIndex);
}
virtual std::string url() const override
{
return m_activeURL;
return m_urls.front();
}
void responseHeadersComplete() override
virtual void responseHeadersComplete()
{
Request::responseHeadersComplete();
Dir d(m_extractPath);
if (!d.create(0755)) {
SG_LOG(SG_GENERAL, SG_WARN, "Failed to create extraction directory" << d.path());
}
d.create(0755);
m_extractor.reset(new ArchiveExtractor(m_extractPath));
memset(&m_md5, 0, sizeof(SG_MD5_CTX));
SG_MD5Init(&m_md5);
}
void gotBodyData(const char* s, int n) override
virtual void gotBodyData(const char* s, int n)
{
// if there's a pre-existing error, discard byte sinstead of pushing
// more through the extactor
if (m_extractor->hasError()) {
return;
}
const uint8_t* ubytes = (uint8_t*) s;
SG_MD5Update(&m_md5, ubytes, n);
m_downloaded += n;
m_owner->installProgress(m_downloaded, responseLength());
m_extractor->extractBytes(ubytes, n);
if (m_extractor->hasError()) {
SG_LOG(SG_GENERAL, SG_WARN, "archive extraction failed (from " + m_activeURL + ")");
}
}
void onDone() override
virtual void onDone()
{
if (responseCode() != 200) {
SG_LOG(SG_GENERAL, SG_WARN, "download failure:" << responseCode() <<
SG_LOG(SG_GENERAL, SG_ALERT, "download failure:" << responseCode() <<
"\n\t" << url());
Delegate::StatusCode code = Delegate::FAIL_DOWNLOAD;
if (responseCode() == 404) {
@@ -153,7 +139,7 @@ protected:
strutils::encodeHex(digest, MD5_DIGEST_LENGTH);
if (hex_md5 != m_owner->package()->md5()) {
SG_LOG(SG_GENERAL, SG_WARN, "md5 verification failed:\n"
SG_LOG(SG_GENERAL, SG_ALERT, "md5 verification failed:\n"
<< "\t" << hex_md5 << "\n\t"
<< m_owner->package()->md5() << "\n\t"
<< "downloading from:" << url());
@@ -208,7 +194,7 @@ protected:
m_owner->installResult(Delegate::STATUS_SUCCESS);
}
void onFail() override
virtual void onFail()
{
if (responseCode() == -1) {
doFailure(Delegate::USER_CANCELLED);
@@ -224,28 +210,14 @@ private:
if (dir.exists()) {
dir.remove(true /* recursive */);
}
const auto canRetry = (aReason == Delegate::FAIL_NOT_FOUND) ||
(aReason == Delegate::FAIL_DOWNLOAD) || (aReason == Delegate::FAIL_CHECKSUM);
if (canRetry && !m_urls.empty()) {
SG_LOG(SG_GENERAL, SG_WARN, "archive download failed from:" << m_activeURL
<< "\n\twill retry with next mirror");
// becuase selectMirrorUrl erased the active URL from m_urls,
// this new request will select one of the other mirrors
auto retryDownload = new PackageArchiveDownloader(m_owner, m_urls);
m_owner->m_download.reset(retryDownload);
m_owner->package()->catalog()->root()->makeHTTPRequest(retryDownload);
return;
}
// TODO - try other mirrors
m_owner->m_download.reset(); // ensure we get cleaned up
m_owner->installResult(aReason);
}
InstallRef m_owner;
string m_activeURL;
string_list m_urls;
SG_MD5_CTX m_md5;
SGPath m_extractPath;
@@ -309,7 +281,7 @@ void Install::startUpdate()
return; // already active
}
m_download = new PackageArchiveDownloader(this, {});
m_download = new PackageArchiveDownloader(this);
m_package->catalog()->root()->makeHTTPRequest(m_download);
m_package->catalog()->root()->startInstall(this);
}
@@ -369,7 +341,6 @@ void Install::cancelDownload()
}
m_package->catalog()->root()->cancelDownload(this);
m_download.clear();
}
SGPath Install::primarySetPath() const
+1 -18
View File
@@ -414,7 +414,7 @@ Root::Root(const SGPath& aPath, const std::string& aVersion) :
if (cat && cat->isEnabled()) {
d->catalogs.insert({cat->id(), cat});
} else if (cat) {
SG_LOG(SG_GENERAL, SG_DEBUG, "Package-Root init: catalog is disabled: " << cat->id());
SG_LOG(SG_GENERAL, SG_WARN, "Package-Root init: catalog is disabled: " << cat->id());
}
} // of child directories iteration
}
@@ -450,17 +450,6 @@ CatalogRef Root::getCatalogById(const std::string& aId) const
return it->second;
}
CatalogRef Root::getCatalogByUrl(const std::string& aUrl) const
{
auto it = std::find_if(d->catalogs.begin(), d->catalogs.end(),
[aUrl](const CatalogDict::value_type& v)
{ return (v.second->url() == aUrl); });
if (it == d->catalogs.end())
return {};
return it->second;
}
PackageRef Root::getPackageById(const std::string& aName) const
{
size_t lastDot = aName.rfind('.');
@@ -605,12 +594,6 @@ void Root::scheduleToUpdate(InstallRef aInstall)
if (!aInstall) {
throw sg_exception("missing argument to scheduleToUpdate");
}
auto it = std::find(d->updateDeque.begin(), d->updateDeque.end(), aInstall);
if (it != d->updateDeque.end()) {
// already scheduled to update
return;
}
PackageList deps = aInstall->package()->dependencies();
for (Package* dep : deps) {
-2
View File
@@ -132,8 +132,6 @@ public:
CatalogRef getCatalogById(const std::string& aId) const;
CatalogRef getCatalogByUrl(const std::string& aUrl) const;
void scheduleToUpdate(InstallRef aInstall);
/**
@@ -1,141 +0,0 @@
<?xml version="1.0"?>
<PropertyList>
<id>org.flightgear.test.catalog-alt</id>
<description>Alternate test catalog</description>
<url>http://localhost:2000/catalogTest1/catalog-alt.xml</url>
<catalog-version>4</catalog-version>
<version>7.*</version>
<package>
<id>alpha</id>
<name>Alpha package</name>
<revision type="int">9</revision>
<file-size-bytes type="int">593</file-size-bytes>
<md5>a469c4b837f0521db48616cfe65ac1ea</md5>
<url>http://localhost:2000/catalogTest1/alpha.zip</url>
<dir>alpha</dir>
</package>
<package>
<id>c172p</id>
<name>Cessna 172-P</name>
<dir>c172p</dir>
<description>A plane made by Cessna</description>
<revision type="int">42</revision>
<file-size-bytes type="int">860</file-size-bytes>
<tag>cessna</tag>
<tag>ga</tag>
<tag>piston</tag>
<tag>ifr</tag>
<rating>
<FDM type="int">3</FDM>
<systems type="int">4</systems>
<model type="int">5</model>
<cockpit type="int">4</cockpit>
</rating>
<preview>
<type>exterior</type>
<path>thumb-exterior.png</path>
<url>http://foo.bar.com/thumb-exterior.png</url>
</preview>
<preview>
<type>panel</type>
<path>thumb-panel.png</path>
<url>http://foo.bar.com/thumb-panel.png</url>
</preview>
<preview>
<path>thumb-something.png</path>
<url>http://foo.bar.com/thumb-something.png</url>
</preview>
<variant>
<id>c172p-2d-panel</id>
<name>C172 with 2d panel only</name>
</variant>
<variant>
<id>c172p-floats</id>
<name>C172 with floats</name>
<preview>
<type>exterior</type>
<path>thumb-exterior-floats.png</path>
<url>http://foo.bar.com/thumb-exterior-floats.png</url>
</preview>
<preview>
<type>panel</type>
<path>thumb-panel.png</path>
<url>http://foo.bar.com/thumb-panel.png</url>
</preview>
</variant>
<variant>
<id>c172p-skis</id>
<name>C172 with skis</name>
<preview>
<type>exterior</type>
<path>thumb-exterior-skis.png</path>
<url>http://foo.bar.com/thumb-exterior-skis.png</url>
</preview>
<preview>
<type>panel</type>
<path>thumb-panel.png</path>
<url>http://foo.bar.com/thumb-panel.png</url>
</preview>
</variant>
<md5>ec0e2ffdf98d6a5c05c77445e5447ff5</md5>
<url>http://localhost:2000/catalogTest1/c172p.zip</url>
</package>
<package>
<id>b737-NG</id>
<name>Boeing 737 NG</name>
<dir>b737NG</dir>
<description>A popular twin-engined narrow body jet</description>
<revision type="int">112</revision>
<file-size-bytes type="int">860</file-size-bytes>
<tag>boeing</tag>
<tag>jet</tag>
<tag>ifr</tag>
<rating>
<FDM type="int">5</FDM>
<systems type="int">5</systems>
<model type="int">4</model>
<cockpit type="int">4</cockpit>
</rating>
<md5>a94ca5704f305b90767f40617d194ed6</md5>
<url>http://localhost:2000/catalogTest1/b737.tar.gz</url>
</package>
<package>
<id>dc3</id>
<name>DC-3</name>
<revision type="int">9</revision>
<file-size-bytes type="int">593</file-size-bytes>
<md5>a469c4b837f0521db48616cfe65ac1ea</md5>
<url>http://localhost:2000/catalogTest1/alpha.zip</url>
<dir>dc3</dir>
</package>
</PropertyList>
@@ -15,12 +15,6 @@
<url>http://localhost:2000/catalogTest1/catalog-v10.xml</url>
</alternate-version>
<alternate-version>
<version>7.*</version>
<id>org.flightgear.test.catalog-alt</id>
<url>http://localhost:2000/catalogTest1/catalog-alt.xml</url>
</alternate-version>
<package>
<id>alpha</id>
<name>Alpha package</name>
+4 -7
View File
@@ -122,17 +122,14 @@ void printPackageInfo(pkg::Package* pkg)
int main(int argc, char** argv)
{
sglog().setLogLevels( SG_ALL, SG_INFO );
HTTP::Client* http = new HTTP::Client();
SGPath rootPath = SGPath::fromEnv("SG_PKG_ROOT", Dir::current().path());
pkg::Root* root = new pkg::Root(rootPath, "2019.1.1");
pkg::Root* root = new pkg::Root(Dir::current().path(), "");
MyDelegate dlg;
root->addDelegate(&dlg);
cout << "Package root is:" << rootPath << endl;
cout << "Package root is:" << Dir::current().path() << endl;
cout << "have " << root->catalogs().size() << " catalog(s)" << endl;
root->setHTTPClient(http);
+1 -6
View File
@@ -55,18 +55,13 @@ namespace boost {
struct disable_if : public disable_if_c<Cond::value, T> {};
}
#else
# include <boost/utility.hpp>
# include <boost/type_traits/is_enum.hpp>
#if BOOST_VERSION >= 105600
#include <boost/core/enable_if.hpp>
#else
#include <boost/utility/enable_if.hpp>
#endif
# include <simgear/debug/logstream.hxx>
# include <simgear/math/SGMathFwd.hxx>
# include <simgear/math/sg_types.hxx>
#endif
#include <simgear/structure/SGReferenced.hxx>
#include <simgear/structure/SGSharedPtr.hxx>
+7 -8
View File
@@ -257,8 +257,7 @@ bool setAttrs(const TexTuple& attrs, Texture* tex,
return false;
osgDB::ReaderWriter::ReadResult result;
result = osgDB::readRefImageFile(imageName, options);
result = osgDB::readImageFile(imageName, options);
osg::ref_ptr<osg::Image> image;
if (result.success())
image = result.getImage();
@@ -591,27 +590,27 @@ Texture* CubeMapBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode*
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::POSITIVE_X, image);
}
result = osgDB::readRefImageFile(_tuple.get<1>(), options);
result = osgDB::readImageFile(_tuple.get<1>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::NEGATIVE_X, image);
}
result = osgDB::readRefImageFile(_tuple.get<2>(), options);
result = osgDB::readImageFile(_tuple.get<2>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::POSITIVE_Y, image);
}
result = osgDB::readRefImageFile(_tuple.get<3>(), options);
result = osgDB::readImageFile(_tuple.get<3>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Y, image);
}
result = osgDB::readRefImageFile(_tuple.get<4>(), options);
result = osgDB::readImageFile(_tuple.get<4>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::POSITIVE_Z, image);
}
result = osgDB::readRefImageFile(_tuple.get<5>(), options);
result = osgDB::readImageFile(_tuple.get<5>(), options);
if(result.success()) {
osg::Image* image = result.getImage();
cubeTexture->setImage(TextureCubeMap::NEGATIVE_Z, image);
@@ -635,7 +634,7 @@ Texture* CubeMapBuilder::build(Effect* effect, Pass* pass, const SGPropertyNode*
return cubeTexture.release();
osgDB::ReaderWriter::ReadResult result;
result = osgDB::readRefImageFile(texname, options);
result = osgDB::readImageFile(texname, options);
if(result.success()) {
osg::Image* image = result.getImage();
image->flipVertical(); // Seems like the image coordinates are somewhat funny, flip to get better ones
+1 -1
View File
@@ -227,7 +227,7 @@ SGMaterial::read_properties(const SGReaderWriterOptions* options,
}
else
{
osg::Image* image = osgDB::readRefImageFile(fullMaskPath, options);
osg::Image* image = osgDB::readImageFile(fullMaskPath, options);
if (image && image->valid())
{
Texture2DRef object_mask = new osg::Texture2D;
+10 -12
View File
@@ -280,21 +280,19 @@ ModelRegistry::readImage(const string& fileName,
}
osg::ref_ptr<osg::Node> DefaultCachePolicy::find(const string& fileName, const Options* opt)
osg::Node* DefaultCachePolicy::find(const string& fileName,
const Options* opt)
{
Registry* registry = Registry::instance();
#if OSG_VERSION_LESS_THAN(3,4,0)
osg::ref_ptr<osg::Object> cachedObject = registry->getFromObjectCache(fileName);
#else
osg::ref_ptr<osg::Object> cachedObject = registry->getRefFromObjectCache(fileName);
#endif
ref_ptr<osg::Node> cachedNode = dynamic_cast<osg::Node*>(cachedObject.get());
if (cachedNode.valid())
SG_LOG(SG_IO, SG_BULK, "Got cached model \"" << fileName << "\"");
osg::Node* cached
= dynamic_cast<Node*>(registry->getFromObjectCache(fileName));
if (cached)
SG_LOG(SG_IO, SG_BULK, "Got cached model \""
<< fileName << "\"");
else
SG_LOG(SG_IO, SG_BULK, "Reading model \"" << fileName << "\"");
return cachedNode;
SG_LOG(SG_IO, SG_BULK, "Reading model \""
<< fileName << "\"");
return cached;
}
void DefaultCachePolicy::addToCache(const string& fileName,
+1 -1
View File
@@ -132,7 +132,7 @@ struct DefaultProcessPolicy {
struct DefaultCachePolicy {
DefaultCachePolicy(const std::string& extension) {}
osg::ref_ptr<osg::Node> find(const std::string& fileName,
osg::Node* find(const std::string& fileName,
const osgDB::Options* opt);
void addToCache(const std::string& filename, osg::Node* node);
};
+9 -23
View File
@@ -136,19 +136,11 @@ osg::Vec2d eventToWindowCoords(const osgGA::GUIEventAdapter& ea)
virtual void update(double dt, int keyModState)
{
SG_UNUSED(keyModState);
if (_condition && !_condition->test()) {
return;
}
if (!_condition || _condition->test()) {
SG_UNUSED(keyModState);
if (!_repeatable)
return;
if (!_repeatable)
return;
const bool zeroInterval = (_repeatInterval <= 0.0);
if (zeroInterval) {
// fire once per frame
fireBindingList(_bindingsDown);
} else {
_repeatTime += dt;
while (_repeatInterval < _repeatTime) {
_repeatTime -= _repeatInterval;
@@ -690,18 +682,12 @@ public:
if (_hasDragged) {
return;
}
const bool zeroInterval = (_repeatInterval <= 0.0);
if (zeroInterval) {
// fire once per frame
_repeatTime += dt;
while (_repeatInterval < _repeatTime) {
_repeatTime -= _repeatInterval;
fire(keyModState & osgGA::GUIEventAdapter::MODKEY_SHIFT, _direction);
} else {
_repeatTime += dt;
while (_repeatInterval < _repeatTime) {
_repeatTime -= _repeatInterval;
fire(keyModState & osgGA::GUIEventAdapter::MODKEY_SHIFT, _direction);
} // of repeat iteration
}
} // of repeat iteration
}
virtual bool hover( const osg::Vec2d& windowPos,
+2 -2
View File
@@ -335,7 +335,7 @@ sgLoad3DModel_internal(const SGPath& path,
options->setDatabasePath(texturepath.local8BitStr());
osgDB::ReaderWriter::ReadResult modelResult;
modelResult = osgDB::readRefNodeFile(modelpath.local8BitStr(), options.get());
modelResult = osgDB::readNodeFile(modelpath.local8BitStr(), options.get());
if (!modelResult.validNode())
throw sg_io_exception("Failed to load 3D model:" + modelResult.message(),
modelpath);
@@ -481,7 +481,7 @@ sgLoad3DModel_internal(const SGPath& path,
}
}
if (GlobalParticleCallback::getEnabled()){//dbOptions->getPluginStringData("SimGear::PARTICLESYSTEM") != "OFF") {
if (dbOptions->getPluginStringData("SimGear::PARTICLESYSTEM") != "OFF") {
std::vector<SGPropertyNode_ptr> particle_nodes;
particle_nodes = props->getChildren("particlesystem");
for (unsigned i = 0; i < particle_nodes.size(); ++i) {
+3 -3
View File
@@ -43,9 +43,9 @@ SGLoadTexture2D(bool staticTexture, const std::string& path,
{
osg::Image* image;
if (options)
image = osgDB::readRefImageFile(path, options);
image = osgDB::readImageFile(path, options);
else
image = osgDB::readRefImageFile(path);
image = osgDB::readImageFile(path);
osg::ref_ptr<osg::Texture2D> texture = new osg::Texture2D;
texture->setImage(image);
if (staticTexture)
@@ -141,7 +141,7 @@ Texture2D* TextureUpdateVisitor::textureReplace(int unit, const StateAttribute*
// If it is empty or they are identical then there is nothing to do
if (fullLiveryFile.empty() || fullLiveryFile == *fullFilePath)
return 0;
Image* newImage = readRefImageFile(fullLiveryFile);
Image* newImage = readImageFile(fullLiveryFile);
if (!newImage)
return 0;
CopyOp copyOp(CopyOp::DEEP_COPY_ALL & ~CopyOp::DEEP_COPY_IMAGES);
+5 -6
View File
@@ -169,7 +169,6 @@ SGModelLib::loadDeferredModel(const string &path, SGPropertyNode *prop_root,
osg::PagedLOD*
SGModelLib::loadPagedModel(SGPropertyNode *prop_root, SGModelData *data, SGModelLOD model_lods)
{
unsigned int simple_models = 0;
osg::PagedLOD *plod = new osg::PagedLOD;
osg::ref_ptr<SGReaderWriterOptions> opt;
@@ -190,15 +189,15 @@ SGModelLib::loadPagedModel(SGPropertyNode *prop_root, SGModelData *data, SGModel
plod->setMinimumExpiryTime(i, prop_root->getDoubleValue("/sim/rendering/plod-minimum-expiry-time-secs", 180.0 ) );
std::string lext = SGPath(lod.path).lower_extension();
// We can only have one set of ReaderWriterOptions for the PagedLOD, so
// we will just have to assume that if one of the defined models can
// handle instantiated effects, then the other can as well.
if ((lext == "ac") || (lext == "obj")) {
simple_models++;
opt->setInstantiateEffects(true);
}
}
// If all we have are simple models, then we can instantiate effects in
// the loader.
if (simple_models == model_lods.getNumLODs()) opt->setInstantiateEffects(true);
plod->setDatabaseOptions(opt.get());
return plod;
+3 -5
View File
@@ -485,11 +485,9 @@ SGCloudLayer::rebuild()
// repaint the cloud layer colors
bool SGCloudLayer::repaint( const SGVec3f& fog_color ) {
osg::Vec4f combineColor(toOsg(fog_color), cloud_alpha);
osg::StateAttribute* textureAtt = layer_root->getStateSet()->getTextureAttribute(1, osg::StateAttribute::TEXENV);
osg::TexEnvCombine* combiner = dynamic_cast<osg::TexEnvCombine*>(textureAtt);
if (combiner == nullptr)
return false;
osg::TexEnvCombine* combiner
= dynamic_cast<osg::TexEnvCombine*>(layer_root->getStateSet()
->getTextureAttribute(1, osg::StateAttribute::TEXENV));
combiner->setConstantColor(combineColor);
// Set the fog color for the 3D clouds too.
+1 -1
View File
@@ -208,7 +208,7 @@ ReaderWriterSPT::readObject(const std::string& fileName, const osgDB::Options* o
imageFileName = osgDB::concatPaths(imageFileName, "Globe");
imageFileName = osgDB::concatPaths(imageFileName, "world.topo.bathy.200407.3x4096x2048.png");
}
if (osg::Image* image = osgDB::readRefImageFile(imageFileName, options)) {
if (osg::Image* image = osgDB::readImageFile(imageFileName, options)) {
osg::Texture2D* texture = new osg::Texture2D;
texture->setImage(image);
texture->setWrap(osg::Texture2D::WRAP_S, osg::Texture2D::REPEAT);
-1
View File
@@ -27,5 +27,4 @@
#cmakedefine ENABLE_SOUND
#cmakedefine USE_AEONWAVE
#cmakedefine ENABLE_SIMD
#cmakedefine ENABLE_SIMD_CODE
#cmakedefine ENABLE_GDAL
+4
View File
@@ -353,6 +353,10 @@ void SGSampleGroup::update_sample_config( SGSoundSample *sample )
velocity = sample->get_velocity();
}
if (_smgr->bad_doppler_effect()) {
velocity *= 100.0f;
}
#if 0
if (length(position) > 20000)
printf("%s source and listener distance greater than 20km!\n",
+8 -5
View File
@@ -8,7 +8,7 @@
// Modified for the new SoundSystem by Erik Hofman, October 2009
//
// Copyright (C) 2001 Curtis L. Olson - http://www.flightgear.org/~curt
// Copyright (C) 2009-2019 Erik Hofman <erik@ehofman.com>
// Copyright (C) 2009 Erik Hofman <erik@ehofman.com>
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
@@ -418,8 +418,8 @@ void SGSoundMgr::release_source( unsigned int source )
{
aax::Emitter& emitter = source_it->second;
enum aaxState state = emitter.state();
if (state != AAX_PROCESSED) {
TRY( emitter.set(AAX_PROCESSED) );
if (state == AAX_PLAYING || state == AAX_SUSPENDED) {
TRY( emitter.set(AAX_STOPPED) );
TRY( d->_aax.remove(emitter) );
}
TRY( emitter.remove_buffer() );
@@ -555,6 +555,7 @@ void SGSoundMgr::sample_play( SGSoundSample *sample )
if (bufid == SGSoundMgr::FAILED_BUFFER ||
bufid == SGSoundMgr::NO_BUFFER)
{
printf("A: release: %i, bufid: %i (%i, %i)\n", sample->get_source(), bufid, SGSoundMgr::FAILED_BUFFER, SGSoundMgr::NO_BUFFER);
release_source(sample->get_source());
return;
}
@@ -589,7 +590,8 @@ void SGSoundMgr::sample_stop( SGSoundSample *sample )
if ( sample->is_looping() && !stopped) {
#ifdef ENABLE_SOUND
aax::Emitter& emitter = d->get_emitter(source);
TRY( emitter.set(AAX_PROCESSED) );
TRY( emitter.set(AAX_STOPPED) );
TRY( d->_aax.remove(emitter) );
#endif
stopped = is_sample_stopped(sample);
}
@@ -608,7 +610,8 @@ void SGSoundMgr::sample_destroy( SGSoundSample *sample )
unsigned int source = sample->get_source();
if ( sample->is_playing() ) {
aax::Emitter& emitter = d->get_emitter(source);
TRY( emitter.set(AAX_PROCESSED) );
TRY( emitter.set(AAX_STOPPED) );
TRY( d->_aax.remove(emitter) );
}
release_source( source );
#endif
+7 -16
View File
@@ -50,7 +50,6 @@ using std::vector;
#define MAX_SOURCES 128
#define SPEED_OF_SOUND 340.4f
#ifndef ALC_ALL_DEVICES_SPECIFIER
# define ALC_ALL_DEVICES_SPECIFIER 0x1013
@@ -219,8 +218,8 @@ void SGSoundMgr::init()
alListenerfv( AL_POSITION, SGVec3f::zeros().data() );
alListenerfv( AL_VELOCITY, SGVec3f::zeros().data() );
alDopplerFactor(1.0f);
alDopplerVelocity(SPEED_OF_SOUND);
alDopplerFactor(1.0);
alDopplerVelocity(340.3); // speed of sound in meters per second.
// gain = AL_REFERENCE_DISTANCE / (AL_REFERENCE_DISTANCE +
// AL_ROLLOFF_FACTOR * (distance - AL_REFERENCE_DISTANCE));
@@ -249,10 +248,8 @@ void SGSoundMgr::init()
_renderer = (const char *)alGetString(AL_RENDERER);
if (_vendor == "Creative Labs Inc.") {
alDopplerFactor(100.0f);
_bad_doppler = true;
} else if (_vendor == "OpenAL Community" && _renderer == "OpenAL Soft") {
alDopplerFactor(100.0f);
_bad_doppler = true;
}
@@ -343,7 +340,7 @@ void SGSoundMgr::suspend()
for ( auto current = d->_sample_groups.begin();
current != d->_sample_groups.end(); ++current ) {
SGSampleGroup *sgrp = current->second;
sgrp->suspend();
sgrp->stop();
}
_active = false;
}
@@ -395,20 +392,14 @@ if (isNaN(toVec3f(_velocity).data())) printf("NaN in listener velocity\n");
SGVec3d velocity = SGVec3d::zeros();
if ( _velocity[0] || _velocity[1] || _velocity[2] ) {
velocity = hlOr.backTransform(_velocity*SG_FEET_TO_METER);
}
if ( _bad_doppler ) {
double fact = 100.0;
double mag = length( velocity );
if (mag > SPEED_OF_SOUND) {
fact *= SPEED_OF_SOUND / mag;
}
alDopplerFactor(fact);
}
if ( _bad_doppler ) {
velocity *= 100.0f;
}
alListenerfv( AL_VELOCITY, toVec3f(velocity).data() );
// alDopplerVelocity(SPEED_OF_SOUND);
// alDopplerVelocity(340.3); // TODO: altitude dependent
testForError("update");
_changed = false;
}
-3
View File
@@ -83,9 +83,6 @@ SGXmlSound::~SGXmlSound()
if (_sample)
_sample->stop();
if (_sgrp && (_name != ""))
_sgrp->remove(_name);
_volume.clear();
_pitch.clear();
}
-4
View File
@@ -22,11 +22,7 @@
#include "SGSharedPtr.hxx"
#include <boost/type_traits/is_base_of.hpp>
#if BOOST_VERSION >= 105600
#include <boost/core/enable_if.hpp>
#else
#include <boost/utility/enable_if.hpp>
#endif
#ifdef _MSC_VER
# pragma warning(push)
-1
View File
@@ -253,7 +253,6 @@ SGSubsystemGroup::incrementalInit()
{
// special case this, simplifies the logic below
if (_members.empty()) {
_state = State::INIT;
return INIT_DONE;
}
+1 -28
View File
@@ -314,7 +314,6 @@ void testIncrementalInit()
instruments->set_subsystem(radio1);
instruments->set_subsystem(radio2);
manager->bind();
for ( ; ; ) {
auto status = manager->incrementalInit();
@@ -339,34 +338,9 @@ void testIncrementalInit()
SG_VERIFY(d->hasEvent("fake-radio.nav2-will-init"));
SG_VERIFY(d->hasEvent("fake-radio.nav2-did-init"));
}
void testEmptyGroup()
{
// testing the assert described here:
// https://sourceforge.net/p/flightgear/codetickets/2043/
// when an empty group is inited, we skipped setting the state
SGSharedPtr<SGSubsystemMgr> manager = new SGSubsystemMgr;
auto d = new RecorderDelegate;
manager->addDelegate(d);
auto mySub = manager->add<MySub1>(SGSubsystemMgr::POST_FDM);
auto anotherSub = manager->add<AnotherSub>(SGSubsystemMgr::POST_FDM);
auto instruments = manager->add<InstrumentGroup>(SGSubsystemMgr::POST_FDM);
manager->bind();
for ( ; ; ) {
auto status = manager->incrementalInit();
if (status == SGSubsystemMgr::INIT_DONE)
break;
}
manager->postinit();
SG_VERIFY(mySub->wasInited);
SG_VERIFY(d->hasEvent("instruments-will-init"));
SG_VERIFY(d->hasEvent("instruments-did-init"));
}
void testSuspendResume()
@@ -546,7 +520,6 @@ int main(int argc, char* argv[])
testSuspendResume();
testPropertyRoot();
testAddRemoveAfterInit();
testEmptyGroup();
cout << __FILE__ << ": All tests passed" << endl;
return EXIT_SUCCESS;
+1 -1
View File
@@ -1 +1 @@
2018.3.6
2018.4.0