svn commit: r442981 - in head/devel/allegro: . files
Tobias Kortkamp
tobik at FreeBSD.org
Fri Jun 9 13:30:22 UTC 2017
Author: tobik
Date: Fri Jun 9 13:30:19 2017
New Revision: 442981
URL: https://svnweb.freebsd.org/changeset/ports/442981
Log:
- Add sndio support [1]
- Remove ALSA from default options
- Switch to options helpers
- Move audio output options to their own option group
- Make OSS support an explicit option, so that it can be turned off
- Remove OGG option and make it mandatory: audio/libogg is already a
dependency via audio/libvorbis
- Make the port simpler by not building the examples and not
installing the example games (if necessary installing them can be done
later in a separate port)
- Add LICENSE
- Fix WWW
- Allegro never directly links with libpng or libGLU; make them a build
dependency only
- Reset maintainer
PR: 215838
Obtained from: OpenBSD [1]
Approved by: mat (mentor), maintainer timeout (5 months)
Differential Revision: https://reviews.freebsd.org/D11039
Added:
head/devel/allegro/files/patch-allegro.cfg (contents, props changed)
head/devel/allegro/files/patch-cmake_FileList.cmake (contents, props changed)
head/devel/allegro/files/patch-include_allegro_platform_alunix.h (contents, props changed)
head/devel/allegro/files/patch-include_allegro_platform_alunixac.h.cmake (contents, props changed)
head/devel/allegro/files/patch-modules.lst (contents, props changed)
head/devel/allegro/files/patch-src_unix_usnddrv.c (contents, props changed)
head/devel/allegro/files/patch-src_x_xkeyboard.c (contents, props changed)
head/devel/allegro/files/sndio.c (contents, props changed)
Deleted:
head/devel/allegro/files/patch-src-x-xkeyboard.c
head/devel/allegro/files/pkg-message.in
head/devel/allegro/files/shooter.in
head/devel/allegro/files/skater.in
head/devel/allegro/files/skater_agl.in
Modified:
head/devel/allegro/Makefile
head/devel/allegro/distinfo
head/devel/allegro/files/patch-CMakeLists.txt
head/devel/allegro/pkg-descr
head/devel/allegro/pkg-plist
Modified: head/devel/allegro/Makefile
==============================================================================
--- head/devel/allegro/Makefile Fri Jun 9 13:05:04 2017 (r442980)
+++ head/devel/allegro/Makefile Fri Jun 9 13:30:19 2017 (r442981)
@@ -3,119 +3,77 @@
PORTNAME= allegro
DISTVERSION= 4.4.2
-PORTREVISION= 6
+PORTREVISION= 7
CATEGORIES= devel
MASTER_SITES= SF/alleg/allegro/${PORTVERSION}
-DISTFILES= ${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}
-DIST_SUBDIR= ${PORTNAME}
-EXTRACT_ONLY= ${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}
-MAINTAINER= koalative at gmail.com
+MAINTAINER= ports at FreeBSD.org
COMMENT= Cross-platform library for games and multimedia programming
-LIB_DEPENDS+= libpng.so:graphics/png \
+LICENSE= GIFTWARE
+LICENSE_NAME= Giftware
+LICENSE_FILE= ${WRKSRC}/docs/txt/license.txt
+LICENSE_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
+
+# Required for building libloadpng.a and liballeggl.a
+BUILD_DEPENDS= png>0:graphics/png \
+ libGLU>0:graphics/libGLU
+LIB_DEPENDS= libogg.so:audio/libogg \
libvorbis.so:audio/libvorbis
USES= cmake makeinfo pkgconfig
-USE_XORG= x11 xpm xext xcursor xxf86vm xxf86dga
-USE_GL= glu
+USE_XORG= ice sm x11 xpm xext xcursor xxf86vm xxf86dga
USE_LDCONFIG= yes
INFO= allegro
PORTDOCS= *
PORTEXAMPLES= *
-PLIST_SUB+= SHLIB_VER="${SHLIB_VER}"
-CMAKE_ARGS+= -DDOCDIR="${DOCSDIR}"
+PLIST_SUB= SHLIB_VER="${PORTVERSION}"
+CMAKE_ARGS= -DDOCDIR="${DOCSDIR}" \
+ -DWANT_MODULES=off \
+ -DWANT_LOGG=on \
+ -DWANT_EXAMPLES=off
-SHLIB_VER= ${PORTVERSION}
-
# Wrong versioning upstream
PORTSCOUT= ignore:1
-OPTIONS_DEFINE= ALSA JACK OGG DOCS
-OPTIONS_GROUP= DEMOS_EXAMPLES
-OPTIONS_GROUP_DEMOS_EXAMPLES= DEMOS EXAMPLES
-OPTIONS_DEFAULT= ALSA DEMOS OGG
-DEMOS_DESC= Install Demos programs, requires EXAMPLES
+OPTIONS_DEFINE= EXAMPLES DOCS
+OPTIONS_MULTI= AUDIO
+OPTIONS_MULTI_AUDIO= ALSA JACK OSS SNDIO
+OPTIONS_DEFAULT= OSS
-DOCSRCDIR1= ${WRKSRC}
-DOC_FILES1= AUTHORS CHANGES THANKS readme.txt
-
-DOCSRCDIR2= ${WRKSRC}/docs
-DOCSDIR2= ${DOCSDIR}/docs
-
OPTIONS_SUB= yes
-EXAMPLES_CMAKE_ON= -DWANT_EXAMPLES=on
-EXAMPLES_CMAKE_OFF= -DWANT_EXAMPLES=off
ALSA_LIB_DEPENDS= libasound.so:audio/alsa-lib
-ALSA_CMAKE_ON= -DWANT_ALSA=on
-ALSA_CMAKE_OFF= -DWANT_ALSA=off
+ALSA_USES= localbase:ldflags
+ALSA_CMAKE_BOOL= WANT_ALSA
+
JACK_LIB_DEPENDS= libjack.so:audio/jack
-JACK_CMAKE_ON= -DWANT_JACK=on
-JACK_CMAKE_OFF= -DWANT_JACK=off
-OGG_LIB_DEPENDS= libogg.so:audio/libogg
-OGG_CMAKE_ON= -DWANT_LOGG=on
-OGG_CMAKE_OFF= -DWANT_LOGG=of
+JACK_CMAKE_BOOL= WANT_JACK
-.include <bsd.port.options.mk>
+OSS_CMAKE_BOOL= WANT_OSS
-.if ${PORT_OPTIONS:MALSA}
-CFLAGS+= -L${LOCALBASE}/lib
-.endif
+SNDIO_LIB_DEPENDS= libsndio.so:audio/sndio
+SNDIO_CMAKE_BOOL= WANT_SNDIO
-.if ${PORT_OPTIONS:MDEMOS} && ${PORT_OPTIONS:MEXAMPLES}
-SUB_FILES+= shooter skater skater_agl \
- pkg-message
-MASTER_SITES+= SF/nemysisfreebsdp/${CATEGORIES}/${PORTNAME}/:icons
-DISTFILES+= shooter.png:icons \
- skater.png:icons
-DESKTOP_ENTRIES+="Shooter" "In a distant corner of the galaxy" "shooter" \
- "shooter" "Game;ArcadeGame;" false
-DESKTOP_ENTRIES+="Skater" "Allegro's next demo game" "skater" \
- "skater" "Game;ArcadeGame;" false
-DESKTOP_ENTRIES+="Skater AGL" "Allegro's next demo game" "skater" \
- "skater_agl" "Game;ArcadeGame;" false
-.endif
-
post-patch:
@${REINPLACE_CMD} -e 's|/allegro-$${ALLEGRO_VERSION}||' \
${WRKSRC}/docs/CMakeLists.txt
@${REINPLACE_CMD} -e 's|<X11/extensions/xf86dga.h>|<X11/extensions/Xxf86dga.h>|' \
${WRKSRC}/src/x/xdga2.c
-.if ${PORT_OPTIONS:MJACK}
+ @${CP} ${FILESDIR}/sndio.c ${WRKSRC}/src/unix
+
+post-patch-JACK-on:
@${REINPLACE_CMD} -e 's|jack_client = jack_client_new(jack_client_name);|jack_client = jack_client_open(jack_client_name, (jack_options_t)0, NULL);|' \
${WRKSRC}/src/unix/jack.c
-.endif
post-install:
- @${INSTALL_MAN} ${WRKSRC}/docs/man/*.3 ${STAGEDIR}${MAN3PREFIX}/man/man3/
+ ${INSTALL_MAN} ${WRKSRC}/docs/man/*.3 ${STAGEDIR}${MAN3PREFIX}/man/man3/
-.if ${PORT_OPTIONS:MEXAMPLES}
+post-install-EXAMPLES-on:
@(cd ${WRKSRC}/examples && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR})
-. for l in ex12bit ex3buf ex3d exaccel exalpha exbitmap exblend excamera excolmap \
- exconfig excustom exdata exdbuf exexedat exfixed exflame exflip exfont \
- exgui exhello exjoy exkeys exlights exmem exmidi exmouse expackf expal \
- expat exquat exrgbhsv exrotscl exsample exscale exscn3d exscroll exshade \
- exspline exsprite exstars exstream exswitch exsyscur extimer extrans \
- extrans2 extruec exunicod exupdate exxfade exzbuf
- @${CHMOD} u+w ${STAGEDIR}${EXAMPLESDIR}/${l}
- ${STRIP_CMD} ${STAGEDIR}${EXAMPLESDIR}/${l}
- @${CHMOD} u-w ${STAGEDIR}${EXAMPLESDIR}/${l}
-. endfor
-.endif
-
-.if ${PORT_OPTIONS:MDEMOS} && ${PORT_OPTIONS:MEXAMPLES}
@(cd ${WRKSRC} && ${COPYTREE_SHARE} demos ${STAGEDIR}${EXAMPLESDIR})
- ${INSTALL_SCRIPT} ${WRKDIR}/shooter ${STAGEDIR}${PREFIX}/bin/
- ${INSTALL_DATA} ${_DISTDIR}/shooter.png ${STAGEDIR}${PREFIX}/share/pixmaps/
- @(cd ${STAGEDIR}${EXAMPLESDIR}/demos/shooter && ${CHMOD} 755 shooter)
- ${INSTALL_SCRIPT} ${WRKDIR}/skater* ${STAGEDIR}${PREFIX}/bin
- ${INSTALL_DATA} ${_DISTDIR}/skater.png ${STAGEDIR}${PREFIX}/share/pixmaps/
- @(cd ${STAGEDIR}${EXAMPLESDIR}/demos/skater && ${CHMOD} 755 skater*)
- ${STRIP_CMD} ${STAGEDIR}${EXAMPLESDIR}/demos/shooter/shooter
- ${STRIP_CMD} ${STAGEDIR}${EXAMPLESDIR}/demos/skater/skater*
-.endif
+ ${INSTALL_DATA} ${WRKSRC}/allegro.cfg ${STAGEDIR}${EXAMPLESDIR}
.include <bsd.port.mk>
Modified: head/devel/allegro/distinfo
==============================================================================
--- head/devel/allegro/distinfo Fri Jun 9 13:05:04 2017 (r442980)
+++ head/devel/allegro/distinfo Fri Jun 9 13:30:19 2017 (r442981)
@@ -1,6 +1,3 @@
-SHA256 (allegro/allegro-4.4.2.tar.gz) = 1b21e7577dbfada02d85ca4510bd22fedaa6ce76fde7f4838c7c1276eb840fdc
-SIZE (allegro/allegro-4.4.2.tar.gz) = 4674902
-SHA256 (allegro/shooter.png) = cf73f63f0224a9ee77c287b6211beb4a072ba4aa969a57993e60a2e97996e468
-SIZE (allegro/shooter.png) = 1741
-SHA256 (allegro/skater.png) = f0274627c6eae2ecad880c3e2f25bf5f8944f08829ac32ab0a00f77001e8b2f3
-SIZE (allegro/skater.png) = 3395
+TIMESTAMP = 1483711950
+SHA256 (allegro-4.4.2.tar.gz) = 1b21e7577dbfada02d85ca4510bd22fedaa6ce76fde7f4838c7c1276eb840fdc
+SIZE (allegro-4.4.2.tar.gz) = 4674902
Modified: head/devel/allegro/files/patch-CMakeLists.txt
==============================================================================
--- head/devel/allegro/files/patch-CMakeLists.txt Fri Jun 9 13:05:04 2017 (r442980)
+++ head/devel/allegro/files/patch-CMakeLists.txt Fri Jun 9 13:30:19 2017 (r442981)
@@ -1,6 +1,6 @@
---- CMakeLists.txt.orig
+--- CMakeLists.txt.orig 2011-03-24 23:18:50 UTC
+++ CMakeLists.txt
-@@ -66,7 +66,7 @@
+@@ -66,7 +66,7 @@ if(WIN32)
endif(WIN32)
set(ALLEGRO_VERSION 4.4.2)
@@ -9,7 +9,33 @@
# Mac OS X -compatibility_version.
# XXX doesn't seem to work
-@@ -961,7 +961,7 @@
+@@ -408,6 +408,7 @@ option(WANT_OSS "Build OSS support" on)
+ option(WANT_ALSA "Build ALSA support" on)
+ option(WANT_JACK "Build JACK support" on)
+ option(WANT_SGIAUDIO "Build SGI audio support" on)
++option(WANT_SNDIO "Build sndio audio support" on)
+
+ if(ALLEGRO_UNIX) # not MACOSX
+ find_package(Threads)
+@@ -471,6 +472,17 @@ if(ALLEGRO_UNIX) # not MACOSX
+ endif(SGIAUDIO_FOUND)
+ endif(WANT_SGIAUDIO)
+
++ if(WANT_SNDIO)
++ find_path(SNDIO_INCLUDE_DIR sndio.h)
++ find_library(SNDIO_LIBRARY NAMES sndio)
++ if(SNDIO_INCLUDE_DIR AND SNDIO_LIBRARY)
++ set(ALLEGRO_WITH_SNDIODIGI 1)
++ include_directories(SYSTEM ${SNDIO_INCLUDE_DIR})
++ list(APPEND PLATFORM_LIBS_NON_MODULES ${SNDIO_LIBRARY})
++ add_our_module(alleg-sndiodigi src/unix/sndio.c ${SNDIO_LIBRARY})
++ endif(SNDIO_INCLUDE_DIR AND SNDIO_LIBRARY)
++ endif(WANT_SNDIO)
++
+ # aRts is obsolete
+ # esd is obsolete
+ endif(ALLEGRO_UNIX)
+@@ -961,7 +973,7 @@ if(UNIX)
@ONLY
)
install(FILES ${LIBRARY_OUTPUT_PATH}/pkgconfig/${name}${lib_type}.pc
Added: head/devel/allegro/files/patch-allegro.cfg
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/patch-allegro.cfg Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,11 @@
+$OpenBSD: patch-allegro_cfg,v 1.1 2010/04/26 02:56:30 jakemsr Exp $
+--- allegro.cfg.orig 2006-05-21 10:01:46 UTC
++++ allegro.cfg
+@@ -326,6 +326,7 @@ mouse_accel_factor =
+ # ARTS - aRts (Analog Real-Time Synthesizer)
+ # ALSA - ALSA Sound System
+ # JACK - JACK Audio Server
++# SIOD - sndio Audio API
+ #
+ # BeOS digital sound drivers:
+ #
Added: head/devel/allegro/files/patch-cmake_FileList.cmake
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/patch-cmake_FileList.cmake Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,10 @@
+--- cmake/FileList.cmake.orig 2011-03-12 00:26:00 UTC
++++ cmake/FileList.cmake
+@@ -260,6 +260,7 @@ set(ALLEGRO_SRC_UNIX_FILES
+ src/unix/arts.c
+ src/unix/sgial.c
+ src/unix/jack.c
++ src/unix/sndio.c
+ src/unix/udjgpp.c
+ src/unix/udrvlist.c
+ src/unix/udummy.c
Added: head/devel/allegro/files/patch-include_allegro_platform_alunix.h
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/patch-include_allegro_platform_alunix.h Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,25 @@
+$OpenBSD: patch-include_allegro_platform_alunix_h,v 1.1 2010/04/26 02:56:30 jakemsr Exp $
+--- include/allegro/platform/alunix.h.orig 2007-06-16 01:52:28 UTC
++++ include/allegro/platform/alunix.h
+@@ -69,6 +69,8 @@ AL_VAR(TIMER_DRIVER, timerdrv_unix_sigal
+ #define DIGI_ALSA AL_ID('A','L','S','A')
+ #define MIDI_ALSA AL_ID('A','M','I','D')
+ #define DIGI_JACK AL_ID('J','A','C','K')
++#define DIGI_SNDIO AL_ID('S','I','O','D')
++#define MIDI_SNDIO AL_ID('M','I','O','M')
+
+
+ #ifdef ALLEGRO_WITH_OSSDIGI
+@@ -85,6 +87,12 @@ AL_VAR(MIDI_DRIVER, midi_oss);
+
+ #ifndef ALLEGRO_WITH_MODULES
+
++#ifdef ALLEGRO_WITH_SNDIODIGI
++AL_VAR(DIGI_DRIVER, digi_sndio);
++#define DIGI_DRIVER_SNDIO \
++ { DIGI_SNDIO, &digi_sndio, TRUE },
++#endif /* ALLEGRO_WITH_SNDIODIGI */
++
+ #ifdef ALLEGRO_WITH_ESDDIGI
+ AL_VAR(DIGI_DRIVER, digi_esd);
+ #define DIGI_DRIVER_ESD \
Added: head/devel/allegro/files/patch-include_allegro_platform_alunixac.h.cmake
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/patch-include_allegro_platform_alunixac.h.cmake Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,12 @@
+--- include/allegro/platform/alunixac.h.cmake.orig 2010-05-08 05:55:30 UTC
++++ include/allegro/platform/alunixac.h.cmake
+@@ -143,6 +143,9 @@
+ /* Define if JACK DIGI driver is supported. */
+ #cmakedefine ALLEGRO_WITH_JACKDIGI
+
++/* Define if SNDIO DIGI driver is supported. */
++#cmakedefine ALLEGRO_WITH_SNDIODIGI
++
+ /* Define if OSS DIGI driver is supported. */
+ #cmakedefine ALLEGRO_WITH_OSSDIGI
+
Added: head/devel/allegro/files/patch-modules.lst
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/patch-modules.lst Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,7 @@
+--- modules.lst.orig 2004-04-10 00:19:15 UTC
++++ modules.lst
+@@ -10,3 +10,4 @@ alleg-sgialdigi.so
+ alleg-alsadigi.so
+ alleg-alsamidi.so
+ alleg-jackdigi.so
++alleg-sndiodigi.so
Added: head/devel/allegro/files/patch-src_unix_usnddrv.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/patch-src_unix_usnddrv.c Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,12 @@
+--- src/unix/usnddrv.c.orig 2004-09-24 14:45:03 UTC
++++ src/unix/usnddrv.c
+@@ -24,6 +24,9 @@ BEGIN_DIGI_DRIVER_LIST
+ #if (defined ALLEGRO_WITH_JACKDIGI) && (!defined ALLEGRO_WITH_MODULES)
+ DIGI_DRIVER_JACK
+ #endif
++#if (defined ALLEGRO_WITH_SNDIODIGI) && (!defined ALLEGRO_WITH_MODULES)
++ DIGI_DRIVER_SNDIO
++#endif
+ #if (defined ALLEGRO_WITH_SGIALDIGI) && (!defined ALLEGRO_WITH_MODULES)
+ DIGI_DRIVER_SGIAL
+ #endif
Added: head/devel/allegro/files/patch-src_x_xkeyboard.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/patch-src_x_xkeyboard.c Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,19 @@
+--- src/x/xkeyboard.c.orig 2010-12-08 08:13:50 UTC
++++ src/x/xkeyboard.c
+@@ -23,6 +23,7 @@
+ #include <X11/Xos.h>
+ #include <X11/Xlib.h>
+ #include <X11/Xutil.h>
++#include <X11/XKBlib.h>
+ #include <X11/Xproto.h>
+
+ #include "allegro.h"
+@@ -617,7 +618,7 @@ void _xwin_get_keyboard_mapping(void)
+
+ TRACE (PREFIX_I "Modifier %d:", i + 1);
+ for (j = 0; j < xmodmap->max_keypermod; j++) {
+- KeySym sym = XKeycodeToKeysym(_xwin.display,
++ KeySym sym = XkbKeycodeToKeysym(_xwin.display, 0,
+ xmodmap->modifiermap[i * xmodmap->max_keypermod + j], 0);
+ char *sym_str = XKeysymToString(sym);
+ TRACE(" %s", sym_str ? sym_str : "NULL");
Added: head/devel/allegro/files/sndio.c
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ head/devel/allegro/files/sndio.c Fri Jun 9 13:30:19 2017 (r442981)
@@ -0,0 +1,509 @@
+/*
+ * Copyright (c) 2010 Jacob Meuser <jakemsr at sdf.lonestar.org>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
+#include "allegro.h"
+
+#if (defined ALLEGRO_WITH_SNDIODIGI) && ((!defined ALLEGRO_WITH_MODULES) || (defined ALLEGRO_MODULE))
+
+#include "allegro/internal/aintern.h"
+#include "allegro/platform/aintunix.h"
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <limits.h>
+#include <unistd.h>
+#include <poll.h>
+#include <sndio.h>
+
+static int sndio_detect(int input);
+static int sndio_init(int input, int voices);
+static void sndio_exit(int input);
+static int sndio_set_mixer_volume(int volume);
+static int sndio_get_mixer_volume(void);
+
+static int sndio_buffer_size(void);
+
+static int sndio_rec_cap_rate(int bits, int stereo);
+static int sndio_rec_cap_parm(int rate, int bits, int stereo);
+static int sndio_rec_source(int source);
+static int sndio_rec_start(int rate, int bits, int stereo);
+static void sndio_rec_stop(void);
+static int sndio_rec_read(void *buf);
+
+static int open_sndio_device(int input);
+static void sndio_update(int threaded);
+static void movecb(void *addr, int delta);
+static void volcb(void *addr, unsigned vol);
+
+static struct sio_hdl *hdl;
+static struct sio_par par;
+static int sndio_signed;
+static int sndio_play_bufsize, sndio_play_round, sndio_play_appbufsz;
+static unsigned char *sndio_play_bufdata;
+static char sndio_desc[256] = EMPTY_STRING;
+long long sndio_realpos, sndio_playpos;
+int sndio_volume;
+
+static int sndio_save_bits, sndio_save_stereo, sndio_save_freq;
+static int sndio_rec_bufsize, sndio_rec_round, sndio_rec_appbufsz;
+static unsigned char *sndio_rec_bufdata;
+
+DIGI_DRIVER digi_sndio =
+{
+ DIGI_SNDIO,
+ empty_string,
+ empty_string,
+ "sndio",
+ 0,
+ 0,
+ MIXER_MAX_SFX,
+ MIXER_DEF_SFX,
+
+ /* setup routines */
+ sndio_detect,
+ sndio_init,
+ sndio_exit,
+ sndio_set_mixer_volume,
+ sndio_get_mixer_volume,
+
+ /* for use by the audiostream functions */
+ NULL,
+ NULL,
+ sndio_buffer_size,
+
+ /* voice control functions */
+ _mixer_init_voice,
+ _mixer_release_voice,
+ _mixer_start_voice,
+ _mixer_stop_voice,
+ _mixer_loop_voice,
+
+ /* position control functions */
+ _mixer_get_position,
+ _mixer_set_position,
+
+ /* volume control functions */
+ _mixer_get_volume,
+ _mixer_set_volume,
+ _mixer_ramp_volume,
+ _mixer_stop_volume_ramp,
+
+ /* pitch control functions */
+ _mixer_get_frequency,
+ _mixer_set_frequency,
+ _mixer_sweep_frequency,
+ _mixer_stop_frequency_sweep,
+
+ /* pan control functions */
+ _mixer_get_pan,
+ _mixer_set_pan,
+ _mixer_sweep_pan,
+ _mixer_stop_pan_sweep,
+
+ /* effect control functions */
+ _mixer_set_echo,
+ _mixer_set_tremolo,
+ _mixer_set_vibrato,
+
+ /* input functions */
+ 0,
+ 0,
+ sndio_rec_cap_rate,
+ sndio_rec_cap_parm,
+ sndio_rec_source,
+ sndio_rec_start,
+ sndio_rec_stop,
+ sndio_rec_read
+};
+
+
+/* used to probe and to configure the device. don't use sio_start() here. */
+static int
+open_sndio_device(int input)
+{
+ hdl = sio_open(NULL, (input ? SIO_REC : SIO_PLAY), 0);
+ if (hdl == NULL) {
+ uszprintf(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("sio_opn failed"));
+ return -1;
+ }
+
+ sio_initpar(&par);
+ par.bits = (_sound_bits == 8) ? 8 : 16;
+ par.sig = (_sound_bits == 8) ? 0 : 1;
+ if (input)
+ par.rchan = (_sound_stereo) ? 2 : 1;
+ else
+ par.pchan = (_sound_stereo) ? 2 : 1;
+ par.rate = (_sound_freq > 0) ? _sound_freq : 48000;
+ par.le = SIO_LE_NATIVE;
+ /* allegro wants small blocks */
+ par.round = 512;
+ par.appbufsz = par.rate / 10;
+
+ if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
+ (par.bits != 8 && par.bits != 16) ||
+ (par.bits == 8 && par.sig) ||
+ (par.bits == 16 && !par.sig) ||
+ (par.bits == 16 && par.le != SIO_LE_NATIVE) ||
+ (input && (par.rchan != 1 && par.rchan != 2)) ||
+ (!input && (par.pchan != 1 && par.pchan != 2))) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("could not set sndio parameters"));
+ sio_close(hdl);
+ return -1;
+ }
+
+ _sound_bits = par.bits;
+ _sound_stereo = input ? par.rchan == 2 : par.pchan == 2;
+ _sound_freq = par.rate;
+
+ if (input) {
+ sndio_rec_round = par.round;
+ sndio_rec_appbufsz = par.appbufsz;
+ sndio_rec_bufsize = par.round * par.bps * par.rchan;
+ } else {
+ sndio_play_round = par.round;
+ sndio_play_appbufsz = par.appbufsz;
+ sndio_play_bufsize = sndio_play_round * par.bps * par.pchan;
+ }
+ sndio_signed = par.sig ? 1 : 0;
+
+ return 0;
+}
+
+
+static int
+sndio_detect(int input)
+{
+ if (input) {
+ if (digi_driver != digi_input_driver) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("sndio output driver must be installed before input can be read"));
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ if (open_sndio_device(0) != 0)
+ return FALSE;
+
+ sio_close(hdl);
+ return TRUE;
+}
+
+
+/* number of samples per channel in a block */
+static int
+sndio_buffer_size(void)
+{
+ return sndio_play_round;
+}
+
+
+/* callback for data movement notification */
+static void
+movecb(void *addr, int delta)
+{
+ sndio_realpos += delta;
+}
+
+
+/* callback for volume change notification */
+static void
+volcb(void *addr, unsigned vol)
+{
+ sndio_volume = vol;
+}
+
+
+/* write as many blocks as is currently possible */
+static void
+sndio_update(int threaded)
+{
+ struct pollfd pfd;
+ nfds_t nfds;
+ int i, nblocks, nbytes;
+
+ /* make sure counters have been updated */
+ nfds = sio_pollfd(hdl, &pfd, POLLOUT);
+ poll(&pfd, nfds, 0);
+ if (!(sio_revents(hdl, &pfd) & POLLOUT))
+ return;
+
+ nblocks = (sndio_play_appbufsz - (sndio_playpos - sndio_realpos)) /
+ sndio_play_round;
+
+ /* we got POLLOUT, so we can write something. if we don't
+ * write anything, we could underrun.
+ */
+ if (nblocks < 1)
+ nblocks = 1;
+
+ for (i = 0; i < nblocks; i++) {
+ sio_write(hdl, sndio_play_bufdata, sndio_play_bufsize);
+ sndio_playpos += sndio_play_round;
+ if (sio_eof(hdl)) {
+ /* print error message? */
+ return;
+ }
+ _mix_some_samples((uintptr_t) sndio_play_bufdata, 0, sndio_signed);
+ }
+}
+
+
+static int
+sndio_init(int input, int voices)
+{
+ char tmp1[128], tmp2[128];
+
+ if (input) {
+ digi_driver->rec_cap_bits = 16;
+ digi_driver->rec_cap_stereo = TRUE;
+ return 0;
+ }
+
+ if (open_sndio_device(0) != 0)
+ return -1;
+
+ sndio_play_bufdata = _AL_MALLOC_ATOMIC(sndio_play_bufsize);
+ if (sndio_play_bufdata == 0) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("Can not allocate audio buffer"));
+ sio_close(hdl);
+ return -1;
+ }
+
+ sndio_realpos = sndio_playpos = 0;
+ sio_onmove(hdl, movecb, NULL);
+
+ sndio_volume = 127;
+ sio_onvol(hdl, volcb, NULL);
+
+ if (!sio_start(hdl)) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("Can not start sndio"));
+ sio_close(hdl);
+ return -1;
+ }
+
+ digi_sndio.voices = voices;
+
+ /* first arg is total number of samples */
+ if (_mixer_init(sndio_play_round * (_sound_stereo ? 2 : 1),
+ _sound_freq, _sound_stereo, ((_sound_bits == 16) ? 1 : 0),
+ &digi_sndio.voices) != 0) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("Can not init software mixer"));
+ sio_close(hdl);
+ return -1;
+ }
+
+ _mix_some_samples((uintptr_t) sndio_play_bufdata, 0, sndio_signed);
+
+ /* Add audio interrupt. */
+ _unix_bg_man->register_func(sndio_update);
+
+ uszprintf(sndio_desc, sizeof(sndio_desc),
+ get_config_text("%s: %d bits, %s, %d Hz, %s"),
+ "sndio device",
+ _sound_bits,
+ uconvert_ascii((sndio_signed ? "signed" : "unsigned"), tmp1),
+ _sound_freq,
+ uconvert_ascii((par.pchan == 2 ? "stereo" : "mono"), tmp2));
+
+ digi_driver->desc = sndio_desc;
+
+ return 0;
+}
+
+
+static void
+sndio_exit(int input)
+{
+ if (input)
+ return;
+
+ _unix_bg_man->unregister_func(sndio_update);
+
+ _AL_FREE(sndio_play_bufdata);
+ sndio_play_bufdata = 0;
+
+ _mixer_exit();
+
+ if (hdl != NULL)
+ sio_close(hdl);
+ hdl = NULL;
+}
+
+
+/* 'volume' is 0-255 */
+static int
+sndio_set_mixer_volume(int volume)
+{
+ if (!sio_setvol(hdl, volume / 2))
+ return -1;
+
+ return 0;
+}
+
+
+/* should return 0-255 */
+static int
+sndio_get_mixer_volume(void)
+{
+ return sndio_volume * 2;
+}
+
+
+/* Returns maximum recording sampling rate. */
+static int
+sndio_rec_cap_rate(int bits, int stereo)
+{
+ /* should use sio_getcap() */
+ return 48000;
+}
+
+
+/* Returns whether the specified parameters can be set. */
+static int
+sndio_rec_cap_parm(int rate, int bits, int stereo)
+{
+ /* should use sio_getcap() */
+ return 1;
+}
+
+
+/* Sets the sampling source for audio recording. */
+static int
+sndio_rec_source(int source)
+{
+ /* not implemented in sndio */
+
+ switch (source) {
+ case SOUND_INPUT_MIC:
+ break;
+ case SOUND_INPUT_LINE:
+ break;
+ case SOUND_INPUT_CD:
+ break;
+ default:
+ return -1;
+ }
+
+ return 0;
+}
+
+
+/*
+ * Re-opens device with read-mode and starts recording (half-duplex).
+ * Returns the DMA buffer size if successful.
+ */
+static int
+sndio_rec_start(int rate, int bits, int stereo)
+{
+ sndio_save_bits = _sound_bits;
+ sndio_save_stereo = _sound_stereo;
+ sndio_save_freq = _sound_freq;
+
+ _unix_bg_man->unregister_func(sndio_update);
+
+ if (hdl != NULL)
+ sio_close(hdl);
+ hdl = NULL;
+
+ _sound_bits = bits;
+ _sound_stereo = stereo;
+ _sound_freq = rate;
+
+ if (open_sndio_device(1) != 0)
+ return 0;
+
+ sndio_volume = 127;
+ sio_onvol(hdl, volcb, NULL);
+
+ if (!sio_start(hdl)) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("Can not start sndio for recording"));
+ sio_close(hdl);
+ return 0;
+ }
+
+ return sndio_rec_bufsize;
+}
+
+
+/* Stops recording and switches the device back to the original mode. */
+static void
+sndio_rec_stop(void)
+{
+ if (hdl != NULL)
+ sio_close(hdl);
+ hdl = NULL;
+
+ _sound_bits = sndio_save_bits;
+ _sound_stereo = sndio_save_stereo;
+ _sound_freq = sndio_save_freq;
+
+ if (open_sndio_device(0) != 0)
+ return;
+
+ sndio_realpos = sndio_playpos = 0;
+ sio_onmove(hdl, movecb, NULL);
+
+ sndio_volume = 127;
+ sio_onvol(hdl, volcb, NULL);
+
+ if (!sio_start(hdl)) {
+ ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
+ get_config_text("Can not start sndio"));
+ sio_close(hdl);
+ return;
+ }
+
+ _unix_bg_man->register_func(sndio_update);
+}
+
+
+/* Retrieves the just recorded buffer, if there is one. */
+static int
+sndio_rec_read(void *buf)
+{
+ struct pollfd pfd;
+ nfds_t nfds;
+ int ret, nbytes, offset = 0;
+
+ /* make sure counters have been updated */
+ nfds = sio_pollfd(hdl, &pfd, POLLIN);
+ poll(&pfd, nfds, 0);
+ sio_revents(hdl, &pfd);
+ if (!(sio_revents(hdl, &pfd) & POLLIN))
+ return 0;
+
+ nbytes = sndio_rec_bufsize;
+ while (nbytes) {
+ ret = sio_read(hdl, buf + offset, nbytes);
+ if (sio_eof(hdl))
+ return 0;
+ offset += ret;
+ nbytes -= ret;
+ }
+
+ return 1;
+}
+
+#endif /* ALLEGRO_WITH_SNDIODIGI */
Modified: head/devel/allegro/pkg-descr
==============================================================================
--- head/devel/allegro/pkg-descr Fri Jun 9 13:05:04 2017 (r442980)
+++ head/devel/allegro/pkg-descr Fri Jun 9 13:30:19 2017 (r442981)
@@ -4,4 +4,4 @@ other types of multimedia programming.
A wide range of extension packages and add-on modules are also available, which
can be found in the "Library Extensions" section of the Allegro website.
-WWW: http://www.talula.demon.co.uk/allegro/
+WWW: http://liballeg.org/
Modified: head/devel/allegro/pkg-plist
==============================================================================
--- head/devel/allegro/pkg-plist Fri Jun 9 13:05:04 2017 (r442980)
+++ head/devel/allegro/pkg-plist Fri Jun 9 13:30:19 2017 (r442981)
@@ -8,9 +8,6 @@ bin/grabber
bin/pack
bin/pat2dat
bin/rgbmap
-%%DEMOS%%%%EXAMPLES%%bin/shooter
-%%DEMOS%%%%EXAMPLES%%bin/skater
-%%DEMOS%%%%EXAMPLES%%bin/skater_agl
bin/textconv
include/alleggl.h
include/allegro.h
@@ -118,11 +115,6 @@ include/jpgalleg.h
include/loadpng.h
include/logg.h
include/xalleg.h
-%%ALSA%%lib/allegro/%%SHLIB_VER%%/alleg-alsadigi.so
-%%ALSA%%lib/allegro/%%SHLIB_VER%%/alleg-alsamidi.so
-%%ALSA%%lib/allegro/%%SHLIB_VER%%/alleg-dga2.so
-%%JACK%%lib/allegro/%%SHLIB_VER%%/alleg-jack.so
-lib/allegro/%%SHLIB_VER%%/modules.lst
lib/liballeg.so
lib/liballeg.so.4
lib/liballeg.so.%%SHLIB_VER%%
@@ -1058,5 +1050,3 @@ man/man3/voice_sweep_pan.3.gz
man/man3/vsync.3.gz
man/man3/xor_mode.3.gz
man/man3/xwin_set_window_name.3.gz
-%%DEMOS%%%%EXAMPLES%%share/pixmaps/shooter.png
-%%DEMOS%%%%EXAMPLES%%share/pixmaps/skater.png
More information about the svn-ports-all
mailing list