|
|
ab7bd3 |
diff --git a/src/audio_out.c b/src/audio_out.c
|
|
|
ab7bd3 |
index bd8f6fc..f5942d6 100644
|
|
|
ab7bd3 |
--- a/src/audio_out.c
|
|
|
ab7bd3 |
+++ b/src/audio_out.c
|
|
|
ab7bd3 |
@@ -634,6 +634,10 @@ static char *_sanitize_matrix(int maxchannels, char *matrix, ao_device *device){
|
|
|
ab7bd3 |
char *ret = calloc(strlen(matrix)+1,1); /* can only get smaller */
|
|
|
ab7bd3 |
char *p=matrix;
|
|
|
ab7bd3 |
int count=0;
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
+ if(!ret)
|
|
|
ab7bd3 |
+ return NULL;
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
while(count
|
|
|
ab7bd3 |
char *h,*t;
|
|
|
ab7bd3 |
int m=0;
|
|
|
ab7bd3 |
@@ -706,6 +710,15 @@ static int _find_channel(int needle, char *haystack){
|
|
|
ab7bd3 |
return -1;
|
|
|
ab7bd3 |
}
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
+static void _free_map(char **m){
|
|
|
ab7bd3 |
+ char **in=m;
|
|
|
ab7bd3 |
+ while(m && *m){
|
|
|
ab7bd3 |
+ free(*m);
|
|
|
ab7bd3 |
+ m++;
|
|
|
ab7bd3 |
+ }
|
|
|
ab7bd3 |
+ if(in)free(in);
|
|
|
ab7bd3 |
+}
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
static char **_tokenize_matrix(char *matrix){
|
|
|
ab7bd3 |
char **ret=NULL;
|
|
|
ab7bd3 |
char *p=matrix;
|
|
|
ab7bd3 |
@@ -730,6 +743,8 @@ static char **_tokenize_matrix(char *matrix){
|
|
|
ab7bd3 |
}
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
ret = calloc(count+1,sizeof(*ret));
|
|
|
ab7bd3 |
+ if(!ret)
|
|
|
ab7bd3 |
+ return NULL;
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
p=matrix;
|
|
|
ab7bd3 |
count=0;
|
|
|
ab7bd3 |
@@ -748,6 +763,10 @@ static char **_tokenize_matrix(char *matrix){
|
|
|
ab7bd3 |
while(t>p && isspace(*(t-1)))t--;
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
ret[count] = calloc(t-p+1,1);
|
|
|
ab7bd3 |
+ if(!ret[count]){
|
|
|
ab7bd3 |
+ _free_map(ret);
|
|
|
ab7bd3 |
+ return NULL;
|
|
|
ab7bd3 |
+ }
|
|
|
ab7bd3 |
memcpy(ret[count],p,t-p);
|
|
|
ab7bd3 |
count++;
|
|
|
ab7bd3 |
if(!*h)break;
|
|
|
ab7bd3 |
@@ -755,16 +774,6 @@ static char **_tokenize_matrix(char *matrix){
|
|
|
ab7bd3 |
}
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
return ret;
|
|
|
ab7bd3 |
-
|
|
|
ab7bd3 |
-}
|
|
|
ab7bd3 |
-
|
|
|
ab7bd3 |
-static void _free_map(char **m){
|
|
|
ab7bd3 |
- char **in=m;
|
|
|
ab7bd3 |
- while(m && *m){
|
|
|
ab7bd3 |
- free(*m);
|
|
|
ab7bd3 |
- m++;
|
|
|
ab7bd3 |
- }
|
|
|
ab7bd3 |
- if(in)free(in);
|
|
|
ab7bd3 |
}
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
static unsigned int _matrix_to_channelmask(int ch, char *matrix, char *premap, int **mout){
|
|
|
ab7bd3 |
@@ -772,7 +781,14 @@ static unsigned int _matrix_to_channelmask(int ch, char *matrix, char *premap, i
|
|
|
ab7bd3 |
char *p=matrix;
|
|
|
ab7bd3 |
int *perm=(*mout=malloc(ch*sizeof(*mout)));
|
|
|
ab7bd3 |
int i;
|
|
|
ab7bd3 |
- char **map = _tokenize_matrix(premap);
|
|
|
ab7bd3 |
+ char **map;
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
+ if(!perm)
|
|
|
ab7bd3 |
+ return 0;
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
+ map = _tokenize_matrix(premap);
|
|
|
ab7bd3 |
+ if(!map)
|
|
|
ab7bd3 |
+ return 0;
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
for(i=0;i
|
|
|
ab7bd3 |
i=0;
|
|
|
ab7bd3 |
@@ -810,6 +826,9 @@ static char *_channelmask_to_matrix(unsigned int mask, char *premap){
|
|
|
ab7bd3 |
char buffer[257]={0};
|
|
|
ab7bd3 |
char **map = _tokenize_matrix(premap);
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
+ if(!map)
|
|
|
ab7bd3 |
+ return NULL;
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
while(map[m]){
|
|
|
ab7bd3 |
if(mask & (1<
|
|
|
ab7bd3 |
if(count)
|
|
|
ab7bd3 |
@@ -849,6 +868,9 @@ static char *_matrix_intersect(char *matrix,char *premap){
|
|
|
ab7bd3 |
int count=0;
|
|
|
ab7bd3 |
char **map = _tokenize_matrix(premap);
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
+ if(!map)
|
|
|
ab7bd3 |
+ return NULL;
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
while(1){
|
|
|
ab7bd3 |
char *h=p;
|
|
|
ab7bd3 |
int m=0;
|
|
|
ab7bd3 |
@@ -1039,7 +1061,7 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
|
|
|
ab7bd3 |
device->output_matrix,
|
|
|
ab7bd3 |
&device->input_map);
|
|
|
ab7bd3 |
int channels = _channelmask_bits(mask);
|
|
|
ab7bd3 |
- if(channels<0){
|
|
|
ab7bd3 |
+ if(channels<=0){
|
|
|
ab7bd3 |
aerror("Unable to map any channels from input matrix to output");
|
|
|
ab7bd3 |
errno = AO_EBADFORMAT;
|
|
|
ab7bd3 |
goto error;
|
|
|
ab7bd3 |
@@ -1060,7 +1082,7 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
|
|
|
ab7bd3 |
device->output_matrix,
|
|
|
ab7bd3 |
&device->input_map);
|
|
|
ab7bd3 |
int channels = _channelmask_bits(mask);
|
|
|
ab7bd3 |
- if(channels<0){
|
|
|
ab7bd3 |
+ if(channels<=0){
|
|
|
ab7bd3 |
aerror("Unable to map any channels from input matrix to output");
|
|
|
ab7bd3 |
errno = AO_EBADFORMAT;
|
|
|
ab7bd3 |
goto error;
|
|
|
ab7bd3 |
@@ -1111,6 +1133,10 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
|
|
|
ab7bd3 |
int count=0;
|
|
|
ab7bd3 |
device->inter_permute = calloc(device->output_channels,sizeof(int));
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
+ if (!device->inter_permute) {
|
|
|
ab7bd3 |
+ errno = AO_EFAIL;
|
|
|
ab7bd3 |
+ goto error;
|
|
|
ab7bd3 |
+ }
|
|
|
ab7bd3 |
adebug("\n");
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
while(count<device->output_channels){
|
|
|
ab7bd3 |
@@ -1157,8 +1183,10 @@ static ao_device* _open_device(int driver_id, ao_sample_format *format,
|
|
|
ab7bd3 |
for(i=0;i<device->output_channels;i++)
|
|
|
ab7bd3 |
if(device->inter_permute[i]==j)break;
|
|
|
ab7bd3 |
if(i==device->output_channels){
|
|
|
ab7bd3 |
- adebug("input %d (%s)\t -> none\n",
|
|
|
ab7bd3 |
- j,inch[j]);
|
|
|
ab7bd3 |
+ if(inch){
|
|
|
ab7bd3 |
+ adebug("input %d (%s)\t -> none\n",
|
|
|
ab7bd3 |
+ j,inch[j]);
|
|
|
ab7bd3 |
+ }
|
|
|
ab7bd3 |
unflag=1;
|
|
|
ab7bd3 |
}
|
|
|
ab7bd3 |
}
|
|
|
ab7bd3 |
diff --git a/src/plugins/macosx/ao_macosx.c b/src/plugins/macosx/ao_macosx.c
|
|
|
ab7bd3 |
index a3daf1b..129020d 100644
|
|
|
ab7bd3 |
--- a/src/plugins/macosx/ao_macosx.c
|
|
|
ab7bd3 |
+++ b/src/plugins/macosx/ao_macosx.c
|
|
|
ab7bd3 |
@@ -594,11 +594,11 @@ int ao_plugin_open(ao_device *device, ao_sample_format *format)
|
|
|
ab7bd3 |
internal->firstValidByteOffset = 0;
|
|
|
ab7bd3 |
internal->validByteCount = 0;
|
|
|
ab7bd3 |
internal->buffer = malloc(internal->bufferByteCount);
|
|
|
ab7bd3 |
- memset(internal->buffer, 0, internal->bufferByteCount);
|
|
|
ab7bd3 |
if (!internal->buffer) {
|
|
|
ab7bd3 |
aerror("Unable to allocate queue buffer.\n");
|
|
|
ab7bd3 |
return 0;
|
|
|
ab7bd3 |
}
|
|
|
ab7bd3 |
+ memset(internal->buffer, 0, internal->bufferByteCount);
|
|
|
ab7bd3 |
|
|
|
ab7bd3 |
/* limited to stereo for now */
|
|
|
ab7bd3 |
//if(!device->output_matrix)
|
|
|
ab7bd3 |
diff --git a/src/plugins/sndio/ao_sndio.c b/src/plugins/sndio/ao_sndio.c
|
|
|
ab7bd3 |
index ec251fb..e23fd47 100644
|
|
|
ab7bd3 |
--- a/src/plugins/sndio/ao_sndio.c
|
|
|
ab7bd3 |
+++ b/src/plugins/sndio/ao_sndio.c
|
|
|
ab7bd3 |
@@ -67,6 +67,9 @@ int ao_plugin_device_init(ao_device *device)
|
|
|
ab7bd3 |
{
|
|
|
ab7bd3 |
ao_sndio_internal *internal;
|
|
|
ab7bd3 |
internal = (ao_sndio_internal *) calloc(1,sizeof(*internal));
|
|
|
ab7bd3 |
+ if (internal == NULL)
|
|
|
ab7bd3 |
+ return 0;
|
|
|
ab7bd3 |
+
|
|
|
ab7bd3 |
internal->id=-1;
|
|
|
ab7bd3 |
device->internal = internal;
|
|
|
ab7bd3 |
device->output_matrix_order = AO_OUTPUT_MATRIX_FIXED;
|