From ea84dd1d6283bcac4a4146762d4f1f6ee3d746e1 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 15:46:21 +0100 Subject: [PATCH 1/8] Activate C++11 for clang Tell clang to compile against the C++11 standard --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 784c2d0ac0..5df5951132 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 2.8) - +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") project(emulationstation-all) #------------------------------------------------------------------------------- From 399c160ca5a6817e6e70cfcd8cc6131d92afd8fb Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 15:50:41 +0100 Subject: [PATCH 2/8] Remove #error in VolumeControl for Mac MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaced #errors in __APPLE__ ifdefs to simply no-op. A proper implementation will need some work to interface with CoreAudio on the Mac which will require some c++ to Obj-C bridging which I don’t know how to do yet. --- es-app/src/VolumeControl.cpp | 10 +++++----- es-app/src/VolumeControl.h | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/es-app/src/VolumeControl.cpp b/es-app/src/VolumeControl.cpp index 989d8e323f..181192819e 100644 --- a/es-app/src/VolumeControl.cpp +++ b/es-app/src/VolumeControl.cpp @@ -18,7 +18,7 @@ std::weak_ptr VolumeControl::sInstance; VolumeControl::VolumeControl() : originalVolume(0), internalVolume(0) #if defined (__APPLE__) - #error TODO: Not implemented for MacOS yet!!! + #elif defined(__linux__) , mixerIndex(0), mixerHandle(nullptr), mixerElem(nullptr), mixerSelemId(nullptr) #elif defined(WIN32) || defined(_WIN32) @@ -68,7 +68,7 @@ void VolumeControl::init() { //initialize audio mixer interface #if defined (__APPLE__) - #error TODO: Not implemented for MacOS yet!!! + #elif defined(__linux__) //try to open mixer device if (mixerHandle == nullptr) @@ -212,7 +212,7 @@ void VolumeControl::deinit() { //deinitialize audio mixer interface #if defined (__APPLE__) - #error TODO: Not implemented for MacOS yet!!! + #elif defined(__linux__) if (mixerHandle != nullptr) { snd_mixer_detach(mixerHandle, mixerCard); @@ -239,7 +239,7 @@ int VolumeControl::getVolume() const int volume = 0; #if defined (__APPLE__) - #error TODO: Not implemented for MacOS yet!!! + return 0; #elif defined(__linux__) if (mixerElem != nullptr) { @@ -333,7 +333,7 @@ void VolumeControl::setVolume(int volume) //store values in internal variables internalVolume = volume; #if defined (__APPLE__) - #error TODO: Not implemented for MacOS yet!!! + return; #elif defined(__linux__) if (mixerElem != nullptr) { diff --git a/es-app/src/VolumeControl.h b/es-app/src/VolumeControl.h index 8f35ea2c27..aead48da1b 100644 --- a/es-app/src/VolumeControl.h +++ b/es-app/src/VolumeControl.h @@ -4,7 +4,7 @@ #include #if defined (__APPLE__) - #error TODO: Not implemented for MacOS yet!!! + #elif defined(__linux__) #include #include @@ -22,7 +22,7 @@ Singleton pattern. Call getInstance() to get an object. class VolumeControl { #if defined (__APPLE__) - #error TODO: Not implemented for MacOS yet!!! + #elif defined(__linux__) static const char * mixerName; static const char * mixerCard; From 0962dc8923d62258930ded1927d9ccf47a459e33 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 15:56:05 +0100 Subject: [PATCH 3/8] Suppress inconsistent missing override warnings More clang combat. Added set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") Should make it easier to spot actual clang errors. --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5df5951132..d764a1ca6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,6 @@ cmake_minimum_required(VERSION 2.8) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-inconsistent-missing-override") project(emulationstation-all) #------------------------------------------------------------------------------- From ed568dd1b0b45cefb1423cfa7941536e442043dd Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 18:33:27 +0100 Subject: [PATCH 4/8] ifndef'd a couple of usings which clang didn't like on OS X Everything appears to work anyway! --- es-app/src/components/TextListComponent.h | 4 +++- es-core/src/components/ImageGridComponent.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/es-app/src/components/TextListComponent.h b/es-app/src/components/TextListComponent.h index 8067cd7391..6c56e1cd84 100644 --- a/es-app/src/components/TextListComponent.h +++ b/es-app/src/components/TextListComponent.h @@ -31,8 +31,10 @@ class TextListComponent : public IList using IList::getTransform; using IList::mSize; using IList::mCursor; +#ifndef __APPLE__ using IList::Entry; - +#endif + public: using IList::size; using IList::isScrolling; diff --git a/es-core/src/components/ImageGridComponent.h b/es-core/src/components/ImageGridComponent.h index b00a6c624b..2dff4f8faa 100644 --- a/es-core/src/components/ImageGridComponent.h +++ b/es-core/src/components/ImageGridComponent.h @@ -21,8 +21,10 @@ class ImageGridComponent : public IList using IList::getTransform; using IList::mSize; using IList::mCursor; - using IList::Entry; - using IList::mWindow; +#ifndef __APPLE__ + using IList::Entry; +#endif + using IList::mWindow; public: using IList::size; From d0ddcb17f15f7424541b1d1bf04ed31220b6adb6 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 18:35:56 +0100 Subject: [PATCH 5/8] ifndef'd a call in Window's ctor that was segfaulting on OS X the mBackgroundOverlay setImage call was causing a later call to an OpenGL method before SDL had been asked to init OpenGL on Mac OS X --- es-core/src/Window.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/es-core/src/Window.cpp b/es-core/src/Window.cpp index 76bb1754e3..3e9754c958 100644 --- a/es-core/src/Window.cpp +++ b/es-core/src/Window.cpp @@ -11,9 +11,18 @@ Window::Window() : mNormalizeNextUpdate(false), mFrameTimeElapsed(0), mFrameCountElapsed(0), mAverageDeltaTime(10), mAllowSleep(true), mSleeping(false), mTimeSinceLastInput(0) { + mHelp = new HelpComponent(this); mBackgroundOverlay = new ImageComponent(this); - mBackgroundOverlay->setImage(":/scroll_gradient.png"); + + +#ifndef __APPLE__ + // This ends up calling some OpenGL methods before SDL has been asked to create a context + // On Mac OS X at least, this causes a EXC_BAD_ACCESS (segfault) + mBackgroundOverlay->setImage(":/scroll_gradient.png"); +#endif + + } Window::~Window() @@ -59,6 +68,9 @@ GuiComponent* Window::peekGui() bool Window::init(unsigned int width, unsigned int height) { + + + if(!Renderer::init(width, height)) { LOG(LogError) << "Renderer failed to initialize!"; @@ -69,6 +81,7 @@ bool Window::init(unsigned int width, unsigned int height) ResourceManager::getInstance()->reloadAll(); + //keep a reference to the default fonts, so they don't keep getting destroyed/recreated if(mDefaultFonts.empty()) { From 57cbb1249fa7f4502310997e166032c1b02bd534 Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 22:33:00 +0100 Subject: [PATCH 6/8] Split some double >'s to make clang happy on OS X e.g. static std::vector > sSoundVector; --- es-core/src/AudioManager.cpp | 4 ++-- es-core/src/AudioManager.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/es-core/src/AudioManager.cpp b/es-core/src/AudioManager.cpp index c75d3c4caa..8e67c88eb5 100644 --- a/es-core/src/AudioManager.cpp +++ b/es-core/src/AudioManager.cpp @@ -3,7 +3,7 @@ #include #include "Log.h" -std::vector> AudioManager::sSoundVector; +std::vector > AudioManager::sSoundVector; SDL_AudioSpec AudioManager::sAudioFormat; std::shared_ptr AudioManager::sInstance; @@ -16,7 +16,7 @@ void AudioManager::mixAudio(void *unused, Uint8 *stream, int len) SDL_memset(stream, 0, len); //iterate through all our samples - std::vector>::const_iterator soundIt = sSoundVector.cbegin(); + std::vector >::const_iterator soundIt = sSoundVector.cbegin(); while (soundIt != sSoundVector.cend()) { std::shared_ptr sound = *soundIt; diff --git a/es-core/src/AudioManager.h b/es-core/src/AudioManager.h index 37b6d9f7b2..4ff2306271 100644 --- a/es-core/src/AudioManager.h +++ b/es-core/src/AudioManager.h @@ -12,7 +12,7 @@ class AudioManager { static SDL_AudioSpec sAudioFormat; - static std::vector> sSoundVector; + static std::vector > sSoundVector; static std::shared_ptr sInstance; static void mixAudio(void *unused, Uint8 *stream, int len); From 28c6c44a5d42d9ee0208fee38c84ec92075af89a Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 22:34:16 +0100 Subject: [PATCH 7/8] Ignore dotfiles when scanning directories Generally a good idea to ignore dot files, but especially important on OS X which spews ._SomeFile files on filesystems which do not natively support HFS+ metadata streams --- es-app/src/SystemData.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 5e2b9b4c2e..6d5542d155 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -185,13 +185,29 @@ void SystemData::populateFolder(FileData* folder) //fyi, folders *can* also match the extension and be added as games - this is mostly just to support higan //see issue #75: https://github.com/Aloshi/EmulationStation/issues/75 + //We'll ignore any filenames starting with a period. + // + //Generally a good idea on unix-ish systems, but especially important on OS X when files are stored + //on a filesystem (e.g. network share) which does not have native support for HFS+ metadata. + // + //In that situation, OS X puts ._SomeFile clutter all over the place. +   + std::string prefix = "."; + isGame = false; - if(std::find(mSearchExtensions.begin(), mSearchExtensions.end(), extension) != mSearchExtensions.end()) + if(std::find(mSearchExtensions.begin(), mSearchExtensions.end(), extension) != mSearchExtensions.end() && + filePath.filename().string().compare(0, prefix.length(), prefix) != 0) { FileData* newGame = new FileData(GAME, filePath.generic_string(), this); folder->addChild(newGame); isGame = true; } + + + if (filePath.filename().string().compare(0, prefix.length(), prefix) == 0) { + std::cout << filePath.filename().string(); + isGame = false; + } //add directories that also do not match an extension as folders if(!isGame && fs::is_directory(filePath)) From 96269a5b48349e517f0452d4c23fe094a604becf Mon Sep 17 00:00:00 2001 From: Chris Date: Sun, 12 Jul 2015 22:37:06 +0100 Subject: [PATCH 8/8] Tidy up test code Oops. Left some cruft behind in dotfile exclusion. --- es-app/src/SystemData.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index 6d5542d155..082c25ed1d 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -191,7 +191,7 @@ void SystemData::populateFolder(FileData* folder) //on a filesystem (e.g. network share) which does not have native support for HFS+ metadata. // //In that situation, OS X puts ._SomeFile clutter all over the place. -   + std::string prefix = "."; isGame = false; @@ -204,11 +204,6 @@ void SystemData::populateFolder(FileData* folder) } - if (filePath.filename().string().compare(0, prefix.length(), prefix) == 0) { - std::cout << filePath.filename().string(); - isGame = false; - } - //add directories that also do not match an extension as folders if(!isGame && fs::is_directory(filePath)) {