[vlc-devel] [PATCH 1/3] qtsound: added audio capture functionality for MAC OS X

Rémi Denis-Courmont remi at remlab.net
Tue Oct 18 16:43:41 CEST 2011


Le mardi 18 octobre 2011 17:36:40 Michael Feurstein, vous avez écrit :
> +            for ( count = 0; count < tempAudioBufferList->mNumberBuffers;
> count++ ) +            {
> +                totalDataSize +=
> tempAudioBufferList->mBuffers[count].mDataByteSize; +            }
> +            /*
> +             * Allocate storage for the interleaved audio data
> +             */
> +            rawAudioData = block_Alloc(totalDataSize * sizeof(float));
> +            if (NULL == rawAudioData)
> +            {
> +                free(rawAudioData);

I have a feeling this is going to crash.

> +                return;
> +            }
> +        }
> +        else
> +        {
> +            msg_Err( p_qtsound, "Too many or only one channel found." );
> +            return;
> +        }
> +
> +        /*
> +         * Interleave raw data (provided in two separate channels as
> +         * F32L) with 2 samples per frame
> +         */
> +        if ( totalDataSize )
> +        {
> +            unsigned short i;
> +            const float *b1Ptr, *b2Ptr;
> +            float *uPtr;
> +
> +            for (i = 0,
> +                 uPtr = (float *)rawAudioData,
> +                 b1Ptr = (const float *)
> tempAudioBufferList->mBuffers[0].mData, +                 b2Ptr = (const
> float *) tempAudioBufferList->mBuffers[1].mData; +                 i <
> numberOfSamples; i++)
> +            {
> +                *uPtr = *b1Ptr;
> +                uPtr ++;
> +                b1Ptr ++;
> +                *uPtr = *b2Ptr;
> +                uPtr ++;
> +                b2Ptr ++;
> +            }
> +
> +            if (currentAudioBuffer == nil)
> +            {
> +                currentAudioBuffer = (AudioBuffer
> *)malloc(sizeof(AudioBuffer)); +                if (NULL ==
> currentAudioBuffer)
> +                {
> +                    free(rawAudioData);

Same here.

> +                    return;
> +                }
> +            }
> +            currentAudioBuffer->mNumberChannels = 2;
> +            currentAudioBuffer->mDataByteSize = totalDataSize;
> +            currentAudioBuffer->mData = rawAudioData;
> +        }
> +    }
> +}


-- 
Rémi Denis-Courmont
http://www.remlab.net/
http://fi.linkedin.com/in/remidenis



More information about the vlc-devel mailing list