git: 7059a13adc92 - main - audio/sdl2_sound: add port: Abstract SDL soundfile decoder

From: Dmitry Marakasov <amdmi3_at_FreeBSD.org>
Date: Thu, 31 Mar 2022 18:37:01 UTC
The branch main has been updated by amdmi3:

URL: https://cgit.FreeBSD.org/ports/commit/?id=7059a13adc92a19a89653671e065e9d2dd968a4c

commit 7059a13adc92a19a89653671e065e9d2dd968a4c
Author:     Dmitry Marakasov <amdmi3@FreeBSD.org>
AuthorDate: 2022-03-31 14:45:59 +0000
Commit:     Dmitry Marakasov <amdmi3@FreeBSD.org>
CommitDate: 2022-03-31 18:36:12 +0000

    audio/sdl2_sound: add port: Abstract SDL soundfile decoder
    
    - Add the latest version of sdl_sound with support for
      USE_SDL=sound2.
    - Note that this is sdl2-only library, so audio/sdl_sound,
      which is sdl1-only library, remains in the tree and is
      not affected. I've had to rename playsound binary this
      port also installs to avoid the conflict.
    - The library now contains all the decoder code, so no external
      depends and options are needed any longer. I've added MIDI
      option though, since upstream has it disabled by default due
      to different license.
---
 Mk/Uses/sdl.mk             |  7 +++++--
 audio/Makefile             |  1 +
 audio/sdl2_sound/Makefile  | 43 +++++++++++++++++++++++++++++++++++++++++++
 audio/sdl2_sound/distinfo  |  3 +++
 audio/sdl2_sound/pkg-descr | 14 ++++++++++++++
 audio/sdl2_sound/pkg-plist |  6 ++++++
 6 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/Mk/Uses/sdl.mk b/Mk/Uses/sdl.mk
index 14631bd8735b..76839cd5cc28 100644
--- a/Mk/Uses/sdl.mk
+++ b/Mk/Uses/sdl.mk
@@ -3,7 +3,7 @@
 # Feature:	sdl
 # Usage:	USES=sdl
 #		USE_SDL=sdl console gfx image mixer mm net pango sound ttf
-#		        sdl2 gfx2 image2 mixer2 net2 ttf2
+#		        sdl2 gfx2 image2 mixer2 net2 sound2 ttf2
 #
 #		USE_SDL specifies which SDL components to add as dependencies.
 #		Not specifying USE_SDL with USES=sdl is an error.
@@ -47,7 +47,7 @@ _SDL_ttf_LIB_DEPENDS=		libSDL_ttf.so:graphics/sdl_ttf
 _SDL_ttf_REQUIRES=		sdl
 
 # These are the current supported SDL2 modules
-_SDL_USE_ALL+=	sdl2 gfx2 image2 mixer2 net2 ttf2
+_SDL_USE_ALL+=	sdl2 gfx2 image2 mixer2 net2 sound2 ttf2
 
 _SDL_sdl2_LIB_DEPENDS=		libSDL2.so:devel/sdl20
 
@@ -63,6 +63,9 @@ _SDL_mixer2_REQUIRES=		sdl2
 _SDL_net2_LIB_DEPENDS=		libSDL2_net.so:net/sdl2_net
 _SDL_net2_REQUIRES=		sdl2
 
+_SDL_sound2_LIB_DEPENDS=	libSDL2_sound.so:audio/sdl2_sound
+_SDL_sound2_REQUIRES=		sdl2
+
 _SDL_ttf2_LIB_DEPENDS=		libSDL2_ttf.so:graphics/sdl2_ttf
 _SDL_ttf2_REQUIRES=		sdl2
 
diff --git a/audio/Makefile b/audio/Makefile
index e9bfa067701c..ddad344eed75 100644
--- a/audio/Makefile
+++ b/audio/Makefile
@@ -718,6 +718,7 @@
     SUBDIR += schismtracker
     SUBDIR += screcord-lv2
     SUBDIR += sdl2_mixer
+    SUBDIR += sdl2_sound
     SUBDIR += sdl_mixer
     SUBDIR += sdl_sound
     SUBDIR += sfizz
diff --git a/audio/sdl2_sound/Makefile b/audio/sdl2_sound/Makefile
new file mode 100644
index 000000000000..07e901e76e04
--- /dev/null
+++ b/audio/sdl2_sound/Makefile
@@ -0,0 +1,43 @@
+PORTNAME=	sdl2_sound
+DISTVERSIONPREFIX=	v
+DISTVERSION=	2.0.1
+CATEGORIES=	audio
+
+MAINTAINER=	amdmi3@FreeBSD.org
+COMMENT=	Abstract SDL soundfile decoder
+
+LICENSE=	ZLIB
+LICENSE_FILE_ZLIB=${WRKSRC}/LICENSE.txt
+
+USES=		cmake sdl
+USE_SDL=	sdl2
+USE_GITHUB=	yes
+GH_ACCOUNT=	icculus
+GH_PROJECT=	SDL_sound
+USE_LDCONFIG=	yes
+
+PORTDOCS=	*
+PORTEXAMPLES=	*
+
+OPTIONS_DEFINE=	MIDI DOCS EXAMPLES
+OPTIONS_DEFAULT=MIDI
+
+MIDI_DESC=	MIDI support
+MIDI_CMAKE_BOOL=SDLSOUND_DECODER_MIDI
+MIDI_VARS=	LICENSE+=ART10 \
+		LICENSE_COMB=multi \
+		LICENSE_FILE_ART10=${WRKSRC}/src/timidity/COPYING
+
+post-install:
+	@cd ${STAGEDIR}${PREFIX}/bin && ${MV} playsound playsound2
+
+post-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}
+	cd ${WRKSRC}/docs && ${INSTALL_DATA} CHANGELOG.txt \
+		CREDITS.txt README.txt ${STAGEDIR}${DOCSDIR}
+
+post-install-EXAMPLES-on:
+	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
+	${INSTALL_DATA} ${WRKSRC}/examples/*.c ${STAGEDIR}${EXAMPLESDIR}
+
+.include <bsd.port.mk>
diff --git a/audio/sdl2_sound/distinfo b/audio/sdl2_sound/distinfo
new file mode 100644
index 000000000000..fe9a77ff4686
--- /dev/null
+++ b/audio/sdl2_sound/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1648728983
+SHA256 (icculus-SDL_sound-v2.0.1_GH0.tar.gz) = 3527f05b7a3f00d8523cf25671598c85568b4e8b615ce7570113b44cbb7d555c
+SIZE (icculus-SDL_sound-v2.0.1_GH0.tar.gz) = 443682
diff --git a/audio/sdl2_sound/pkg-descr b/audio/sdl2_sound/pkg-descr
new file mode 100644
index 000000000000..5126766ed9f4
--- /dev/null
+++ b/audio/sdl2_sound/pkg-descr
@@ -0,0 +1,14 @@
+SDL_sound is a library that handles the decoding of several popular
+sound file formats, such as .WAV and .MP3. It is meant to make the
+programmer's sound playback tasks simpler. The programmer gives
+SDL_sound a filename, or feeds it data directly from one of many
+sources, and then reads the decoded waveform data back at her
+leisure. If resource constraints are a concern, SDL_sound can process
+sound data in programmer-specified blocks. Alternately, SDL_sound
+can decode a whole sound file and hand back a single pointer to the
+whole waveform. SDL_sound can also handle sample rate, audio format,
+and channel conversion on-the-fly and behind-the-scenes, if the
+programmer desires.
+
+WWW: https://icculus.org/SDL_sound/
+WWW: https://github.com/icculus/SDL_sound
diff --git a/audio/sdl2_sound/pkg-plist b/audio/sdl2_sound/pkg-plist
new file mode 100644
index 000000000000..51db3494f23c
--- /dev/null
+++ b/audio/sdl2_sound/pkg-plist
@@ -0,0 +1,6 @@
+bin/playsound2
+include/SDL2/SDL_sound.h
+lib/libSDL2_sound.a
+lib/libSDL2_sound.so
+lib/libSDL2_sound.so.2
+lib/libSDL2_sound.so.2.0.1