Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

boost updates & cmake modernization #1166

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
92 changes: 25 additions & 67 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ option(ENABLE_TESTSUITE "Compile testsuite." ON)

if(CMAKE_SYSTEM_NAME MATCHES "Linux")
option(SUPERNOVA "Build with supernova as optional audio synthesis server" ON)
elseif()
else()
option(SUPERNOVA "Build with supernova as optional audio synthesis server" OFF)
endif()

Expand Down Expand Up @@ -296,10 +296,16 @@ endif()
configure_file(common/SC_Version.hpp.in common/SC_Version.hpp)
include_directories(${CMAKE_CURRENT_BINARY_DIR}/common)

file(GLOB_RECURSE ClassLibrary SCClassLibrary/*sc)
file(GLOB_RECURSE HelpSource HelpSource/*)
file(GLOB_RECURSE Sounds sounds/*)
file(GLOB_RECURSE Examples examples/*)


add_subdirectory(server)
add_subdirectory(lang)
add_subdirectory(editors)
add_subdirectory(platform)
add_subdirectory(editors)

if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
install(DIRECTORY include/common include/plugin_interface include/server include/lang
Expand All @@ -311,18 +317,11 @@ if(CMAKE_SYSTEM_NAME MATCHES "Linux" OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
)
endif()

if(APPLE)
# determines the app name and app install location (scappbundlename, scappdir):
include (cmake_modules/MacAppFolder.cmake)

set(auxresourcesdir ${scappauxresourcesdir})

# Some aux files which go in the app's folder
install(FILES README.md README_OS_X.md ChangeLog COPYING AUTHORS MOVED_STUFF.txt
DESTINATION ${scappbundlename}
)
elseif (WIN32)
if (WIN32)
set(auxresourcesdir "SuperCollider")
elseif(APPLE)
include(cmake_modules/MacAppFolder.cmake)
set(auxresourcesdir ${scappbundlename})
else()
set(auxresourcesdir "share/SuperCollider")
endif()
Expand Down Expand Up @@ -360,24 +359,6 @@ if(APPLE)
"EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/SCClassLibrary/${onedirectory} ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/${onedirectory} )" )
endif()
endforeach(onedirectory)
else()
message(STATUS "Will copy SCCLassLibrary to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")

#if directory contains symlinks, unlink them.
if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary")
file(GLOB classlibraryfolders "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/SCClassLibrary/[^.]*")
foreach(onedirectory ${classlibraryfolders})
if(IS_SYMLINK "${onedirectory}")
message(STATUS "Unlinking ${onedirectory}")
install( CODE "EXECUTE_PROCESS(COMMAND unlink ${onedirectory} )" )
endif()
endforeach(onedirectory)
endif()

install(DIRECTORY SCClassLibrary
DESTINATION ${auxresourcesdir}
REGEX ${SCCLASSLIB_EXCLUDE_REGEX} EXCLUDE
)
endif()
else()
install(DIRECTORY SCClassLibrary
Expand All @@ -388,21 +369,21 @@ else()
)
endif()

install(DIRECTORY sounds
DESTINATION ${auxresourcesdir}
)

if(APPLE AND ("${standalone}" STREQUAL ""))
set(exampledir "${scappbundlename}")
else()
set(exampledir "${auxresourcesdir}")
if(NOT APPLE)
install(DIRECTORY sounds DESTINATION ${auxresourcesdir})
endif()

install(DIRECTORY examples
DESTINATION ${exampledir}
PATTERN "*~" EXCLUDE
PATTERN "*#" EXCLUDE
)
set( AdditionalInstallFiles
README.md
README_OS_X.md
ChangeLog
COPYING
AUTHORS
MOVED_STUFF.txt
)

install(DIRECTORY examples DESTINATION ${auxresourcesdir})
install(FILES ${AdditionalInstallFiles} DESTINATION ${auxresourcesdir})

if(INSTALL_HELP)
if(SC_SYMLINK_CLASSLIB AND APPLE)
Expand All @@ -412,33 +393,10 @@ if(INSTALL_HELP)
endif()
install( CODE
"EXECUTE_PROCESS(COMMAND ln -shF ${CMAKE_CURRENT_SOURCE_DIR}/HelpSource ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
else()
message(STATUS "Will copy HelpSource to ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}")
if(APPLE)
if(EXISTS "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
if(IS_SYMLINK "${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
message(STATUS "Unlinking ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource")
install( CODE "EXECUTE_PROCESS(COMMAND unlink ${CMAKE_INSTALL_PREFIX}/${auxresourcesdir}/HelpSource )" )
endif()
endif()
endif()
install(DIRECTORY HelpSource
DESTINATION ${auxresourcesdir}
PATTERN "*~" EXCLUDE
PATTERN "*#" EXCLUDE
)
endif()
endif()


#hid resources directory:
set(HID_HUT_PATH ${auxresourcesdir}/SCClassLibrary/Common/Control/HID_support)

install(DIRECTORY external_libraries/hidapi/hut
DESTINATION ${HID_HUT_PATH}
FILES_MATCHING PATTERN "*.yaml"
)

#############################################
#
# build scdoc help files
Expand Down
27 changes: 14 additions & 13 deletions common/scope_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
#ifndef SC_SCOPE_BUFFER_HPP
#define SC_SCOPE_BUFFER_HPP

#include <atomic>

#include <boost/interprocess/offset_ptr.hpp>
#include <boost/atomic.hpp>

extern "C" {
#include "tlsf.h"
Expand All @@ -31,7 +32,7 @@ extern "C" {
namespace detail_server_shm {

using boost::interprocess::offset_ptr;
using boost::atomic;
using std::atomic;

class scope_buffer_writer;
class scope_buffer_reader;
Expand Down Expand Up @@ -123,7 +124,7 @@ class scope_buffer

bool allocate( scope_buffer_pool & pool, unsigned int channels, unsigned int size )
{
bool available = _status.load( boost::memory_order_relaxed ) == free;
bool available = _status.load( std::memory_order_relaxed ) == free;
if( !available ) return false;

_size = size;
Expand All @@ -138,48 +139,48 @@ class scope_buffer
_state[1].data = _data + asset_size;
_state[2].data = _data + asset_size + asset_size;

_status.store( initialized, boost::memory_order_release );
_status.store( initialized, std::memory_order_release );

return true;
}

void release( scope_buffer_pool & pool )
{
bool allocated = _status.load( boost::memory_order_relaxed ) != free;
bool allocated = _status.load( std::memory_order_relaxed ) != free;
if( !allocated ) return;

pool.deallocate( _data.get() );

_status.store( free, boost::memory_order_release );
_status.store( free, std::memory_order_release );
}

float * write_address() { return _state[_in].data.get(); }

void push( unsigned int frames )
{
_state[_in].frames = frames;
_state[_in].changed.store( true, boost::memory_order_relaxed );
_in = _stage.exchange( _in, boost::memory_order_release );
_state[_in].changed.store( true, std::memory_order_relaxed );
_in = _stage.exchange( _in, std::memory_order_release );
}

// reader interface

bool valid()
{
return _status.load( boost::memory_order_acquire ) == initialized;
return _status.load( std::memory_order_acquire ) == initialized;
}

float * read_address() { return _state[_out].data.get(); }

unsigned int pull()
{
int stage = _stage.load( boost::memory_order_relaxed );
bool changed = _state[stage].changed.load( boost::memory_order_relaxed );
int stage = _stage.load( std::memory_order_relaxed );
bool changed = _state[stage].changed.load( std::memory_order_relaxed );

if( changed )
{
_state[_out].changed.store( false, boost::memory_order_relaxed );
_out = _stage.exchange( _out, boost::memory_order_acquire );
_state[_out].changed.store( false, std::memory_order_relaxed );
_out = _stage.exchange( _out, std::memory_order_acquire );
}

return _state[_out].frames;
Expand Down
Loading