diff options
author | wiz <wiz@pkgsrc.org> | 2014-09-15 17:31:18 +0000 |
---|---|---|
committer | wiz <wiz@pkgsrc.org> | 2014-09-15 17:31:18 +0000 |
commit | b66d618fca2c85da6b05fe8fc8d9eaab91b21f1e (patch) | |
tree | da9acc4e4805e7d6d1e78c33dcf503a5ab46d1cc | |
parent | 9de1f680c8bc0e55d53d0d651eb8a1f43534d80f (diff) | |
download | pkgsrc-b66d618fca2c85da6b05fe8fc8d9eaab91b21f1e.tar.gz |
Close audio device on pausing; allows multiple parallel mpv (or mplayer
or whatever) instances if only one of them is playing, like mplayer does.
Patch from Nat Sloss <nat@NetBSD.org>, thank you!
Sent upstream to
https://github.com/mpv-player/mpv/issues/1080
Bump PKGREVISION.
-rw-r--r-- | multimedia/mpv/Makefile | 3 | ||||
-rw-r--r-- | multimedia/mpv/distinfo | 4 | ||||
-rw-r--r-- | multimedia/mpv/patches/patch-audio_out_ao__oss.c | 93 | ||||
-rw-r--r-- | multimedia/mpv/patches/patch-audio_out_push.c | 15 |
4 files changed, 113 insertions, 2 deletions
diff --git a/multimedia/mpv/Makefile b/multimedia/mpv/Makefile index 72e2c173c8a..16047cce7cf 100644 --- a/multimedia/mpv/Makefile +++ b/multimedia/mpv/Makefile @@ -1,6 +1,7 @@ -# $NetBSD: Makefile,v 1.2 2014/09/08 12:12:22 wiz Exp $ +# $NetBSD: Makefile,v 1.3 2014/09/15 17:31:18 wiz Exp $ DISTNAME= mpv-0.5.1 +PKGREVISION= 1 CATEGORIES= multimedia MASTER_SITES= -https://github.com/mpv-player/mpv/archive/v${PKGVERSION_NOREV}${EXTRACT_SUFX} diff --git a/multimedia/mpv/distinfo b/multimedia/mpv/distinfo index cf9bae8acc5..641df575fb1 100644 --- a/multimedia/mpv/distinfo +++ b/multimedia/mpv/distinfo @@ -1,5 +1,7 @@ -$NetBSD: distinfo,v 1.1 2014/09/08 11:38:17 wiz Exp $ +$NetBSD: distinfo,v 1.2 2014/09/15 17:31:18 wiz Exp $ SHA1 (mpv-0.5.1.tar.gz) = a72be602156497545eeb78ee6adfe98720650f27 RMD160 (mpv-0.5.1.tar.gz) = f341e4647257cc35b902c3fe1787840f82a4052e Size (mpv-0.5.1.tar.gz) = 2578630 bytes +SHA1 (patch-audio_out_ao__oss.c) = ee387e66cafe3122dadabbd8246a2dbce90ed18d +SHA1 (patch-audio_out_push.c) = bde00289d2490fcfe839e6d7c80d65e4f72dd482 diff --git a/multimedia/mpv/patches/patch-audio_out_ao__oss.c b/multimedia/mpv/patches/patch-audio_out_ao__oss.c new file mode 100644 index 00000000000..f6e877ba50e --- /dev/null +++ b/multimedia/mpv/patches/patch-audio_out_ao__oss.c @@ -0,0 +1,93 @@ +$NetBSD: patch-audio_out_ao__oss.c,v 1.1 2014/09/15 17:31:18 wiz Exp $ + +https://github.com/mpv-player/mpv/issues/1080 + +--- audio/out/ao_oss.c.orig 2014-08-26 08:27:40.000000000 +0000 ++++ audio/out/ao_oss.c +@@ -450,7 +450,7 @@ static void drain(struct ao *ao) + #endif + } + +-#ifndef SNDCTL_DSP_RESET ++#if !defined(SNDCTL_DSP_RESET) || defined(__NetBSD__) + static void close_device(struct ao *ao) + { + struct priv *p = ao->priv; +@@ -464,7 +464,7 @@ static void reset(struct ao *ao) + { + struct priv *p = ao->priv; + int oss_format; +-#ifdef SNDCTL_DSP_RESET ++#if defined(SNDCTL_DSP_RESET) && !defined(__NetBSD__) + ioctl(p->audio_fd, SNDCTL_DSP_RESET, NULL); + #else + close_device(ao); +@@ -502,6 +502,9 @@ static int get_space(struct ao *ao) + struct priv *p = ao->priv; + int playsize = p->outburst; + ++ if (p->audio_fd < 0) ++ return p->outburst / ao->sstride; ++ + #ifdef SNDCTL_DSP_GETOSPACE + if (ioctl(p->audio_fd, SNDCTL_DSP_GETOSPACE, &p->zz) != -1) { + // calculate exact buffer space: +@@ -531,8 +534,12 @@ static int get_space(struct ao *ao) + static void audio_pause(struct ao *ao) + { + struct priv *p = ao->priv; ++ ++ if (p->audio_fd < 0) ++ return; ++ + p->prepause_space = get_space(ao) * ao->sstride; +-#ifdef SNDCTL_DSP_RESET ++#if defined(SNDCTL_DSP_RESET) && !defined(__NetBSD__) + ioctl(p->audio_fd, SNDCTL_DSP_RESET, NULL); + #else + close_device(ao); +@@ -548,11 +555,18 @@ static int play(struct ao *ao, void **da + int len = samples * ao->sstride; + if (len == 0) + return len; ++ + if (len > p->outburst || !(flags & AOPLAY_FINAL_CHUNK)) { + len /= p->outburst; + len *= p->outburst; + } +- len = write(p->audio_fd, data[0], len); ++ ++ if (p->audio_fd < 0) { ++ usleep((1000000 * samples) / (ao->bps + 1)); ++ return samples; ++ } else ++ len = write(p->audio_fd, data[0], len); ++ + return len / ao->sstride; + } + +@@ -560,9 +574,12 @@ static int play(struct ao *ao, void **da + static void audio_resume(struct ao *ao) + { + struct priv *p = ao->priv; +-#ifndef SNDCTL_DSP_RESET ++#if !defined (SNDCTL_DSP_RESET) || defined(__NetBSD__) + reset(ao); + #endif ++ if (p->audio_fd < 0) ++ return; ++ + int fillframes = get_space(ao) - p->prepause_space / ao->sstride; + if (fillframes > 0) + ao_play_silence(ao, fillframes); +@@ -572,6 +589,10 @@ static void audio_resume(struct ao *ao) + static float get_delay(struct ao *ao) + { + struct priv *p = ao->priv; ++ ++ if (p->audio_fd < 0) ++ return 1.0; ++ + /* Calculate how many bytes/second is sent out */ + if (p->audio_delay_method == 2) { + #ifdef SNDCTL_DSP_GETODELAY diff --git a/multimedia/mpv/patches/patch-audio_out_push.c b/multimedia/mpv/patches/patch-audio_out_push.c new file mode 100644 index 00000000000..aa6a51441f9 --- /dev/null +++ b/multimedia/mpv/patches/patch-audio_out_push.c @@ -0,0 +1,15 @@ +$NetBSD: patch-audio_out_push.c,v 1.1 2014/09/15 17:31:18 wiz Exp $ + +https://github.com/mpv-player/mpv/issues/1080 + +--- audio/out/push.c.orig 2014-08-26 08:27:40.000000000 +0000 ++++ audio/out/push.c +@@ -296,7 +296,7 @@ static void *playthread(void *arg) + // Request new data from decoder if buffer goes below "full". + // Allow a small margin of missing data for AOs that use timeouts. + double margin = ao->driver->wait ? 0 : ao->device_buffer / 8; +- if (!p->buffers_full && unlocked_get_space(ao) > margin) { ++ if (!p->paused && !p->buffers_full && unlocked_get_space(ao) > margin) { + if (!p->requested_data) + mp_input_wakeup(ao->input_ctx); + p->requested_data = true; |