initial import

This commit is contained in:
2025-06-22 20:39:04 -05:00
commit f8a70886f0
3428 changed files with 302546 additions and 0 deletions

View File

@@ -0,0 +1,193 @@
From d5221655dfd1a2156aa6be83b5aadea7c1e0f5bd Mon Sep 17 00:00:00 2001
From: Ron <ron@debian.org>
Date: Sat, 13 Jan 2018 20:19:20 +1030
Subject: [PATCH 1/2] Check memory allocations for success
Adds some missing checks spotted by eye in a visual review while looking
into the details of https://bugs.debian.org/870608
---
src/audio_out.c | 58 +++++++++++++++++++++++++++++++-----------
src/plugins/macosx/ao_macosx.c | 2 +-
src/plugins/sndio/ao_sndio.c | 3 +++
3 files changed, 47 insertions(+), 16 deletions(-)
diff --git a/src/audio_out.c b/src/audio_out.c
index bd8f6fc..f5942d6 100644
--- a/src/audio_out.c
+++ b/src/audio_out.c
@@ -634,6 +634,10 @@ static char *_sanitize_matrix(int maxchannels, char *matrix, ao_device *device){
char *ret = calloc(strlen(matrix)+1,1); /* can only get smaller */
char *p=matrix;
int count=0;
+
+ if(!ret)
+ return NULL;
+
while(count<maxchannels){
char *h,*t;
int m=0;
@@ -706,6 +710,15 @@ static int _find_channel(int needle, char *haystack){
return -1;
}
+static void _free_map(char **m){
+ char **in=m;
+ while(m && *m){
+ free(*m);
+ m++;
+ }
+ if(in)free(in);
+}
+
static char **_tokenize_matrix(char *matrix){
char **ret=NULL;
char *p=matrix;
@@ -730,6 +743,8 @@ static char **_tokenize_matrix(char *matrix){
}
ret = calloc(count+1,sizeof(*ret));
+ if(!ret)
+ return NULL;
p=matrix;
count=0;
@@ -748,6 +763,10 @@ static char **_tokenize_matrix(char *matrix){
while(t>p && isspace(*(t-1)))t--;
ret[count] = calloc(t-p+1,1);
+ if(!ret[count]){
+ _free_map(ret);
+ return NULL;
+ }
memcpy(ret[count],p,t-p);
count++;
if(!*h)break;
@@ -755,16 +774,6 @@ static char **_tokenize_matrix(char *matrix){
}
return ret;
-
-}
-
-static void _free_map(char **m){
- char **in=m;
- while(m && *m){
- free(*m);
- m++;
- }
- if(in)free(in);
}
static unsigned int _matrix_to_channelmask(int ch, char *matrix, char *premap, int **mout){
@@ -772,7 +781,14 @@ static unsigned int _matrix_to_channelmask(int ch, char *matrix, char *premap, i
char *p=matrix;
int *perm=(*mout=malloc(ch*sizeof(*mout)));
int i;
- char **map = _tokenize_matrix(premap);
+ char **map;
+
+ if(!perm)
+ return 0;
+
+ map = _tokenize_matrix(premap);
+ if(!map)
+ return 0;
for(i=0;i<ch;i++) perm[i] = -1;
i=0;
@@ -810,6 +826,9 @@ static char *_channelmask_to_matrix(unsigned int mask, char *premap){
char buffer[257]={0};
char **map = _tokenize_matrix(premap);
+ if(!map)
+ return NULL;
+
while(map[m]){
if(mask & (1<<m)){
if(count)
@@ -849,6 +868,9 @@ static char *_matrix_intersect(char *matrix,char *premap){
int count=0;
char **map = _tokenize_matrix(premap);
+ if(!map)
+ return NULL;
+
while(1){
char *h=p;
int m=0;
@@ -1039,7 +1061,7 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
device->output_matrix,
&device->input_map);
int channels = _channelmask_bits(mask);
- if(channels<0){
+ if(channels<=0){
aerror("Unable to map any channels from input matrix to output");
errno = AO_EBADFORMAT;
goto error;
@@ -1060,7 +1082,7 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
device->output_matrix,
&device->input_map);
int channels = _channelmask_bits(mask);
- if(channels<0){
+ if(channels<=0){
aerror("Unable to map any channels from input matrix to output");
errno = AO_EBADFORMAT;
goto error;
@@ -1111,6 +1133,10 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
int count=0;
device->inter_permute = calloc(device->output_channels,sizeof(int));
+ if (!device->inter_permute) {
+ errno = AO_EFAIL;
+ goto error;
+ }
adebug("\n");
while(count<device->output_channels){
@@ -1157,8 +1183,10 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
for(i=0;i<device->output_channels;i++)
if(device->inter_permute[i]==j)break;
if(i==device->output_channels){
- adebug("input %d (%s)\t -> none\n",
- j,inch[j]);
+ if(inch){
+ adebug("input %d (%s)\t -> none\n",
+ j,inch[j]);
+ }
unflag=1;
}
}
diff --git a/src/plugins/macosx/ao_macosx.c b/src/plugins/macosx/ao_macosx.c
index a3daf1b..129020d 100644
--- a/src/plugins/macosx/ao_macosx.c
+++ b/src/plugins/macosx/ao_macosx.c
@@ -594,11 +594,11 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format)
internal->firstValidByteOffset = 0;
internal->validByteCount = 0;
internal->buffer = malloc(internal->bufferByteCount);
- memset(internal->buffer, 0, internal->bufferByteCount);
if (!internal->buffer) {
aerror("Unable to allocate queue buffer.\n");
return 0;
}
+ memset(internal->buffer, 0, internal->bufferByteCount);
/* limited to stereo for now */
//if(!device->output_matrix)
diff --git a/src/plugins/sndio/ao_sndio.c b/src/plugins/sndio/ao_sndio.c
index ec251fb..e23fd47 100644
--- a/src/plugins/sndio/ao_sndio.c
+++ b/src/plugins/sndio/ao_sndio.c
@@ -67,6 +67,9 @@ int ao_plugin_device_init(ao_device *device)
{
ao_sndio_internal *internal;
internal = (ao_sndio_internal *) calloc(1,sizeof(*internal));
+ if (internal == NULL)
+ return 0;
+
internal->id=-1;
device->internal = internal;
device->output_matrix_order = AO_OUTPUT_MATRIX_FIXED;
--
2.12.2

View File

@@ -0,0 +1,25 @@
From 20dc8ed9fa4605f5c25e7496ede42e8ba6468225 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tmatth@videolan.org>
Date: Sat, 29 Dec 2018 15:47:27 -0500
Subject: [PATCH 2/2] ao_example: free buffer
Fixes #3
---
doc/ao_example.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/doc/ao_example.c b/doc/ao_example.c
index a2764c3..053a577 100644
--- a/doc/ao_example.c
+++ b/doc/ao_example.c
@@ -83,5 +83,7 @@ int main(int argc, char **argv)
ao_shutdown();
+ free(buffer);
+
return (0);
}
--
2.12.2

54
libao/PKGBUILD Normal file
View File

@@ -0,0 +1,54 @@
# Maintainer: Jesus E. <heckyel@riseup.net>
pkgname=libao
pkgver=1.2.2
pkgrel=2
pkgdesc='Cross-platform audio output library and plugins'
url='https://xiph.org/ao/'
arch=('i686' 'x86_64')
license=('GPL-2')
depends=('alsa-lib' 'libsndio')
optdepends=('sndio: sndio audio backend')
backup=('etc/libao.conf')
source=("$pkgname-$pkgver.tar.gz::https://github.com/xiph/$pkgname/archive/$pkgver.tar.gz"
'libao.conf'
'0001-Check-memory-allocations-for-success.patch'
'0002-ao_example-free-buffer.patch'
'patch-src_plugins_sndio_ao_sndio_c.patch')
sha512sums=('d2736d25b60862e7d7469611ce31b1df40a4366ab160e2ff1b46919ae91692d1596c8468e4f016303b306fc3ac1bddc7b727f535a362f403c3fe7c6532e9045a'
'7064b123b0a4827241e1554752344b97202d5d5c9522c5e126aba25548e3218237828aa2e5fa5b4c2d0354833bf15f894d189372a82e7cc96d395cfcbc9bd323'
'09bc3b90a6403563d2b9628aa81210e41c2935b0141fb164be60c6b82a38a16cc4f6a307df2d543d5001a740757e78de9778f8342aaeae9a8a57a190e2cdb753'
'e5a95c772a66f7631c6f7cf9d6872b1e867836599b548076d8ec689363cee4649b3234b41e2e553905c2223434dba632ae064eafb4ce1a2e6c04c7626ca687be'
'4753de36a6a222e1dd6fc3e0ff38950373b2c53c22905724e1c8db4fa799ef0c34115f4e7b7e438622e2dd5be619de6585776f2946888a4bede45612478ca23a')
conflicts=('libao-pulse')
provides=("libao-pulse=${pkgver}-${pkgrel}")
replaces=('libao-pulse')
prepare() {
cd "${srcdir}/${pkgname}-${pkgver}"
patch -p1 -i ../0001-Check-memory-allocations-for-success.patch
patch -p1 -i ../0002-ao_example-free-buffer.patch
patch -p0 -i ../patch-src_plugins_sndio_ao_sndio_c.patch
./autogen.sh
}
build() {
cd "${srcdir}/${pkgname}-${pkgver}"
./configure \
--prefix=/usr \
--enable-alsa-mmap \
--disable-pulse
make
}
package() {
cd "${srcdir}/${pkgname}-${pkgver}"
make DESTDIR="${pkgdir}" install
install -Dm644 "${srcdir}"/libao.conf "${pkgdir}"/etc/libao.conf
install -Dm644 COPYING "${pkgdir}"/usr/share/licenses/${pkgname}/COPYING
}

4
libao/libao.conf Normal file
View File

@@ -0,0 +1,4 @@
default_driver=alsa
dev=hw:0
#default_driver=sndio
#dev=snd/0

View File

@@ -0,0 +1,59 @@
$OpenBSD: patch-src_plugins_sndio_ao_sndio_c,v 1.3 2014/05/27 19:44:56 naddy Exp $
--- src/plugins/sndio/ao_sndio.c.orig Tue Feb 14 01:46:06 2012
+++ src/plugins/sndio/ao_sndio.c Tue May 27 17:07:14 2014
@@ -99,6 +99,7 @@ int ao_plugin_set_option(ao_device *device, const char
int ao_plugin_open(ao_device *device, ao_sample_format *format)
{
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
+ struct sio_hdl *hdl;
struct sio_par par;
if(!internal->dev && internal->id>=0){
@@ -107,21 +108,27 @@ int ao_plugin_open(ao_device *device, ao_sample_format
internal->dev = strdup(buf);
}
- internal->hdl = sio_open(internal->dev, SIO_PLAY, 0);
- if (internal->hdl == NULL)
+ hdl = sio_open(internal->dev, SIO_PLAY, 0);
+ if (hdl == NULL)
return 0;
+ internal->hdl = hdl;
sio_initpar(&par);
par.sig = 1;
- par.le = SIO_LE_NATIVE;
+ if (format->bits > 8)
+ par.le = device->client_byte_format == AO_FMT_LITTLE ? 1 : 0;
par.bits = format->bits;
par.rate = format->rate;
par.pchan = device->output_channels;
- if (!sio_setpar(internal->hdl, &par))
+ if (!sio_setpar(hdl, &par))
return 0;
- device->driver_byte_format = AO_FMT_NATIVE;
- if (!sio_start(internal->hdl))
+ if (!sio_getpar(hdl, &par))
return 0;
+ if (par.bits != format->bits)
+ return 0;
+ device->driver_byte_format = par.le ? AO_FMT_LITTLE : AO_FMT_BIG;
+ if (!sio_start(hdl))
+ return 0;
if(!device->inter_matrix){
/* set up matrix such that users are warned about > stereo playback */
@@ -148,9 +155,10 @@ int ao_plugin_close(ao_device *device)
ao_sndio_internal *internal = (ao_sndio_internal *) device->internal;
struct sio_hdl *hdl = internal->hdl;
- if(hdl)
- if (!sio_stop(hdl))
- return 0;
+ if(hdl){
+ sio_close(hdl);
+ internal->hdl = NULL;
+ }
return 1;
}