pkgsrc-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

CVS commit: pkgsrc/audio



Module Name:    pkgsrc
Committed By:   nia
Date:           Fri Jul  1 18:36:28 UTC 2022

Modified Files:
        pkgsrc/audio: Makefile
Added Files:
        pkgsrc/audio/shairport-sync: DESCR MESSAGE.NetBSD Makefile PLIST
            distinfo options.mk
        pkgsrc/audio/shairport-sync/files: shairport-sync.sh
        pkgsrc/audio/shairport-sync/patches: patch-Makefile.am patch-audio.c
            patch-audio__sun.c patch-common.c patch-configure.ac
            patch-shairport.c

Log Message:
add audio/shairport-sync

Shairport Sync is an AirPlay audio player - it plays audio streamed from
Apple devices and AirPlay sources such as ForkedDaapd (but apparently not
rtunes).

Audio played by a Shairport Sync-powered device stays synchronised with the
source and hence with similar devices playing the same source. In this way,
synchronised multi-room audio is possible for players that support it.


To generate a diff of this commit:
cvs rdiff -u -r1.654 -r1.655 pkgsrc/audio/Makefile
cvs rdiff -u -r0 -r1.1 pkgsrc/audio/shairport-sync/DESCR \
    pkgsrc/audio/shairport-sync/MESSAGE.NetBSD \
    pkgsrc/audio/shairport-sync/Makefile pkgsrc/audio/shairport-sync/PLIST \
    pkgsrc/audio/shairport-sync/distinfo \
    pkgsrc/audio/shairport-sync/options.mk
cvs rdiff -u -r0 -r1.1 pkgsrc/audio/shairport-sync/files/shairport-sync.sh
cvs rdiff -u -r0 -r1.1 pkgsrc/audio/shairport-sync/patches/patch-Makefile.am \
    pkgsrc/audio/shairport-sync/patches/patch-audio.c \
    pkgsrc/audio/shairport-sync/patches/patch-audio__sun.c \
    pkgsrc/audio/shairport-sync/patches/patch-common.c \
    pkgsrc/audio/shairport-sync/patches/patch-configure.ac \
    pkgsrc/audio/shairport-sync/patches/patch-shairport.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: pkgsrc/audio/Makefile
diff -u pkgsrc/audio/Makefile:1.654 pkgsrc/audio/Makefile:1.655
--- pkgsrc/audio/Makefile:1.654 Sun Apr 24 00:20:01 2022
+++ pkgsrc/audio/Makefile       Fri Jul  1 18:36:27 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.654 2022/04/24 00:20:01 tnn Exp $
+# $NetBSD: Makefile,v 1.655 2022/07/01 18:36:27 nia Exp $
 #
 
 COMMENT=       Audio tools, players, and libraries
@@ -436,6 +436,7 @@ SUBDIR+=    ruby-mp3info
 SUBDIR+=       ruby-taglib
 SUBDIR+=       schismtracker
 SUBDIR+=       sfxr
+SUBDIR+=       shairport-sync
 SUBDIR+=       shine
 SUBDIR+=       shntool
 SUBDIR+=       shorten

Added files:

Index: pkgsrc/audio/shairport-sync/DESCR
diff -u /dev/null pkgsrc/audio/shairport-sync/DESCR:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/DESCR   Fri Jul  1 18:36:27 2022
@@ -0,0 +1,7 @@
+Shairport Sync is an AirPlay audio player - it plays audio streamed from
+Apple devices and AirPlay sources such as ForkedDaapd (but apparently not
+rtunes).
+
+Audio played by a Shairport Sync-powered device stays synchronised with the
+source and hence with similar devices playing the same source. In this way,
+synchronised multi-room audio is possible for players that support it.
Index: pkgsrc/audio/shairport-sync/MESSAGE.NetBSD
diff -u /dev/null pkgsrc/audio/shairport-sync/MESSAGE.NetBSD:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/MESSAGE.NetBSD  Fri Jul  1 18:36:27 2022
@@ -0,0 +1,9 @@
+===========================================================================
+$NetBSD: MESSAGE.NetBSD,v 1.1 2022/07/01 18:36:27 nia Exp $
+
+To run shairport-sync as the shairport user, make sure audio(4) is
+configured for multi-user access:
+
+# sysctl -w hw.audio0.multiuser=1
+
+===========================================================================
Index: pkgsrc/audio/shairport-sync/Makefile
diff -u /dev/null pkgsrc/audio/shairport-sync/Makefile:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/Makefile        Fri Jul  1 18:36:27 2022
@@ -0,0 +1,79 @@
+# $NetBSD: Makefile,v 1.1 2022/07/01 18:36:27 nia Exp $
+
+DISTNAME=      shairport-sync-3.3.9
+CATEGORIES=    audio
+MASTER_SITES=  ${MASTER_SITE_GITHUB:=mikebrady/}
+
+MAINTAINER=    nia%NetBSD.org@localhost
+HOMEPAGE=      https://github.com/mikebrady/shairport-sync
+COMMENT=       AirPlay audio player with multi-room audio synchronisation capability
+LICENSE=       mit # possibly others?
+
+USE_TOOLS+=    autoconf autoreconf automake
+USE_TOOLS+=    pkg-config
+USE_LANGUAGES= c c++
+
+GNU_CONFIGURE= yes
+
+BUILD_DEFS+=   VARBASE
+
+SHAIRPORT_GROUP?=      shairport
+SHAIRPORT_USER?=       shairport
+
+.include "../../mk/bsd.prefs.mk"
+
+PKG_GROUPS=            ${SHAIRPORT_GROUP}
+PKG_USERS=             ${SHAIRPORT_USER}:${SHAIRPORT_GROUP}
+
+RCD_SCRIPTS=           ${PKGBASE}
+
+FILES_SUBST+=          SHAIRPORT_USER=${SHAIRPORT_USER}
+FILES_SUBST+=          SHAIRPORT_GROUP=${SHAIRPORT_GROUP}
+FILES_SUBST+=          VARBASE=${VARBASE}
+
+CONFIGURE_ARGS+=       --with-ao
+CONFIGURE_ARGS+=       --with-libdaemon
+CONFIGURE_ARGS+=       --with-metadata
+CONFIGURE_ARGS+=       --with-pipe
+CONFIGURE_ARGS+=       --with-soxr
+CONFIGURE_ARGS+=       --with-stdout
+
+CONFIGURE_ARGS+=       --without-configfiles
+
+.if ${OPSYS} == "NetBSD" || ${OPSYS} == "SunOS" || \
+    exists(/usr/include/sys/audioio.h)
+CONFIGURE_ARGS+=       --with-sun
+.endif
+
+.if ${OPSYS} != "Darwin"
+CPPFLAGS+=     -DCOMPILE_FOR_LINUX_AND_FREEBSD_AND_CYGWIN_AND_OPENBSD=1
+.endif
+
+SUBST_CLASSES+=                etc
+SUBST_STAGE.etc=       pre-configure
+SUBST_FILES.etc+=      shairport.c
+SUBST_VARS.etc+=       PKG_SYSCONFDIR
+SUBST_VARS.etc+=       VARBASE
+
+INSTALLATION_DIRS+=    share/examples/${PKGBASE}
+
+CONF_FILES+=   ${PREFIX}/share/examples/${PKGBASE}/${PKGBASE}.conf \
+               ${PKG_SYSCONFDIR}/${PKGBASE}.conf
+
+OWN_DIRS_PERMS+=       ${VARBASE}/run/shairport-sync \
+                       ${SHAIRPORT_USER} ${SHAIRPORT_GROUP} 0755
+
+pre-configure:
+       cd ${WRKSRC} && autoreconf -fi
+
+post-install:
+       ${INSTALL_DATA} ${WRKSRC}/scripts/shairport-sync.conf \
+           ${DESTDIR}${PREFIX}/share/examples/${PKGBASE}/${PKGBASE}.conf
+
+.include "options.mk"
+.include "../../audio/libao/buildlink3.mk"
+.include "../../audio/libsoxr/buildlink3.mk"
+.include "../../devel/libconfig/buildlink3.mk"
+.include "../../devel/libdaemon/buildlink3.mk"
+.include "../../devel/popt/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
Index: pkgsrc/audio/shairport-sync/PLIST
diff -u /dev/null pkgsrc/audio/shairport-sync/PLIST:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/PLIST   Fri Jul  1 18:36:27 2022
@@ -0,0 +1,4 @@
+@comment $NetBSD: PLIST,v 1.1 2022/07/01 18:36:27 nia Exp $
+bin/shairport-sync
+man/man7/shairport-sync.7
+share/examples/shairport-sync/shairport-sync.conf
Index: pkgsrc/audio/shairport-sync/distinfo
diff -u /dev/null pkgsrc/audio/shairport-sync/distinfo:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/distinfo        Fri Jul  1 18:36:27 2022
@@ -0,0 +1,11 @@
+$NetBSD: distinfo,v 1.1 2022/07/01 18:36:27 nia Exp $
+
+BLAKE2s (shairport-sync-3.3.9.tar.gz) = 1fb7074a2af92bb759c07a408e7078f96fd7363d2e963111664a7ebdb15f18c2
+SHA512 (shairport-sync-3.3.9.tar.gz) = 725bbab9f35a209a1893851d6f470a830d396cf73620361b42444459359c04bb98a090d91b74db080eb17cee597ca9da2dd51285e629bd34d6e5f79682fe6470
+Size (shairport-sync-3.3.9.tar.gz) = 426827 bytes
+SHA1 (patch-Makefile.am) = 7986bbcd9db23bbb46bb6f383bf20268fd0e56cd
+SHA1 (patch-audio.c) = 09efa3814893b878214505c7e95b6f323e317399
+SHA1 (patch-audio__sun.c) = b48b166b557bb61e89b7f91ba812ef9f3f76ff01
+SHA1 (patch-common.c) = 495e6e7cdf243daf18c695e052eef1bf0174c880
+SHA1 (patch-configure.ac) = ea06a77574022542263fab5affef5722a6a31b7c
+SHA1 (patch-shairport.c) = e8905c0b705b048d8934051f43c7054a3c1c5483
Index: pkgsrc/audio/shairport-sync/options.mk
diff -u /dev/null pkgsrc/audio/shairport-sync/options.mk:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/options.mk      Fri Jul  1 18:36:27 2022
@@ -0,0 +1,58 @@
+# $NetBSD: options.mk,v 1.1 2022/07/01 18:36:27 nia Exp $
+
+PKG_OPTIONS_VAR=       PKG_OPTIONS.shairport-sync
+
+PKG_OPTIONS_REQUIRED_GROUPS=   ssl
+PKG_OPTIONS_OPTIONAL_GROUPS=   dnssd
+PKG_OPTIONS_GROUP.ssl=         openssl mbedtls
+PKG_OPTIONS_GROUP.dnssd=       avahi dnssd
+
+.include "../../mk/bsd.fast.prefs.mk"
+
+PKG_SUPPORTED_OPTIONS+=                jack pulseaudio
+
+.if ${OPSYS} == "Linux"
+PKG_SUPPORTED_OPTIONS+=                alsa
+PKG_SUGGESTED_OPTIONS+=                alsa avahi
+.else
+PKG_SUGGESTED_OPTIONS+=                dnssd
+.endif
+
+PKG_SUGGESTED_OPTIONS+=                openssl
+
+.include "../../mk/bsd.options.mk"
+
+.if !empty(PKG_OPTIONS:Malsa)
+.  include "../../audio/alsa-lib/buildlink3.mk"
+CONFIGURE_ARGS+=       --with-alsa
+.endif
+
+.if !empty(PKG_OPTIONS:Mavahi)
+.  include "../../net/avahi/buildlink3.mk"
+CONFIGURE_ARGS+=       --with-avahi
+.endif
+
+.if !empty(PKG_OPTIONS:Mdnssd)
+.  include "../../net/mDNSResponder/buildlink3.mk"
+CONFIGURE_ARGS+=       --with-dns_sd
+.endif
+
+.if !empty(PKG_OPTIONS:Mjack)
+.  include "../../audio/jack/buildlink3.mk"
+CONFIGURE_ARGS+=       --with-jack
+.endif
+
+.if !empty(PKG_OPTIONS:Mpulseaudio)
+.  include "../../audio/pulseaudio/buildlink3.mk"
+CONFIGURE_ARGS+=       --with-pa
+.endif
+
+.if !empty(PKG_OPTIONS:Mopenssl)
+.  include "../../security/openssl/buildlink3.mk"
+CONFIGURE_ARGS+=       --with-ssl=openssl
+.endif
+
+.if !empty(PKG_OPTIONS:Mmbedtls)
+.  include "../../security/mbedtls/buildlink3.mk"
+CONFIGURE_ARGS+=       --with-ssl=mbedtls
+.endif

Index: pkgsrc/audio/shairport-sync/files/shairport-sync.sh
diff -u /dev/null pkgsrc/audio/shairport-sync/files/shairport-sync.sh:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/files/shairport-sync.sh Fri Jul  1 18:36:27 2022
@@ -0,0 +1,24 @@
+#!@RCD_SCRIPTS_SHELL@
+#
+# $NetBSD: shairport-sync.sh,v 1.1 2022/07/01 18:36:27 nia Exp $
+#
+# PROVIDE: shairport
+# REQUIRE: mdnsd
+# KEYWORD: shutdown
+#
+
+if [ -f /etc/rc.subr ]
+then
+       . /etc/rc.subr
+fi
+
+name="shairport"
+rcvar=${name}
+command="@PREFIX@/bin/shairport-sync"
+command_args="-d"
+shairport_user="@SHAIRPORT_USER@"
+shairport_group="@SHAIRPORT_GROUP@"
+pidfile="@VARBASE@/run/shairport-sync/shairport-sync.pid"
+
+load_rc_config $name
+run_rc_command "$1"

Index: pkgsrc/audio/shairport-sync/patches/patch-Makefile.am
diff -u /dev/null pkgsrc/audio/shairport-sync/patches/patch-Makefile.am:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/patches/patch-Makefile.am       Fri Jul  1 18:36:28 2022
@@ -0,0 +1,17 @@
+$NetBSD: patch-Makefile.am,v 1.1 2022/07/01 18:36:28 nia Exp $
+
+Add support for Sun/NetBSD audio.
+
+--- Makefile.am.orig   2020-12-01 12:16:11.000000000 +0000
++++ Makefile.am
+@@ -56,6 +56,10 @@ if USE_SNDIO
+ shairport_sync_SOURCES += audio_sndio.c
+ endif
+ 
++if USE_SUN
++shairport_sync_SOURCES += audio_sun.c
++endif
++
+ if USE_STDOUT
+ shairport_sync_SOURCES += audio_stdout.c
+ endif
Index: pkgsrc/audio/shairport-sync/patches/patch-audio.c
diff -u /dev/null pkgsrc/audio/shairport-sync/patches/patch-audio.c:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/patches/patch-audio.c   Fri Jul  1 18:36:28 2022
@@ -0,0 +1,26 @@
+$NetBSD: patch-audio.c,v 1.1 2022/07/01 18:36:28 nia Exp $
+
+Add support for Sun/NetBSD audio.
+
+--- audio.c.orig       2020-12-01 12:16:11.000000000 +0000
++++ audio.c
+@@ -37,6 +37,9 @@ extern audio_output audio_jack;
+ #ifdef CONFIG_SNDIO
+ extern audio_output audio_sndio;
+ #endif
++#ifdef CONFIG_SUN
++extern audio_output audio_sun;
++#endif
+ #ifdef CONFIG_AO
+ extern audio_output audio_ao;
+ #endif
+@@ -66,6 +69,9 @@ static audio_output *outputs[] = {
+ #ifdef CONFIG_SNDIO
+     &audio_sndio,
+ #endif
++#ifdef CONFIG_SUN
++    &audio_sun,
++#endif
+ #ifdef CONFIG_PA
+     &audio_pa,
+ #endif
Index: pkgsrc/audio/shairport-sync/patches/patch-audio__sun.c
diff -u /dev/null pkgsrc/audio/shairport-sync/patches/patch-audio__sun.c:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/patches/patch-audio__sun.c      Fri Jul  1 18:36:28 2022
@@ -0,0 +1,265 @@
+$NetBSD: patch-audio__sun.c,v 1.1 2022/07/01 18:36:28 nia Exp $
+
+Add support for Sun/NetBSD audio.
+
+--- audio_sun.c.orig   2021-04-04 06:45:52.830430162 +0000
++++ audio_sun.c
+@@ -0,0 +1,258 @@
++/*
++ * sun output driver. This file is part of Shairport Sync.
++ * Copyright (c) 2013 Dimitri Sokolyuk <demon%dim13.org@localhost>
++ * Copyright (c) 2017 Tobias Kortkamp <t%tobik.me@localhost>
++ * Copyright (c) 2021 Nia Alarie <nia%NetBSD.org@localhost>
++ *
++ * Modifications for audio synchronisation
++ * and related work, copyright (c) Mike Brady 2014 -- 2017
++ * All rights reserved.
++ *
++ * 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 "audio.h"
++#include "common.h"
++#include <pthread.h>
++#include <sys/audioio.h>
++#include <sys/ioctl.h>
++#include <sys/types.h>
++#ifdef __sun
++#include <sys/conf.h>
++#include <stropts.h>
++#endif
++#include <stdbool.h>
++#include <stdio.h>
++#include <string.h>
++#include <unistd.h>
++#include <fcntl.h>
++
++static void help(void);
++static int init(int, char **);
++static void deinit(void);
++static void start(int, int);
++static int play(void *, int);
++static void stop(void);
++static int delay(long *);
++static void flush(void);
++
++audio_output audio_sun = {.name = "sun",
++                            .help = &help,
++                            .init = &init,
++                            .deinit = &deinit,
++                            .prepare = NULL,
++                            .start = &start,
++                            .stop = &stop,
++                            .is_running = NULL,
++                            .flush = &flush,
++                            .delay = &delay,
++                            .play = &play,
++                            .volume = NULL,
++                            .parameters = NULL,
++                            .mute = NULL};
++
++static pthread_mutex_t sun_mutex = PTHREAD_MUTEX_INITIALIZER;
++static int framesize;
++static int fd;
++
++struct sun_format {
++  const char *name;
++  sps_format_t fmt;
++  unsigned int encoding;
++  unsigned int precision;
++};
++
++/* SunOS compatibility defines for NetBSD extensions. */
++
++#ifndef AUDIO_ENCODING_SLINEAR
++#define AUDIO_ENCODING_SLINEAR AUDIO_ENCODING_LINEAR
++#endif
++
++#ifndef AUDIO_ENCODING_ULINEAR
++#define AUDIO_ENCODING_ULINEAR AUDIO_ENCODING_LINEAR8
++#endif
++
++#ifndef AUDIO_ENCODING_SLINEAR_LE
++#define AUDIO_ENCODING_SLINEAR_LE AUDIO_ENCODING_LINEAR
++#endif
++
++#ifndef AUDIO_ENCODING_SLINEAR_BE
++#define AUDIO_ENCODING_SLINEAR_BE AUDIO_ENCODING_LINEAR
++#endif
++
++#ifndef AUDIO_GETBUFINFO
++#define AUDIO_GETBUFINFO AUDIO_GETINFO
++#endif
++
++#ifndef DEFAULT_DEV
++#define DEFAULT_DEV "/dev/audio"
++#endif
++
++static struct sun_format formats[] = {{"U8", SPS_FORMAT_U8, AUDIO_ENCODING_ULINEAR, 8},
++                                         {"S8", SPS_FORMAT_S8, AUDIO_ENCODING_SLINEAR, 16},
++                                         {"S16", SPS_FORMAT_S16, AUDIO_ENCODING_SLINEAR, 16},
++                                         {"S16_LE", SPS_FORMAT_S16_LE, AUDIO_ENCODING_SLINEAR_LE, 16},
++                                         {"S16_BE", SPS_FORMAT_S16_BE, AUDIO_ENCODING_SLINEAR_BE, 16},
++                                         {"S32", SPS_FORMAT_S16, AUDIO_ENCODING_SLINEAR, 32},
++                                         {"S32_LE", SPS_FORMAT_S32_LE, AUDIO_ENCODING_SLINEAR_LE, 32},
++                                         {"S32_BE", SPS_FORMAT_S32_BE, AUDIO_ENCODING_SLINEAR_BE, 32}};
++
++static void help() { printf("    -d output-device    set the output device [default*|...]\n"); }
++
++static int init(int argc, char **argv) {
++  struct audio_info info;
++  int found, opt;
++  unsigned int i;
++  const char *devname, *tmp;
++
++  // set up default values first
++
++  AUDIO_INITINFO(&info);
++  info.play.encoding = AUDIO_ENCODING_SLINEAR_LE;
++  info.play.sample_rate = 44100;
++  info.play.channels = 2;
++  info.play.precision = 16;
++
++  devname = DEFAULT_DEV;
++
++  config.audio_backend_buffer_desired_length = 1.0;
++  config.audio_backend_buffer_interpolation_threshold_in_seconds =
++      0.25; // below this, soxr interpolation will not occur -- it'll be basic interpolation
++            // instead.
++  config.audio_backend_latency_offset = 0;
++
++  // get settings from settings file
++
++  // do the "general" audio  options. Note, these options are in the "general" stanza!
++  parse_general_audio_options();
++
++  // get the specific settings
++
++  if (config.cfg != NULL) {
++    if (!config_lookup_string(config.cfg, "sun.device", &devname))
++      devname = DEFAULT_DEV;
++    if (config_lookup_string(config.cfg, "sun.format", &tmp)) {
++      for (i = 0, found = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
++        if (strcasecmp(formats[i].name, tmp) == 0) {
++          config.output_format = formats[i].fmt;
++          info.play.encoding = formats[i].encoding;
++          info.play.precision = formats[i].precision;
++          found = 1;
++          break;
++        }
++      }
++      if (!found)
++        die("Invalid output format \"%s\". Should be one of: U8, S8, S16, S16_LE, S16_BE, S32, S32_LE, S32_BE",
++            tmp);
++    }
++  }
++  optind = 1; // optind=0 is equivalent to optind=1 plus special behaviour
++  argv--;     // so we shift the arguments to satisfy getopt()
++  argc++;
++  while ((opt = getopt(argc, argv, "d:")) > 0) {
++    switch (opt) {
++    case 'd':
++      devname = optarg;
++      break;
++    default:
++      help();
++      die("Invalid audio option -%c specified", opt);
++    }
++  }
++  if (optind < argc)
++    die("Invalid audio argument: %s", argv[optind]);
++
++  pthread_mutex_lock(&sun_mutex);
++  debug(1, "Output device name is \"%s\".", devname);
++  fd = open(devname, O_WRONLY);
++  if (fd < 0)
++    die("sun: cannot open audio device");
++
++  if (ioctl(fd, AUDIO_SETINFO, &info) < 0)
++    die("sun: failed to set audio parameters");
++  if (ioctl(fd, AUDIO_GETINFO, &info) < 0)
++    die("sun: failed to get audio parameters");
++
++  framesize = (info.play.precision / 8) * info.play.channels;
++  config.output_rate = info.play.sample_rate;
++  config.audio_backend_buffer_desired_length = 1.0 * info.play.buffer_size / info.play.sample_rate;
++  config.audio_backend_latency_offset = 0;
++
++  pthread_mutex_unlock(&sun_mutex);
++  return 0;
++}
++
++static void deinit() {
++  pthread_mutex_lock(&sun_mutex);
++  close(fd);
++  pthread_mutex_unlock(&sun_mutex);
++}
++
++static void start(__attribute__((unused)) int sample_rate,
++                  __attribute__((unused)) int sample_format) {
++  struct audio_info tmpinfo;
++
++  AUDIO_INITINFO(&tmpinfo);
++  tmpinfo.play.pause = false;
++
++  pthread_mutex_lock(&sun_mutex);
++  if (ioctl(fd, AUDIO_SETINFO, &tmpinfo) < 0)
++      die("sun: unable to start");
++  pthread_mutex_unlock(&sun_mutex);
++}
++
++static int play(void *buf, int frames) {
++  if (frames > 0) {
++    pthread_mutex_lock(&sun_mutex);
++    if (write(fd, buf, frames * framesize) < 0)
++      die("sun: unable to write");
++    pthread_mutex_unlock(&sun_mutex);
++  }
++  return 0;
++}
++
++static void stop() {
++  struct audio_info tmpinfo;
++
++  AUDIO_INITINFO(&tmpinfo);
++  tmpinfo.play.pause = true;
++
++  pthread_mutex_lock(&sun_mutex);
++  (void)ioctl(fd, AUDIO_DRAIN, NULL);
++  if (ioctl(fd, AUDIO_SETINFO, &tmpinfo) < 0)
++      die("sun: unable to stop");
++  pthread_mutex_unlock(&sun_mutex);
++}
++
++static int delay(long *_delay) {
++  struct audio_info tmpinfo;
++
++  pthread_mutex_lock(&sun_mutex);
++  if (ioctl(fd, AUDIO_GETBUFINFO, &tmpinfo) < 0)
++    die("sun: unable to get audio buffer info");
++  *_delay = tmpinfo.play.seek / framesize;
++  pthread_mutex_unlock(&sun_mutex);
++  return 0;
++}
++
++static void flush() {
++  pthread_mutex_lock(&sun_mutex);
++#ifdef AUDIO_FLUSH
++  if (ioctl(fd, AUDIO_FLUSH, NULL) < 0)
++    die("sun: unable to flush");
++#else
++  if (ioctl(fd, I_FLUSH, FLUSHW) < 0)
++    die("sun: unable to flush");
++#endif
++  pthread_mutex_unlock(&sun_mutex);
++}
Index: pkgsrc/audio/shairport-sync/patches/patch-common.c
diff -u /dev/null pkgsrc/audio/shairport-sync/patches/patch-common.c:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/patches/patch-common.c  Fri Jul  1 18:36:28 2022
@@ -0,0 +1,16 @@
+$NetBSD: patch-common.c,v 1.1 2022/07/01 18:36:28 nia Exp $
+
+Add support for Sun/NetBSD audio.
+
+--- common.c.orig      2020-12-01 12:16:11.000000000 +0000
++++ common.c
+@@ -1465,6 +1465,9 @@ char *get_version_string() {
+ #ifdef CONFIG_SNDIO
+     strcat(version_string, "-sndio");
+ #endif
++#ifdef CONFIG_SUN
++    strcat(version_string, "-sun");
++#endif
+ #ifdef CONFIG_JACK
+     strcat(version_string, "-jack");
+ #endif
Index: pkgsrc/audio/shairport-sync/patches/patch-configure.ac
diff -u /dev/null pkgsrc/audio/shairport-sync/patches/patch-configure.ac:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/patches/patch-configure.ac      Fri Jul  1 18:36:28 2022
@@ -0,0 +1,21 @@
+$NetBSD: patch-configure.ac,v 1.1 2022/07/01 18:36:28 nia Exp $
+
+Add support for Sun/NetBSD audio.
+
+--- configure.ac.orig  2021-12-08 10:42:01.000000000 +0000
++++ configure.ac
+@@ -268,6 +268,14 @@ if test "x$with_sndio" = "xyes" ; then
+ fi
+ AM_CONDITIONAL([USE_SNDIO], [test "x$with_sndio" = "xyes"])
+ 
++# Look for SUN flag
++AC_ARG_WITH(sun, [AS_HELP_STRING([--with-sun],[choose Sun/NetBSD audio API support])])
++if test "x$with_sun" = "xyes" ; then
++  AC_DEFINE([CONFIG_SUN], 1, [Include a Sun-compatible audio backend.])
++  AC_CHECK_HEADER([sys/audioio.h], , AC_MSG_ERROR(Sun audio support requires the sys/audioio.h header))
++fi
++AM_CONDITIONAL([USE_SUN], [test "x$with_sun" = "xyes"])
++
+ # Look for AO flag
+ AC_ARG_WITH(ao, [AS_HELP_STRING([--with-ao],[choose AO (Audio Output?) API support. N.B. no synchronisation -- so underflow or overflow is inevitable!])])
+ if test "x$with_ao" = "xyes" ; then
Index: pkgsrc/audio/shairport-sync/patches/patch-shairport.c
diff -u /dev/null pkgsrc/audio/shairport-sync/patches/patch-shairport.c:1.1
--- /dev/null   Fri Jul  1 18:36:28 2022
+++ pkgsrc/audio/shairport-sync/patches/patch-shairport.c       Fri Jul  1 18:36:28 2022
@@ -0,0 +1,29 @@
+$NetBSD: patch-shairport.c,v 1.1 2022/07/01 18:36:28 nia Exp $
+
+Show the configurable config file install location.
+
+--- shairport.c.orig   2021-12-08 10:42:01.000000000 +0000
++++ shairport.c
+@@ -217,11 +217,11 @@ void usage(char *progname) {
+ #endif
+   printf("    -V, --version           show version information.\n");
+   printf("    -c, --configfile=FILE   read configuration settings from FILE. Default is "
+-         "/etc/shairport-sync.conf.\n");
++         "@PKG_SYSCONFDIR@/shairport-sync.conf.\n");
+ 
+   printf("\n");
+   printf("The following general options are for backward compatibility. These and all new options "
+-         "have settings in the configuration file, by default /etc/shairport-sync.conf:\n");
++         "have settings in the configuration file, by default @PKG_SYSCONFDIR@/shairport-sync.conf:\n");
+   printf("    -v, --verbose           -v print debug information; -vv more; -vvv lots.\n");
+   printf("    -p, --port=PORT         set RTSP listening port.\n");
+   printf("    -a, --name=NAME         set advertised name.\n");
+@@ -1279,7 +1279,7 @@ int parse_options(int argc, char **argv)
+ #ifdef DEFINED_CUSTOM_PID_DIR
+   char *use_this_pid_dir = PIDDIR;
+ #else
+-  char *use_this_pid_dir = "/var/run/shairport-sync";
++  char *use_this_pid_dir = "@VARBASE@/run/shairport-sync";
+ #endif
+   // debug(1,"config.piddir \"%s\".",config.piddir);
+   if (config.piddir)



Home | Main Index | Thread Index | Old Index