Merge branch '2.0.x' into master

This commit is contained in:
derselbst 2019-02-07 08:55:24 +01:00
commit aa65624f8c
9 changed files with 75 additions and 21 deletions

View File

@ -77,10 +77,10 @@ option ( enable-readline "compile readline lib line editing (if it is available)
option ( enable-threads "enable multi-threading support (such as parallel voice synthesis)" on )
# Platform specific options
if ( CMAKE_SYSTEM MATCHES "Linux" )
if ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" )
option ( enable-lash "compile LASH support (if it is available)" on )
option ( enable-alsa "compile ALSA support (if it is available)" on )
endif ( CMAKE_SYSTEM MATCHES "Linux" )
endif ( CMAKE_SYSTEM MATCHES "Linux|FreeBSD|DragonFly" )
if ( CMAKE_SYSTEM MATCHES "Darwin" )
option ( enable-coreaudio "compile CoreAudio support (if it is available)" on )
@ -95,7 +95,7 @@ if ( CMAKE_SYSTEM MATCHES "OS2" )
endif ( CMAKE_SYSTEM MATCHES "OS2" )
# Initialize the library directory name suffix.
if (NOT MINGW AND NOT MSVC)
if (NOT MINGW AND NOT MSVC AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD|DragonFly")
if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
set ( _init_lib_suffix "64" )
else ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
@ -465,6 +465,10 @@ else(NOT enable-pkgconfig)
# Mandatory libraries: glib and gthread
pkg_check_modules ( GLIB REQUIRED glib-2.0>=2.6.5 gthread-2.0>=2.6.5 )
if ( GLIB_VERSION VERSION_LESS "2.26" )
message ( WARNING "Your version of glib is very old. This may cause problems with fluidsynth's sample cache on Windows. Consider updating to glib 2.26 or newer!" )
endif ( GLIB_VERSION VERSION_LESS "2.26" )
include ( UnsetPkgConfig )
# Optional features

View File

@ -53,7 +53,11 @@ set (INFO_INSTALL_DIR "share/info" CACHE STRING "The info install dir")
mark_as_advanced (INFO_INSTALL_DIR)
# MAN_INSTALL_DIR - the man pages install dir
set (MAN_INSTALL_DIR "share/man/man1" CACHE STRING "The man pages install dir")
if ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD|DragonFly")
set (MAN_INSTALL_DIR "man/man1" CACHE STRING "The man pages install dir")
else()
set (MAN_INSTALL_DIR "share/man/man1" CACHE STRING "The man pages install dir")
endif()
mark_as_advanced (MAN_INSTALL_DIR)
# SYSCONF_INSTALL_DIR - the config file install dir

View File

@ -298,7 +298,7 @@ new_fluid_file_renderer(fluid_synth_t *synth)
sf_command(dev->sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE);
#else
dev->file = fopen(filename, "wb");
dev->file = FLUID_FOPEN(filename, "wb");
if(dev->file == NULL)
{

View File

@ -32,7 +32,7 @@
#include "fluid_rtkit.h"
#if defined(__linux__) || defined(__APPLE__)
#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__) || defined(__DragonFly__)
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
@ -42,10 +42,17 @@
#include <sys/syscall.h>
#include <sys/resource.h>
#if defined(__FreeBSD__) || defined(__DragonFly__)
#include <pthread_np.h>
#endif
static pid_t _gettid(void)
{
#if defined(__FreeBSD__) || defined(__DragonFly__)
return pthread_getthreadid_np();
#else
return (pid_t) syscall(SYS_gettid);
#endif
}
static int translate_error(const char *name)

View File

@ -4,6 +4,12 @@ cmake_minimum_required(VERSION 3.1)
# which hopefully will be the host compiler
unset(ENV{CC})
# also unset $CFLAGS to avoid passing any cross compilation flags to the host compiler
unset(ENV{CFLAGS})
# linker flags as well
unset(ENV{LDFLAGS})
project (gentables C)
set ( CMAKE_BUILD_TYPE Debug )

View File

@ -92,17 +92,23 @@ static int fluid_midi_file_get_division(fluid_midi_file *midifile);
*/
int fluid_is_midifile(const char *filename)
{
FILE *fp = FLUID_FOPEN(filename, "rb");
FILE *fp;
uint32_t id;
int retcode = FALSE;
do
{
if(fp == NULL)
if(!fluid_file_test(filename, G_FILE_TEST_IS_REGULAR))
{
return retcode;
}
// file seems to exist and is a regular file or a symlink to such
if((fp = FLUID_FOPEN(filename, "rb")) == NULL)
{
return retcode;
}
if(FLUID_FREAD(&id, sizeof(id), 1, fp) != 1)
{
break;

View File

@ -334,17 +334,23 @@ static int fluid_sffile_read_wav(SFData *sf, unsigned int start, unsigned int en
*/
int fluid_is_soundfont(const char *filename)
{
FILE *fp = FLUID_FOPEN(filename, "rb");
FILE *fp;
uint32_t fcc;
int retcode = FALSE;
do
{
if(fp == NULL)
if(!fluid_file_test(filename, G_FILE_TEST_IS_REGULAR))
{
return retcode;
}
// file seems to exist and is a regular file or a symlink to such
if((fp = FLUID_FOPEN(filename, "rb")) == NULL)
{
return retcode;
}
if(FLUID_FREAD(&fcc, sizeof(fcc), 1, fp) != 1)
{
break;

View File

@ -24,7 +24,27 @@
void *default_fopen(const char *path)
{
return FLUID_FOPEN(path, "rb");
FILE* handle;
if(!fluid_file_test(path, G_FILE_TEST_EXISTS))
{
FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Unable to load non-existent file. ('%s')", path);
return NULL;
}
if(!fluid_file_test(path, G_FILE_TEST_IS_REGULAR))
{
FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Refusing to load non-regular file! ('%s')", path);
return NULL;
}
if((handle = FLUID_FOPEN(path, "rb")) == NULL)
{
FLUID_LOG(FLUID_ERR, "fluid_sfloader_load(): Specified file does not exists or insufficient permissions to open it! ('%s')", path);
return NULL;
}
return handle;
}
int default_fclose(void *handle)

View File

@ -374,25 +374,26 @@ fluid_istream_t fluid_socket_get_istream(fluid_socket_t sock);
fluid_ostream_t fluid_socket_get_ostream(fluid_socket_t sock);
/* File access */
#define fluid_stat(_filename, _statbuf) g_stat((_filename), (_statbuf))
#if !GLIB_CHECK_VERSION(2, 26, 0)
/* GStatBuf has not been introduced yet, manually typedef to what they had at that time:
* https://github.com/GNOME/glib/blob/e7763678b56e3be073cc55d707a6e92fc2055ee0/glib/gstdio.h#L98-L115
*/
#if defined(WIN32) || HAVE_WINDOWS_H // somehow reliably mock G_OS_WIN32??
#if defined (_MSC_VER) && !defined(_WIN64)
typedef struct _stat32 fluid_stat_buf_t;
#else
typedef struct _stat fluid_stat_buf_t;
#endif
// Any effort from our side to reliably mock GStatBuf on Windows is in vain. E.g. glib-2.16 is broken as it uses struct stat rather than struct _stat32 on Win x86.
// Disable it (the user has been warned by cmake).
#undef fluid_stat
#define fluid_stat(_filename, _statbuf) (-1)
typedef struct _fluid_stat_buf_t{int st_mtime;} fluid_stat_buf_t;
#else
/* posix, OS/2, etc. */
typedef struct stat fluid_stat_buf_t;
/* posix, OS/2, etc. */
typedef struct stat fluid_stat_buf_t;
#endif
#else
typedef GStatBuf fluid_stat_buf_t;
#endif
#define fluid_stat(_filename, _statbuf) g_stat((_filename), (_statbuf))
#define fluid_file_test g_file_test
/* Profiling */
#if WITH_PROFILING