Skip to content

Commit cef782a

Browse files
committed
alternate iOS implementation. screw this
1 parent dbf3243 commit cef782a

File tree

2 files changed

+19
-15
lines changed

2 files changed

+19
-15
lines changed

CMakeLists.txt

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ endif()
2727

2828
add_subdirectory($ENV{GEODE_SDK} ${CMAKE_CURRENT_BINARY_DIR}/geode)
2929

30-
CPMAddPackage("gh:mackron/miniaudio#f40cf03")
31-
3230
# https://miniaud.io/docs/manual/index.html
3331
# The macOS build should compile cleanly without the need to download any dependencies
3432
# nor link to any libraries or frameworks.
@@ -37,19 +35,9 @@ CPMAddPackage("gh:mackron/miniaudio#f40cf03")
3735
# Compiling through the command line requires linking to -lpthread and -lm.
3836

3937
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "iOS" OR IOS)
40-
# add_library(miniaudio_objcxx INTERFACE)
41-
target_compile_options(miniaudio INTERFACE
42-
$<$<PLATFORM_ID:Darwin>:-x objective-c++>
43-
)
44-
target_link_libraries(${PROJECT_NAME} miniaudio_objcxx)
45-
target_link_libraries(miniaudio PUBLIC
46-
"-framework AudioToolbox"
47-
"-framework CoreAudio"
48-
"-framework CoreFoundation"
49-
pthread
50-
m
51-
)
38+
message(STATUS "Fuck iOS.")
5239
else()
40+
CPMAddPackage("gh:mackron/miniaudio#f40cf03")
5341
target_link_libraries(${PROJECT_NAME} miniaudio)
5442
endif()
5543

src/ui/SongListLayer.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
#include "../Utils.hpp"
66
#include "../SongControl.hpp"
77
#include "../SongManager.hpp"
8+
#ifndef GEODE_IS_IOS
89
#include <miniaudio.h>
10+
#endif
911

1012
#define SAVED(key) geode::Mod::get()->getSavedValue<bool>(key, false)
1113

@@ -605,7 +607,8 @@ bool SongListLayer::songLength(MLRSongCell* a, MLRSongCell* b, const bool revers
605607
}
606608

607609
unsigned int SongListLayer::getLength(const std::string& path, const bool reverse) {
608-
const double extreme = reverse ? std::numeric_limits<double>::min() : std::numeric_limits<double>::max();
610+
const unsigned int extreme = reverse ? std::numeric_limits<unsigned int>::min() : std::numeric_limits<unsigned int>::max();
611+
#ifndef GEODE_IS_IOS
609612
ma_decoder decoder;
610613
if (ma_decoder_init_file(path.c_str(), nullptr, &decoder) != MA_SUCCESS) return extreme;
611614

@@ -620,6 +623,19 @@ unsigned int SongListLayer::getLength(const std::string& path, const bool revers
620623

621624
if (sampleRate == 0) return extreme;
622625
return static_cast<unsigned int>(static_cast<double>(frames) / static_cast<double>(sampleRate));
626+
#else
627+
FMOD::System* system = FMODAudioEngine::get()->m_system;
628+
if (!system) return extreme;
629+
unsigned int temp = extreme;
630+
FMOD::Sound* sound;
631+
FMOD_RESULT resultSoundA = sys->createSound(path.c_str(), FMOD_OPENONLY | FMOD_2D, nullptr, &sound);
632+
if (sound && resultSoundA == FMOD_OK) {
633+
sound->getLength(&temp, FMOD_TIMEUNIT_MS);
634+
sound->release();
635+
return temp;
636+
}
637+
return extreme;
638+
#endif
623639
}
624640

625641
void SongListLayer::update(float) {

0 commit comments

Comments
 (0)