Bug 666672 - Fix OSX compile warnings in sydneyaudio and vorbis. r=giles

This commit is contained in:
Atul Aggarwal 2011-09-01 11:19:22 +05:30
parent ff0c4ed5ec
commit 4091a8e4db
8 changed files with 138 additions and 27 deletions

View File

@ -387,12 +387,13 @@ sa_stream_drain(sa_stream_t *s)
if (snd_pcm_state(s->output_unit) == SND_PCM_STATE_PREPARED) {
size_t min_samples = 0;
size_t min_bytes = 0;
void *buf;
if (sa_stream_get_min_write(s, &min_samples) < 0)
return SA_ERROR_SYSTEM;
min_bytes = snd_pcm_frames_to_bytes(s->output_unit, min_samples);
void* buf = malloc(min_bytes);
buf = malloc(min_bytes);
if (!buf)
return SA_ERROR_SYSTEM;
memset(buf, 0, min_bytes);

View File

@ -120,6 +120,8 @@ sa_stream_create_pcm(
unsigned int n_channels
) {
sa_stream_t * s;
/*
* Make sure we return a NULL stream pointer on failure.
*/
@ -138,7 +140,6 @@ sa_stream_create_pcm(
/*
* Allocate the instance and required resources.
*/
sa_stream_t * s;
if ((s = malloc(sizeof(sa_stream_t))) == NULL) {
return SA_ERROR_OOM;
}
@ -170,6 +171,11 @@ sa_stream_create_pcm(
int
sa_stream_open(sa_stream_t *s) {
ComponentDescription desc;
Component comp;
AURenderCallbackStruct input;
AudioStreamBasicDescription fmt;
if (s == NULL) {
return SA_ERROR_NO_INIT;
}
@ -180,14 +186,13 @@ sa_stream_open(sa_stream_t *s) {
/*
* Open the default audio output unit.
*/
ComponentDescription desc;
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
desc.componentFlags = 0;
desc.componentFlagsMask = 0;
Component comp = FindNextComponent(NULL, &desc);
comp = FindNextComponent(NULL, &desc);
if (comp == NULL) {
return SA_ERROR_NO_DEVICE;
}
@ -199,7 +204,6 @@ sa_stream_open(sa_stream_t *s) {
/*
* Set up the render callback used to feed audio data into the output unit.
*/
AURenderCallbackStruct input;
input.inputProc = audio_callback;
input.inputProcRefCon = s;
if (AudioUnitSetProperty(s->output_unit, kAudioUnitProperty_SetRenderCallback,
@ -222,7 +226,6 @@ sa_stream_open(sa_stream_t *s) {
*
* http://developer.apple.com/documentation/MusicAudio/Reference/CoreAudioDataTypesRef/Reference/reference.html#//apple_ref/c/tdef/AudioStreamBasicDescription
*/
AudioStreamBasicDescription fmt;
fmt.mFormatID = kAudioFormatLinearPCM;
fmt.mFormatFlags = kLinearPCMFormatFlagIsSignedInteger |
#ifdef __BIG_ENDIAN__
@ -259,6 +262,8 @@ sa_stream_open(sa_stream_t *s) {
int
sa_stream_destroy(sa_stream_t *s) {
int result = SA_SUCCESS;
if (s == NULL) {
return SA_SUCCESS;
}
@ -273,7 +278,6 @@ sa_stream_destroy(sa_stream_t *s) {
* until in-flight callbacks complete and the HAL shuts down. See:
* http://lists.apple.com/archives/coreaudio-api/2005/Dec/msg00055.html
*/
int result = SA_SUCCESS;
if (s->output_unit != NULL) {
if (s->playing && AudioOutputUnitStop(s->output_unit) != 0) {
result = SA_ERROR_SYSTEM;
@ -313,6 +317,8 @@ sa_stream_destroy(sa_stream_t *s) {
int
sa_stream_write(sa_stream_t *s, const void *data, size_t nbytes) {
int result = SA_SUCCESS;
if (s == NULL || s->output_unit == NULL) {
return SA_ERROR_NO_INIT;
}
@ -325,7 +331,6 @@ sa_stream_write(sa_stream_t *s, const void *data, size_t nbytes) {
/*
* Append the new data to the end of our buffer list.
*/
int result = SA_SUCCESS;
while (1) {
unsigned int avail = s->bl_tail->size - s->bl_tail->end;
@ -371,8 +376,9 @@ sa_stream_write(sa_stream_t *s, const void *data, size_t nbytes) {
break;
}
while (s->n_bufs == BUF_LIMIT) {
pthread_mutex_unlock(&s->mutex);
struct timespec ts = {0, 1000000};
pthread_mutex_unlock(&s->mutex);
nanosleep(&ts, NULL);
pthread_mutex_lock(&s->mutex);
}
@ -420,6 +426,11 @@ audio_callback(
AudioBufferList * data
) {
sa_stream_t * s = arg;
unsigned char * dst;
unsigned int bytes_per_frame;
unsigned int bytes_to_copy;
#ifdef TIMING_TRACE
printf("."); /* audio read 'tick' */
#endif
@ -430,13 +441,11 @@ audio_callback(
*/
assert(data->mNumberBuffers == 1);
sa_stream_t * s = arg;
pthread_mutex_lock(&s->mutex);
unsigned char * dst = data->mBuffers[0].mData;
unsigned int bytes_per_frame = s->n_channels * s->bytes_per_ch;
unsigned int bytes_to_copy = n_frames * bytes_per_frame;
dst = data->mBuffers[0].mData;
bytes_per_frame = s->n_channels * s->bytes_per_ch;
bytes_to_copy = n_frames * bytes_per_frame;
s->bytes_played += s->bytes_played_last;
s->bytes_played_last = 0;
@ -445,9 +454,10 @@ audio_callback(
* Consume data from the start of the buffer list.
*/
while (1) {
assert(s->bl_head->start <= s->bl_head->end);
unsigned int avail = s->bl_head->end - s->bl_head->start;
assert(s->bl_head->start <= s->bl_head->end);
if (avail >= bytes_to_copy) {
/*
@ -460,6 +470,8 @@ audio_callback(
} else {
sa_buf * next;
/*
* Copy what we can from the head and move on to the next buffer.
*/
@ -474,7 +486,7 @@ audio_callback(
* current tail. If it is the tail, we don't have enough data to fill
* the destination buffer, so we'll just zero it out and give up.
*/
sa_buf * next = s->bl_head->next;
next = s->bl_head->next;
if (next == NULL) {
#ifdef TIMING_TRACE
printf("!"); /* not enough audio data */
@ -505,6 +517,8 @@ audio_callback(
int
sa_stream_get_write_size(sa_stream_t *s, size_t *size) {
unsigned int avail;
if (s == NULL || s->output_unit == NULL) {
return SA_ERROR_NO_INIT;
}
@ -515,7 +529,7 @@ sa_stream_get_write_size(sa_stream_t *s, size_t *size) {
* The sum of the free space in the tail buffer plus the size of any new
* buffers represents the write space available before blocking.
*/
unsigned int avail = s->bl_tail->size - s->bl_tail->end;
avail = s->bl_tail->size - s->bl_tail->end;
avail += (BUF_LIMIT - s->n_bufs) * BUF_SIZE;
*size = avail;
@ -612,9 +626,11 @@ sa_stream_drain(sa_stream_t *s)
}
while (1) {
pthread_mutex_lock(&s->mutex);
sa_buf * b;
size_t used = 0;
struct timespec ts = {0, 1000000};
pthread_mutex_lock(&s->mutex);
for (b = s->bl_head; b != NULL; b = b->next) {
used += b->end - b->start;
}
@ -624,7 +640,6 @@ sa_stream_drain(sa_stream_t *s)
break;
}
struct timespec ts = {0, 1000000};
nanosleep(&ts, NULL);
}
return SA_SUCCESS;
@ -656,12 +671,13 @@ sa_stream_set_volume_abs(sa_stream_t *s, float vol) {
int
sa_stream_get_volume_abs(sa_stream_t *s, float *vol) {
Float32 local_vol = 0;
if (s == NULL || s->output_unit == NULL) {
return SA_ERROR_NO_INIT;
}
pthread_mutex_lock(&s->mutex);
Float32 local_vol = 0;
AudioUnitGetParameter(s->output_unit, kHALOutputParam_Volume,
kAudioUnitParameterFlag_Output, 0, &local_vol);
*vol = local_vol;

View File

@ -9,3 +9,4 @@ Some files are renamed during the copy to prevent clashes with object
file names with other Mozilla libraries.
alloca.diff - Bug 469639 - Failed to build firefox trunk on OpenSolaris
bug666672_gccWarnings.diff - Bug 666672 - Fixing some gcc compiler warnings

View File

@ -0,0 +1,91 @@
diff --git a/media/libvorbis/lib/vorbis_codebook.c b/media/libvorbis/lib/vorbis_codebook.c
--- a/media/libvorbis/lib/vorbis_codebook.c
+++ b/media/libvorbis/lib/vorbis_codebook.c
@@ -243,17 +243,17 @@ static_codebook *vorbis_staticbook_unpac
quantvals=(s->dim==0?0:_book_maptype1_quantvals(s));
break;
case 2:
quantvals=s->entries*s->dim;
break;
}
/* quantized values */
- if((quantvals*s->q_quant+7>>3)>opb->storage-oggpack_bytes(opb))
+ if(((quantvals*s->q_quant+7)>>3)>opb->storage-oggpack_bytes(opb))
goto _eofout;
s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++)
s->quantlist[i]=oggpack_read(opb,s->q_quant);
if(quantvals&&s->quantlist[quantvals-1]==-1)goto _eofout;
}
break;
diff --git a/media/libvorbis/lib/vorbis_floor1.c b/media/libvorbis/lib/vorbis_floor1.c
--- a/media/libvorbis/lib/vorbis_floor1.c
+++ b/media/libvorbis/lib/vorbis_floor1.c
@@ -1030,17 +1030,17 @@ static void *floor1_inverse1(vorbis_bloc
}else{
if(val&1){
val= -((val+1)>>1);
}else{
val>>=1;
}
}
- fit_value[i]=val+predicted&0x7fff;
+ fit_value[i]=(val+predicted)&0x7fff;
fit_value[look->loneighbor[i-2]]&=0x7fff;
fit_value[look->hineighbor[i-2]]&=0x7fff;
}else{
fit_value[i]=predicted|0x8000;
}
}
diff --git a/media/libvorbis/lib/vorbis_psy.c b/media/libvorbis/lib/vorbis_psy.c
--- a/media/libvorbis/lib/vorbis_psy.c
+++ b/media/libvorbis/lib/vorbis_psy.c
@@ -1149,37 +1149,38 @@ void _vp_couple_quantize_normalize(int b
}else{
/* lossy (point) coupling */
if(j<limit-i){
/* dipole */
reM[j] += reA[j];
qeM[j] = fabs(reM[j]);
}else{
+#if 0
/* AoTuV */
/** @ M2 **
The boost problem by the combination of noise normalization and point stereo is eased.
However, this is a temporary patch.
by Aoyumi @ 2004/04/18
*/
- /*float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit)));
- /* elliptical
+ float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit)));
+ /* elliptical */
if(reM[j]+reA[j]<0){
reM[j] = - (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
}else{
reM[j] = (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
- }*/
-
+ }
+#else
/* elliptical */
if(reM[j]+reA[j]<0){
reM[j] = - (qeM[j] = fabs(reM[j])+fabs(reA[j]));
}else{
reM[j] = (qeM[j] = fabs(reM[j])+fabs(reA[j]));
}
-
+#endif
}
reA[j]=qeA[j]=0.f;
fA[j]=1;
iA[j]=0;
}
}
floorM[j]=floorA[j]=floorM[j]+floorA[j];

View File

@ -248,7 +248,7 @@ static_codebook *vorbis_staticbook_unpack(oggpack_buffer *opb){
}
/* quantized values */
if((quantvals*s->q_quant+7>>3)>opb->storage-oggpack_bytes(opb))
if(((quantvals*s->q_quant+7)>>3)>opb->storage-oggpack_bytes(opb))
goto _eofout;
s->quantlist=_ogg_malloc(sizeof(*s->quantlist)*quantvals);
for(i=0;i<quantvals;i++)

View File

@ -1035,7 +1035,7 @@ static void *floor1_inverse1(vorbis_block *vb,vorbis_look_floor *in){
}
}
fit_value[i]=val+predicted&0x7fff;
fit_value[i]=(val+predicted)&0x7fff;
fit_value[look->loneighbor[i-2]]&=0x7fff;
fit_value[look->hineighbor[i-2]]&=0x7fff;

View File

@ -1154,27 +1154,28 @@ void _vp_couple_quantize_normalize(int blobno,
reM[j] += reA[j];
qeM[j] = fabs(reM[j]);
}else{
#if 0
/* AoTuV */
/** @ M2 **
The boost problem by the combination of noise normalization and point stereo is eased.
However, this is a temporary patch.
by Aoyumi @ 2004/04/18
*/
/*float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit)));
/* elliptical
float derate = (1.0 - de*((float)(j-limit+i) / (float)(n-limit)));
/* elliptical */
if(reM[j]+reA[j]<0){
reM[j] = - (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
}else{
reM[j] = (qeM[j] = (fabs(reM[j])+fabs(reA[j]))*derate*derate);
}*/
}
#else
/* elliptical */
if(reM[j]+reA[j]<0){
reM[j] = - (qeM[j] = fabs(reM[j])+fabs(reA[j]));
}else{
reM[j] = (qeM[j] = fabs(reM[j])+fabs(reA[j]));
}
#endif
}
reA[j]=qeA[j]=0.f;

View File

@ -47,3 +47,4 @@ cp $1/COPYING ./COPYING
cp $1/README ./README
cp $1/AUTHORS ./AUTHORS
patch -p3 < ./alloca.diff
patch -p3 < ./bug666672_gccWarnings.diff