/[svn]/linuxsampler/trunk/src/common/global_private.h
ViewVC logotype

Diff of /linuxsampler/trunk/src/common/global_private.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 2012 by iliev, Fri Oct 23 17:53:17 2009 UTC revision 3763 by schoenebeck, Sun Apr 5 20:15:57 2020 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2009 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2020 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 30  Line 30 
30  #include "global.h"  #include "global.h"
31  #include "Exception.h"  #include "Exception.h"
32  #include <sstream>  #include <sstream>
33    #include <algorithm>
34    #include <math.h>
35    
36  #if HAVE_CONFIG_H  #if HAVE_CONFIG_H
37  # include <config.h>  # include <config.h>
# Line 41  Line 43 
43  #  define dmsg(debuglevel,x)  #  define dmsg(debuglevel,x)
44  #endif // CONFIG_DEBUG_LEVEL > 0  #endif // CONFIG_DEBUG_LEVEL > 0
45    
46    #define _strfy(s) #s
47    #define strfy(s) _strfy(s)
48    
49  #define EMMS __asm__ __volatile__ ("emms" ::: "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7")  #define EMMS __asm__ __volatile__ ("emms" ::: "st", "st(1)", "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)", "mm0", "mm1", "mm2", "mm3", "mm4", "mm5", "mm6", "mm7")
50    
51  /// defines globally the bit depth of used samples  /// defines globally the bit depth of used samples
# Line 49  typedef int16_t sample_t; Line 54  typedef int16_t sample_t;
54  // macro to check for a certain version (or newer) of GCC  // macro to check for a certain version (or newer) of GCC
55  #define GNUC_VERSION_PREREQ(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))  #define GNUC_VERSION_PREREQ(major,minor) (__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)))
56    
57  // macro which checks if GCC vector extensions are avialable  #if ( GNUC_VERSION_PREREQ(3,3) && ( defined(__i386__) || defined(__x86_64__) || defined(_ARCH_PPC) ) )
58  #define HAVE_GCC_VECTOR_EXTENSIONS ( GNUC_VERSION_PREREQ(3,3) && ( defined(__i386__) || defined(__x86_64__) || defined(_ARCH_PPC) ) )  #define HAVE_GCC_VECTOR_EXTENSIONS 1
59    #endif
60    
61  #if HAVE_GCC_VECTOR_EXTENSIONS  #if HAVE_GCC_VECTOR_EXTENSIONS
62  // v4sf is used by some routines that make use of GCC vector extensions (ie AudioChannel.cpp)  // v4sf is used by some routines that make use of GCC vector extensions (ie AudioChannel.cpp)
63  typedef float v4sf __attribute__ ((vector_size(16)));  typedef float v4sf __attribute__ ((vector_size(16)));
64  #endif  #endif
65    
66    // circumvents a bug in GCC 4.x which causes a sizeof() expression applied
67    // on a class member to throw a compiler error, i.e. with GCC 4.4:
68    // "object missing in reference to 'LinuxSampler::AbstractEngineChannel::ControllerTable'")
69    // or with GCC 4.0:
70    // "invalid use of non-static data member 'LinuxSampler::AbstractEngineChannel::ControllerTable'"
71    #define _MEMBER_SIZEOF(T_Class, Member) sizeof(((T_Class*)NULL)->Member)
72    
73  /**  /**
74   * Whether a function / method call was successful, or if warnings or even an   * Whether a function / method call was successful, or if warnings or even an
75   * error occured.   * error occured.
# Line 97  inline float ToFloat(const std::string& Line 110  inline float ToFloat(const std::string&
110      return i;      return i;
111  }  }
112    
113    inline std::string ltrim(std::string s) {
114        s.erase(s.begin(), std::find_if(s.begin(), s.end(), [](int ch) {
115            return !std::isspace(ch);
116        }));
117        return s;
118    }
119    
120    inline std::string rtrim(std::string s) {
121        s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
122            return !std::isspace(ch);
123        }).base(), s.end());
124        return s;
125    }
126    
127    inline std::string trim(std::string s) {
128        return ltrim(rtrim(s));
129    }
130    
131  class Runnable {  class Runnable {
132      public:      public:
133          virtual ~Runnable() { }          virtual ~Runnable() { }
# Line 107  extern double GLOBAL_VOLUME; Line 138  extern double GLOBAL_VOLUME;
138  extern int GLOBAL_MAX_VOICES;  extern int GLOBAL_MAX_VOICES;
139  extern int GLOBAL_MAX_STREAMS;  extern int GLOBAL_MAX_STREAMS;
140    
141    //TODO: (hopefully) just a temporary nasty hack for launching gigedit on the main thread on Mac (see comments in gigedit.cpp for details)
142    #if defined(__APPLE__)
143    extern bool g_mainThreadCallbackSupported;
144    extern void (*g_mainThreadCallback)(void* info);
145    extern void* g_mainThreadCallbackInfo;
146    extern bool g_fireMainThreadCallback;
147    #endif
148    
149  // I read with some Linux kernel versions (between 2.4.18 and 2.4.21)  // I read with some Linux kernel versions (between 2.4.18 and 2.4.21)
150  // sscanf() might be buggy regarding parsing of hex characters, so ...  // sscanf() might be buggy regarding parsing of hex characters, so ...
151  int hexToNumber(char hex_digit);  int hexToNumber(char hex_digit);
152  int hexsToNumber(char hex_digit0, char hex_digit1 = '0');  int hexsToNumber(char hex_digit0, char hex_digit1 = '0');
153    
154    std::string backtraceAsString();
155    
156  #endif // __LS_GLOBAL_PRIVATE_H__  #endif // __LS_GLOBAL_PRIVATE_H__

Legend:
Removed from v.2012  
changed lines
  Added in v.3763

  ViewVC Help
Powered by ViewVC