pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
ffmpeg4-nbsdaudio: Solaris compat
Module Name: pkgsrc-wip
Committed By: nia <nia%netbsd.org@localhost>
Pushed By: nee
Date: Sun Mar 15 19:38:51 2020 +0000
Changeset: aeddc95046ddf78db64776a3b8b60b07d3f48662
Modified Files:
ffmpeg4-nbsdaudio/distinfo
ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h
ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
Log Message:
ffmpeg4-nbsdaudio: Solaris compat
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=aeddc95046ddf78db64776a3b8b60b07d3f48662
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
ffmpeg4-nbsdaudio/distinfo | 8 ++--
.../patches/patch-libavdevice_nbsdaudio.c | 46 ++++++++++------------
.../patches/patch-libavdevice_nbsdaudio.h | 9 ++---
.../patches/patch-libavdevice_nbsdaudio__dec.c | 16 ++------
.../patches/patch-libavdevice_nbsdaudio__enc.c | 13 +++---
5 files changed, 39 insertions(+), 53 deletions(-)
diffs:
diff --git a/ffmpeg4-nbsdaudio/distinfo b/ffmpeg4-nbsdaudio/distinfo
index b7700c465c..a2d2363731 100644
--- a/ffmpeg4-nbsdaudio/distinfo
+++ b/ffmpeg4-nbsdaudio/distinfo
@@ -12,10 +12,10 @@ SHA1 (patch-doc_indevs.texi) = 0ca344129aca5abe1b664b39745676d2f24af9c7
SHA1 (patch-doc_outdevs.texi) = cc014637c2d8928596e4db6019f9c9e7f7fd5752
SHA1 (patch-libavdevice_Makefile) = 1d1073a3c73468e4c2c00aae48acbb7f2b402146
SHA1 (patch-libavdevice_alldevices.c) = 8662bced2511d3ab6a6f0a7b7055978a3f6d06db
-SHA1 (patch-libavdevice_nbsdaudio.c) = 4f64e2e5cb4d66204c87612008f705474ca81631
-SHA1 (patch-libavdevice_nbsdaudio.h) = 3fde4e36921ab1219158effb94e7e9e14c3adae7
-SHA1 (patch-libavdevice_nbsdaudio__dec.c) = 3f6d2846aebc02e2581d234b2bef172b347ec1e1
-SHA1 (patch-libavdevice_nbsdaudio__enc.c) = 16ed3be456d7d69e30f40059a973ba1ad0b21543
+SHA1 (patch-libavdevice_nbsdaudio.c) = 7637a69aa9b720fd16e98df4460baeb5146b5a5e
+SHA1 (patch-libavdevice_nbsdaudio.h) = 5a588bf223cd3cb7559314a3945c474c7aa4b025
+SHA1 (patch-libavdevice_nbsdaudio__dec.c) = 2c9b35944a0cf107b355548f1b3ebac75c304bd5
+SHA1 (patch-libavdevice_nbsdaudio__enc.c) = 94905ad6600b8a47970cbf7dd96c7877e81317c9
SHA1 (patch-libavformat_sctp.c) = 22bad9c7dc152aec3c60e0009899af241f495535
SHA1 (patch-libavutil_common.h) = d0f1093bc82567807b39dde990ee347f90a082c9
SHA1 (patch-libavutil_x86_asm.h) = 8f48f9e8ec08b5176bb40fc0021f3bb913dbef22
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
index 81982d4550..4ab86e131b 100644
--- a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
@@ -2,9 +2,9 @@ $NetBSD$
Add support for NetBSD audio.
---- libavdevice/nbsdaudio.c.orig 2020-03-15 17:26:08.418265764 +0000
+--- libavdevice/nbsdaudio.c.orig 2020-03-15 19:23:38.114268444 +0000
+++ libavdevice/nbsdaudio.c
-@@ -0,0 +1,106 @@
+@@ -0,0 +1,102 @@
+/*
+ * NetBSD play and grab interface
+ * Copyright (c) 2020 Yorick Hardy
@@ -30,9 +30,7 @@ Add support for NetBSD audio.
+
+#include <string.h>
+
-+#if HAVE_UNISTD_H
+#include <unistd.h>
-+#endif
+#include <fcntl.h>
+#include <sys/audioio.h>
+#include <sys/ioctl.h>
@@ -60,18 +58,16 @@ Add support for NetBSD audio.
+
+ AUDIO_INITINFO(&info);
+
-+ if (is_output) {
-+ prinfo = &(info.play);
-+ info.mode = AUMODE_PLAY;
-+ } else {
-+ prinfo = &(info.record);
-+ info.mode = AUMODE_RECORD;
-+ }
++#ifdef AUMODE_PLAY /* BSD only */
++ info.mode = is_output ? AUMODE_PLAY : AUMODE_RECORD;
++#endif
+
-+ prinfo->encoding = AUDIO_ENCODING_SLINEAR;
++ prinfo = is_output ? &info.play : &info.record;
++
++ prinfo->encoding = AUDIO_ENCODING_LINEAR;
++ prinfo->precision = 16;
+ prinfo->sample_rate = s->sample_rate;
+ prinfo->channels = s->channels;
-+ prinfo->precision = 16;
+
+ if ((err = ioctl(audio_fd, AUDIO_SETINFO, &info)) < 0) {
+ av_log(s1, AV_LOG_ERROR, "AUDIO_SETINFO: %s\n", av_err2str(AVERROR(errno)));
@@ -79,24 +75,24 @@ Add support for NetBSD audio.
+ }
+
+ if ((err = ioctl(audio_fd, AUDIO_GETINFO, &info)) < 0) {
-+ av_log(s1, AV_LOG_ERROR, "AUDIO_SETINFO: %s\n", av_err2str(AVERROR(errno)));
++ av_log(s1, AV_LOG_ERROR, "AUDIO_GETINFO: %s\n", av_err2str(AVERROR(errno)));
+ goto fail;
+ }
+
+ s->fd = audio_fd;
++#ifdef HAVE_BIGENDIAN
++ s->codec_id = AV_CODEC_ID_PCM_S16BE;
++#else
++ s->codec_id = AV_CODEC_ID_PCM_S16LE;
++#endif
++ s->precision = prinfo->precision;
+ s->sample_rate = prinfo->sample_rate;
+ s->channels = prinfo->channels;
-+ s->frame_size = NBSDAUDIO_BLOCK_SIZE;
-+
-+ switch (prinfo->encoding) {
-+ case AUDIO_ENCODING_SLINEAR_LE:
-+ s->codec_id = AV_CODEC_ID_PCM_S16LE;
-+ break;
-+ case AUDIO_ENCODING_SLINEAR_BE:
-+ s->codec_id = AV_CODEC_ID_PCM_S16BE;
-+ break;
-+ default:
-+ av_log(s1, AV_LOG_ERROR, "Could not configure device for signed 16 bit sample format\n");
++
++ s->frame_size = 32 * prinfo->precision * prinfo->channels;
++
++ if ((s->buffer = malloc(s->frame_size)) == NULL) {
++ av_log(s1, AV_LOG_ERROR, "malloc: %s\n", av_err2str(AVERROR(errno)));
+ goto fail;
+ }
+
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h
index e95a123077..ba1a1adb98 100644
--- a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.h
@@ -2,9 +2,9 @@ $NetBSD$
Add support for NetBSD audio.
---- libavdevice/nbsdaudio.h.orig 2020-03-14 15:39:35.182631007 +0000
+--- libavdevice/nbsdaudio.h.orig 2020-03-15 19:23:38.138784844 +0000
+++ libavdevice/nbsdaudio.h
-@@ -0,0 +1,44 @@
+@@ -0,0 +1,43 @@
+/*
+ * This file is part of FFmpeg.
+ *
@@ -30,16 +30,15 @@ Add support for NetBSD audio.
+
+#include "libavformat/avformat.h"
+
-+#define NBSDAUDIO_BLOCK_SIZE 4096
-+
+typedef struct NBSDAudioData {
+ AVClass *class;
+ int fd;
+ int sample_rate;
+ int channels;
+ int frame_size; /* in bytes ! */
++ int precision;
+ enum AVCodecID codec_id;
-+ uint8_t buffer[NBSDAUDIO_BLOCK_SIZE];
++ uint8_t *buffer;
+ int buffer_ptr;
+} NBSDAudioData;
+
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
index 48ef5a9a5e..4ea230f228 100644
--- a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
@@ -2,9 +2,9 @@ $NetBSD$
Add support for NetBSD audio.
---- libavdevice/nbsdaudio_dec.c.orig 2020-03-15 17:26:08.461803619 +0000
+--- libavdevice/nbsdaudio_dec.c.orig 2020-03-15 19:23:38.163902783 +0000
+++ libavdevice/nbsdaudio_dec.c
-@@ -0,0 +1,141 @@
+@@ -0,0 +1,133 @@
+/*
+ * NetBSD play and grab interface
+ * Copyright (c) 2020 Yorick Hardy
@@ -30,9 +30,7 @@ Add support for NetBSD audio.
+
+#include <stdint.h>
+
-+#if HAVE_UNISTD_H
+#include <unistd.h>
-+#endif
+#include <fcntl.h>
+#include <poll.h>
+#include <sys/audioio.h>
@@ -53,16 +51,13 @@ Add support for NetBSD audio.
+{
+ NBSDAudioData *s = s1->priv_data;
+ AVStream *st;
-+ int ret;
-+ uint8_t b[4]; /* enough for 1 frame: 2 channels * 16 bit */
+
+ st = avformat_new_stream(s1, NULL);
+ if (!st) {
+ return AVERROR(ENOMEM);
+ }
+
-+ ret = ff_nbsdaudio_audio_open(s1, 0, s1->url);
-+ if (ret < 0) {
++ if (ff_nbsdaudio_audio_open(s1, 0, s1->url) < 0) {
+ return AVERROR(EIO);
+ }
+
@@ -74,9 +69,6 @@ Add support for NetBSD audio.
+
+ avpriv_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
+
-+ /* start recording */
-+ read(s->fd, b, 4);
-+
+ return 0;
+}
+
@@ -106,7 +98,7 @@ Add support for NetBSD audio.
+ }
+
+ /* subtract time represented by the number of bytes in the audio fifo */
-+ cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels);
++ cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels * s->precision);
+
+ /* convert to wanted units */
+ pkt->pts = cur_time;
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
index 16946b1635..2599fc48fd 100644
--- a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
@@ -2,9 +2,9 @@ $NetBSD$
Add support for NetBSD audio.
---- libavdevice/nbsdaudio_enc.c.orig 2020-03-15 17:33:20.411872730 +0000
+--- libavdevice/nbsdaudio_enc.c.orig 2020-03-15 19:23:38.188567160 +0000
+++ libavdevice/nbsdaudio_enc.c
-@@ -0,0 +1,107 @@
+@@ -0,0 +1,106 @@
+/*
+ * NetBSD play and grab interface
+ * Copyright (c) 2020 Yorick Hardy
@@ -28,9 +28,7 @@ Add support for NetBSD audio.
+
+#include "config.h"
+
-+#if HAVE_UNISTD_H
+#include <unistd.h>
-+#endif
+#include <fcntl.h>
+#include <sys/audioio.h>
+#include <sys/ioctl.h>
@@ -52,6 +50,7 @@ Add support for NetBSD audio.
+ st = s1->streams[0];
+ s->sample_rate = st->codecpar->sample_rate;
+ s->channels = st->codecpar->channels;
++ s->codec_id = st->codecpar->codec_id;
+ return ff_nbsdaudio_audio_open(s1, 1, s1->url) < 0 ? AVERROR(EIO) : 0;
+}
+
@@ -63,12 +62,12 @@ Add support for NetBSD audio.
+ uint8_t *buf= pkt->data;
+
+ while (size > 0) {
-+ len = FFMIN(NBSDAUDIO_BLOCK_SIZE - s->buffer_ptr, size);
++ len = FFMIN(s->frame_size - s->buffer_ptr, size);
+ memcpy(s->buffer + s->buffer_ptr, buf, len);
+ s->buffer_ptr += len;
-+ if (s->buffer_ptr >= NBSDAUDIO_BLOCK_SIZE) {
++ if (s->buffer_ptr >= s->frame_size) {
+ for(;;) {
-+ ret = write(s->fd, s->buffer, NBSDAUDIO_BLOCK_SIZE);
++ ret = write(s->fd, s->buffer, s->frame_size);
+ if (ret > 0)
+ break;
+ if (ret < 0 && (errno != EAGAIN && errno != EINTR))
Home |
Main Index |
Thread Index |
Old Index