pkgsrc-WIP-changes archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
ffmpeg4-nbsdaudio: Various cleanups
Module Name: pkgsrc-wip
Committed By: nia <nia%netbsd.org@localhost>
Pushed By: nee
Date: Sun Mar 15 17:51:57 2020 +0000
Changeset: 4a22edbba7f1e2bad04df30e7a792927fe1e96aa
Modified Files:
ffmpeg4-nbsdaudio/distinfo
ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio.c
ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
Log Message:
ffmpeg4-nbsdaudio: Various cleanups
To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=4a22edbba7f1e2bad04df30e7a792927fe1e96aa
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
diffstat:
ffmpeg4-nbsdaudio/distinfo | 6 +--
.../patches/patch-libavdevice_nbsdaudio.c | 61 +++++++---------------
.../patches/patch-libavdevice_nbsdaudio__dec.c | 37 +++++--------
.../patches/patch-libavdevice_nbsdaudio__enc.c | 14 ++---
4 files changed, 40 insertions(+), 78 deletions(-)
diffs:
diff --git a/ffmpeg4-nbsdaudio/distinfo b/ffmpeg4-nbsdaudio/distinfo
index 4d6f3315eb..726b271edd 100644
--- a/ffmpeg4-nbsdaudio/distinfo
+++ b/ffmpeg4-nbsdaudio/distinfo
@@ -11,10 +11,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) = 4e876a88375cc4d556475e8f4f23fb01d159d18b
+SHA1 (patch-libavdevice_nbsdaudio.c) = 4f64e2e5cb4d66204c87612008f705474ca81631
SHA1 (patch-libavdevice_nbsdaudio.h) = 3fde4e36921ab1219158effb94e7e9e14c3adae7
-SHA1 (patch-libavdevice_nbsdaudio__dec.c) = 7ccc2cb5c89e7a179e59ea82f4ad6e1e51a649df
-SHA1 (patch-libavdevice_nbsdaudio__enc.c) = a9e50c61fb31422e57918bf9b9b72d63ebf4253f
+SHA1 (patch-libavdevice_nbsdaudio__dec.c) = 3f6d2846aebc02e2581d234b2bef172b347ec1e1
+SHA1 (patch-libavdevice_nbsdaudio__enc.c) = 16ed3be456d7d69e30f40059a973ba1ad0b21543
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 8464edc035..81982d4550 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-14 15:39:35.169889227 +0000
+--- libavdevice/nbsdaudio.c.orig 2020-03-15 17:26:08.418265764 +0000
+++ libavdevice/nbsdaudio.c
-@@ -0,0 +1,129 @@
+@@ -0,0 +1,106 @@
+/*
+ * NetBSD play and grab interface
+ * Copyright (c) 2020 Yorick Hardy
@@ -48,36 +48,16 @@ Add support for NetBSD audio.
+ const char *audio_device)
+{
+ NBSDAudioData *s = s1->priv_data;
-+ audio_info_t info;
++ struct audio_info info;
+ struct audio_prinfo *prinfo;
+ int audio_fd, err;
+
-+ if (is_output)
-+ audio_fd = avpriv_open(audio_device, O_WRONLY);
-+ else
-+ audio_fd = avpriv_open(audio_device, O_RDONLY);
++ audio_fd = avpriv_open(audio_device, is_output ? O_WRONLY : O_RDONLY);
+ if (audio_fd < 0) {
+ av_log(s1, AV_LOG_ERROR, "%s: %s\n", audio_device, av_err2str(AVERROR(errno)));
+ return AVERROR(EIO);
+ }
+
-+#if 0
-+ /* non blocking mode */
-+ if (!is_output) {
-+ if (fcntl(audio_fd, F_SETFL, O_NONBLOCK) < 0) {
-+ av_log(s1, AV_LOG_WARNING, "%s: Could not enable non block mode (%s)\n", audio_device, av_err2str(AVERROR(errno)));
-+ }
-+ }
-+#endif
-+
-+ s->frame_size = NBSDAUDIO_BLOCK_SIZE;
-+
-+#define CHECK_IOCTL_ERROR(event) \
-+ if (err < 0) { \
-+ av_log(s1, AV_LOG_ERROR, #event ": %s\n", av_err2str(AVERROR(errno)));\
-+ goto fail; \
-+ }
-+
+ AUDIO_INITINFO(&info);
+
+ if (is_output) {
@@ -92,24 +72,23 @@ Add support for NetBSD audio.
+ prinfo->sample_rate = s->sample_rate;
+ prinfo->channels = s->channels;
+ prinfo->precision = 16;
-+ prinfo->pause = 0;
-+
-+ err=ioctl(audio_fd, AUDIO_SETINFO, &info);
-+ CHECK_IOCTL_ERROR(AUDIO_SETINFO)
+
-+ err=ioctl(audio_fd, AUDIO_GETINFO, &info);
-+ CHECK_IOCTL_ERROR(AUDIO_GETINFO)
++ if ((err = ioctl(audio_fd, AUDIO_SETINFO, &info)) < 0) {
++ av_log(s1, AV_LOG_ERROR, "AUDIO_SETINFO: %s\n", av_err2str(AVERROR(errno)));
++ goto fail;
++ }
+
-+ s->fd = audio_fd;
-+ if (is_output) {
-+ s->sample_rate = prinfo->sample_rate;
-+ s->channels = prinfo->channels;
-+ } else {
-+ s->sample_rate = prinfo->sample_rate;
-+ s->channels = prinfo->channels;
++ if ((err = ioctl(audio_fd, AUDIO_GETINFO, &info)) < 0) {
++ av_log(s1, AV_LOG_ERROR, "AUDIO_SETINFO: %s\n", av_err2str(AVERROR(errno)));
++ goto fail;
+ }
+
-+ switch(prinfo->encoding) {
++ s->fd = audio_fd;
++ 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;
@@ -117,16 +96,14 @@ Add support for NetBSD audio.
+ s->codec_id = AV_CODEC_ID_PCM_S16BE;
+ break;
+ default:
-+ av_log(s1, AV_LOG_ERROR, "Soundcard does not support signed 16 bit sample format\n");
-+ close(audio_fd);
-+ return AVERROR(EIO);
++ av_log(s1, AV_LOG_ERROR, "Could not configure device for signed 16 bit sample format\n");
++ goto fail;
+ }
+
+ return 0;
+ fail:
+ close(audio_fd);
+ return AVERROR(EIO);
-+#undef CHECK_IOCTL_ERROR
+}
+
+int ff_nbsdaudio_audio_close(NBSDAudioData *s)
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
index 38e78553e9..48ef5a9a5e 100644
--- a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__dec.c
@@ -2,11 +2,11 @@ $NetBSD$
Add support for NetBSD audio.
---- libavdevice/nbsdaudio_dec.c.orig 2020-03-14 15:39:35.195802010 +0000
+--- libavdevice/nbsdaudio_dec.c.orig 2020-03-15 17:26:08.461803619 +0000
+++ libavdevice/nbsdaudio_dec.c
-@@ -0,0 +1,150 @@
+@@ -0,0 +1,141 @@
+/*
-+ * Sun and NetBSD play and grab interface
++ * NetBSD play and grab interface
+ * Copyright (c) 2020 Yorick Hardy
+ *
+ * This file is part of FFmpeg.
@@ -83,43 +83,34 @@ Add support for NetBSD audio.
+static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
+{
+ NBSDAudioData *s = s1->priv_data;
-+ audio_info_t info;
++ struct audio_info info;
+ int ret, bdelay;
+ int64_t cur_time;
-+ struct pollfd pfd;
+
-+ if ((ret=av_new_packet(pkt, s->frame_size)) < 0)
++ if ((ret = av_new_packet(pkt, s->frame_size)) < 0)
+ return ret;
+
-+ pfd.fd = s->fd;
-+ pfd.events = POLLRDNORM;
-+ if ((poll(&pfd, 1, 0) != 1) || (pfd.revents != POLLRDNORM)) {
-+ av_packet_unref(pkt);
-+ pkt->size = 0;
-+ return AVERROR(EAGAIN);
-+ }
-+
+ ret = read(s->fd, pkt->data, pkt->size);
-+ if (ret <= 0){
++ if (ret <= 0) {
+ av_packet_unref(pkt);
+ pkt->size = 0;
-+ if (ret<0) return AVERROR(errno);
-+ else return AVERROR_EOF;
++ return ret < 0 ? AVERROR(errno) : AVERROR_EOF;
+ }
-+ pkt->size = ret;
+
+ /* compute pts of the start of the packet */
+ cur_time = av_gettime();
+ bdelay = ret;
++
+ if (ioctl(s->fd, AUDIO_GETBUFINFO, &info) == 0) {
+ bdelay += info.record.seek;
+ }
++
+ /* subtract time represented by the number of bytes in the audio fifo */
+ cur_time -= (bdelay * 1000000LL) / (s->sample_rate * s->channels);
+
+ /* convert to wanted units */
+ pkt->pts = cur_time;
-+
++
+ return 0;
+}
+
@@ -132,13 +123,13 @@ Add support for NetBSD audio.
+}
+
+static const AVOption options[] = {
-+ { "sample_rate", "", offsetof(NBSDAudioData, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
-+ { "channels", "", offsetof(NBSDAudioData, channels), AV_OPT_TYPE_INT, {.i64 = 2}, 1, INT_MAX, AV_OPT_FLAG_DECODING_PARAM },
++ { "sample_rate", "", offsetof(NBSDAudioData, sample_rate), AV_OPT_TYPE_INT, {.i64 = 48000}, 1000, 192000, AV_OPT_FLAG_DECODING_PARAM },
++ { "channels", "", offsetof(NBSDAudioData, channels), AV_OPT_TYPE_INT, {.i64 = 2}, 1, 12, AV_OPT_FLAG_DECODING_PARAM },
+ { NULL },
+};
+
+static const AVClass nbsdaudio_demuxer_class = {
-+ .class_name = "Sun audio demuxer",
++ .class_name = "NetBSD audio demuxer",
+ .item_name = av_default_item_name,
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
@@ -147,7 +138,7 @@ Add support for NetBSD audio.
+
+AVInputFormat ff_nbsdaudio_demuxer = {
+ .name = "nbsdaudio",
-+ .long_name = NULL_IF_CONFIG_SMALL("Sun audio capture"),
++ .long_name = NULL_IF_CONFIG_SMALL("NetBSD audio capture"),
+ .priv_data_size = sizeof(NBSDAudioData),
+ .read_header = audio_read_header,
+ .read_packet = audio_read_packet,
diff --git a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
index 460889f906..16946b1635 100644
--- a/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
+++ b/ffmpeg4-nbsdaudio/patches/patch-libavdevice_nbsdaudio__enc.c
@@ -2,11 +2,11 @@ $NetBSD$
Add support for NetBSD audio.
---- libavdevice/nbsdaudio_enc.c.orig 2020-03-14 15:39:35.204240213 +0000
+--- libavdevice/nbsdaudio_enc.c.orig 2020-03-15 17:33:20.411872730 +0000
+++ libavdevice/nbsdaudio_enc.c
-@@ -0,0 +1,113 @@
+@@ -0,0 +1,107 @@
+/*
-+ * Sun and NetBSD play and grab interface
++ * NetBSD play and grab interface
+ * Copyright (c) 2020 Yorick Hardy
+ *
+ * This file is part of FFmpeg.
@@ -48,17 +48,11 @@ Add support for NetBSD audio.
+{
+ NBSDAudioData *s = s1->priv_data;
+ AVStream *st;
-+ int ret;
+
+ st = s1->streams[0];
+ s->sample_rate = st->codecpar->sample_rate;
+ s->channels = st->codecpar->channels;
-+ ret = ff_nbsdaudio_audio_open(s1, 1, s1->url);
-+ if (ret < 0) {
-+ return AVERROR(EIO);
-+ } else {
-+ return 0;
-+ }
++ return ff_nbsdaudio_audio_open(s1, 1, s1->url) < 0 ? AVERROR(EIO) : 0;
+}
+
+static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
Home |
Main Index |
Thread Index |
Old Index