1/* 2 * Copyright (c) 1998-2014 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * The contents of this file constitute Original Code as defined in and 7 * are subject to the Apple Public Source License Version 1.1 (the 8 * "License"). You may not use this file except in compliance with the 9 * License. Please obtain a copy of the License at 10 * http://www.apple.com/publicsource and read it before using this file. 11 * 12 * This Original Code and all software distributed under the License are 13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER 14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the 17 * License for the specific language governing rights and limitations 18 * under the License. 19 * 20 * @APPLE_LICENSE_HEADER_END@ 21 */ 22 23#include "IOAudioDebug.h" 24#include "IOAudioEngine.h" 25#include "IOAudioStream.h" 26#include "IOAudioTypes.h" 27 28#include <vecLib/vecLib.h> // <rdar://14058728> 29 30IOReturn IOAudioEngine::mixOutputSamples(const void *sourceBuf, void *mixBuf, UInt32 firstSampleFrame, UInt32 numSampleFrames, const IOAudioStreamFormat *streamFormat, IOAudioStream *audioStream) 31{ 32 IOReturn result = kIOReturnBadArgument; 33 34 if (sourceBuf && mixBuf) 35 { 36 const float * floatSource1Buf; 37 const float * floatSource2Buf; 38 float * floatMixBuf; 39 40 UInt32 numSamplesLeft = numSampleFrames * streamFormat->fNumChannels; 41 42 __darwin_size_t numSamps = numSamplesLeft; 43 44 floatMixBuf = &(((float *)mixBuf)[firstSampleFrame * streamFormat->fNumChannels]); 45 floatSource2Buf = floatMixBuf; 46 floatSource1Buf = (const float *)sourceBuf; 47 48 __darwin_ptrdiff_t strideOne=1, strideTwo=1, resultStride=1; 49 50 vDSP_vadd(floatSource1Buf, strideOne, floatSource2Buf, strideTwo, floatMixBuf, resultStride, numSamps); 51 52 result = kIOReturnSuccess; 53 } 54 55 return result; 56} 57