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

WIP: upgrade to SDL3 #103

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

WIP: upgrade to SDL3 #103

wants to merge 1 commit into from

Conversation

superzazu
Copy link
Contributor

@superzazu superzazu commented Dec 21, 2024

Hello!

I worked on this for one of my projects, and I figured I might as well open a PR, even if the work is not finished. For now, the focus was to get it to work with SDL3 while minimising changes (that means API changes such as returning bools instead of ints etc. was not done).

To do list:

  • base upgrade: both example programs work
  • update CMakeLists.txt: I only replaced occurrences of "SDL2" with "SDL3", just enough to make it compile to test my changes (I'm not very good at writing CMake code...)
  • how to handle SHN_TYPE_U16**?
  • in timidity.c, do_song_load(), buffer size is incorrect (was taken from AudioSpec), I've hardcoded it to 4096 (to make it compile)
  • test every file format (I have only tested WAV, AIFF, MP3 & OGG files)
  • update GitHub workflow
  • MSVC (x86) and MSVC (ARM64) builds do not work

Some things I would like to point out:

  • I really am not familiar with SDL_TLS** & SDL_SIMD** functions, so there's a good chance I made some mistakes there
  • I removed the ability of reading from standard I/O in example program (because SDL_RWFromFP has been removed)

Have a good day!

CMakeLists.txt Outdated Show resolved Hide resolved
src/SDL_sound_aiff.c Outdated Show resolved Hide resolved
src/SDL_sound.c Outdated Show resolved Hide resolved
src/SDL_sound.c Outdated Show resolved Hide resolved
@superzazu superzazu force-pushed the SDL3 branch 3 times, most recently from 2c3e1bb to c35a531 Compare December 21, 2024 11:22
@sezero
Copy link
Collaborator

sezero commented Dec 21, 2024

Here is a patch in git am format that makes things configure using cmake and build cleanly for me:
0001.patch.txt

And no, I don't think it is complete..

P.S.: The patch is incremental, i.e. it is against your branch..

@superzazu
Copy link
Contributor Author

Here is a patch in git am format that makes things configure using cmake and build cleanly for me: 0001.patch.txt

And no, I don't think it is complete..

P.S.: The patch is incremental, i.e. it is against your branch..

Thank you! I added your commit to the branch

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

Thank you! I added your commit to the branch

You're welcome. Minor nit:

--- a/src/SDL_sound.h
+++ b/src/SDL_sound.h
@@ -72,5 +72,5 @@
 
-#define SOUND_VER_MAJOR 2
+#define SOUND_VER_MAJOR 3
 #define SOUND_VER_MINOR 0
-#define SOUND_VER_PATCH 3
+#define SOUND_VER_PATCH 0
 #endif

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

For the tls thing, maybe do what sdl2-compat does? Like the following? (not tested)

diff --git a/src/SDL_sound.c b/src/SDL_sound.c
index bacfc02..461e374 100644
--- a/src/SDL_sound.c
+++ b/src/SDL_sound.c
@@ -94,2 +94,15 @@ typedef struct
 
+static SDL_TLSID SDL_TLSCreate(void)
+{
+    SDL_TLSID tlsid;
+    tlsid.value = 0;  /* zero, so that SDL3 creates a new TLSID. */
+    /* this will create the new ID when it sees a zero, and just set a
+       harmless NULL in the slot for this thread, which is what SDL_TLSGet
+       will return if nothing was ever set. */
+    if (!SDL_SetTLS(&tlsid, NULL, NULL)) {
+        return 0;  /* probably out of memory. */
+    }
+    return tlsid.value;
+}
+
 static Sound_Sample *sample_list = NULL;  /* this is a linked list. */
@@ -129,3 +142,3 @@ int Sound_Init(void)
 
-    // tlsid_errmsg = SDL_TLSCreate();
+    tlsid_errmsg = SDL_TLSCreate();
 
@@ -176,3 +189,3 @@ int Sound_Quit(void)
 
-    // tlsid_errmsg = 0;
+    tlsid_errmsg = 0;
 

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

P.S.: I created a new stable-2.0 branch, so that main focuses on SDL3 from now on.

@superzazu
Copy link
Contributor Author

For the tls thing, maybe do what sdl2-compat does? Like the following? (not tested)

diff --git a/src/SDL_sound.c b/src/SDL_sound.c
index bacfc02..461e374 100644
--- a/src/SDL_sound.c
+++ b/src/SDL_sound.c
@@ -94,2 +94,15 @@ typedef struct
 
+static SDL_TLSID SDL_TLSCreate(void)
+{
+    SDL_TLSID tlsid;
+    tlsid.value = 0;  /* zero, so that SDL3 creates a new TLSID. */
+    /* this will create the new ID when it sees a zero, and just set a
+       harmless NULL in the slot for this thread, which is what SDL_TLSGet
+       will return if nothing was ever set. */
+    if (!SDL_SetTLS(&tlsid, NULL, NULL)) {
+        return 0;  /* probably out of memory. */
+    }
+    return tlsid.value;
+}
+
 static Sound_Sample *sample_list = NULL;  /* this is a linked list. */
@@ -129,3 +142,3 @@ int Sound_Init(void)
 
-    // tlsid_errmsg = SDL_TLSCreate();
+    tlsid_errmsg = SDL_TLSCreate();
 
@@ -176,3 +189,3 @@ int Sound_Quit(void)
 
-    // tlsid_errmsg = 0;
+    tlsid_errmsg = 0;
 

Good idea! It does not compile, but this does:

diff --git a/src/SDL_sound.c b/src/SDL_sound.c
index bacfc02..aa829b2 100644
--- a/src/SDL_sound.c
+++ b/src/SDL_sound.c
@@ -127,7 +127,8 @@ int Sound_Init(void)
 
     SDL_InitSubSystem(SDL_INIT_AUDIO);
 
-    // tlsid_errmsg = SDL_TLSCreate();
+    tlsid_errmsg.value = 0;
+    BAIL_IF_MACRO(!SDL3_SetTLS(&tlsid_errmsg, NULL, NULL), ERR_OUT_OF_MEMORY, 0);
 
     samplelist_mutex = SDL_CreateMutex();
 
@@ -174,7 +175,7 @@ int Sound_Quit(void)
         SDL_free((void *) available_decoders);
     available_decoders = NULL;
 
-    // tlsid_errmsg = 0;
+    tlsid_errmsg.value = 0;
 
     return 1;
 } /* Sound_Quit */

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

For MSVC build failures, try this:

diff --git a/src/libmodplug/load_mt2.c b/src/libmodplug/load_mt2.c
index c48d9f3..3e22129 100644
--- a/src/libmodplug/load_mt2.c
+++ b/src/libmodplug/load_mt2.c
@@ -358,8 +358,8 @@ BOOL CSoundFile_ReadMT2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
 		}
 	}
 	// Load Instruments
-	SDL_memset(InstrMap, 0, sizeof(InstrMap));
 	_this->m_nInstruments = (pfh->wInstruments < MAX_INSTRUMENTS) ? pfh->wInstruments : MAX_INSTRUMENTS-1;
+	for (j=0; j< 255; j++) InstrMap[j]=NULL;
 	for (j=1; j<=255; j++)
 	{
 		const MT2INSTRUMENT *pmi;
@@ -493,8 +493,8 @@ BOOL CSoundFile_ReadMT2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
 			dwMemPos += 36;
 		}
 	}
-	SDL_memset(SampleMap, 0, sizeof(SampleMap));
 	_this->m_nSamples = (pfh->wSamples < MAX_SAMPLES) ? pfh->wSamples : MAX_SAMPLES-1;
+	for (j=0; j< 256; j++) SampleMap[j]=NULL;
 	for (j=1; j<=256; j++)
 	{
 		const MT2SAMPLE *pms;

@superzazu
Copy link
Contributor Author

For MSVC build failures, try this:

diff --git a/src/libmodplug/load_mt2.c b/src/libmodplug/load_mt2.c
index c48d9f3..3e22129 100644
--- a/src/libmodplug/load_mt2.c
+++ b/src/libmodplug/load_mt2.c
@@ -358,8 +358,8 @@ BOOL CSoundFile_ReadMT2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
 		}
 	}
 	// Load Instruments
-	SDL_memset(InstrMap, 0, sizeof(InstrMap));
 	_this->m_nInstruments = (pfh->wInstruments < MAX_INSTRUMENTS) ? pfh->wInstruments : MAX_INSTRUMENTS-1;
+	for (j=0; j< 255; j++) InstrMap[j]=NULL;
 	for (j=1; j<=255; j++)
 	{
 		const MT2INSTRUMENT *pmi;
@@ -493,8 +493,8 @@ BOOL CSoundFile_ReadMT2(CSoundFile *_this, LPCBYTE lpStream, DWORD dwMemLength)
 			dwMemPos += 36;
 		}
 	}
-	SDL_memset(SampleMap, 0, sizeof(SampleMap));
 	_this->m_nSamples = (pfh->wSamples < MAX_SAMPLES) ? pfh->wSamples : MAX_SAMPLES-1;
+	for (j=0; j< 256; j++) SampleMap[j]=NULL;
 	for (j=1; j<=256; j++)
 	{
 		const MT2SAMPLE *pms;

I tried it ; but it looks like I did something wrong in the workflow file for ARM64 & x86:

CMake Error at CMakeLists.txt:31 (find_package):
  Could not find a configuration file for package "SDL3" that is compatible
  with requested version "".

  The following configuration files were considered but not accepted:

    C:/setupsdl/5e00b17a8b3388ed035aca3d2952dd877a10943d8d21b069970b9fb58c7f5e4b/package/cmake/SDL3Config.cmake, version: 3.1.7 (32bit)

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

I tried it ; but it looks like I did something wrong in the workflow file for ARM64 & x86:

CMake Error at CMakeLists.txt:31 (find_package):
  Could not find a configuration file for package "SDL3" that is compatible
  with requested version "".

  The following configuration files were considered but not accepted:

    C:/setupsdl/5e00b17a8b3388ed035aca3d2952dd877a10943d8d21b069970b9fb58c7f5e4b/package/cmake/SDL3Config.cmake, version: 3.1.7 (32bit)

@madebr to rescue..

@superzazu
Copy link
Contributor Author

I guess the problem is with the cross-compilation to x86/ARM64: when building the project, it looks like CMake still tries to build for x64 (it finds the x86 SDL lib but says it can't find a compatible version)

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

@superzazu: Can you please rebase to current main: I hand-picked three commits, so only the conflicts will be (1) the UTF-8'ization in SDL_sound_aiff.c which is now in, (2) the memset change to libmodplug/load_mt2.c which is now in, and (3) the cmake_minimum_required() statement which had a change 3.0...3.5 -> 3.0...3.10, which should be easy to resolve.

@superzazu
Copy link
Contributor Author

superzazu commented Dec 22, 2024

@superzazu: Can you please rebase to current main: I hand-picked three commits, so only the conflicts will be (1) the UTF-8'ization in SDL_sound_aiff.c which is now in, (2) the memset change to libmodplug/load_mt2.c which is now in, and (3) the cmake_minimum_required() statement which had a change 3.0...3.5 -> 3.0...3.10, which should be easy to resolve.

Done!

EDIT: I had to add cmake_policy(SET CMP0074 NEW) to make the builds work.

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

EDIT: I had to add cmake_policy(SET CMP0074 NEW) to make the builds work.

Do the disabled msvc builds work now?

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

Do the disabled msvc builds work now?

Ugh, looks like they don't. Let's keep it that way though, so that @madebr might help.

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

This seems to revert changes to load_mt2.c. May I force-push to your branch a clean & squashed version of this?

@superzazu
Copy link
Contributor Author

This seems to revert changes to load_mt2.c. May I force-push to your branch a clean & squashed version of this?

Ah yes, it's because of the commit 0193ce4 I've made before the rebase to revert the changes. You can either revert this commit or force-push, as you'd like!

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

OK, squashed and force-pushed: please remember to refresh your local source (or do a fresh clone.)

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

I don't have commit rights

Do you want it? (CC: @icculus)

, but the issue is you're using the Visual Studio generator on Windows, thus targeting always x64. This patch changes this to the Ninja generator.

Applied the patch and force-pushed

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

, but the issue is you're using the Visual Studio generator on Windows, thus targeting always x64. This patch changes this to the Ninja generator.

Applied the patch and force-pushed

Hm, failing again:

Run cmake -S cmake/test -B build_cmake_test  -DCMAKE_PREFIX_PATH="D:\a\SDL_sound\SDL_sound/prefix" -DCMAKE_BUILD_TYPE=Release
-- Building for: Visual Studio 17 2022
-- The C compiler identification is MSVC 19.42.34435.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Enterprise/VC/Tools/MSVC/14.42.34433/bin/Hostx64/x64/cl.exe - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- The following features have been enabled:

 * TEST_SHARED, Test linking with shared library
 * TEST_STATIC, Test linking with static library

-- The following OPTIONAL packages have been found:

 * SDL3, low level access to audio, keyboard, mouse, joystick, and graphics hardware, <https://www.libsdl.org/>

-- The following REQUIRED packages have been found:

 * SDL3_sound,  An abstract soundfile decoder, <https://github.com/icculus/SDL_sound/>

-- Configuring done (7.9s)
CMake Warning:
  Manually-specified variables were not used by the project:

    CMAKE_BUILD_TYPE


-- Generating done (0.0s)
-- Build files have been written to: D:/a/SDL_sound/SDL_sound/build_cmake_test
Change Dir: 'D:/a/SDL_sound/SDL_sound/build_cmake_test'

Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n
MSBuild version 17.12.12+1cce77968 for .NET Framework
Build started 12/22/2024 7:58:59 PM.

Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" on node 1 (default targets).
Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (1) is building "D:\a\SDL_sound\SDL_sound\build_cmake_test\ZERO_CHECK.vcxproj" (2) on node 1 (default targets).
PrepareForBuild:
  Creating directory "x64\Release\ZERO_CHECK\".
  Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://aka.ms/cpp/structured-output for more details.
  Creating directory "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\".
InitializeBuildStatus:
  Creating "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
  Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
CustomBuild:
  1>Checking Build System
FinalizeBuildStatus:
  Deleting file "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\unsuccessfulbuild".
  Touching "x64\Release\ZERO_CHECK\ZERO_CHECK.tlog\ZERO_CHECK.lastbuildstate".
Done Building Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\ZERO_CHECK.vcxproj" (default targets).
Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (1) is building "D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj" (3) on node 1 (default targets).
PrepareForBuild:
  Creating directory "main_shared.dir\Release\".
  Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://aka.ms/cpp/structured-output for more details.
  Creating directory "D:\a\SDL_sound\SDL_sound\build_cmake_test\Release\".
  Creating directory "main_shared.dir\Release\main_shared.tlog\".
InitializeBuildStatus:
  Creating "main_shared.dir\Release\main_shared.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
  Touching "main_shared.dir\Release\main_shared.tlog\unsuccessfulbuild".
CustomBuild:
  Building Custom Rule D:/a/SDL_sound/SDL_sound/cmake/test/CMakeLists.txt
ClCompile:
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\CL.exe /c /IC:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\include /nologo /W3 /WX- /diagnostics:column /O2 /Ob2 /D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"main_shared.dir\Release\\" /Fd"main_shared.dir\Release\vc143.pdb" /external:W0 /Gd /TC /errorReport:queue  /external:I "D:/a/SDL_sound/SDL_sound/prefix/include" D:\a\SDL_sound\SDL_sound\cmake\test\main.c
  main.c
Link:
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"D:\a\SDL_sound\SDL_sound\build_cmake_test\Release\main_shared.exe" /INCREMENTAL:NO /NOLOGO D:\a\SDL_sound\SDL_sound\prefix\lib\SDL3_sound.lib C:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\lib\SDL3.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"D:/a/SDL_sound/SDL_sound/build_cmake_test/Release/main_shared.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:/a/SDL_sound/SDL_sound/build_cmake_test/Release/main_shared.lib" /MACHINE:X64  /machine:x64 main_shared.dir\Release\main.obj
main.obj : error LNK2019: unresolved external symbol SDL_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
main.obj : error LNK2019: unresolved external symbol SDL_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
main.obj : error LNK2019: unresolved external symbol SDL_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
main.obj : error LNK2019: unresolved external symbol SDL_SetMainReady referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
main.obj : error LNK2019: unresolved external symbol Sound_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
main.obj : error LNK2019: unresolved external symbol Sound_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
main.obj : error LNK2019: unresolved external symbol Sound_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
D:\a\SDL_sound\SDL_sound\prefix\lib\SDL3_sound.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
C:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\lib\SDL3.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
D:\a\SDL_sound\SDL_sound\build_cmake_test\Release\main_shared.exe : fatal error LNK1120: 7 unresolved externals [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
Done Building Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj" (default targets) -- FAILED.
Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (1) is building "D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj" (4) on node 1 (default targets).
PrepareForBuild:
  Creating directory "main_static.dir\Release\".
  Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://aka.ms/cpp/structured-output for more details.
  Creating directory "main_static.dir\Release\main_static.tlog\".
InitializeBuildStatus:
  Creating "main_static.dir\Release\main_static.tlog\unsuccessfulbuild" because "AlwaysCreate" was specified.
  Touching "main_static.dir\Release\main_static.tlog\unsuccessfulbuild".
CustomBuild:
  Building Custom Rule D:/a/SDL_sound/SDL_sound/cmake/test/CMakeLists.txt
ClCompile:
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\CL.exe /c /IC:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\include /nologo /W3 /WX- /diagnostics:column /O2 /Ob2 /D _MBCS /D WIN32 /D _WINDOWS /D NDEBUG /D "CMAKE_INTDIR=\"Release\"" /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"main_static.dir\Release\\" /Fd"main_static.dir\Release\vc143.pdb" /external:W0 /Gd /TC /errorReport:queue  /external:I "D:/a/SDL_sound/SDL_sound/prefix/include" D:\a\SDL_sound\SDL_sound\cmake\test\main.c
  main.c
Link:
  C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.42.34433\bin\HostX64\x64\link.exe /ERRORREPORT:QUEUE /OUT:"D:\a\SDL_sound\SDL_sound\build_cmake_test\Release\main_static.exe" /INCREMENTAL:NO /NOLOGO "D:\a\SDL_sound\SDL_sound\prefix\lib\SDL3_sound-static.lib" C:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\lib\SDL3.lib kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /MANIFEST /MANIFESTUAC:"level='asInvoker' uiAccess='false'" /manifest:embed /PDB:"D:/a/SDL_sound/SDL_sound/build_cmake_test/Release/main_static.pdb" /SUBSYSTEM:CONSOLE /TLBID:1 /DYNAMICBASE /NXCOMPAT /IMPLIB:"D:/a/SDL_sound/SDL_sound/build_cmake_test/Release/main_static.lib" /MACHINE:X64  /machine:x64 main_static.dir\Release\main.obj
main.obj : error LNK2019: unresolved external symbol SDL_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
main.obj : error LNK2019: unresolved external symbol SDL_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
main.obj : error LNK2019: unresolved external symbol SDL_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
main.obj : error LNK2019: unresolved external symbol SDL_SetMainReady referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
main.obj : error LNK2019: unresolved external symbol Sound_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
main.obj : error LNK2019: unresolved external symbol Sound_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
main.obj : error LNK2019: unresolved external symbol Sound_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
D:\a\SDL_sound\SDL_sound\prefix\lib\SDL3_sound-static.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
C:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\lib\SDL3.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
D:\a\SDL_sound\SDL_sound\build_cmake_test\Release\main_static.exe : fatal error LNK1120: 7 unresolved externals [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
Done Building Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj" (default targets) -- FAILED.
Done Building Project "D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (default targets) -- FAILED.

Build FAILED.

"D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (default target) (1) ->
"D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj" (default target) (3) ->
(Link target) -> 
  D:\a\SDL_sound\SDL_sound\prefix\lib\SDL3_sound.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  C:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\lib\SDL3.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]


"D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (default target) (1) ->
"D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj" (default target) (4) ->
  D:\a\SDL_sound\SDL_sound\prefix\lib\SDL3_sound-static.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  C:\setupsdl\e39b786efa8a176ed6a337930484ea0d71a70857539b5d330123e17e1e612cf9\package\lib\SDL3.lib : warning LNK4272: library machine type 'ARM64' conflicts with target machine type 'x64' [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]


"D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (default target) (1) ->
"D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj" (default target) (3) ->
(Link target) -> 
  main.obj : error LNK2019: unresolved external symbol SDL_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  main.obj : error LNK2019: unresolved external symbol SDL_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  main.obj : error LNK2019: unresolved external symbol SDL_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  main.obj : error LNK2019: unresolved external symbol SDL_SetMainReady referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  main.obj : error LNK2019: unresolved external symbol Sound_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  main.obj : error LNK2019: unresolved external symbol Sound_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  main.obj : error LNK2019: unresolved external symbol Sound_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]
  D:\a\SDL_sound\SDL_sound\build_cmake_test\Release\main_shared.exe : fatal error LNK1120: 7 unresolved externals [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_shared.vcxproj]


"D:\a\SDL_sound\SDL_sound\build_cmake_test\ALL_BUILD.vcxproj" (default target) (1) ->
"D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj" (default target) (4) ->
  main.obj : error LNK2019: unresolved external symbol SDL_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  main.obj : error LNK2019: unresolved external symbol SDL_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  main.obj : error LNK2019: unresolved external symbol SDL_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  main.obj : error LNK2019: unresolved external symbol SDL_SetMainReady referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  main.obj : error LNK2019: unresolved external symbol Sound_Init referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  main.obj : error LNK2019: unresolved external symbol Sound_Quit referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  main.obj : error LNK2019: unresolved external symbol Sound_GetError referenced in function main [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]
  D:\a\SDL_sound\SDL_sound\build_cmake_test\Release\main_static.exe : fatal error LNK1120: 7 unresolved externals [D:\a\SDL_sound\SDL_sound\build_cmake_test\main_static.vcxproj]

    4 Warning(s)
    16 Error(s)

@madebr
Copy link
Collaborator

madebr commented Dec 22, 2024

Try also replacing ${{ matrix.platform.flags }} with -GNinja in the Verify CMake configuration files step.

cmake/test/CMakeLists.txt Outdated Show resolved Hide resolved
cmake/test/CMakeLists.txt Outdated Show resolved Hide resolved
cmake/test/CMakeLists.txt Outdated Show resolved Hide resolved
src/SDL_sound.h Outdated Show resolved Hide resolved
cmake/SDL3_sound.pc.in Outdated Show resolved Hide resolved
cmake/test/main.c Outdated Show resolved Hide resolved
src/version.rc Outdated Show resolved Hide resolved
src/version.rc Show resolved Hide resolved
@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

Failing again (Didi I apply your suggestions correctly?)

CMake Error at CMakeLists.txt:20 (find_package):
  Could not find a configuration file for package "SDL3_sound" that is
  compatible with requested version "".

  The following configuration files were considered but not accepted:

    D:/a/SDL_sound/SDL_sound/prefix/cmake/SDL3_soundConfig.cmake, version: 3.0.0 (32bit)



-- Configuring incomplete, errors occurred!
Change Dir: 'D:/a/SDL_sound/SDL_sound/build_cmake_test'

Run Build Command(s): "C:/Program Files/Microsoft Visual Studio/2022/Enterprise/MSBuild/Current/Bin/amd64/MSBuild.exe" ALL_BUILD.vcxproj /p:Configuration=Release /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n
MSBuild version 17.12.12+1cce77968 for .NET Framework
MSBUILD : error MSB1009: Project file does not exist.
Switch: ALL_BUILD.vcxproj

Error: Process completed with exit code 1.

set_target_properties(SDL2_sound PROPERTIES MACOSX_RPATH 1)
set_target_properties(SDL2_sound PROPERTIES VERSION ${SDLSOUND_VERSION})
set_target_properties(SDL2_sound PROPERTIES SOVERSION ${SDLSOUND_SOVERSION})
add_library(SDL3_sound SHARED ${SDLSOUND_ALL_SRCS} ${SDLSOUND_SHARED_SRCS})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SDL3 and all SDL3 satellite libraries create a SDL_xxx::SDL_xxx-shared and SDL_xxx::SDL_xxx-static target,
with SDL_xxx::SDL_xxx an alias to one of these (depending on what is available).

Should SDL_sound do the same?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really don't know. I'm not much of a cmake guy as you know :)

Copy link
Collaborator

@madebr madebr Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, you can do a lot with Makefiles ;)

@madebr
Copy link
Collaborator

madebr commented Dec 22, 2024

Failing again (Didi I apply your suggestions correctly?)

#103 (comment) is missing

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

#103 (comment) is missing

Oops, done.

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

Oops, done.

.. and CI is green. Yey !!!

@sezero
Copy link
Collaborator

sezero commented Dec 22, 2024

OK, there are still unresolved suggestions from you: I or @superzazu can do those later, or if you get write permission from @icculus we can leave those to you.

Thanks!

@icculus
Copy link
Owner

icculus commented Dec 23, 2024

I sent an invite.

I've not caught up on this thread yet, but I'll try to soon.

@sezero sezero force-pushed the SDL3 branch 2 times, most recently from f207042 to ec6d222 Compare December 25, 2024 12:56
@sezero
Copy link
Collaborator

sezero commented Dec 25, 2024

I cleaned up several stuff, squashed and rebased to current main: Removed old SDL2 version checks, replaced SIMDRealloc from the one in sdl2-compat, replaced rand/srand use with new SDL3 calls. (Maybe a few other things..)

@sezero
Copy link
Collaborator

sezero commented Dec 25, 2024

For SHN_TYPE_U16**: Maybe the following? (Build-tested only.)

diff --git a/src/SDL_sound_shn.c b/src/SDL_sound_shn.c
index d2e0b79..e705a2b 100644
--- a/src/SDL_sound_shn.c
+++ b/src/SDL_sound_shn.c
@@ -402,11 +402,11 @@ static SDL_INLINE Uint16 cvt_shnftype_to_sdlfmt(Sint16 shntype)
         case SHN_TYPE_S16LH:
             return SDL_AUDIO_S16LE;
 
-        // case SHN_TYPE_U16HL:
-        //     return AUDIO_U16MSB;
+        case SHN_TYPE_U16HL:
+            return SDL_AUDIO_S16BE;
 
-        // case SHN_TYPE_U16LH:
-        //     return AUDIO_U16LSB;
+        case SHN_TYPE_U16LH:
+            return SDL_AUDIO_S16LE;
     } /* switch */
 
     return 0;
@@ -919,18 +919,18 @@ static Uint32 put_to_buffers(Sound_Sample *sample, Uint32 bw)
         case SHN_TYPE_U16HL:
         case SHN_TYPE_U16LH:
         {
-            Uint16 *writebufp = (Uint16 *) shn->backBuffer;
+            Sint16 *writebufp = (Sint16 *) shn->backBuffer;
             if (shn->nchan == 1)
             {
                 for (i = 0; i < nitem; i++)
-                    *writebufp++ = CAPMAXUSHORT(data0[i]);
+                    *writebufp++ = CAPMAXUSHORT(data0[i]) ^ 0x8000;
             } /* if */
             else
             {
                 for (i = 0; i < nitem; i++)
                 {
                     for (chan = 0; chan < shn->nchan; chan++)
-                        *writebufp++ = CAPMAXUSHORT(shn->buffer[chan][i]);
+                        *writebufp++ = CAPMAXUSHORT(shn->buffer[chan][i]) ^ 0x8000;
                 } /* for */
             } /* else */
         } /* case */

@sezero
Copy link
Collaborator

sezero commented Dec 25, 2024

For SHN_TYPE_U16**: Maybe the following? (Build-tested only.)

OK, pushed my shn patch for now.

@sezero
Copy link
Collaborator

sezero commented Dec 25, 2024

About timidity.c, do_song_load() buffer_size: @icculus did the same thing in SDL_mixer, so we should be OK I guess.

Co-authored-by: Anonymous Maarten <[email protected]>
Co-authored-by: Ozkan Sezer <[email protected]>
@sezero
Copy link
Collaborator

sezero commented Dec 26, 2024

@icculus: This should be ready for review.

WAV, AIFF, MP3 & OGG files briefly tested; VOC should work after #104 fix which this PR is already rebased to. Remaining are, if I'm not missing anything, AU and SHN testing.

Edit: MIDI files briefly tested too (remember to configure with -DSDLSOUND_DECODER_MIDI=ON )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants