shithub: duke3d

Download patch

ref: 9bb4db58a341dedd5fa0f4904b589efdbe3871be
parent: 38b0a0e8cd2cb0d1f3ba0154735c6847a7cbb0c0
author: Tanguy Fautre <tanguy@fautre.com>
date: Sat Feb 15 10:23:39 EST 2020

Chasing MIDI not playing by default on Ubuntu via SDL2-mixer/vcpkg

--- a/Game/src/audiolib/dsl.c
+++ b/Game/src/audiolib/dsl.c
@@ -71,7 +71,9 @@
 {
 	DSL_SetErrorCode(DSL_Ok);
 	
-	if (SDL_InitSubSystem(SDL_INIT_AUDIO|SDL_INIT_NOPARACHUTE) < 0) {
+	if (SDL_InitSubSystem(SDL_INIT_AUDIO|SDL_INIT_NOPARACHUTE) < 0)
+	{
+	    printf("SDL_InitSubSystem: %s", SDL_GetError());
 		DSL_SetErrorCode(DSL_SDLInitFailure);
 		return DSL_Error;
 	}
@@ -167,7 +169,7 @@
 	if (chunksize % blah) chunksize += blah - (chunksize % blah);
 
 	if (Mix_OpenAudio(SampleRate, format, channels, chunksize) < 0) {
-        printf("SDL: failed to open audio: %s\n", SDL_GetError());
+        printf("Mix_OpenAudio: failed to open audio: %s\n", Mix_GetError());
 		DSL_SetErrorCode(DSL_MixerInitFailure);
 		
 		return DSL_Error;
--- a/Game/src/midi/sdl_midi.c
+++ b/Game/src/midi/sdl_midi.c
@@ -26,6 +26,12 @@
 
 int MUSIC_Init(int SoundCard, int Address)
 {
+    if (Mix_Init(MIX_INIT_MID) != MIX_INIT_MID)
+    {
+        printf("Mix_Init: %s\n", Mix_GetError());
+        return MUSIC_Error;
+    }
+
 	if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, 2, 1024)==-1) {
 	    printf("Mix_OpenAudio: %s\n", Mix_GetError());
     }
@@ -119,11 +125,23 @@
     kclose( fd );
     
     //Ok, the file is in memory
-    rw = SDL_RWFromMem((void *) musicDataBuffer, fileSize); 
+    if ((rw = SDL_RWFromMem((void *) musicDataBuffer, fileSize)) == NULL)
+    {
+        printf("SDL_RWFromMem: %s\n", SDL_GetError());
+        return 0;
+    }
     
-    sdlMusic = Mix_LoadMUS_RW(rw, SDL_TRUE);
+    if ((sdlMusic = Mix_LoadMUS_RW(rw, SDL_TRUE)) == NULL)
+    {
+        printf("Mix_LoadMUS_RW: %s\n", Mix_GetError());
+        return 0;
+    }
     
-    Mix_PlayMusic(sdlMusic, (loopflag == MUSIC_PlayOnce) ? 0 : -1);
+    if (Mix_PlayMusic(sdlMusic, (loopflag == MUSIC_PlayOnce) ? 0 : -1) == -1)
+    {
+        printf("Mix_PlayMusic: %s\n", Mix_GetError());
+        return 0;
+    }
     
     return 1;
 }
--- a/README.md
+++ b/README.md
@@ -33,8 +33,9 @@
 ```
 
 **Linux (GCC Makefile)** [![Linux CI Status](https://github.com/GPSnoopy/BelgianChocolateDuke3D/workflows/Linux%20CI/badge.svg)](https://github.com/GPSnoopy/BelgianChocolateDuke3D/actions?query=workflow%3A%22Linux+CI%22)
-```
-> sudo apt-get install libasound2-dev libpulse-dev 
+```bash
+# get all native libraries needed for SDL2 in vcpkg
+> sudo apt-get install libsdl2-dev timidity
 > ./vcpkg_linux.sh
 > ./build_linux.sh
 ```