protected int Setup(string audioAltName, IntPtr vidEnc, IntPtr audEnc, IntPtr cfgAud) { if (context == null || context.Data == null || vidEnc == IntPtr.Zero || cfgAud == IntPtr.Zero || audEnc == IntPtr.Zero) { Debug.LogError("The encode or data objects are not yet setup for creating audio encoder"); return(-1); } _audioAltName = audioAltName; //this uses a different number each time, and the isBufferFreshAudioEncodeAsync() API call will //clean the number and its access for if it is not used for two callbacks or more encodeInterfaceNumber = MixCastAV.AudioEncodeInterfaceCounter++; //TODO: //for persistent encode async run, and the aud async becomes dereferenced for whatever reason //if (_vidEncCopy != IntPtr.Zero && _audEncCopy != IntPtr.Zero && _cfgAudCopy != IntPtr.Zero) //{} if (_audAsyncEncode != IntPtr.Zero) { MixCastAV.stopAudioEncodeAsync(_audAsyncEncode); MixCastAV.freeAudioEncodeAsync(_audAsyncEncode); _audAsyncEncode = IntPtr.Zero; } //assumes an universal AudioAsyncFeed _audAsyncDecodeCopy = AudioAsyncFeed.Instance(context.Data.id).audAsyncDec; _vidEncCopy = vidEnc; _audEncCopy = audEnc; _cfgAudCopy = cfgAud; _audAsyncEncode = MixCastAV.createAudioEncodeAsync(_audAsyncDecodeCopy, _vidEncCopy, _cfgAudCopy, _audEncCopy, MixCastAV.chunksPerSec); if (_audAsyncEncode == IntPtr.Zero) { Debug.LogError("Could not setup audio encode async interface"); return(-1); } if (MixCastAV.startAudioEncodeAsync(_audAsyncEncode) < 0) { MixCastAV.freeAudioEncodeAsync(_audAsyncEncode); _audAsyncEncode = IntPtr.Zero; Debug.LogError("Could not start audio encode async interface"); return(-1); } #if _DEBUG Debug.LogWarning(string.Format("Encode started for decoder: {0} with encoder: {1}", (int)_audAsyncDecodeCopy, (int)_audAsyncEncode)); #endif return(0); }