Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d421546
Generic Asset Loading
TheBrokenRail Apr 21, 2025
c93b07e
Load Sounds From Files
TheBrokenRail Apr 21, 2025
da350ca
Some Fixes
TheBrokenRail Apr 21, 2025
6eecdec
Added OGG Vorbis Support
BrentDaMage Apr 21, 2025
225d649
Fix Native Android
TheBrokenRail Apr 21, 2025
5f3ca18
Fix WASM Build
TheBrokenRail Apr 21, 2025
b75625e
Fix macOS Build
TheBrokenRail Apr 21, 2025
a3e92aa
Salvage unmerged changes from cmake-mingw-things
BrentDaMage Apr 21, 2025
b3b8d4d
Bugfixes
BrentDaMage Apr 22, 2025
dd08de3
WIP SoundStream
BrentDaMage Apr 21, 2025
329d77a
Sound Fixes
BrentDaMage Apr 24, 2025
8403fa0
SoundSystem cleanup
BrentDaMage Apr 29, 2025
a7fc246
Added Music
BrentDaMage May 1, 2025
85b877f
Fix Android & macOS Build Issues
BrentDaMage May 1, 2025
4465d0a
Fix Android Building (oops)
BrentDaMage May 1, 2025
f87a6db
SoundStream / Music Fixes
BrentDaMage May 7, 2025
cc0c4ae
Merge branch 'master' into sound-v2
BrentDaMage May 8, 2025
fb1ee5b
Fix unresolved merge conflicts
BrentDaMage May 8, 2025
4015585
Add SoundStreamAL.cpp to CMakeLists.txt
BrentDaMage May 8, 2025
c299a22
Remove leftover "platforms/openal" directory
BrentDaMage May 8, 2025
4c78c56
Fixed building on macOS
BrentDaMage May 8, 2025
fbc7aef
Fix VS Project Paths
BrentDaMage May 9, 2025
e8859aa
SoundStream Abstractions
BrentDaMage May 10, 2025
a0e9f10
Update SoundSystemSL.cpp
BrentDaMage May 10, 2025
4b9223e
Update SoundSystemDS.cpp
BrentDaMage May 10, 2025
55dcfec
SoundStreamAL C++03 Compatibility
BrentDaMage May 10, 2025
165d0e6
for real this time
BrentDaMage May 10, 2025
b956268
More Paulscode Parity
BrentDaMage May 10, 2025
5bc6bb1
Merge branch 'master' into sound-v2
BrentDaMage May 27, 2025
dd44b45
Support for loading from multiple sound/music directories
BrentDaMage May 27, 2025
0ab9a2c
Merge branch 'master' into sound-v2
BrentDaMage Jun 4, 2025
994eca5
Update README.md
BrentDaMage Jun 5, 2025
04953f4
Update README.md
TheBrokenRail Jun 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ jobs:
-sdk macosx \
-configuration "Release (Default)" \
-destination generic/platform=macOS \
GCC_PREPROCESSOR_DEFINITIONS='MISSING_SOUND_DATA $(GCC_PREPROCESSOR_DEFINITIONS)' \
GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \
-quiet \
clean archive
# @NOTE: Newer versions of Xcode will complain and refuse to build old XIB files or target old iOS versions
Expand All @@ -83,7 +83,7 @@ jobs:
# -sdk iphoneos \
# -configuration "Release (iOS)" \
# -destination generic/platform=iOS \
# GCC_PREPROCESSOR_DEFINITIONS='MISSING_SOUND_DATA $(GCC_PREPROCESSOR_DEFINITIONS)' \
# GCC_PREPROCESSOR_DEFINITIONS='$(GCC_PREPROCESSOR_DEFINITIONS)' \
# -quiet \
# clean archive
android:
Expand Down
16 changes: 11 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,12 @@ xcuserdata/
/game/assets/gui/touchgui2.png
/game/assets/item/arrows.png
/game/assets/item/sign.png
# Sound
/game/assets/sound
/game/assets/newsound
/game/assets/sound3
/game/assets/music
/game/assets/newmusic
# Java
/game/assets/terrain/sun.png
/game/assets/terrain/moon.png
Expand Down Expand Up @@ -242,11 +248,11 @@ xcuserdata/
# Ignore options.txt - where your configuration will be saved
/game/options.txt
/game/assetsO
/game/assets/gui/feedback_fill.png
/game/assets/gui/feedback_outer.png
/game/assets/snow.png
/game/assets/mob/pig.png

# CLion
/.idea
/cmake-build-*
/cmake-build-*

# PCM sound extraction
/tools/__pycache__
/tools/venv
19 changes: 13 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,19 @@ This fetches the three dependencies we have:
- [coi-serviceworker](https://github.com/gzuidhof/coi-serviceworker)
- [gles-compatibility-layer](https://github.com/TheBrokenRail/gles-compatibility-layer.git)

2. Load the sound assets into the `sound_data/` folder in the root of the project
by **running the following command**:
* `tools/grabsounds.py /path/to/the/apk/lib/armeabi-v7a/libminecraftpe.so`.

After that, **prepare the assets folder** from the apk. You will need it for the platform specific
build.
2. Copy the assets (including sounds and textures) into the necessary folders within the project.<br>
Do this by performing <ins>**one**</ins> of the following:
- To extract all assets from _Pocket Edition_:
- **Run the following command**:
- `tools/extract_apk.py /path/to/the/apk`
- You can also run it with an interactive GUI by not providing arguments.
- To extract only the sounds from _Pocket Edition_:
- **Run the following command**:
- `tools/grabsounds.py /path/to/the/apk/lib/armeabi-v7a/libminecraftpe.so`
- You will need to extract textures and other assets manually.
- To retrieve only the sounds from _Java Edition_:
- Locate the `resources` directory in the `.minecraft` folder and copy its contents (e.g. `music`, `sound`, etc.) into the `game/assets/` directory of the project.
- You will need to extract textures and other assets manually from _Pocket Edition_.

## Building

Expand Down
19 changes: 19 additions & 0 deletions platforms/android/AppPlatform_android.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,3 +357,22 @@ int AppPlatform_android::getKeyboardUpOffset()
// For now we'll just return 1/2 of the screen height. That ought to cover most cases.
return m_ScreenHeight / 2;
}

AssetFile AppPlatform_android::readAssetFile(const std::string& str, bool quiet) const
{
std::string realPath = str;
if (realPath.size() && realPath[0] == '/')
// trim it off
realPath = realPath.substr(1);

AAsset* asset = AAssetManager_open(m_app->activity->assetManager, str.c_str(), AASSET_MODE_BUFFER);
if (!asset) {
if (!quiet) LOG_E("File %s couldn't be opened", realPath.c_str());
return AssetFile();
}
size_t cnt = AAsset_getLength(asset);
unsigned char* buffer = new unsigned char[cnt];
AAsset_read(asset, (void*)buffer, cnt);
AAsset_close(asset);
return AssetFile(ssize_t(cnt), buffer);
}
2 changes: 2 additions & 0 deletions platforms/android/AppPlatform_android.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class AppPlatform_android : public AppPlatform
void initAndroidApp(android_app* ptr);
void setExternalStoragePath(const std::string& path);

AssetFile readAssetFile(const std::string&, bool) const override;

private:
void changeKeyboardVisibility(bool bShown);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@
8426107E2AE989730065905F /* RakNetInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD64E2AC810620006A435 /* RakNetInstance.cpp */; };
8426107F2AE989730065905F /* ServerSideNetworkHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 840DD6502AC810620006A435 /* ServerSideNetworkHandler.cpp */; };
842610882AE98A4C0065905F /* libRakNet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 84FFBD7E2ACA2876005A8CCF /* libRakNet.a */; };
8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */; };
8435BB1A2DCD47F400D38282 /* SoundStreamAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */; };
8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; };
8441F9962DB4E911005977BD /* SoundSystemAL.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8441F9862DB4E911005977BD /* SoundSystemAL.cpp */; };
8443B6EA2A98675F0086730C /* libSDL2.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8443B6E92A98675F0086730C /* libSDL2.a */; };
Expand Down Expand Up @@ -393,6 +395,11 @@
849FF0DC2AF465340013BAE3 /* char.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018E2AF3A28B009B9555 /* char.png */; };
849FF0DD2AF465340013BAE3 /* particles.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E0018F2AF3A28B009B9555 /* particles.png */; };
849FF0DE2AF465340013BAE3 /* terrain.png in Resources */ = {isa = PBXBuildFile; fileRef = 84E001912AF3A28B009B9555 /* terrain.png */; };
84A2FF162DB5B7B70090CE3E /* AssetFile.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */; };
84A2FF182DB61D440090CE3E /* SoundPathRepository.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF172DB61D3A0090CE3E /* SoundPathRepository.hpp */; };
84A2FF1A2DB61D720090CE3E /* SoundPathRepository.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A2FF192DB61D6D0090CE3E /* SoundPathRepository.cpp */; };
84A2FF1C2DB61F650090CE3E /* SoundStream.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84A2FF1B2DB61F610090CE3E /* SoundStream.hpp */; };
84A2FF1E2DB61F6C0090CE3E /* SoundStream.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84A2FF1D2DB61F690090CE3E /* SoundStream.cpp */; };
84AA8B502B32F39A003F5B82 /* BinaryHeap.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8B482B32F39A003F5B82 /* BinaryHeap.cpp */; };
84AA8B512B32F39A003F5B82 /* BinaryHeap.hpp in Headers */ = {isa = PBXBuildFile; fileRef = 84AA8B492B32F39A003F5B82 /* BinaryHeap.hpp */; };
84AA8B522B32F39A003F5B82 /* Node.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 84AA8B4A2B32F39A003F5B82 /* Node.cpp */; };
Expand Down Expand Up @@ -1776,6 +1783,8 @@
84336BA52B1EB57E00097DB0 /* Settings_iOS_Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_iOS_Debug.xcconfig; path = ../Configuration/Settings_iOS_Debug.xcconfig; sourceTree = "<group>"; };
84336BA82B1EB88500097DB0 /* Settings_macOS.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_macOS.xcconfig; path = ../Configuration/Settings_macOS.xcconfig; sourceTree = "<group>"; };
84336BA92B1EB9C200097DB0 /* Settings_macOS_Debug.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Settings_macOS_Debug.xcconfig; path = ../Configuration/Settings_macOS_Debug.xcconfig; sourceTree = "<group>"; };
8435BB172DCD47F400D38282 /* SoundStreamAL.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SoundStreamAL.hpp; sourceTree = "<group>"; };
8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundStreamAL.cpp; sourceTree = "<group>"; };
8441F9852DB4E911005977BD /* CustomSoundSystem.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = CustomSoundSystem.hpp; sourceTree = "<group>"; };
8441F9862DB4E911005977BD /* SoundSystemAL.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundSystemAL.cpp; sourceTree = "<group>"; };
8443B6E92A98675F0086730C /* libSDL2.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libSDL2.a; path = /opt/local/lib/libSDL2.a; sourceTree = "<absolute>"; };
Expand Down Expand Up @@ -1925,6 +1934,11 @@
849488352C9284DA006DB706 /* Lighting.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = Lighting.hpp; sourceTree = "<group>"; };
8495E4872AF0905B00A06901 /* AppPlatform_iOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppPlatform_iOS.h; sourceTree = "<group>"; };
8495E4882AF0905B00A06901 /* AppPlatform_iOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppPlatform_iOS.mm; sourceTree = "<group>"; };
84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = AssetFile.hpp; sourceTree = "<group>"; };
84A2FF172DB61D3A0090CE3E /* SoundPathRepository.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SoundPathRepository.hpp; sourceTree = "<group>"; };
84A2FF192DB61D6D0090CE3E /* SoundPathRepository.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundPathRepository.cpp; sourceTree = "<group>"; };
84A2FF1B2DB61F610090CE3E /* SoundStream.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; path = SoundStream.hpp; sourceTree = "<group>"; };
84A2FF1D2DB61F690090CE3E /* SoundStream.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SoundStream.cpp; sourceTree = "<group>"; };
84AA8B482B32F39A003F5B82 /* BinaryHeap.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BinaryHeap.cpp; sourceTree = "<group>"; };
84AA8B492B32F39A003F5B82 /* BinaryHeap.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; path = BinaryHeap.hpp; sourceTree = "<group>"; };
84AA8B4A2B32F39A003F5B82 /* Node.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Node.cpp; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2314,14 +2328,15 @@
840DD57D2AC810620006A435 /* app */ = {
isa = PBXGroup;
children = (
840DD57E2AC810620006A435 /* App.cpp */,
840DD57F2AC810620006A435 /* App.hpp */,
840DD5802AC810620006A435 /* AppPlatform.cpp */,
840DD57E2AC810620006A435 /* App.cpp */,
840DD5812AC810620006A435 /* AppPlatform.hpp */,
840DD5822AC810620006A435 /* Minecraft.cpp */,
840DD5802AC810620006A435 /* AppPlatform.cpp */,
84A2FF152DB5B7B70090CE3E /* AssetFile.hpp */,
840DD5832AC810620006A435 /* Minecraft.hpp */,
840DD5842AC810620006A435 /* NinecraftApp.cpp */,
840DD5822AC810620006A435 /* Minecraft.cpp */,
840DD5852AC810620006A435 /* NinecraftApp.hpp */,
840DD5842AC810620006A435 /* NinecraftApp.cpp */,
);
path = app;
sourceTree = "<group>";
Expand Down Expand Up @@ -2531,15 +2546,19 @@
840DD61A2AC810620006A435 /* sound */ = {
isa = PBXGroup;
children = (
840DD61B2AC810620006A435 /* SoundData.cpp */,
84A2FF172DB61D3A0090CE3E /* SoundPathRepository.hpp */,
84A2FF192DB61D6D0090CE3E /* SoundPathRepository.cpp */,
840DD61C2AC810620006A435 /* SoundData.hpp */,
840DD61B2AC810620006A435 /* SoundData.cpp */,
840DD61D2AC810620006A435 /* SoundDefs.hpp */,
840DD61E2AC810620006A435 /* SoundEngine.cpp */,
840DD61F2AC810620006A435 /* SoundEngine.hpp */,
840DD6202AC810620006A435 /* SoundRepository.cpp */,
840DD61E2AC810620006A435 /* SoundEngine.cpp */,
840DD6212AC810620006A435 /* SoundRepository.hpp */,
840DD6222AC810620006A435 /* SoundSystem.cpp */,
840DD6202AC810620006A435 /* SoundRepository.cpp */,
84A2FF1B2DB61F610090CE3E /* SoundStream.hpp */,
84A2FF1D2DB61F690090CE3E /* SoundStream.cpp */,
840DD6232AC810620006A435 /* SoundSystem.hpp */,
840DD6222AC810620006A435 /* SoundSystem.cpp */,
);
path = sound;
sourceTree = "<group>";
Expand Down Expand Up @@ -3383,6 +3402,8 @@
isa = PBXGroup;
children = (
8441F9852DB4E911005977BD /* CustomSoundSystem.hpp */,
8435BB172DCD47F400D38282 /* SoundStreamAL.hpp */,
8435BB182DCD47F400D38282 /* SoundStreamAL.cpp */,
8441F9862DB4E911005977BD /* SoundSystemAL.cpp */,
);
path = openal;
Expand Down Expand Up @@ -4081,9 +4102,11 @@
84AA8C232B32F3F3003F5B82 /* ItemInHandRenderer.hpp in Headers */,
84AA8C272B32F3F3003F5B82 /* LevelRenderer.hpp in Headers */,
84AA8C292B32F3F3003F5B82 /* LightLayer.hpp in Headers */,
84A2FF182DB61D440090CE3E /* SoundPathRepository.hpp in Headers */,
84AA8C2B2B32F3F3003F5B82 /* LightUpdate.hpp in Headers */,
84AA8C2D2B32F3F3003F5B82 /* PatchManager.hpp in Headers */,
84AA8C2F2B32F3F3003F5B82 /* RenderChunk.hpp in Headers */,
84A2FF162DB5B7B70090CE3E /* AssetFile.hpp in Headers */,
84AA8C312B32F3F3003F5B82 /* RenderList.hpp in Headers */,
84AA8C332B32F3F3003F5B82 /* Tesselator.hpp in Headers */,
84AA8C342B32F3F3003F5B82 /* Texture.hpp in Headers */,
Expand All @@ -4092,6 +4115,7 @@
84AA8C392B32F3F3003F5B82 /* VertexPT.hpp in Headers */,
84AA8C5B2B32F535003F5B82 /* ChickenModel.hpp in Headers */,
84AA8C5D2B32F535003F5B82 /* CowModel.hpp in Headers */,
84A2FF1C2DB61F650090CE3E /* SoundStream.hpp in Headers */,
84AA8C5F2B32F535003F5B82 /* CreeperModel.hpp in Headers */,
84AA8C672B32F535003F5B82 /* ModelPart.hpp in Headers */,
84AA8C692B32F535003F5B82 /* PigModel.hpp in Headers */,
Expand Down Expand Up @@ -4856,6 +4880,7 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
8435BB192DCD47F400D38282 /* SoundStreamAL.cpp in Sources */,
84EAE8F72AF1EAFA000894E8 /* main.cpp in Sources */,
841DD8772AF8AA7A00AA3B66 /* AppPlatform_sdl_base.cpp in Sources */,
841DD8782AF8AA7A00AA3B66 /* AppPlatform_sdl.cpp in Sources */,
Expand All @@ -4877,6 +4902,7 @@
8441F98F2DB4E911005977BD /* SoundSystemAL.cpp in Sources */,
84CEF0032AE3C97D006C5829 /* EAGLView.m in Sources */,
8495E4892AF0905B00A06901 /* AppPlatform_iOS.mm in Sources */,
8435BB1A2DCD47F400D38282 /* SoundStreamAL.cpp in Sources */,
8488C08A2B1EDD4F001AEC4F /* ShowKeyboardView.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -4984,6 +5010,7 @@
84AA8C182B32F3F3003F5B82 /* Font.cpp in Sources */,
84AA8C1A2B32F3F3003F5B82 /* Frustum.cpp in Sources */,
84AA8C1C2B32F3F3003F5B82 /* FrustumCuller.cpp in Sources */,
84A2FF1A2DB61D720090CE3E /* SoundPathRepository.cpp in Sources */,
84AA8C1E2B32F3F3003F5B82 /* GameRenderer.cpp in Sources */,
84AA8C202B32F3F3003F5B82 /* GrassColor.cpp in Sources */,
84AA8C222B32F3F3003F5B82 /* ItemInHandRenderer.cpp in Sources */,
Expand All @@ -4998,6 +5025,7 @@
84AA8C302B32F3F3003F5B82 /* RenderList.cpp in Sources */,
84AA8C322B32F3F3003F5B82 /* Tesselator.cpp in Sources */,
84AA8C352B32F3F3003F5B82 /* Textures.cpp in Sources */,
84A2FF1E2DB61F6C0090CE3E /* SoundStream.cpp in Sources */,
84AA8C372B32F3F3003F5B82 /* TileRenderer.cpp in Sources */,
84AA8C3A2B32F3F3003F5B82 /* WaterSideTexture.cpp in Sources */,
84AA8C3B2B32F3F3003F5B82 /* WaterTexture.cpp in Sources */,
Expand Down
27 changes: 27 additions & 0 deletions platforms/sdl/base/AppPlatform_sdl_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,4 +397,31 @@ void AppPlatform_sdl_base::handleControllerAxisEvent(SDL_JoystickID controllerIn
Controller::feedTrigger(2, val);
break;
}
}

AssetFile AppPlatform_sdl_base::readAssetFile(const std::string& str, bool quiet) const
{
std::string path = getAssetPath(str);
SDL_RWops *io = SDL_RWFromFile(path.c_str(), "rb");
// Open File
if (!io)
{
if (!quiet) LOG_W("Couldn't find asset file: %s", path.c_str());
return AssetFile();
}
// Get File Size
int64_t size = SDL_RWsize(io);
if (size < 0)
{
if (!quiet) LOG_E("Error determining the size of the asset file!");
SDL_RWclose(io);
return AssetFile();
}
// Read Data
unsigned char *buf = new unsigned char[size];
SDL_RWread(io, buf, size, 1);
// Close File
SDL_RWclose(io);
// Return
return AssetFile(size, buf);
}
3 changes: 3 additions & 0 deletions platforms/sdl/base/AppPlatform_sdl_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class AppPlatform_sdl_base : public AppPlatform
void handleKeyEvent(int key, uint8_t state);
void handleButtonEvent(SDL_JoystickID controllerIndex, uint8_t button, uint8_t state);
void handleControllerAxisEvent(SDL_JoystickID controllerIndex, uint8_t axis, int16_t value);

// Read Sounds
AssetFile readAssetFile(const std::string&, bool) const override;
protected:
SDL_Window *_window;
private:
Expand Down
14 changes: 6 additions & 8 deletions platforms/sound/directsound/CustomSoundSystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ class SoundSystemDS : public SoundSystem
public:
SoundSystemDS();
~SoundSystemDS();
virtual bool isAvailable();
virtual void setListenerPos(float x, float y, float z);
virtual void setListenerAngle(float yaw, float pitch);
virtual void load(const std::string& sound);
virtual void play(const std::string& sound);
virtual void pause(const std::string& sound);
virtual void stop(const std::string& sound);
virtual void playAt(const SoundDesc& sound, float x, float y, float z, float a, float b);
virtual bool isAvailable() override;
virtual void setListenerPos(const Vec3& pos) override;
virtual void setListenerAngle(const Vec2& rot) override;
virtual void playAt(const SoundDesc& sound, const Vec3& pos, float volume, float pitch) override;
private:
WAVEFORMATEX _getWaveFormat(const PCMSoundHeader& header, float pitch) const;
void _cleanSources();

struct BufferInfo
{
Expand Down
Loading