예제 #1
0
 public _AudioConverterEventArgs(
     uint _NumberDataPackets,
     AudioBufferList _Data,
     AudioStreamPacketDescription[] _DataPacketDescription)
 {
     NumberDataPackets = _NumberDataPackets;
     Data = _Data;
     DataPacketDescription = _DataPacketDescription;
 }
예제 #2
0
		public static CMSampleBuffer CreateReadyWithPacketDescriptions (CMBlockBuffer dataBuffer, CMFormatDescription formatDescription, int samplesCount,
			CMTime sampleTimestamp, AudioStreamPacketDescription[] packetDescriptions, out CMSampleBufferError error)
		{
			if (dataBuffer == null)
				throw new ArgumentNullException ("dataBuffer");
			if (formatDescription == null)
				throw new ArgumentNullException ("formatDescription");
			if (samplesCount <= 0)
				throw new ArgumentOutOfRangeException ("samplesCount");

			IntPtr buffer;
			error = CMAudioSampleBufferCreateReadyWithPacketDescriptions (IntPtr.Zero, dataBuffer.handle,
				formatDescription.handle, samplesCount, sampleTimestamp, packetDescriptions, out buffer);

			if (error != CMSampleBufferError.None)
				return null;

			return new CMSampleBuffer (buffer, true);
		}
예제 #3
0
		extern static /* OSStatus */ CMSampleBufferError CMAudioSampleBufferCreateReadyWithPacketDescriptions (
			/* CFAllocatorRef */ IntPtr allocator,
			/* CMBlockBufferRef */ IntPtr dataBuffer,
			/* CMFormatDescriptionRef */ IntPtr formatDescription,
			/* CMItemCount */ nint numSamples,
			CMTime sbufPTS,
			/* AudioStreamPacketDescription* */ AudioStreamPacketDescription[] packetDescriptions,
			/* CMSampleBufferRef* */ out IntPtr sBufOut);
예제 #4
0
		extern static CMSampleBufferError CMAudioSampleBufferCreateWithPacketDescriptions (
			/* CFAllocatorRef */ IntPtr allocator,
			/* CMBlockBufferRef */ IntPtr dataBuffer,
			/* Boolean */ bool dataReady,
			/* CMSampleBufferMakeDataReadyCallback */ IntPtr makeDataReadyCallback,
			/* void */ IntPtr makeDataReadyRefcon,
			/* CMFormatDescriptionRef */ IntPtr formatDescription,
			/* CMItemCount */ nint numSamples,
			CMTime sbufPTS,
			/* AudioStreamPacketDescription* */ AudioStreamPacketDescription[] packetDescriptions,
			/* CMSampleBufferRef* */ out IntPtr sBufOut);
예제 #5
0
        static int complexInputDataProc(
            IntPtr inAudioConverrter,
            ref uint ioNumberDataPackets,
            AudioBufferList ioData,
            ref AudioStreamPacketDescription[] outDataPacketDescription, //AudioStreamPacketDescription**
            IntPtr inUserData
            )
        {
            // getting audiounit instance
            var handler = GCHandle.FromIntPtr(inUserData);
            var inst = (_AudioConverter)handler.Target;

            // evoke event handler with an argument
            if (inst.EncoderCallback != null)
            {
                var args = new _AudioConverterEventArgs(
                    ioNumberDataPackets,
                    ioData,
                    outDataPacketDescription);
                inst.EncoderCallback(inst, args);
            }

            return 0; // noerror
        }
예제 #6
0
 static extern int AudioConverterFillComplexBuffer(
     IntPtr 		inAudioConverter,
     AudioConverterComplexInputDataProc	inInputDataProc,
     IntPtr inInputDataProcUserData,
     ref uint ioOutputDataPacketSize,
     AudioBufferList outOutputData,
     AudioStreamPacketDescription[] outPacketDescription);
예제 #7
0
 public void FillBuffer(AudioBufferList data, uint numberFrames, AudioStreamPacketDescription[] packetDescs)
 {
     uint numPackets = numberFrames;
     int err = AudioConverterFillComplexBuffer(
         _audioConverter,
         complexInputDataProc,
         GCHandle.ToIntPtr(_handle),
         ref numPackets,
         data,
         packetDescs);
     if(err != 0 || numPackets == 0) {
         throw new InvalidOperationException(String.Format("Error code:{0}", err));
     }
 }