View | Details | Raw Unified | Return to bug 215838 | Differences between
and this patch

Collapse All | Expand All

(-)Makefile (-69 / +33 lines)
Lines 3-24 Link Here
3
3
4
PORTNAME=	allegro
4
PORTNAME=	allegro
5
DISTVERSION=	4.4.2
5
DISTVERSION=	4.4.2
6
PORTREVISION=	5
6
PORTREVISION=	6
7
CATEGORIES=	devel
7
CATEGORIES=	devel
8
MASTER_SITES=	SF/alleg/allegro/${PORTVERSION}
8
MASTER_SITES=	SF/alleg/allegro/${PORTVERSION}
9
DISTFILES=	${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}
10
DIST_SUBDIR=	${PORTNAME}
11
EXTRACT_ONLY=	${PORTNAME}-${DISTVERSION}${EXTRACT_SUFX}
12
9
13
MAINTAINER=	koalative@gmail.com
10
MAINTAINER=	koalative@gmail.com
14
COMMENT=	Cross-platform library for games and multimedia programming
11
COMMENT=	Cross-platform library for games and multimedia programming
15
12
16
LIB_DEPENDS+=	libpng.so:graphics/png \
13
LICENSE=	GIFTWARE
14
LICENSE_NAME=	Giftware
15
LICENSE_FILE=	${WRKSRC}/docs/txt/license.txt
16
LICENSE_PERMS=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
17
18
# Required for building libloadpng.a and liballeggl.a
19
BUILD_DEPENDS=	png>0:graphics/png \
20
		libGLU>0:graphics/libGLU
21
LIB_DEPENDS=	libogg.so:audio/libogg \
17
		libvorbis.so:audio/libvorbis
22
		libvorbis.so:audio/libvorbis
18
23
19
USES=		cmake makeinfo pkgconfig
24
USES=		cmake makeinfo pkgconfig
20
USE_XORG=	x11 xpm xext xcursor xxf86vm xxf86dga
25
USE_XORG=	ice sm x11 xpm xext xcursor xxf86vm xxf86dga
21
USE_GL=		glu
22
USE_LDCONFIG=	yes
26
USE_LDCONFIG=	yes
23
27
24
INFO=		allegro
28
INFO=		allegro
Lines 25-43 Link Here
25
PORTDOCS=	*
29
PORTDOCS=	*
26
PORTEXAMPLES=	*
30
PORTEXAMPLES=	*
27
31
28
PLIST_SUB+=	SHLIB_VER="${SHLIB_VER}"
32
PLIST_SUB=	SHLIB_VER="${PORTVERSION}"
29
CMAKE_ARGS+=	-DDOCDIR="${DOCSDIR}"
33
CMAKE_ARGS=	-DDOCDIR="${DOCSDIR}" \
34
		-DWANT_MODULES=off \
35
		-DWANT_LOGG=on \
36
		-DWANT_EXAMPLES=off
30
37
31
SHLIB_VER=	${PORTVERSION}
32
33
# Wrong versioning upstream
38
# Wrong versioning upstream
34
PORTSCOUT=	ignore:1
39
PORTSCOUT=	ignore:1
35
40
36
OPTIONS_DEFINE=	ALSA JACK OGG DOCS
41
OPTIONS_DEFINE=	EXAMPLES DOCS
37
OPTIONS_GROUP=	DEMOS_EXAMPLES
42
OPTIONS_MULTI=	AUDIO
38
OPTIONS_GROUP_DEMOS_EXAMPLES=	DEMOS EXAMPLES
43
OPTIONS_MULTI_AUDIO=	ALSA JACK OSS SNDIO
39
OPTIONS_DEFAULT=	ALSA DEMOS OGG
44
OPTIONS_DEFAULT=	ALSA OSS
40
DEMOS_DESC=	Install Demos programs, requires EXAMPLES
41
45
42
DOCSRCDIR1=	${WRKSRC}
46
DOCSRCDIR1=	${WRKSRC}
43
DOC_FILES1=	AUTHORS CHANGES THANKS readme.txt
47
DOC_FILES1=	AUTHORS CHANGES THANKS readme.txt
Lines 47-121 Link Here
47
51
48
OPTIONS_SUB=	yes
52
OPTIONS_SUB=	yes
49
53
50
EXAMPLES_CMAKE_ON=	-DWANT_EXAMPLES=on
51
EXAMPLES_CMAKE_OFF=	-DWANT_EXAMPLES=off
52
ALSA_LIB_DEPENDS=	libasound.so:audio/alsa-lib
54
ALSA_LIB_DEPENDS=	libasound.so:audio/alsa-lib
53
ALSA_CMAKE_ON=		-DWANT_ALSA=on
55
ALSA_LDFLAGS=		-L${LOCALBASE}/lib
54
ALSA_CMAKE_OFF=		-DWANT_ALSA=off
56
ALSA_CMAKE_BOOL=	WANT_ALSA
57
55
JACK_LIB_DEPENDS=	libjack.so:audio/jack
58
JACK_LIB_DEPENDS=	libjack.so:audio/jack
56
JACK_CMAKE_ON=		-DWANT_JACK=on
59
JACK_CMAKE_BOOL=	WANT_JACK
57
JACK_CMAKE_OFF=		-DWANT_JACK=off
58
OGG_LIB_DEPENDS=	libogg.so:audio/libogg
59
OGG_CMAKE_ON=		-DWANT_LOGG=on
60
OGG_CMAKE_OFF=		-DWANT_LOGG=of
61
60
62
.include <bsd.port.options.mk>
61
OSS_CMAKE_BOOL=		WANT_OSS
63
62
64
.if ${PORT_OPTIONS:MALSA}
63
SNDIO_LIB_DEPENDS=	libsndio.so:audio/sndio
65
CFLAGS+=	-L${LOCALBASE}/lib
64
SNDIO_CMAKE_BOOL=	WANT_SNDIO
66
.endif
67
65
68
.if ${PORT_OPTIONS:MDEMOS} && ${PORT_OPTIONS:MEXAMPLES}
69
SUB_FILES+=	shooter skater skater_agl \
70
		pkg-message
71
MASTER_SITES+=	SF/nemysisfreebsdp/${CATEGORIES}/${PORTNAME}/:icons
72
DISTFILES+=	shooter.png:icons \
73
		skater.png:icons
74
DESKTOP_ENTRIES+="Shooter" "In a distant corner of the galaxy" "shooter" \
75
		"shooter" "Game;ArcadeGame;" false
76
DESKTOP_ENTRIES+="Skater" "Allegro's next demo game" "skater" \
77
		"skater" "Game;ArcadeGame;" false
78
DESKTOP_ENTRIES+="Skater AGL" "Allegro's next demo game" "skater" \
79
		"skater_agl" "Game;ArcadeGame;" false
80
.endif
81
82
post-patch:
66
post-patch:
83
	@${REINPLACE_CMD} -e 's|/allegro-$${ALLEGRO_VERSION}||' \
67
	@${REINPLACE_CMD} -e 's|/allegro-$${ALLEGRO_VERSION}||' \
84
		${WRKSRC}/docs/CMakeLists.txt
68
		${WRKSRC}/docs/CMakeLists.txt
85
	@${REINPLACE_CMD} -e 's|<X11/extensions/xf86dga.h>|<X11/extensions/Xxf86dga.h>|' \
69
	@${REINPLACE_CMD} -e 's|<X11/extensions/xf86dga.h>|<X11/extensions/Xxf86dga.h>|' \
86
		${WRKSRC}/src/x/xdga2.c
70
		${WRKSRC}/src/x/xdga2.c
87
.if ${PORT_OPTIONS:MJACK}
71
	@${CP} ${FILESDIR}/sndio.c ${WRKSRC}/src/unix
72
73
post-patch-JACK-on:
88
	@${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);|' \
74
	@${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);|' \
89
		${WRKSRC}/src/unix/jack.c
75
		${WRKSRC}/src/unix/jack.c
90
.endif
91
76
92
post-install:
77
post-install:
93
	@${INSTALL_MAN} ${WRKSRC}/docs/man/*.3 ${STAGEDIR}${MAN3PREFIX}/man/man3/
78
	${INSTALL_MAN} ${WRKSRC}/docs/man/*.3 ${STAGEDIR}${MAN3PREFIX}/man/man3/
94
79
95
.if ${PORT_OPTIONS:MEXAMPLES}
80
post-install-EXAMPLES-on:
96
	@(cd ${WRKSRC}/examples && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR})
81
	@(cd ${WRKSRC}/examples && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR})
97
. for l in ex12bit ex3buf ex3d exaccel exalpha exbitmap exblend excamera excolmap \
98
	exconfig excustom exdata exdbuf exexedat exfixed exflame exflip exfont \
99
	exgui exhello exjoy exkeys exlights exmem exmidi exmouse expackf expal \
100
	expat exquat exrgbhsv exrotscl exsample exscale exscn3d exscroll exshade \
101
	exspline exsprite exstars exstream exswitch exsyscur extimer extrans \
102
	extrans2 extruec exunicod exupdate exxfade exzbuf
103
	@${CHMOD} u+w ${STAGEDIR}${EXAMPLESDIR}/${l}
104
	${STRIP_CMD} ${STAGEDIR}${EXAMPLESDIR}/${l}
105
	@${CHMOD} u-w ${STAGEDIR}${EXAMPLESDIR}/${l}
106
. endfor
107
.endif
108
109
.if ${PORT_OPTIONS:MDEMOS} && ${PORT_OPTIONS:MEXAMPLES}
110
	@(cd ${WRKSRC} && ${COPYTREE_SHARE} demos ${STAGEDIR}${EXAMPLESDIR})
82
	@(cd ${WRKSRC} && ${COPYTREE_SHARE} demos ${STAGEDIR}${EXAMPLESDIR})
111
	${INSTALL_SCRIPT} ${WRKDIR}/shooter ${STAGEDIR}${PREFIX}/bin/
83
	${INSTALL_DATA} ${WRKSRC}/allegro.cfg ${STAGEDIR}${EXAMPLESDIR}
112
	${INSTALL_DATA} ${_DISTDIR}/shooter.png ${STAGEDIR}${PREFIX}/share/pixmaps/
113
	@(cd ${STAGEDIR}${EXAMPLESDIR}/demos/shooter && ${CHMOD} 755 shooter)
114
	${INSTALL_SCRIPT} ${WRKDIR}/skater* ${STAGEDIR}${PREFIX}/bin
115
	${INSTALL_DATA} ${_DISTDIR}/skater.png ${STAGEDIR}${PREFIX}/share/pixmaps/
116
	@(cd ${STAGEDIR}${EXAMPLESDIR}/demos/skater && ${CHMOD} 755 skater*)
117
	${STRIP_CMD} ${STAGEDIR}${EXAMPLESDIR}/demos/shooter/shooter
118
	${STRIP_CMD} ${STAGEDIR}${EXAMPLESDIR}/demos/skater/skater*
119
.endif
120
84
121
.include <bsd.port.mk>
85
.include <bsd.port.mk>
(-)distinfo (-6 / +3 lines)
Lines 1-6 Link Here
1
SHA256 (allegro/allegro-4.4.2.tar.gz) = 1b21e7577dbfada02d85ca4510bd22fedaa6ce76fde7f4838c7c1276eb840fdc
1
TIMESTAMP = 1483711950
2
SIZE (allegro/allegro-4.4.2.tar.gz) = 4674902
2
SHA256 (allegro-4.4.2.tar.gz) = 1b21e7577dbfada02d85ca4510bd22fedaa6ce76fde7f4838c7c1276eb840fdc
3
SHA256 (allegro/shooter.png) = cf73f63f0224a9ee77c287b6211beb4a072ba4aa969a57993e60a2e97996e468
3
SIZE (allegro-4.4.2.tar.gz) = 4674902
4
SIZE (allegro/shooter.png) = 1741
5
SHA256 (allegro/skater.png) = f0274627c6eae2ecad880c3e2f25bf5f8944f08829ac32ab0a00f77001e8b2f3
6
SIZE (allegro/skater.png) = 3395
(-)files/patch-CMakeLists.txt (-3 / +29 lines)
Lines 1-6 Link Here
1
--- CMakeLists.txt.orig
1
--- CMakeLists.txt.orig	2011-03-24 23:18:50 UTC
2
+++ CMakeLists.txt
2
+++ CMakeLists.txt
3
@@ -66,7 +66,7 @@
3
@@ -66,7 +66,7 @@ if(WIN32)
4
 endif(WIN32)
4
 endif(WIN32)
5
 
5
 
6
 set(ALLEGRO_VERSION 4.4.2)
6
 set(ALLEGRO_VERSION 4.4.2)
Lines 9-15 Link Here
9
 
9
 
10
 # Mac OS X -compatibility_version.
10
 # Mac OS X -compatibility_version.
11
 # XXX doesn't seem to work
11
 # XXX doesn't seem to work
12
@@ -961,7 +961,7 @@
12
@@ -408,6 +408,7 @@ option(WANT_OSS "Build OSS support" on)
13
 option(WANT_ALSA "Build ALSA support" on)
14
 option(WANT_JACK "Build JACK support" on)
15
 option(WANT_SGIAUDIO "Build SGI audio support" on)
16
+option(WANT_SNDIO "Build sndio audio support" on)
17
 
18
 if(ALLEGRO_UNIX) # not MACOSX
19
     find_package(Threads)
20
@@ -471,6 +472,17 @@ if(ALLEGRO_UNIX) # not MACOSX
21
         endif(SGIAUDIO_FOUND)
22
     endif(WANT_SGIAUDIO)
23
 
24
+    if(WANT_SNDIO)
25
+        find_path(SNDIO_INCLUDE_DIR sndio.h)
26
+        find_library(SNDIO_LIBRARY NAMES sndio)
27
+        if(SNDIO_INCLUDE_DIR AND SNDIO_LIBRARY)
28
+            set(ALLEGRO_WITH_SNDIODIGI 1)
29
+            include_directories(SYSTEM ${SNDIO_INCLUDE_DIR})
30
+            list(APPEND PLATFORM_LIBS_NON_MODULES ${SNDIO_LIBRARY})
31
+            add_our_module(alleg-sndiodigi src/unix/sndio.c ${SNDIO_LIBRARY})
32
+        endif(SNDIO_INCLUDE_DIR AND SNDIO_LIBRARY)
33
+    endif(WANT_SNDIO)
34
+
35
     # aRts is obsolete
36
     # esd is obsolete
37
 endif(ALLEGRO_UNIX)
38
@@ -961,7 +973,7 @@ if(UNIX)
13
             @ONLY
39
             @ONLY
14
             )
40
             )
15
         install(FILES ${LIBRARY_OUTPUT_PATH}/pkgconfig/${name}${lib_type}.pc
41
         install(FILES ${LIBRARY_OUTPUT_PATH}/pkgconfig/${name}${lib_type}.pc
(-)files/patch-allegro.cfg (+11 lines)
Line 0 Link Here
1
$OpenBSD: patch-allegro_cfg,v 1.1 2010/04/26 02:56:30 jakemsr Exp $
2
--- allegro.cfg.orig	2006-05-21 10:01:46 UTC
3
+++ allegro.cfg
4
@@ -326,6 +326,7 @@ mouse_accel_factor = 
5
 #  ARTS     - aRts (Analog Real-Time Synthesizer)
6
 #  ALSA     - ALSA Sound System
7
 #  JACK     - JACK Audio Server
8
+#  SIOD     - sndio Audio API
9
 #
10
 # BeOS digital sound drivers:
11
 #
(-)files/patch-cmake_FileList.cmake (+10 lines)
Line 0 Link Here
1
--- cmake/FileList.cmake.orig	2011-03-12 00:26:00 UTC
2
+++ cmake/FileList.cmake
3
@@ -260,6 +260,7 @@ set(ALLEGRO_SRC_UNIX_FILES
4
         src/unix/arts.c
5
         src/unix/sgial.c
6
         src/unix/jack.c
7
+	src/unix/sndio.c
8
         src/unix/udjgpp.c
9
         src/unix/udrvlist.c
10
         src/unix/udummy.c
(-)files/patch-include_allegro_platform_alunix.h (+25 lines)
Line 0 Link Here
1
$OpenBSD: patch-include_allegro_platform_alunix_h,v 1.1 2010/04/26 02:56:30 jakemsr Exp $
2
--- include/allegro/platform/alunix.h.orig	2007-06-16 01:52:28 UTC
3
+++ include/allegro/platform/alunix.h
4
@@ -69,6 +69,8 @@ AL_VAR(TIMER_DRIVER, timerdrv_unix_sigal
5
 #define DIGI_ALSA             AL_ID('A','L','S','A')
6
 #define MIDI_ALSA             AL_ID('A','M','I','D')
7
 #define DIGI_JACK             AL_ID('J','A','C','K')
8
+#define DIGI_SNDIO            AL_ID('S','I','O','D')
9
+#define MIDI_SNDIO            AL_ID('M','I','O','M')
10
 
11
 
12
 #ifdef ALLEGRO_WITH_OSSDIGI
13
@@ -85,6 +87,12 @@ AL_VAR(MIDI_DRIVER, midi_oss);
14
 
15
 #ifndef ALLEGRO_WITH_MODULES
16
 
17
+#ifdef ALLEGRO_WITH_SNDIODIGI
18
+AL_VAR(DIGI_DRIVER, digi_sndio);
19
+#define DIGI_DRIVER_SNDIO                                         \
20
+      {  DIGI_SNDIO,       &digi_sndio,           TRUE  },
21
+#endif /* ALLEGRO_WITH_SNDIODIGI */
22
+
23
 #ifdef ALLEGRO_WITH_ESDDIGI
24
 AL_VAR(DIGI_DRIVER, digi_esd);
25
 #define DIGI_DRIVER_ESD                                          \
(-)files/patch-include_allegro_platform_alunixac.h.cmake (+12 lines)
Line 0 Link Here
1
--- include/allegro/platform/alunixac.h.cmake.orig	2010-05-08 05:55:30 UTC
2
+++ include/allegro/platform/alunixac.h.cmake
3
@@ -143,6 +143,9 @@
4
 /* Define if JACK DIGI driver is supported. */
5
 #cmakedefine ALLEGRO_WITH_JACKDIGI
6
 
7
+/* Define if SNDIO DIGI driver is supported. */
8
+#cmakedefine ALLEGRO_WITH_SNDIODIGI
9
+
10
 /* Define if OSS DIGI driver is supported. */
11
 #cmakedefine ALLEGRO_WITH_OSSDIGI
12
 
(-)files/patch-modules.lst (+7 lines)
Line 0 Link Here
1
--- modules.lst.orig	2004-04-10 00:19:15 UTC
2
+++ modules.lst
3
@@ -10,3 +10,4 @@ alleg-sgialdigi.so
4
 alleg-alsadigi.so
5
 alleg-alsamidi.so
6
 alleg-jackdigi.so
7
+alleg-sndiodigi.so
(-)files/patch-src-x-xkeyboard.c (-19 lines)
Lines 1-19 Link Here
1
--- src/x/xkeyboard.c.orig	2010-12-08 09:13:50.000000000 +0100
2
+++ src/x/xkeyboard.c	2013-07-28 00:17:52.000000000 +0200
3
@@ -23,6 +23,7 @@
4
 #include <X11/Xos.h>
5
 #include <X11/Xlib.h>
6
 #include <X11/Xutil.h>
7
+#include <X11/XKBlib.h>
8
 #include <X11/Xproto.h>
9
 
10
 #include "allegro.h"
11
@@ -617,7 +618,7 @@
12
 
13
       TRACE (PREFIX_I "Modifier %d:", i + 1);
14
       for (j = 0; j < xmodmap->max_keypermod; j++) {
15
-	 KeySym sym = XKeycodeToKeysym(_xwin.display,
16
+	 KeySym sym = XkbKeycodeToKeysym(_xwin.display, 0,
17
 	    xmodmap->modifiermap[i * xmodmap->max_keypermod + j], 0);
18
          char *sym_str = XKeysymToString(sym);
19
          TRACE(" %s", sym_str ? sym_str : "NULL");
(-)files/patch-src_unix_usnddrv.c (+12 lines)
Line 0 Link Here
1
--- src/unix/usnddrv.c.orig	2004-09-24 14:45:03 UTC
2
+++ src/unix/usnddrv.c
3
@@ -24,6 +24,9 @@ BEGIN_DIGI_DRIVER_LIST
4
 #if (defined ALLEGRO_WITH_JACKDIGI) && (!defined ALLEGRO_WITH_MODULES)
5
    DIGI_DRIVER_JACK
6
 #endif
7
+#if (defined ALLEGRO_WITH_SNDIODIGI) && (!defined ALLEGRO_WITH_MODULES)
8
+   DIGI_DRIVER_SNDIO
9
+#endif
10
 #if (defined ALLEGRO_WITH_SGIALDIGI) && (!defined ALLEGRO_WITH_MODULES)
11
    DIGI_DRIVER_SGIAL
12
 #endif
(-)files/patch-src_x_xkeyboard.c (-3 / +3 lines)
Lines 1-5 Link Here
1
--- src/x/xkeyboard.c.orig	2010-12-08 09:13:50.000000000 +0100
1
--- src/x/xkeyboard.c.orig	2010-12-08 08:13:50 UTC
2
+++ src/x/xkeyboard.c	2013-07-28 00:17:52.000000000 +0200
2
+++ src/x/xkeyboard.c
3
@@ -23,6 +23,7 @@
3
@@ -23,6 +23,7 @@
4
 #include <X11/Xos.h>
4
 #include <X11/Xos.h>
5
 #include <X11/Xlib.h>
5
 #include <X11/Xlib.h>
Lines 8-14 Link Here
8
 #include <X11/Xproto.h>
8
 #include <X11/Xproto.h>
9
 
9
 
10
 #include "allegro.h"
10
 #include "allegro.h"
11
@@ -617,7 +618,7 @@
11
@@ -617,7 +618,7 @@ void _xwin_get_keyboard_mapping(void)
12
 
12
 
13
       TRACE (PREFIX_I "Modifier %d:", i + 1);
13
       TRACE (PREFIX_I "Modifier %d:", i + 1);
14
       for (j = 0; j < xmodmap->max_keypermod; j++) {
14
       for (j = 0; j < xmodmap->max_keypermod; j++) {
(-)files/pkg-message.in (-25 lines)
Lines 1-25 Link Here
1
===============================================================================
2
3
Allegro has been installed.
4
5
Allegro have two Demos (Games)
6
7
Shooter and Skater
8
9
10
You can use executable
11
12
    %%LOCALBASE%%/bin/shooter
13
14
    %%LOCALBASE%%/bin/skater
15
16
17
Or can use desktop files
18
19
    %%LOCALBASE%%/share/applications/shooter.desktop
20
21
    %%LOCALBASE%%/share/applications/skater.desktop
22
23
Have fun!
24
25
===============================================================================
(-)files/shooter.in (-7 lines)
Lines 1-7 Link Here
1
#!/bin/sh
2
#
3
# # $FreeBSD$
4
#
5
6
cd "%%EXAMPLESDIR%%/demos/shooter"
7
exec ./shooter "${@}"
(-)files/skater.in (-7 lines)
Lines 1-7 Link Here
1
#!/bin/sh
2
#
3
# # $FreeBSD$
4
#
5
6
cd "%%EXAMPLESDIR%%/demos/skater"
7
exec ./skater "${@}"
(-)files/skater_agl.in (-7 lines)
Lines 1-7 Link Here
1
#!/bin/sh
2
#
3
# # $FreeBSD$
4
#
5
6
cd "%%EXAMPLESDIR%%/demos/skater"
7
exec ./skater_agl "${@}"
(-)files/sndio.c (+509 lines)
Line 0 Link Here
1
/*
2
 * Copyright (c) 2010 Jacob Meuser <jakemsr@sdf.lonestar.org>
3
 *
4
 * Permission to use, copy, modify, and distribute this software for any
5
 * purpose with or without fee is hereby granted, provided that the above
6
 * copyright notice and this permission notice appear in all copies.
7
 *
8
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15
 */
16
17
18
#include "allegro.h"
19
20
#if (defined ALLEGRO_WITH_SNDIODIGI) && ((!defined ALLEGRO_WITH_MODULES) || (defined ALLEGRO_MODULE))
21
22
#include "allegro/internal/aintern.h"
23
#include "allegro/platform/aintunix.h"
24
25
#include <stdlib.h>
26
#include <stdio.h>
27
#include <limits.h>
28
#include <unistd.h>
29
#include <poll.h>
30
#include <sndio.h>
31
32
static int sndio_detect(int input);
33
static int sndio_init(int input, int voices);
34
static void sndio_exit(int input);
35
static int sndio_set_mixer_volume(int volume);
36
static int sndio_get_mixer_volume(void);
37
38
static int sndio_buffer_size(void);
39
40
static int sndio_rec_cap_rate(int bits, int stereo);
41
static int sndio_rec_cap_parm(int rate, int bits, int stereo);
42
static int sndio_rec_source(int source);
43
static int sndio_rec_start(int rate, int bits, int stereo);
44
static void sndio_rec_stop(void);
45
static int sndio_rec_read(void *buf);
46
47
static int open_sndio_device(int input);
48
static void sndio_update(int threaded);
49
static void movecb(void *addr, int delta);
50
static void volcb(void *addr, unsigned vol);
51
52
static struct sio_hdl *hdl;
53
static struct sio_par par;
54
static int sndio_signed;
55
static int sndio_play_bufsize, sndio_play_round, sndio_play_appbufsz;
56
static unsigned char *sndio_play_bufdata;
57
static char sndio_desc[256] = EMPTY_STRING;
58
long long sndio_realpos, sndio_playpos;
59
int sndio_volume;
60
61
static int sndio_save_bits, sndio_save_stereo, sndio_save_freq;
62
static int sndio_rec_bufsize, sndio_rec_round, sndio_rec_appbufsz;
63
static unsigned char *sndio_rec_bufdata;
64
65
DIGI_DRIVER digi_sndio =
66
{
67
	DIGI_SNDIO,
68
	empty_string,
69
	empty_string,
70
	"sndio",
71
	0,
72
	0,
73
	MIXER_MAX_SFX,
74
	MIXER_DEF_SFX,
75
76
	/* setup routines */
77
	sndio_detect,
78
	sndio_init,
79
	sndio_exit,
80
	sndio_set_mixer_volume,
81
	sndio_get_mixer_volume,
82
83
	/* for use by the audiostream functions */
84
	NULL,
85
	NULL,
86
	sndio_buffer_size,
87
88
	/* voice control functions */
89
	_mixer_init_voice,
90
	_mixer_release_voice,
91
	_mixer_start_voice,
92
	_mixer_stop_voice,
93
	_mixer_loop_voice,
94
95
	/* position control functions */
96
	_mixer_get_position,
97
	_mixer_set_position,
98
99
	/* volume control functions */
100
	_mixer_get_volume,
101
	_mixer_set_volume,
102
	_mixer_ramp_volume,
103
	_mixer_stop_volume_ramp,
104
105
	/* pitch control functions */
106
	_mixer_get_frequency,
107
	_mixer_set_frequency,
108
	_mixer_sweep_frequency,
109
	_mixer_stop_frequency_sweep,
110
111
	/* pan control functions */
112
	_mixer_get_pan,
113
	_mixer_set_pan,
114
	_mixer_sweep_pan,
115
	_mixer_stop_pan_sweep,
116
117
	/* effect control functions */
118
	_mixer_set_echo,
119
	_mixer_set_tremolo,
120
	_mixer_set_vibrato,
121
122
	/* input functions */
123
	0,
124
	0,
125
	sndio_rec_cap_rate,
126
	sndio_rec_cap_parm,
127
	sndio_rec_source,
128
	sndio_rec_start,
129
	sndio_rec_stop,
130
	sndio_rec_read
131
};
132
133
134
/* used to probe and to configure the device.  don't use sio_start() here. */
135
static int
136
open_sndio_device(int input)
137
{
138
	hdl = sio_open(NULL, (input ? SIO_REC : SIO_PLAY), 0);
139
	if (hdl == NULL) {
140
		uszprintf(allegro_error, ALLEGRO_ERROR_SIZE,
141
		    get_config_text("sio_opn failed"));
142
		return -1;
143
	}
144
145
	sio_initpar(&par);
146
	par.bits = (_sound_bits == 8) ? 8 : 16;
147
	par.sig = (_sound_bits == 8) ? 0 : 1;
148
	if (input)
149
		par.rchan = (_sound_stereo) ? 2 : 1;
150
	else
151
		par.pchan = (_sound_stereo) ? 2 : 1;
152
	par.rate = (_sound_freq > 0) ? _sound_freq : 48000;
153
	par.le = SIO_LE_NATIVE;
154
	/* allegro wants small blocks */
155
	par.round = 512;
156
	par.appbufsz = par.rate / 10;
157
158
	if (!sio_setpar(hdl, &par) || !sio_getpar(hdl, &par) ||
159
	    (par.bits != 8 && par.bits != 16) ||
160
	    (par.bits == 8 && par.sig) ||
161
	    (par.bits == 16 && !par.sig) ||
162
	    (par.bits == 16 && par.le != SIO_LE_NATIVE) ||
163
	    (input && (par.rchan != 1 && par.rchan != 2)) ||
164
	    (!input && (par.pchan != 1 && par.pchan != 2))) {
165
		ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
166
		    get_config_text("could not set sndio parameters"));
167
		sio_close(hdl);
168
		return -1;
169
	}
170
171
	_sound_bits = par.bits;
172
	_sound_stereo = input ? par.rchan == 2 : par.pchan == 2;
173
	_sound_freq = par.rate;
174
175
	if (input) {
176
		sndio_rec_round = par.round; 
177
		sndio_rec_appbufsz = par.appbufsz;
178
		sndio_rec_bufsize = par.round * par.bps * par.rchan;
179
	} else {
180
		sndio_play_round = par.round;
181
		sndio_play_appbufsz = par.appbufsz;
182
		sndio_play_bufsize = sndio_play_round * par.bps * par.pchan;
183
	}
184
	sndio_signed = par.sig ? 1 : 0;
185
186
	return 0;
187
}
188
189
190
static int
191
sndio_detect(int input)
192
{
193
	if (input) {
194
		if (digi_driver != digi_input_driver) {
195
			ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
196
			    get_config_text("sndio output driver must be installed before input can be read"));
197
			return FALSE;
198
		}
199
		return TRUE;
200
	}
201
202
	if (open_sndio_device(0) != 0)
203
		return FALSE;
204
205
	sio_close(hdl);
206
	return TRUE;
207
}
208
209
210
/* number of samples per channel in a block */
211
static int
212
sndio_buffer_size(void)
213
{
214
	return sndio_play_round;
215
}
216
217
218
/* callback for data movement notification */ 
219
static void
220
movecb(void *addr, int delta)
221
{
222
	sndio_realpos += delta;
223
}
224
225
226
/* callback for volume change notification */ 
227
static void
228
volcb(void *addr, unsigned vol)
229
{
230
	sndio_volume = vol;
231
}
232
233
234
/* write as many blocks as is currently possible */
235
static void
236
sndio_update(int threaded)
237
{
238
	struct pollfd pfd;
239
	nfds_t nfds;
240
	int i, nblocks, nbytes;
241
242
	/* make sure counters have been updated */
243
	nfds = sio_pollfd(hdl, &pfd, POLLOUT);
244
	poll(&pfd, nfds, 0);
245
	if (!(sio_revents(hdl, &pfd) & POLLOUT))
246
		return;
247
248
	nblocks = (sndio_play_appbufsz - (sndio_playpos - sndio_realpos)) /
249
	    sndio_play_round;
250
251
	/* we got POLLOUT, so we can write something.  if we don't
252
	 * write anything, we could underrun.
253
	 */
254
	if (nblocks < 1)
255
		nblocks = 1;
256
257
	for (i = 0; i < nblocks; i++) {
258
		sio_write(hdl, sndio_play_bufdata, sndio_play_bufsize);
259
		sndio_playpos += sndio_play_round;
260
		if (sio_eof(hdl)) {
261
			/* print error message? */
262
			return;
263
		}
264
		_mix_some_samples((uintptr_t) sndio_play_bufdata, 0, sndio_signed);
265
	}
266
}
267
268
269
static int
270
sndio_init(int input, int voices)
271
{
272
	char tmp1[128], tmp2[128];
273
274
	if (input) {
275
		digi_driver->rec_cap_bits = 16;
276
		digi_driver->rec_cap_stereo = TRUE;
277
		return 0;
278
	}
279
280
	if (open_sndio_device(0) != 0)
281
		return -1;
282
283
	sndio_play_bufdata = _AL_MALLOC_ATOMIC(sndio_play_bufsize);
284
	if (sndio_play_bufdata == 0) {
285
		ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
286
		    get_config_text("Can not allocate audio buffer"));
287
		sio_close(hdl);
288
		return -1;
289
	}
290
291
	sndio_realpos = sndio_playpos = 0;
292
	sio_onmove(hdl, movecb, NULL);
293
294
	sndio_volume = 127;
295
	sio_onvol(hdl, volcb, NULL);
296
297
	if (!sio_start(hdl)) {
298
		ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
299
		    get_config_text("Can not start sndio"));
300
		sio_close(hdl);
301
		return -1;
302
	}
303
304
	digi_sndio.voices = voices;
305
306
	/* first arg is total number of samples */
307
	if (_mixer_init(sndio_play_round * (_sound_stereo ? 2 : 1),
308
	    _sound_freq, _sound_stereo, ((_sound_bits == 16) ? 1 : 0),
309
	    &digi_sndio.voices) != 0) {
310
		ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
311
		    get_config_text("Can not init software mixer"));
312
		sio_close(hdl);
313
		return -1;
314
	}
315
316
	_mix_some_samples((uintptr_t) sndio_play_bufdata, 0, sndio_signed);
317
318
	/* Add audio interrupt.  */
319
	_unix_bg_man->register_func(sndio_update);
320
321
	uszprintf(sndio_desc, sizeof(sndio_desc),
322
	    get_config_text("%s: %d bits, %s, %d Hz, %s"),
323
	    "sndio device",
324
	    _sound_bits,
325
	    uconvert_ascii((sndio_signed ? "signed" : "unsigned"), tmp1),
326
	    _sound_freq,
327
	    uconvert_ascii((par.pchan == 2 ? "stereo" : "mono"), tmp2));
328
329
	digi_driver->desc = sndio_desc;
330
331
	return 0;
332
}
333
334
335
static void
336
sndio_exit(int input)
337
{
338
	if (input)
339
		return;
340
341
	_unix_bg_man->unregister_func(sndio_update);
342
343
	_AL_FREE(sndio_play_bufdata);
344
	sndio_play_bufdata = 0;
345
346
	_mixer_exit();
347
348
	if (hdl != NULL)
349
		sio_close(hdl);
350
	hdl = NULL;
351
}
352
353
354
/* 'volume' is 0-255 */
355
static int
356
sndio_set_mixer_volume(int volume)
357
{
358
	if (!sio_setvol(hdl, volume / 2))
359
		return -1;
360
361
	return 0;
362
}
363
364
365
/* should return 0-255 */
366
static int
367
sndio_get_mixer_volume(void)
368
{
369
	return sndio_volume * 2;
370
}
371
372
373
/*  Returns maximum recording sampling rate. */
374
static int
375
sndio_rec_cap_rate(int bits, int stereo)
376
{
377
	/* should use sio_getcap() */
378
	return 48000;
379
}
380
381
382
/* Returns whether the specified parameters can be set. */
383
static int
384
sndio_rec_cap_parm(int rate, int bits, int stereo)
385
{
386
	/* should use sio_getcap() */
387
	return 1;
388
}
389
390
391
/* Sets the sampling source for audio recording. */
392
static int
393
sndio_rec_source(int source)
394
{
395
	/* not implemented in sndio */
396
397
	switch (source) {
398
	case SOUND_INPUT_MIC:
399
		break;
400
	case SOUND_INPUT_LINE:
401
		break;
402
	case SOUND_INPUT_CD:
403
		break;
404
	default:
405
		return -1;
406
   }
407
408
   return 0;
409
}
410
411
412
/*
413
 *  Re-opens device with read-mode and starts recording (half-duplex).
414
 *  Returns the DMA buffer size if successful.
415
 */
416
static int
417
sndio_rec_start(int rate, int bits, int stereo)
418
{
419
	sndio_save_bits = _sound_bits;
420
	sndio_save_stereo = _sound_stereo;
421
	sndio_save_freq = _sound_freq;
422
423
	_unix_bg_man->unregister_func(sndio_update);
424
425
	if (hdl != NULL)
426
		sio_close(hdl);
427
	hdl = NULL;
428
429
	_sound_bits = bits;
430
	_sound_stereo = stereo;
431
	_sound_freq = rate;
432
433
	if (open_sndio_device(1) != 0)
434
		return 0;
435
436
	sndio_volume = 127;
437
	sio_onvol(hdl, volcb, NULL);
438
439
	if (!sio_start(hdl)) {
440
		ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
441
		    get_config_text("Can not start sndio for recording"));
442
		sio_close(hdl);
443
		return 0;
444
	}
445
446
	return sndio_rec_bufsize;
447
}
448
449
450
/* Stops recording and switches the device back to the original mode. */
451
static void
452
sndio_rec_stop(void)
453
{
454
	if (hdl != NULL)
455
		sio_close(hdl);
456
	hdl = NULL;
457
458
	_sound_bits = sndio_save_bits;
459
	_sound_stereo = sndio_save_stereo;
460
	_sound_freq = sndio_save_freq;
461
462
	if (open_sndio_device(0) != 0)
463
		return;
464
465
	sndio_realpos = sndio_playpos = 0;
466
	sio_onmove(hdl, movecb, NULL);
467
468
	sndio_volume = 127;
469
	sio_onvol(hdl, volcb, NULL);
470
471
	if (!sio_start(hdl)) {
472
		ustrzcpy(allegro_error, ALLEGRO_ERROR_SIZE,
473
		    get_config_text("Can not start sndio"));
474
		sio_close(hdl);
475
		return;
476
	}
477
478
	_unix_bg_man->register_func(sndio_update);
479
}
480
481
482
/* Retrieves the just recorded buffer, if there is one. */
483
static int
484
sndio_rec_read(void *buf)
485
{
486
	struct pollfd pfd;
487
	nfds_t nfds;
488
	int ret, nbytes, offset = 0;
489
490
	/* make sure counters have been updated */
491
	nfds = sio_pollfd(hdl, &pfd, POLLIN);
492
	poll(&pfd, nfds, 0);
493
	sio_revents(hdl, &pfd);
494
	if (!(sio_revents(hdl, &pfd) & POLLIN))
495
		return 0;
496
497
	nbytes = sndio_rec_bufsize;
498
	while (nbytes) {
499
		ret = sio_read(hdl, buf + offset, nbytes);
500
		if (sio_eof(hdl))
501
			return 0;
502
		offset += ret;
503
		nbytes -= ret;
504
	}
505
506
	return 1;
507
}
508
509
#endif	/* ALLEGRO_WITH_SNDIODIGI */
(-)pkg-descr (-1 / +1 lines)
Lines 4-7 Link Here
4
A wide range of extension packages and add-on modules are also available, which
4
A wide range of extension packages and add-on modules are also available, which
5
can be found in the "Library Extensions" section of the Allegro website.
5
can be found in the "Library Extensions" section of the Allegro website.
6
6
7
WWW: http://www.talula.demon.co.uk/allegro/
7
WWW: http://liballeg.org/
(-)pkg-plist (-10 lines)
Lines 8-16 Link Here
8
bin/pack
8
bin/pack
9
bin/pat2dat
9
bin/pat2dat
10
bin/rgbmap
10
bin/rgbmap
11
%%DEMOS%%%%EXAMPLES%%bin/shooter
12
%%DEMOS%%%%EXAMPLES%%bin/skater
13
%%DEMOS%%%%EXAMPLES%%bin/skater_agl
14
bin/textconv
11
bin/textconv
15
include/alleggl.h
12
include/alleggl.h
16
include/allegro.h
13
include/allegro.h
Lines 118-128 Link Here
118
include/loadpng.h
115
include/loadpng.h
119
include/logg.h
116
include/logg.h
120
include/xalleg.h
117
include/xalleg.h
121
%%ALSA%%lib/allegro/%%SHLIB_VER%%/alleg-alsadigi.so
122
%%ALSA%%lib/allegro/%%SHLIB_VER%%/alleg-alsamidi.so
123
%%ALSA%%lib/allegro/%%SHLIB_VER%%/alleg-dga2.so
124
%%JACK%%lib/allegro/%%SHLIB_VER%%/alleg-jack.so
125
lib/allegro/%%SHLIB_VER%%/modules.lst
126
lib/liballeg.so
118
lib/liballeg.so
127
lib/liballeg.so.4
119
lib/liballeg.so.4
128
lib/liballeg.so.%%SHLIB_VER%%
120
lib/liballeg.so.%%SHLIB_VER%%
Lines 1058-1062 Link Here
1058
man/man3/vsync.3.gz
1050
man/man3/vsync.3.gz
1059
man/man3/xor_mode.3.gz
1051
man/man3/xor_mode.3.gz
1060
man/man3/xwin_set_window_name.3.gz
1052
man/man3/xwin_set_window_name.3.gz
1061
%%DEMOS%%%%EXAMPLES%%share/pixmaps/shooter.png
1062
%%DEMOS%%%%EXAMPLES%%share/pixmaps/skater.png

Return to bug 215838