Move some macros out of Audacity.h into various header files

This commit is contained in:
Paul Licameli 2021-04-30 22:48:38 -04:00 committed by Leland Lucius
parent 79b259851f
commit b9ca0acb4a
12 changed files with 70 additions and 56 deletions

View File

@ -89,26 +89,10 @@
#endif
// Increment this every time the prefs need to be reset
// the first part (before the r) indicates the version the reset took place
// the second part (after the r) indicates the number of times the prefs have been reset within the same version
#define AUDACITY_PREFS_VERSION_STRING "1.1.1r1"
// Don't change this unless the file format changes
// in an irrevocable way
#define AUDACITY_FILE_FORMAT_VERSION "1.3.0"
class wxWindow;
// Please try to support unlimited path length instead of using PLATFORM_MAX_PATH!
// Define one constant for maximum path value, so we don't have to do
// platform-specific conditionals everywhere we want to check it.
#define PLATFORM_MAX_PATH 260 // Play it safe for default, with same value as Windows' MAX_PATH.
#ifdef __WXMAC__
#include "configmac.h"
#undef PLATFORM_MAX_PATH
#define PLATFORM_MAX_PATH PATH_MAX
#endif
#ifdef __WXGTK__
@ -116,12 +100,6 @@ class wxWindow;
#define __CONFIG_UNIX_INCLUDED
#include "configunix.h"
#endif
// Some systems do not restrict the path length and therefore PATH_MAX is undefined
#ifdef PATH_MAX
#undef PLATFORM_MAX_PATH
#define PLATFORM_MAX_PATH PATH_MAX
#endif
#endif
#ifdef __WXX11__
@ -129,13 +107,10 @@ class wxWindow;
#define __CONFIG_UNIX_INCLUDED
#include "configunix.h"
#endif
// wxX11 should also get the platform-specific definition of PLATFORM_MAX_PATH, so do not declare here.
#endif
#ifdef __WXMSW__
#include "configwin.h"
#undef PLATFORM_MAX_PATH
#define PLATFORM_MAX_PATH MAX_PATH
#endif
/* The dynamic library import and export for Microsoft Windows.
@ -154,15 +129,6 @@ class wxWindow;
#endif
#endif //_WIN32 || (__CYGWIN__ && __GNUC__)
// Put extra symbol information in the release build, for the purpose of gathering
// profiling information (as from Windows Process Monitor), when there otherwise
// isn't a need for AUDACITY_DLL_API.
#ifdef IS_ALPHA
#define PROFILE_DLL_API AUDACITY_DLL_API
#else
#define PROFILE_DLL_API
#endif
/* The GCC-elf implementation */
#ifdef HAVE_VISIBILITY // this is provided by the configure script, is only
// enabled for suitable GCC versions
@ -178,16 +144,6 @@ class wxWindow;
#endif
#endif
// These macros are used widely, so declared here.
#define QUANTIZED_TIME(time, rate) (floor(((double)(time) * (rate)) + 0.5) / (rate))
// dB - linear amplitude conversions
#define DB_TO_LINEAR(x) (pow(10.0, (x) / 20.0))
#define LINEAR_TO_DB(x) (20.0 * log10(x))
#define MAX_AUDIO (1. - 1./(1<<15))
#define JUST_BELOW_MAX_AUDIO (1.f - 1.f/(1<<14))
// This renames a good use of this C++ keyword that we don't need to review when hunting for leaks.
#define PROHIBITED = delete
@ -197,16 +153,6 @@ class wxWindow;
// pointer like std::unique_ptr or std::shared_ptr.
#define safenew new
// Right to left languages fail in many wx3 dialogs with missing buttons.
// The workaround is to use LTR in those dialogs.
#ifndef __WXMAC__
#define RTL_WORKAROUND( pWnd ) \
if ( gPrefs->Read( "/GUI/RtlWorkaround", true) ) \
pWnd->SetLayoutDirection(wxLayout_LeftToRight);
#else
#define RTL_WORKAROUND( pWnd )
#endif
// Define/undefine _DEBUG based on the (CMake provided) NDEBUG symbol
#if defined(NDEBUG)
#undef _DEBUG

View File

@ -19,6 +19,33 @@
#include "Prefs.h"
#include "MemoryX.h"
// Please try to support unlimited path length instead of using PLATFORM_MAX_PATH!
// Define one constant for maximum path value, so we don't have to do
// platform-specific conditionals everywhere we want to check it.
#define PLATFORM_MAX_PATH 260 // Play it safe for default, with same value as Windows' MAX_PATH.
#ifdef __WXMAC__
#undef PLATFORM_MAX_PATH
#define PLATFORM_MAX_PATH PATH_MAX
#endif
#ifdef __WXGTK__
// Some systems do not restrict the path length and therefore PATH_MAX is undefined
#ifdef PATH_MAX
#undef PLATFORM_MAX_PATH
#define PLATFORM_MAX_PATH PATH_MAX
#endif
#endif
#ifdef __WXX11__
// wxX11 should also get the platform-specific definition of PLATFORM_MAX_PATH, so do not declare here.
#endif
#ifdef __WXMSW__
#undef PLATFORM_MAX_PATH
#define PLATFORM_MAX_PATH MAX_PATH
#endif
class wxFileName;
class wxFileNameWrapper;

View File

@ -13,7 +13,7 @@
#include "Lyrics.h"
#include "AudioIOBase.h"
#include "CommonCommandFlags.h"
#include "Prefs.h" // for RTL_WORKAROUND
#include "prefs/GUISettings.h" // for RTL_WORKAROUND
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectFileIO.h"

View File

@ -714,4 +714,12 @@ public:
}
};
// These macros are used widely, so declared here.
#define QUANTIZED_TIME(time, rate) (floor(((double)(time) * (rate)) + 0.5) / (rate))
// dB - linear amplitude conversions
#define DB_TO_LINEAR(x) (pow(10.0, (x) / 20.0))
#define LINEAR_TO_DB(x) (20.0 * log10(x))
#define MAX_AUDIO (1. - 1./(1<<15))
#endif // __AUDACITY_MEMORY_X_H__

View File

@ -34,7 +34,7 @@
#include "CommonCommandFlags.h"
#include "KeyboardCapture.h"
#include "Prefs.h" // for RTL_WORKAROUND
#include "prefs/GUISettings.h" // for RTL_WORKAROUND
#include "Project.h"
#include "ProjectAudioIO.h"
#include "ProjectAudioManager.h"

View File

@ -31,6 +31,11 @@
#include "Audacity.h"
// Increment this every time the prefs need to be reset
// the first part (before the r) indicates the version the reset took place
// the second part (after the r) indicates the number of times the prefs have been reset within the same version
#define AUDACITY_PREFS_VERSION_STRING "1.1.1r1"
#include "../include/audacity/ComponentInterface.h"
#include "MemoryX.h" // for wxArrayStringEx
#include "widgets/FileConfig.h"

View File

@ -36,6 +36,10 @@ Paul Licameli split from AudacityProject.cpp
#include "wxFileNameWrapper.h"
#include "xml/XMLFileReader.h"
// Don't change this unless the file format changes
// in an irrevocable way
#define AUDACITY_FILE_FORMAT_VERSION "1.3.0"
#undef NO_SHM
#if !defined(__WXMSW__)
#define NO_SHM

View File

@ -38,6 +38,7 @@ It forwards the actual work of doing the commands to the ScreenshotCommand.
#include <wx/tglbtn.h>
#include <wx/window.h>
#include "prefs/GUISettings.h" // for RTL_WORKAROUND
#include "Project.h"
#include "ProjectStatus.h"
#include "ProjectWindow.h"

View File

@ -11,6 +11,7 @@
#ifndef __AUDACITY_SEQUENCE__
#define __AUDACITY_SEQUENCE__
#include "Audacity.h"
#include <vector>
#include <functional>
@ -48,6 +49,15 @@ class SeqBlock {
class BlockArray : public std::vector<SeqBlock> {};
using BlockPtrArray = std::vector<SeqBlock*>; // non-owning pointers
// Put extra symbol information in the release build, for the purpose of gathering
// profiling information (as from Windows Process Monitor), when there otherwise
// isn't a need for AUDACITY_DLL_API.
#ifdef IS_ALPHA
#define PROFILE_DLL_API AUDACITY_DLL_API
#else
#define PROFILE_DLL_API
#endif
class PROFILE_DLL_API Sequence final : public XMLTagHandler{
public:

View File

@ -650,6 +650,7 @@ private:
#include "../AudioIO.h"
#include "../CommonCommandFlags.h"
#include "../Menus.h"
#include "../prefs/GUISettings.h" // for RTL_WORKAROUND
#include "../Project.h"
#include "../ProjectAudioManager.h"
#include "../ShuttleGui.h"

View File

@ -15,4 +15,14 @@ Paul Licameli
#define ENV_DB_KEY (wxT("/GUI/EnvdBRange"))
#define ENV_DB_RANGE 60
// Right to left languages fail in many wx3 dialogs with missing buttons.
// The workaround is to use LTR in those dialogs.
#ifndef __WXMAC__
#define RTL_WORKAROUND( pWnd ) \
if ( gPrefs->Read( "/GUI/RtlWorkaround", true) ) \
pWnd->SetLayoutDirection(wxLayout_LeftToRight);
#else
#define RTL_WORKAROUND( pWnd )
#endif
#endif

View File

@ -33,6 +33,8 @@
#include <wx/arrstr.h>
#include <wx/filename.h>
#include "FileNames.h"
// Length check. Is in part about not supplying malicious strings to file functions.
bool XMLValueChecker::IsGoodString(const wxString & str)
{