changeset 8148:6b242a49e749 8u40-b09

RT-34893: [Media] Use of QuickTime prevents Mac AppStore Submission Summary: Added new media platform module which uses AVFoundation instead of QTKit Reviewed-by: almatvee, stayer, kcr, flar
author ddehaven
date Mon, 06 Oct 2014 09:32:41 -0700
parents f9ba8f7e6610
children 88b53c354314 fe2dfb6abaf6 6caacb6da160
files .hgignore build.gradle modules/graphics/src/main/java/com/sun/prism/MediaFrame.java modules/graphics/src/main/java/com/sun/prism/MultiTexture.java modules/graphics/src/main/java/com/sun/prism/d3d/D3DTexture.java modules/graphics/src/main/java/com/sun/prism/es2/ES2Texture.java modules/graphics/src/main/java/com/sun/prism/j2d/J2DTexture.java modules/graphics/src/main/java/com/sun/prism/sw/SWArgbPreTexture.java modules/media/src/main/java/com/sun/javafx/media/PrismMediaFrameHandler.java modules/media/src/main/java/com/sun/media/jfxmedia/control/VideoDataBuffer.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeAudioEqualizer.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeAudioSpectrum.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeEqualizerBand.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaPlayer.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeVideoBuffer.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/Platform.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/PlatformManager.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTAudioEqualizer.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTAudioSpectrum.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTEqualizerBand.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMedia.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMediaPlayer.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTPlatform.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSPlatform.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/java/JavaPlatform.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXMediaPlayer.java modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java modules/media/src/main/native/jfxmedia/PipelineManagement/NullAudioEqualizer.h modules/media/src/main/native/jfxmedia/PipelineManagement/NullAudioSpectrum.h modules/media/src/main/native/jfxmedia/PipelineManagement/VideoFrame.cpp modules/media/src/main/native/jfxmedia/PipelineManagement/VideoFrame.h modules/media/src/main/native/jfxmedia/jni/JniUtils.cpp modules/media/src/main/native/jfxmedia/jni/JniUtils.h modules/media/src/main/native/jfxmedia/jni/NativeAudioEqualizer.cpp modules/media/src/main/native/jfxmedia/jni/NativeAudioSpectrum.cpp modules/media/src/main/native/jfxmedia/jni/NativeEqualizerBand.cpp modules/media/src/main/native/jfxmedia/jni/NativeVideoBuffer.cpp modules/media/src/main/native/jfxmedia/jni/com_sun_media_jfxmediaimpl_NativeVideoConverter.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAVPlaybackPipeline.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioEqualizer.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioEqualizer.h modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioPlaybackPipeline.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioSpectrum.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstEqualizerBand.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstMediaPlayer.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstVideoFrame.cpp modules/media/src/main/native/jfxmedia/platform/gstreamer/GstVideoFrame.h modules/media/src/main/native/jfxmedia/platform/osx/CVVideoFrame.h modules/media/src/main/native/jfxmedia/platform/osx/CVVideoFrame.mm modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/ComponentBase.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/ComponentBase.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/AUEffectBase.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/AUEffectBase.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility/AUBaseHelper.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility/AUBuffer.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility/AUBuffer.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility/AUSilentTimeout.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAtomic.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAtomicStack.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioChannelLayout.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioChannelLayout.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAutoDisposer.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CABitOperations.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CADebugMacros.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CADebugPrintf.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAException.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAHostTimeBase.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAMath.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAMutex.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAReferenceCounted.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CASpectralProcessor.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CASpectralProcessor.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAStreamBasicDescription.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAStreamBasicDescription.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAThreadSafeList.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAVectorUnit.cpp modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAVectorUnit.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAVectorUnitTypes.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAXException.h modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/Readme.rtf modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.h modules/media/src/main/native/jfxmedia/platform/osx/OSXMediaPlayer.mm modules/media/src/main/native/jfxmedia/platform/osx/OSXPlatform.mm modules/media/src/main/native/jfxmedia/platform/osx/OSXPlayerProtocol.h modules/media/src/main/native/jfxmedia/platform/osx/QTKMediaPlayer.h modules/media/src/main/native/jfxmedia/platform/osx/QTKMediaPlayer.mm modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFAudioEqualizer.cpp modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFAudioEqualizer.h modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFAudioProcessor.h modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFAudioProcessor.mm modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFAudioSpectrumUnit.cpp modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFAudioSpectrumUnit.h modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFKernelProcessor.cpp modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFKernelProcessor.h modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFMediaPlayer.h modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFMediaPlayer.mm modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFSoundLevelUnit.cpp modules/media/src/main/native/jfxmedia/platform/osx/avf/AVFSoundLevelUnit.h modules/media/src/main/native/jfxmedia/projects/linux/Makefile modules/media/src/main/native/jfxmedia/projects/mac/Makefile modules/media/src/main/native/jfxmedia/projects/win/Makefile modules/media/src/main/native/xcode_project/JFXMedia-Prefix.pch modules/media/src/main/native/xcode_project/JFXMedia.xcodeproj/project.pbxproj modules/media/src/main/native/xcode_project/JFXMedia.xcodeproj/project.xcworkspace/contents.xcworkspacedata modules/media/src/main/native/xcode_project/build_prereqs.sh modules/media/src/main/native/xcode_project/java_home.sh
diffstat 116 files changed, 19559 insertions(+), 1192 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Mon Oct 06 08:15:37 2014 -0700
+++ b/.hgignore	Mon Oct 06 09:32:41 2014 -0700
@@ -33,6 +33,32 @@
 */Debug/*
 *~
 modules/web/src/main/native/LayoutTests
+
+# avoid someone inadvertently checking in their gradle settings
+gradle.properties
+
+# ignore Xcode project droppings
+modules/media/src/main/native/xcode_project/[Bb]uild
+
+xcuserdata
+DerivedData
+
+*.xccheckout
+*.moved-aside
+*.hmap
+*.ipa
+*~.nib
+*.xcuserstate
+*.pbxuser
+*.mode1v3
+*.mode2v3
+*.perspectivev3
+
+# whitelist default files (if they exist)
+!default.pbxuser
+!default.mode1v3
+!default.mode2v3
+!default.perspectivev3
 apps/scenebuilder/SceneBuilderApp/src/com/oracle/javafx/scenebuilder/app/about/about.properties
 .git
 .gitattributes
--- a/build.gradle	Mon Oct 06 08:15:37 2014 -0700
+++ b/build.gradle	Mon Oct 06 09:32:41 2014 -0700
@@ -2174,9 +2174,9 @@
                              "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTPlatform",
                              "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMedia",
                              "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTMediaPlayer",
-                             "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTAudioEqualizer",
-                             "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTEqualizerBand",
-                             "com.sun.media.jfxmediaimpl.platform.gstreamer.GSTAudioSpectrum"]
+                             "com.sun.media.jfxmediaimpl.NativeAudioEqualizer",
+                             "com.sun.media.jfxmediaimpl.NativeEqualizerBand",
+                             "com.sun.media.jfxmediaimpl.NativeAudioSpectrum"]
             if (IS_MAC) {
                 classesList.addAll( ["com.sun.media.jfxmediaimpl.platform.osx.OSXPlatform",
                                      "com.sun.media.jfxmediaimpl.platform.osx.OSXMedia",
@@ -3056,7 +3056,7 @@
 
                     if (t.name == "mac") {
                         // OSX media natives
-                        [ "jfxmedia_qtkit", "glib-lite" ].each { name ->
+                        [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name ->
                             from ("modules/media/build/native/${t.name}/${mediaBuildType}/${library(name)}") }
                     } else if (t.name == "linux") {
                         from("modules/media/build/native/${t.name}/${mediaBuildType}") { include "libavplugin*.so" }
@@ -3065,7 +3065,11 @@
                     [ "fxplugins", "gstreamer-lite", "jfxmedia" ].each { name ->
                         from ("$LIBRARY_STUB/${library(name)}") }
 
-                    if (t.name == "linux") {
+                    if (t.name == "mac") {
+                        // copy libjfxmedia_{avf,qtkit}.dylib if they exist
+                        [ "jfxmedia_qtkit", "jfxmedia_avf", "glib-lite" ].each { name ->
+                            from ("$LIBRARY_STUB/${library(name)}") }
+                    } else if (t.name == "linux") {
                         from(LIBRARY_STUB) { include "libavplugin*.so" }
                     }
                     else from ("$LIBRARY_STUB/${library("glib-lite")}")
--- a/modules/graphics/src/main/java/com/sun/prism/MediaFrame.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/MediaFrame.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -33,9 +33,11 @@
  */
 public interface MediaFrame {
     /**
-     * @return the {@code ByteBuffer} that holds video data for this frame
+     * @param plane the numeric index of the plane, for chunky formats pass zero
+     * @return the {@code ByteBuffer} for the specified plane or null for
+     * non-existent planes
      */
-    public ByteBuffer getBuffer();
+    public ByteBuffer getBufferForPlane(int plane);
 
     /**
      * @return {@link PixelFormat} describing how pixels are stored in this
@@ -72,23 +74,6 @@
     public int planeCount();
 
     /**
-     * The plane offset is the number of bytes into the ByteBuffer returned by
-     * {@link #getBuffer() getBuffer()} that the specified plane starts.
-     * @return an int array containing the plane byte offsets for each plane
-     */
-    public int[] planeOffsets();
-
-    /**
-     * The plane offset is the number of bytes into the ByteBuffer returned by
-     * {@link #getBuffer() getBuffer()} that the specified plane starts.
-     * @param planeIndex which plane to get the offset for, valid range is zero
-     * to {@link #planeCount() planeCount()}
-     * @return the number of bytes into the buffer that the specified plane
-     * begins
-     */
-    public int offsetForPlane(int planeIndex);
-
-    /**
      * The plane line stride is the number of bytes between two consecutive
      * lines in the buffer. This number will vary depending on the frame's
      * {@code PixelFormat} and decoder output.
@@ -101,7 +86,7 @@
      * lines in the buffer. This number will vary depending on the frame's
      * {@code PixelFormat} and decoder output.
      * @param planeIndex which plane to get the stride for, valid range is zero
-     * to {@link #planeCount() planeCount()}
+     * to {@link #planeCount() planeCount()} non-inclusive
      * @return the line stride for the specified plane
      */
     public int strideForPlane(int planeIndex);
--- a/modules/graphics/src/main/java/com/sun/prism/MultiTexture.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/MultiTexture.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -200,7 +200,6 @@
     public void update(MediaFrame frame, boolean skipFlush) {
         if (frame.getPixelFormat() == PixelFormat.MULTI_YCbCr_420) {
             // call update(..) on each texture
-            ByteBuffer pixels = frame.getBuffer();
             Texture tex;
             int encWidth = frame.getEncodedWidth();
             int encHeight = frame.getEncodedHeight();
@@ -217,8 +216,8 @@
                         texHeight /= 2;
                     }
 
-                    pixels.position(frame.offsetForPlane(index));
-                    tex.update(pixels.slice(), PixelFormat.BYTE_ALPHA,
+                    ByteBuffer pixels = frame.getBufferForPlane(index);
+                    tex.update(pixels, PixelFormat.BYTE_ALPHA,
                             0, 0,
                             0, 0, texWidth, texHeight,
                             frame.strideForPlane(index), skipFlush);
--- a/modules/graphics/src/main/java/com/sun/prism/d3d/D3DTexture.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/d3d/D3DTexture.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -92,7 +92,7 @@
         }
         frame.holdFrame();
 
-        ByteBuffer pixels = (ByteBuffer)frame.getBuffer();
+        ByteBuffer pixels = (ByteBuffer)frame.getBufferForPlane(0);
         int result;
 
         // FIXME: checkVideoParams since they differ from normal params slightly
@@ -107,20 +107,17 @@
 
         // always do plane 0 since it's used for packed formats
         if (targetFormat.getDataType() == PixelFormat.DataType.INT) {
-            pixels.position(frame.offsetForPlane(0));
             result = D3DResourceFactory.nUpdateTextureI(
                     ctx.getContextHandle(),
                     getNativeSourceHandle(),
-                    pixels.slice().asIntBuffer(), null,
+                    pixels.asIntBuffer(), null,
                     0, 0, 0, 0, frame.getEncodedWidth(), frame.getEncodedHeight(),
                     frame.strideForPlane(0));
         } else {
-            pixels.position(frame.offsetForPlane(0));
-            // FIXME: is pixels.slice() necessary?
             result = D3DResourceFactory.nUpdateTextureB(
                     ctx.getContextHandle(),
                     getNativeSourceHandle(),
-                    pixels.slice(), null,
+                    pixels, null,
                     targetFormat.ordinal(),
                     0, 0,
                     0, 0, frame.getEncodedWidth(), frame.getEncodedHeight(),
--- a/modules/graphics/src/main/java/com/sun/prism/es2/ES2Texture.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/es2/ES2Texture.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2009, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,7 +34,6 @@
 import com.sun.prism.impl.BaseTexture;
 import com.sun.prism.impl.BufferUtil;
 import com.sun.prism.impl.PrismSettings;
-import com.sun.prism.impl.PrismTrace;
 import java.nio.Buffer;
 import java.nio.ByteBuffer;
 import java.nio.ByteOrder;
@@ -532,7 +531,7 @@
         int srcw = frame.getEncodedWidth();
         int srch = frame.getEncodedHeight();
         int adjHeight = srch;
-        ByteBuffer pixels = frame.getBuffer();
+        ByteBuffer pixels = frame.getBufferForPlane(0);
 
         switch (frame.getPixelFormat()) {
             case INT_ARGB_PRE:
@@ -576,10 +575,9 @@
             glCtx.pixelStorei(GLContext.GL_UNPACK_ALIGNMENT, alignment);
             glCtx.pixelStorei(GLContext.GL_UNPACK_ROW_LENGTH,
                     frame.strideForPlane(0) / alignment);
-            pixels.position(frame.offsetForPlane(0));
             glCtx.texSubImage2D(target, 0,
                     0, 0, srcw, frame.getHeight(),
-                    pixelFormat, pixelType, pixels.slice());
+                    pixelFormat, pixelType, pixels);
         }
         frame.releaseFrame();
         return result;
--- a/modules/graphics/src/main/java/com/sun/prism/j2d/J2DTexture.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/j2d/J2DTexture.java	Mon Oct 06 09:32:41 2014 -0700
@@ -197,8 +197,7 @@
             }
         }
 
-        ByteBuffer bbuf = frame.getBuffer();
-        bbuf.position(frame.offsetForPlane(0));
+        ByteBuffer bbuf = frame.getBufferForPlane(0);
         BufferedImage bimg = getBufferedImage();
         updateFromBuffer(bimg, bbuf.asIntBuffer(), PixelFormat.INT_ARGB_PRE,
                 0, 0, 0, 0, frame.getWidth(), frame.getHeight(),
--- a/modules/graphics/src/main/java/com/sun/prism/sw/SWArgbPreTexture.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/graphics/src/main/java/com/sun/prism/sw/SWArgbPreTexture.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -131,13 +131,12 @@
             frame = f;
         }
 
-        final int off = frame.offsetForPlane(0) / 4;
         final int stride = frame.strideForPlane(0) / 4;
 
-        IntBuffer ib = frame.getBuffer().asIntBuffer();
+        IntBuffer ib = frame.getBufferForPlane(0).asIntBuffer();
         if (ib.hasArray()) {
             this.allocated = false;
-            this.offset = off;
+            this.offset = 0;
             this.physicalWidth = stride;
             this.data = ib.array();
         } else {
--- a/modules/media/src/main/java/com/sun/javafx/media/PrismMediaFrameHandler.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/javafx/media/PrismMediaFrameHandler.java	Mon Oct 06 09:32:41 2014 -0700
@@ -157,7 +157,7 @@
         textures.clear();
     }
     
-    private RenderJob releaseRenderJob = new RenderJob(() -> {
+    private final RenderJob releaseRenderJob = new RenderJob(() -> {
         releaseData();
     });
 
@@ -209,58 +209,62 @@
             }
         }
 
-        public ByteBuffer getBuffer() {
-            return master.getBuffer();
+        @Override
+        public ByteBuffer getBufferForPlane(int plane) {
+            return master.getBufferForPlane(plane);
         }
 
+        @Override
         public void holdFrame() {
             master.holdFrame();
         }
         
+        @Override
         public void releaseFrame() {
             master.releaseFrame();
         }
 
+        @Override
         public PixelFormat getPixelFormat() {
             return videoFormat;
         }
 
+        @Override
         public int getWidth() {
             return master.getWidth();
         }
 
+        @Override
         public int getHeight() {
             return master.getHeight();
         }
 
+        @Override
         public int getEncodedWidth() {
             return master.getEncodedWidth();
         }
 
+        @Override
         public int getEncodedHeight() {
             return master.getEncodedHeight();
         }
 
+        @Override
         public int planeCount() {
             return master.getPlaneCount();
         }
 
-        public int[] planeOffsets() {
-            return master.getPlaneOffsets();
-        }
-
-        public int offsetForPlane(int planeIndex) {
-            return master.getOffsetForPlane(planeIndex);
-        }
-
+        @Override
         public int[] planeStrides() {
             return master.getPlaneStrides();
         }
 
+        @Override
         public int strideForPlane(int planeIndex) {
             return master.getStrideForPlane(planeIndex);
         }
 
+        @Override
         public MediaFrame convertToFormat(PixelFormat fmt) {
             if (fmt == getPixelFormat()) {
                 return this;
--- a/modules/media/src/main/java/com/sun/media/jfxmedia/control/VideoDataBuffer.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmedia/control/VideoDataBuffer.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,7 +27,7 @@
 import java.nio.ByteBuffer;
 
 /**
- * A (@code VideoDataBuffer} describes a single uncompressed frame of video.
+ * A {@code VideoDataBuffer} describes a single frame of video.
  */
 public interface VideoDataBuffer {
     /** Plane index used by all packed formats */
@@ -43,11 +43,15 @@
     public static final int YCBCR_PLANE_ALPHA = 3;
 
     /**
-     * Retrieve the data buffer containing video data
-     *
-     * @return The media buffer's data.
+     * Retrieve the data buffer for the specified plane. For chunky formats,
+     * pass {@link PACKED_FORMAT_PLANE} as the plane index. If an invalid plane
+     * index is passed this method returns null.
+     * 
+     * @param plane The numeric index of the plane
+     * @return the {@code ByteBuffer} containing video data for the specified
+     * plane or null for non-existent or invalid planes
      */
-    public ByteBuffer getBuffer();
+    public ByteBuffer getBufferForPlane(int plane);
 
     /**
      * Retrieve the timestamp of the buffer.
@@ -57,15 +61,6 @@
     public double getTimestamp();
 
     /**
-     * Retrieves the frame number of this video frame.
-     *
-     * FIXME: Nuke this, it's completely unused and not useful anyways
-     *
-     * @return The frame's number
-     */
-    public long getFrameNumber();
-
-    /**
      * Gets the width of the VideoDataBuffer
      * @return the width of the buffer
      */
@@ -92,7 +87,7 @@
     public int getEncodedHeight();
 
     /**
-     * Gets the format of the videoDataBuffer
+     * @return the format of the videoDataBuffer
      */
     public VideoFormat getFormat();
 
@@ -106,23 +101,12 @@
     public boolean hasAlpha();
 
     /**
-     * Gets the number of bit planes this video image contains. Non planar formats
-     * will always return 1.
+     * @return the number of planes this video buffer contains, or 1 for
+     * non-planar formats
      */
     public int getPlaneCount();
 
     /**
-     * Returns the byte offset to the specified bit plane.
-     *
-     * @param planeIndex The numeric index of the plane.
-     * @return Number of bytes from the beginning of data that the specified
-     * plane starts at. Will return zero if the plane is not in use.
-     */
-    public int getOffsetForPlane(int planeIndex);
-
-    public int[] getPlaneOffsets();
-
-    /**
      * Returns the number of bytes in each row of pixels for the specified plane.
      *
      * @param planeIndex The numeric index of the plane.
@@ -131,6 +115,10 @@
      */
     public int getStrideForPlane(int planeIndex);
 
+    /**
+     * @see getStrideForPlane
+     * @return an array containing the plane strides for all planes
+     */
     public int[] getPlaneStrides();
 
     /**
@@ -139,6 +127,7 @@
      * supported here. Once a conversion is done, a reference to the converted
      * buffer is retained so that future conversions do not need to be performed.
      *
+     * @param newFormat the video format to convert to
      * @return new buffer containing a converted copy of the source video image
      */
     public VideoDataBuffer convertToFormat(VideoFormat newFormat);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeAudioEqualizer.java	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.media.jfxmediaimpl;
+
+import com.sun.media.jfxmedia.effects.AudioEqualizer;
+import com.sun.media.jfxmedia.effects.EqualizerBand;
+
+final class NativeAudioEqualizer implements AudioEqualizer {
+    /**
+     * Handle to the native equalizer.
+     */
+    private final long nativeRef;
+
+    //**************************************************************************
+    //***** Constructors
+    //**************************************************************************
+
+    /**
+     * Constructor.
+     * @param nativeRef A reference to the native component.
+     */
+    NativeAudioEqualizer(long nativeRef) {
+        if (nativeRef == 0) {
+            throw new IllegalArgumentException("Invalid native media reference");
+        }
+
+        this.nativeRef = nativeRef;
+    }
+
+    //**************************************************************************
+    //***** Public functions
+    //**************************************************************************
+
+    @Override
+    public boolean getEnabled() {
+        return nativeGetEnabled(nativeRef);
+    }
+
+    @Override
+    public void setEnabled(boolean enable) {
+        nativeSetEnabled(nativeRef, enable);
+    }
+
+    @Override
+    public EqualizerBand addBand(double centerFrequency, double bandwidth, double gain) {
+        return (nativeGetNumBands(nativeRef) >= MAX_NUM_BANDS &&
+                gain >= EqualizerBand.MIN_GAIN && gain <= EqualizerBand.MAX_GAIN) ?
+                null : nativeAddBand(nativeRef, centerFrequency, bandwidth, gain);
+    }
+
+    @Override
+    public boolean removeBand(double centerFrequency) {
+        return (centerFrequency > 0) ? nativeRemoveBand(nativeRef, centerFrequency) : false;
+    }
+
+    //**************************************************************************
+    //***** JNI methods
+    //**************************************************************************
+    private native boolean nativeGetEnabled(long nativeRef);
+    private native void nativeSetEnabled(long nativeRef, boolean enable);
+    private native int nativeGetNumBands(long nativeRef);
+    private native EqualizerBand nativeAddBand(long nativeRef,
+                                               double centerFrequency, double bandwidth,
+                                               double gain);
+    private native boolean nativeRemoveBand(long nativeRef, double centerFrequency);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeAudioSpectrum.java	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,156 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.media.jfxmediaimpl;
+
+import com.sun.media.jfxmedia.effects.AudioSpectrum;
+
+final class NativeAudioSpectrum implements AudioSpectrum {
+    private static final float[] EMPTY_FLOAT_ARRAY  = new float[0];
+    public static final int      DEFAULT_THRESHOLD = -60;
+    public static final int      DEFAULT_BANDS = 128;
+    public static final double   DEFAULT_INTERVAL = 0.1;
+
+    /**
+     * Handle to the native spectrum.
+     */
+    private final long nativeRef;
+
+    private float[] magnitudes = EMPTY_FLOAT_ARRAY;
+    private float[] phases = EMPTY_FLOAT_ARRAY;
+
+    //**************************************************************************
+    //***** Constructors
+    //**************************************************************************
+
+    /**
+     * Constructor.
+     * @param refNativePlayer A reference to the native player.
+     */
+    NativeAudioSpectrum(long refMedia) {
+        if (refMedia == 0) {
+            throw new IllegalArgumentException("Invalid native media reference");
+        }
+
+        this.nativeRef = refMedia;
+        setBandCount(DEFAULT_BANDS);
+    }
+
+    //**************************************************************************
+    //***** Public functions
+    //**************************************************************************
+    @Override
+    public boolean getEnabled() {
+        return nativeGetEnabled(nativeRef);
+    }
+
+    @Override
+    public void setEnabled(boolean enabled) {
+        nativeSetEnabled(nativeRef, enabled);
+    }
+
+    @Override
+    public int getBandCount() {
+        // just return the current size of one of the band arrays
+        return phases.length;
+    }
+
+    @Override
+    public void setBandCount(int bands) {
+        if (bands > 1) {
+            magnitudes = new float[bands];
+            for (int i = 0; i < magnitudes.length; i++) {
+                magnitudes[i] = (float)DEFAULT_THRESHOLD;//Float.NEGATIVE_INFINITY;
+            }
+
+            phases = new float[bands];
+            nativeSetBands(nativeRef, bands, magnitudes, phases);
+        } else {
+            magnitudes = EMPTY_FLOAT_ARRAY;
+            phases = EMPTY_FLOAT_ARRAY;
+
+            throw new IllegalArgumentException("Number of bands must at least be 2");
+        }
+    }
+
+    @Override
+    public double getInterval() {
+        return nativeGetInterval(nativeRef);
+    }
+
+    @Override
+    public void setInterval(double interval) {
+        if (interval * NativeMediaPlayer.ONE_SECOND >= 1) {
+            nativeSetInterval(nativeRef, interval);
+        } else {
+            throw new IllegalArgumentException("Interval can't be less that 1 nanosecond");
+        }
+    }
+
+    @Override
+    public int getSensitivityThreshold() {
+        return nativeGetThreshold(nativeRef);
+    }
+
+    @Override
+    public void setSensitivityThreshold(int threshold) {
+        if (threshold <= 0) {
+            nativeSetThreshold(nativeRef, threshold);
+        } else {
+            throw new IllegalArgumentException(String.format("Sensitivity threshold must be less than 0: %d", threshold));
+        }
+    }
+
+    @Override
+    public float[] getMagnitudes(float[] mag) {
+        int size = magnitudes.length;
+        if(mag == null || mag.length < size) {
+            mag = new float[size];
+        }
+        System.arraycopy(magnitudes, 0, mag, 0, size);
+        return mag;
+    }
+
+    @Override
+    public float[] getPhases(float[] phs) {
+        int size = phases.length;
+        if(phs == null || phs.length < size) {
+            phs = new float[size];
+        }
+        System.arraycopy(phases, 0, phs, 0, size);
+        return phs;
+    }
+
+    //**************************************************************************
+    //***** JNI methods
+    //**************************************************************************
+    private native boolean nativeGetEnabled(long nativeRef);
+    private native void    nativeSetEnabled(long nativeRef, boolean enable);
+    private native void    nativeSetBands(long nativeRef, int bands, float[] magnitudes, float[] phases);
+    private native double  nativeGetInterval(long nativeRef);
+    private native void    nativeSetInterval(long nativeRef, double interval);
+    private native int     nativeGetThreshold(long nativeRef);
+    private native void    nativeSetThreshold(long nativeRef, int threshold);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeEqualizerBand.java	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.media.jfxmediaimpl;
+
+import com.sun.media.jfxmedia.effects.EqualizerBand;
+
+final class NativeEqualizerBand implements EqualizerBand {
+
+    private final long bandRef; // Native band backend
+
+    private NativeEqualizerBand(long bandRef) {
+        if (bandRef != 0) {
+            this.bandRef = bandRef;
+        } else {
+            throw new IllegalArgumentException("bandRef == 0");
+        }
+    }
+
+    @Override
+    public double getCenterFrequency() {
+        return nativeGetCenterFrequency(bandRef);
+    }
+
+    @Override
+    public void setCenterFrequency(double centerFrequency) {
+        nativeSetCenterFrequency(bandRef, centerFrequency);
+    }
+
+    @Override
+    public double getBandwidth() {
+        return nativeGetBandwidth(bandRef);
+    }
+
+    @Override
+    public void setBandwidth(double bandwidth) {
+        nativeSetBandwidth(bandRef, bandwidth);
+    }
+
+    @Override
+    public double getGain() {
+        return nativeGetGain(bandRef);
+    }
+
+    @Override
+    public void setGain(double gain) {
+        if (gain >= MIN_GAIN && gain <= MAX_GAIN) {
+            nativeSetGain(bandRef, gain);
+        }
+    }
+
+    //**************************************************************************
+    //***** JNI methods
+    //**************************************************************************
+    private native double nativeGetCenterFrequency(long bandRef);
+    private native void   nativeSetCenterFrequency(long bandRef, double centerFrequency);
+    private native double nativeGetBandwidth(long bandRef);
+    private native void   nativeSetBandwidth(long bandRef, double bandwidth);
+    private native double nativeGetGain(long bandRef);
+    private native void   nativeSetGain(long bandRef, double gain);
+}
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaPlayer.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeMediaPlayer.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -89,19 +89,19 @@
      */
     private NativeMedia media;
     private VideoRenderControl videoRenderControl;
-    private final List<WeakReference<MediaErrorListener>> errorListeners = new ArrayList<WeakReference<MediaErrorListener>>();
-    private final List<WeakReference<PlayerStateListener>> playerStateListeners = new ArrayList<WeakReference<PlayerStateListener>>();
-    private final List<WeakReference<PlayerTimeListener>> playerTimeListeners = new ArrayList<WeakReference<PlayerTimeListener>>();
-    private final List<WeakReference<VideoTrackSizeListener>> videoTrackSizeListeners = new ArrayList<WeakReference<VideoTrackSizeListener>>();
-    private final List<WeakReference<VideoRendererListener>> videoUpdateListeners = new ArrayList<WeakReference<VideoRendererListener>>();
-    private final List<WeakReference<VideoFrameRateListener>> videoFrameRateListeners = new ArrayList<WeakReference<VideoFrameRateListener>>();
-    private final List<WeakReference<MarkerListener>> markerListeners = new ArrayList<WeakReference<MarkerListener>>();
-    private final List<WeakReference<BufferListener>> bufferListeners = new ArrayList<WeakReference<BufferListener>>();
-    private final List<WeakReference<AudioSpectrumListener>> audioSpectrumListeners = new ArrayList<WeakReference<AudioSpectrumListener>>();
-    private final List<PlayerStateEvent> cachedStateEvents = new ArrayList<PlayerStateEvent>();
-    private final List<PlayerTimeEvent> cachedTimeEvents = new ArrayList<PlayerTimeEvent>();
-    private final List<BufferProgressEvent> cachedBufferEvents = new ArrayList<BufferProgressEvent>();
-    private final List<MediaErrorEvent> cachedErrorEvents = new ArrayList<MediaErrorEvent>();
+    private final List<WeakReference<MediaErrorListener>> errorListeners = new ArrayList<>();
+    private final List<WeakReference<PlayerStateListener>> playerStateListeners = new ArrayList<>();
+    private final List<WeakReference<PlayerTimeListener>> playerTimeListeners = new ArrayList<>();
+    private final List<WeakReference<VideoTrackSizeListener>> videoTrackSizeListeners = new ArrayList<>();
+    private final List<WeakReference<VideoRendererListener>> videoUpdateListeners = new ArrayList<>();
+    private final List<WeakReference<VideoFrameRateListener>> videoFrameRateListeners = new ArrayList<>();
+    private final List<WeakReference<MarkerListener>> markerListeners = new ArrayList<>();
+    private final List<WeakReference<BufferListener>> bufferListeners = new ArrayList<>();
+    private final List<WeakReference<AudioSpectrumListener>> audioSpectrumListeners = new ArrayList<>();
+    private final List<PlayerStateEvent> cachedStateEvents = new ArrayList<>();
+    private final List<PlayerTimeEvent> cachedTimeEvents = new ArrayList<>();
+    private final List<BufferProgressEvent> cachedBufferEvents = new ArrayList<>();
+    private final List<MediaErrorEvent> cachedErrorEvents = new ArrayList<>();
     private boolean isFirstFrame = true;
     private NewFrameEvent firstFrameEvent = null;
     private double firstFrameTime;
@@ -109,10 +109,10 @@
     private EventQueueThread eventLoop = new EventQueueThread();
     private int frameWidth = -1;
     private int frameHeight = -1;
-    private AtomicBoolean isMediaPulseEnabled = new AtomicBoolean(false);
+    private final AtomicBoolean isMediaPulseEnabled = new AtomicBoolean(false);
     private final Lock mediaPulseLock = new ReentrantLock();
     private Timer mediaPulseTimer;
-    private Lock markerLock = new ReentrantLock();
+    private final Lock markerLock = new ReentrantLock();
     private boolean checkSeek = false;
     private double timeBeforeSeek = 0.0;
     private double timeAfterSeek = 0.0;
@@ -132,7 +132,7 @@
     private double decodedFrameRate;
     // --- End decoded frame rate fields
     private PlayerState playerState = PlayerState.UNKNOWN;
-    private Lock disposeLock = new ReentrantLock();
+    private final Lock disposeLock = new ReentrantLock();
     private boolean isDisposed = false;
     private Runnable onDispose;
 
@@ -187,8 +187,8 @@
      */
     private static class WarningEvent extends PlayerEvent {
 
-        private Object source;
-        private String message;
+        private final Object source;
+        private final String message;
 
         WarningEvent(Object source, String message) {
             this.source = source;
@@ -209,8 +209,8 @@
      */
     public static class MediaErrorEvent extends PlayerEvent {
 
-        private Object source;
-        private MediaError error;
+        private final Object source;
+        private final MediaError error;
 
         public MediaErrorEvent(Object source, MediaError error) {
             this.source = source;
@@ -232,7 +232,7 @@
 
     private static class PlayerTimeEvent extends PlayerEvent {
 
-        private double time;
+        private final double time;
 
         public PlayerTimeEvent(double time) {
             this.time = time;
@@ -248,7 +248,7 @@
      */
     private static class TrackEvent extends PlayerEvent {
 
-        private Track track;
+        private final Track track;
 
         TrackEvent(Track track) {
             this.track = track;
@@ -264,8 +264,8 @@
      */
     private static class FrameSizeChangedEvent extends PlayerEvent {
 
-        private int width;
-        private int height;
+        private final int width;
+        private final int height;
 
         public FrameSizeChangedEvent(int width, int height) {
             if (width > 0) {
@@ -305,6 +305,7 @@
          * @param listener the object which provides the VideoUpdateListener
          * callback interface
          */
+        @Override
         public void addVideoRendererListener(VideoRendererListener listener) {
             if (listener != null) {
                 synchronized (firstFrameLock) {
@@ -316,7 +317,7 @@
                         listener.videoFrameUpdated(firstFrameEvent);
                     }
                 }
-                videoUpdateListeners.add(new WeakReference<VideoRendererListener>(listener));
+                videoUpdateListeners.add(new WeakReference<>(listener));
             }
         }
 
@@ -325,6 +326,7 @@
          *
          * @param listener to be removed from the player
          */
+        @Override
         public void removeVideoRendererListener(VideoRendererListener listener) {
             if (listener != null) {
                 for (ListIterator<WeakReference<VideoRendererListener>> it = videoUpdateListeners.listIterator(); it.hasNext();) {
@@ -336,12 +338,14 @@
             }
         }
 
+        @Override
         public void addVideoFrameRateListener(VideoFrameRateListener listener) {
             if (listener != null) {
-                videoFrameRateListeners.add(new WeakReference<VideoFrameRateListener>(listener));
+                videoFrameRateListeners.add(new WeakReference<>(listener));
             }
         }
 
+        @Override
         public void removeVideoFrameRateListener(VideoFrameRateListener listener) {
             if (listener != null) {
                 for (ListIterator<WeakReference<VideoFrameRateListener>> it = videoFrameRateListeners.listIterator(); it.hasNext();) {
@@ -353,10 +357,12 @@
             }
         }
 
+        @Override
         public int getFrameWidth() {
             return frameWidth;
         }
 
+        @Override
         public int getFrameHeight() {
             return frameHeight;
         }
@@ -373,8 +379,8 @@
      */
     private class EventQueueThread extends Thread {
 
-        private BlockingQueue<PlayerEvent> eventQueue =
-                new LinkedBlockingQueue<PlayerEvent>();
+        private final BlockingQueue<PlayerEvent> eventQueue =
+                new LinkedBlockingQueue<>();
         private volatile boolean stopped = false;
 
         EventQueueThread() {
@@ -738,7 +744,7 @@
                 eventQueue.put(new PlayerEvent());
             } catch(InterruptedException ex) {}
         }
-        
+
         private void sendFakeBufferProgressEvent() {
             // Send fake 100% buffer progress event for HLS or !http protcol
             String contentType = media.getLocator().getContentType();
@@ -765,23 +771,23 @@
     //***** MediaPlayer implementation
     //**************************************************************************
     //***** Listener (un)registration.
+    @Override
     public void addMediaErrorListener(MediaErrorListener listener) {
         if (listener != null) {
-            this.errorListeners.add(new WeakReference<MediaErrorListener>(listener));
+            this.errorListeners.add(new WeakReference<>(listener));
 
             synchronized (cachedErrorEvents) {
                 if (!cachedErrorEvents.isEmpty() && !errorListeners.isEmpty()) {
-                    for (MediaErrorEvent evt : cachedErrorEvents) {
-                        // re-queue this event so the new listener picks it up,
-                        // but it must be done in the event queue thread
+                    cachedErrorEvents.stream().forEach((evt) -> {
                         sendPlayerEvent(evt);
-                    }
+                    });
                     cachedErrorEvents.clear();
                 }
             }
         }
     }
 
+    @Override
     public void removeMediaErrorListener(MediaErrorListener listener) {
         if (listener != null) {
             for (ListIterator<WeakReference<MediaErrorListener>> it = errorListeners.listIterator(); it.hasNext();) {
@@ -793,6 +799,7 @@
         }
     }
 
+    @Override
     public void addMediaPlayerListener(PlayerStateListener listener) {
         if (listener != null) {
             synchronized (cachedStateEvents) {
@@ -829,11 +836,12 @@
                     cachedStateEvents.clear();
                 }
 
-                playerStateListeners.add(new WeakReference<PlayerStateListener>(listener));
+                playerStateListeners.add(new WeakReference(listener));
             }
         }
     }
 
+    @Override
     public void removeMediaPlayerListener(PlayerStateListener listener) {
         if (listener != null) {
             for (ListIterator<WeakReference<PlayerStateListener>> it = playerStateListeners.listIterator(); it.hasNext();) {
@@ -845,6 +853,7 @@
         }
     }
 
+    @Override
     public void addMediaTimeListener(PlayerTimeListener listener) {
         if (listener != null) {
             synchronized (cachedTimeEvents) {
@@ -866,11 +875,12 @@
                     }
                 }
 
-                playerTimeListeners.add(new WeakReference<PlayerTimeListener>(listener));
+                playerTimeListeners.add(new WeakReference(listener));
             }
         }
     }
 
+    @Override
     public void removeMediaTimeListener(PlayerTimeListener listener) {
         if (listener != null) {
             for (ListIterator<WeakReference<PlayerTimeListener>> it = playerTimeListeners.listIterator(); it.hasNext();) {
@@ -882,15 +892,17 @@
         }
     }
 
+    @Override
     public void addVideoTrackSizeListener(VideoTrackSizeListener listener) {
         if (listener != null) {
             if (frameWidth != -1 && frameHeight != -1) {
                 listener.onSizeChanged(frameWidth, frameHeight);
             }
-            videoTrackSizeListeners.add(new WeakReference<VideoTrackSizeListener>(listener));
+            videoTrackSizeListeners.add(new WeakReference(listener));
         }
     }
 
+    @Override
     public void removeVideoTrackSizeListener(VideoTrackSizeListener listener) {
         if (listener != null) {
             for (ListIterator<WeakReference<VideoTrackSizeListener>> it = videoTrackSizeListeners.listIterator(); it.hasNext();) {
@@ -902,12 +914,14 @@
         }
     }
 
+    @Override
     public void addMarkerListener(MarkerListener listener) {
         if (listener != null) {
-            markerListeners.add(new WeakReference<MarkerListener>(listener));
+            markerListeners.add(new WeakReference(listener));
         }
     }
 
+    @Override
     public void removeMarkerListener(MarkerListener listener) {
         if (listener != null) {
             for (ListIterator<WeakReference<MarkerListener>> it = markerListeners.listIterator(); it.hasNext();) {
@@ -919,24 +933,24 @@
         }
     }
 
+    @Override
     public void addBufferListener(BufferListener listener) {
         if (listener != null) {
             synchronized (cachedBufferEvents) {
                 if (!cachedBufferEvents.isEmpty() && bufferListeners.isEmpty()) {
-                    // Forward all cached state events to first listener to register.
-                    for (Iterator<BufferProgressEvent> it = cachedBufferEvents.iterator(); it.hasNext();) {
-                        BufferProgressEvent evt = it.next();
+                    cachedBufferEvents.stream().forEach((evt) -> {
                         listener.onBufferProgress(evt);
-                    }
+                    });
                     // Clear buffer event cache.
                     cachedBufferEvents.clear();
                 }
 
-                bufferListeners.add(new WeakReference<BufferListener>(listener));
+                bufferListeners.add(new WeakReference(listener));
             }
         }
     }
 
+    @Override
     public void removeBufferListener(BufferListener listener) {
         if (listener != null) {
             for (ListIterator<WeakReference<BufferListener>> it = bufferListeners.listIterator(); it.hasNext();) {
@@ -948,12 +962,14 @@
         }
     }
 
+    @Override
     public void addAudioSpectrumListener(AudioSpectrumListener listener) {
         if (listener != null) {
-            audioSpectrumListeners.add(new WeakReference<AudioSpectrumListener>(listener));
+            audioSpectrumListeners.add(new WeakReference(listener));
         }
     }
 
+    @Override
     public void removeAudioSpectrumListener(AudioSpectrumListener listener) {
         if (listener != null) {
             for (ListIterator<WeakReference<AudioSpectrumListener>> it = audioSpectrumListeners.listIterator(); it.hasNext();) {
@@ -966,14 +982,17 @@
     }
 
     //***** Control functions
+    @Override
     public VideoRenderControl getVideoRenderControl() {
         return videoRenderControl;
     }
 
+    @Override
     public Media getMedia() {
         return media;
     }
 
+    @Override
     public void setAudioSyncDelay(long delay) {
         try {
             playerSetAudioSyncDelay(delay);
@@ -982,6 +1001,7 @@
         }
     }
 
+    @Override
     public long getAudioSyncDelay() {
         try {
             return playerGetAudioSyncDelay();
@@ -991,6 +1011,7 @@
         return 0;
     }
 
+    @Override
     public void play() {
         try {
             if (isStartTimeUpdated) {
@@ -1003,6 +1024,7 @@
         }
     }
 
+    @Override
     public void stop() {
         try {
             playerStop();
@@ -1013,6 +1035,7 @@
         }
     }
 
+    @Override
     public void pause() {
         try {
             playerPause();
@@ -1021,6 +1044,7 @@
         }
     }
 
+    @Override
     public float getRate() {
         try {
             return playerGetRate();
@@ -1031,6 +1055,7 @@
     }
 
     //***** Public properties
+    @Override
     public void setRate(float rate) {
         try {
             playerSetRate(rate);
@@ -1040,6 +1065,7 @@
         }
     }
 
+    @Override
     public double getPresentationTime() {
         try {
             return playerGetPresentationTime();
@@ -1049,6 +1075,7 @@
         return -1.0;
     }
 
+    @Override
     public float getVolume() {
         try {
             return playerGetVolume();
@@ -1058,6 +1085,7 @@
         return 0;
     }
 
+    @Override
     public void setVolume(float vol) {
         if (vol < 0.0F) {
             vol = 0.0F;
@@ -1072,6 +1100,7 @@
         }
     }
 
+    @Override
     public boolean getMute() {
         try {
             return playerGetMute();
@@ -1085,6 +1114,7 @@
      * Enables/disable mute. If mute is enabled then disabled, the previous
      * volume goes into effect.
      */
+    @Override
     public void setMute(boolean enable) {
         try {
             playerSetMute(enable);
@@ -1093,6 +1123,7 @@
         }
     }
 
+    @Override
     public float getBalance() {
         try {
             return playerGetBalance();
@@ -1102,6 +1133,7 @@
         return 0;
     }
 
+    @Override
     public void setBalance(float bal) {
         if (bal < -1.0F) {
             bal = -1.0F;
@@ -1116,10 +1148,13 @@
         }
     }
 
+    @Override
     public abstract AudioEqualizer getEqualizer();
 
+    @Override
     public abstract AudioSpectrum getAudioSpectrum();
 
+    @Override
     public double getDuration() {
         try {
             return playerGetDuration();
@@ -1132,6 +1167,7 @@
     /**
      * Gets the time within the duration of the media to start playing.
      */
+    @Override
     public double getStartTime() {
         return startTime;
     }
@@ -1139,6 +1175,7 @@
     /**
      * Sets the start time within the media to play.
      */
+    @Override
     public void setStartTime(double startTime) {
         try {
             markerLock.lock();
@@ -1156,6 +1193,7 @@
     /**
      * Gets the time within the duration of the media to stop playing.
      */
+    @Override
     public double getStopTime() {
         return stopTime;
     }
@@ -1163,6 +1201,7 @@
     /**
      * Sets the stop time within the media to stop playback.
      */
+    @Override
     public void setStopTime(double stopTime) {
         try {
             markerLock.lock();
@@ -1174,6 +1213,7 @@
         }
     }
 
+    @Override
     public void seek(double streamTime) {
         if (playerState == PlayerState.STOPPED) {
             return; // No seek in stopped state
@@ -1261,10 +1301,12 @@
      *
      * @return the current player state.
      */
+    @Override
     public PlayerState getState() {
         return playerState;
     }
 
+    @Override
     final public void dispose() {
         disposeLock.lock();
         try {
@@ -1451,7 +1493,7 @@
         if (!language.equals("und")) {
             locale = new Locale(language);
         }
-        
+
         Track track = new AudioTrack(enabled, trackID, name,
                 locale, Encoding.toEncoding(encoding),
                 numChannels, channelMask, sampleRate);
@@ -1503,6 +1545,7 @@
         sendPlayerEvent(new AudioSpectrumEvent(getAudioSpectrum(), timestamp, duration));
     }
 
+    @Override
     public void markerStateChanged(boolean hasMarkers) {
         if (hasMarkers) {
             markerLock.lock();
@@ -1546,16 +1589,16 @@
     }
 
     boolean doMediaPulseTask() {
-        if (this.isMediaPulseEnabled.get()) {            
+        if (this.isMediaPulseEnabled.get()) {
             disposeLock.lock();
 
             if (isDisposed) {
                 disposeLock.unlock();
                 return false;
             }
-            
+
             double thisTime = getPresentationTime();
-            
+
             markerLock.lock();
 
             try {
@@ -1626,6 +1669,15 @@
 
         return true;
     }
+
+    /* Audio EQ and spectrum creation, used by sub-classes */
+    protected AudioEqualizer createNativeAudioEqualizer(long nativeRef) {
+        return new NativeAudioEqualizer(nativeRef);
+    }
+
+    protected AudioSpectrum createNativeAudioSpectrum(long nativeRef) {
+        return new NativeAudioSpectrum(nativeRef);
+    }
 }
 
 class MediaPulseTask extends TimerTask {
@@ -1633,7 +1685,7 @@
     WeakReference<NativeMediaPlayer> playerRef;
 
     MediaPulseTask(NativeMediaPlayer player) {
-        playerRef = new WeakReference<NativeMediaPlayer>(player);
+        playerRef = new WeakReference<>(player);
     }
 
     @Override
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeVideoBuffer.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/NativeVideoBuffer.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
 
 package com.sun.media.jfxmediaimpl;
 
-import com.sun.media.jfxmedia.MediaException;
 import com.sun.media.jfxmedia.control.VideoDataBuffer;
 import com.sun.media.jfxmedia.control.VideoFormat;
 import java.nio.ByteBuffer;
@@ -36,14 +35,13 @@
  */
 final class NativeVideoBuffer implements VideoDataBuffer {
     private long nativePeer;
-    private AtomicInteger holdCount;
+    private final AtomicInteger holdCount;
     private NativeVideoBuffer cachedBGRARep;
 
     private static native void nativeDisposeBuffer(long handle);
 
     private native double nativeGetTimestamp(long handle);
-    private native ByteBuffer nativeGetBuffer(long handle);
-    private native long nativeGetFrameNumber(long handle);
+    private native ByteBuffer nativeGetBufferForPlane(long handle, int plane);
     private native int nativeGetWidth(long handle);
     private native int nativeGetHeight(long handle);
     private native int nativeGetEncodedWidth(long handle);
@@ -51,7 +49,6 @@
     private native int nativeGetFormat(long handle); // returns FORMAT_TYPE_XXX constant
     private native boolean nativeHasAlpha(long handle);
     private native int nativeGetPlaneCount(long handle);
-    private native int[] nativeGetPlaneOffsets(long handle);
     private native int[] nativeGetPlaneStrides(long handle);
     private native long nativeConvertToFormat(long handle, int formatType);
     private native void nativeSetDirty(long handle);
@@ -72,6 +69,7 @@
     }
 
     /* Call this when we hand this frame off to a renderer */
+    @Override
     public void holdFrame() {
         if (0 != nativePeer) {
             holdCount.incrementAndGet();
@@ -81,6 +79,7 @@
     }
 
     /* Call this when the renderer is done with the frame so that it may be reused */
+    @Override
     public void releaseFrame() {
         if (0 != nativePeer) {
             if (holdCount.decrementAndGet() <= 0) {
@@ -100,6 +99,7 @@
         }
     }
 
+    @Override
     public double getTimestamp() {
         if (0 != nativePeer) {
             return nativeGetTimestamp(nativePeer);
@@ -109,10 +109,12 @@
         return 0.0;
     }
 
-    public ByteBuffer getBuffer() {
+    @Override
+    public ByteBuffer getBufferForPlane(int plane) {
         if (0 != nativePeer) {
-            ByteBuffer buffer = nativeGetBuffer(nativePeer);
-            // HACK: For some reason NewDirectByteBuffer keeps setting BIG_ENDIAN
+            ByteBuffer buffer = nativeGetBufferForPlane(nativePeer, plane);
+            // NewDirectByteBuffer sets BIG_ENDIAN to be consistent with ByteBuffer
+            // So we need to force native order
             buffer.order(java.nio.ByteOrder.nativeOrder());
             return buffer;
         } else if (DEBUG_DISPOSED_BUFFERS) {
@@ -121,15 +123,7 @@
         return null;
     }
 
-    public long getFrameNumber() {
-        if (0 != nativePeer) {
-            return nativeGetFrameNumber(nativePeer);
-        } else if (DEBUG_DISPOSED_BUFFERS) {
-            throw new NullPointerException("method called on disposed NativeVideoBuffer");
-        }
-        return 0;
-    }
-
+    @Override
     public int getWidth() {
         if (0 != nativePeer) {
             return nativeGetWidth(nativePeer);
@@ -139,6 +133,7 @@
         return 0;
     }
 
+    @Override
     public int getHeight() {
         if (0 != nativePeer) {
             return nativeGetHeight(nativePeer);
@@ -148,6 +143,7 @@
         return 0;
     }
 
+    @Override
     public int getEncodedWidth() {
         if (0 != nativePeer) {
             return nativeGetEncodedWidth(nativePeer);
@@ -157,6 +153,7 @@
         return 0;
     }
 
+    @Override
     public int getEncodedHeight() {
         if (0 != nativePeer) {
             return nativeGetEncodedHeight(nativePeer);
@@ -166,6 +163,7 @@
         return 0;
     }
 
+    @Override
     public VideoFormat getFormat() {
         if (0 != nativePeer) {
             int formatType = nativeGetFormat(nativePeer);
@@ -176,6 +174,7 @@
         return null;
     }
 
+    @Override
     public boolean hasAlpha() {
         if (0 != nativePeer) {
             return nativeHasAlpha(nativePeer);
@@ -185,6 +184,7 @@
         return false;
     }
 
+    @Override
     public int getPlaneCount() {
         if (0 != nativePeer) {
             return nativeGetPlaneCount(nativePeer);
@@ -194,25 +194,7 @@
         return 0;
     }
 
-    public int getOffsetForPlane(int planeIndex) {
-        if (0 != nativePeer) {
-            int[] offsets = nativeGetPlaneOffsets(nativePeer);
-            return offsets[planeIndex];
-        } else if (DEBUG_DISPOSED_BUFFERS) {
-            throw new NullPointerException("method called on disposed NativeVideoBuffer");
-        }
-        return 0;
-    }
-
-    public int[] getPlaneOffsets() {
-        if (0 != nativePeer) {
-            return nativeGetPlaneOffsets(nativePeer);
-        } else if (DEBUG_DISPOSED_BUFFERS) {
-            throw new NullPointerException("method called on disposed NativeVideoBuffer");
-        }
-        return null;
-    }
-
+    @Override
     public int getStrideForPlane(int planeIndex) {
         if (0 != nativePeer) {
             int[] strides = nativeGetPlaneStrides(nativePeer);
@@ -223,6 +205,7 @@
         return 0;
     }
 
+    @Override
     public int[] getPlaneStrides() {
         if (0 != nativePeer) {
             return nativeGetPlaneStrides(nativePeer);
@@ -232,6 +215,7 @@
         return null;
     }
 
+    @Override
     public VideoDataBuffer convertToFormat(VideoFormat newFormat) {
         if (0 != nativePeer) {
             // see if we have a converted frame already, if we do bump the hold count and return it instead
@@ -257,6 +241,7 @@
         return null;
     }
 
+    @Override
     public void setDirty() {
         if (0 != nativePeer) {
             nativeSetDirty(nativePeer);
@@ -266,6 +251,7 @@
     }
 
     private static class VideoBufferDisposer implements MediaDisposer.ResourceDisposer {
+        @Override
         public void disposeResource(Object resource) {
             // resource is Long containing the native handle
             if (resource instanceof Long) {
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/Platform.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/Platform.java	Mon Oct 06 09:32:41 2014 -0700
@@ -76,9 +76,7 @@
 
     /**
      * Prepare for playing the specified media. If the media stream is unsupported
-     * return null so other platforms may be used, otherwise return an Object
-     * that gets passed to createMediaPlayer to create the actual player.
+     * return null so other platforms may be used.
      */
-    public abstract Object prerollMediaPlayer(Locator source);
-    public abstract MediaPlayer createMediaPlayer(Locator source, Object cookie);
+    public abstract MediaPlayer createMediaPlayer(Locator source);
 }
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/PlatformManager.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/PlatformManager.java	Mon Oct 06 09:32:41 2014 -0700
@@ -198,14 +198,9 @@
         // go down the list until we get one that can be created
         for (Platform platty : platforms) {
             if (platty.canPlayContentType(mimeType)) {
-                // attempt to preroll the player
-                Object cookie = platty.prerollMediaPlayer(source);
-                if (null != cookie) {
-                    // OK to play, go ahead with player creation
-                    MediaPlayer outPlayer = platty.createMediaPlayer(source, cookie);
-                    if (null != outPlayer) {
-                        return outPlayer;
-                    }
+                MediaPlayer outPlayer = platty.createMediaPlayer(source);
+                if (null != outPlayer) {
+                    return outPlayer;
                 }
             }
         }
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTAudioEqualizer.java	Mon Oct 06 08:15:37 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,86 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.media.jfxmediaimpl.platform.gstreamer;
-
-import com.sun.media.jfxmedia.effects.AudioEqualizer;
-import com.sun.media.jfxmedia.effects.EqualizerBand;
-
-final class GSTAudioEqualizer implements AudioEqualizer {
-    /**
-     * Handle to the native media player.
-     */
-    private long refMedia;
-
-    //**************************************************************************
-    //***** Constructors
-    //**************************************************************************
-
-    /**
-     * Constructor.
-     * @param refNativePlayer A reference to the native player.
-     */
-    GSTAudioEqualizer(long refMedia) {
-        if (refMedia == 0) {
-            throw new IllegalArgumentException("Invalid native media reference");
-        }
-
-        this.refMedia = refMedia;
-    }
-
-    //**************************************************************************
-    //***** Public functions
-    //**************************************************************************
-
-    public boolean getEnabled() {
-        return gstGetEnabled(refMedia);
-    }
-
-    public void setEnabled(boolean enable) {
-        gstSetEnabled(refMedia, enable);
-    }
-
-    public EqualizerBand addBand(double centerFrequency, double bandwidth, double gain) {
-        return (gstGetNumBands(refMedia) >= MAX_NUM_BANDS &&
-                gain >= EqualizerBand.MIN_GAIN && gain <= EqualizerBand.MAX_GAIN) ?
-                null : gstAddBand(refMedia, centerFrequency, bandwidth, gain);
-    }
-
-    public boolean removeBand(double centerFrequency) {
-        return (centerFrequency > 0) ? gstRemoveBand(refMedia, centerFrequency) : false;
-    }
-
-    //**************************************************************************
-    //***** JNI functions
-    //**************************************************************************
-    private native boolean gstGetEnabled(long refMedia);
-    private native void gstSetEnabled(long refMedia, boolean enable);
-    private native int gstGetNumBands(long refMedia);
-    private native EqualizerBand gstAddBand(long refMedia,
-                                               double centerFrequency, double bandwidth,
-                                               double gain);
-    private native boolean gstRemoveBand(long refMedia,
-                                            double centerFrequency);
-}
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTAudioSpectrum.java	Mon Oct 06 08:15:37 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,146 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.media.jfxmediaimpl.platform.gstreamer;
-
-import com.sun.media.jfxmedia.effects.AudioSpectrum;
-
-final class GSTAudioSpectrum implements AudioSpectrum {
-    private static float[] EMPTY_FLOAT_ARRAY  = new float[0];
-    public static final int      DEFAULT_THRESHOLD = -60;
-    public static final int      DEFAULT_BANDS = 128;
-    public static final double   DEFAULT_INTERVAL = 0.1;
-
-    /**
-     * Handle to the native media player.
-     */
-    private long refMedia;
-
-    private float[] magnitudes = EMPTY_FLOAT_ARRAY;
-    private float[] phases = EMPTY_FLOAT_ARRAY;
-
-    //**************************************************************************
-    //***** Constructors
-    //**************************************************************************
-
-    /**
-     * Constructor.
-     * @param refNativePlayer A reference to the native player.
-     */
-    GSTAudioSpectrum(long refMedia) {
-        if (refMedia == 0) {
-            throw new IllegalArgumentException("Invalid native media reference");
-        }
-
-        this.refMedia = refMedia;
-        setBandCount(DEFAULT_BANDS);
-    }
-
-    //**************************************************************************
-    //***** Public functions
-    //**************************************************************************
-    public boolean getEnabled() {
-        return gstGetEnabled(refMedia);
-    }
-
-    public void setEnabled(boolean enabled) {
-        gstSetEnabled(refMedia, enabled);
-    }
-
-    public int getBandCount() {
-        // just return the current size of one of the band arrays
-        return phases.length;
-    }
-
-    public void setBandCount(int bands) {
-        if (bands > 1) {
-            magnitudes = new float[bands];
-            for (int i = 0; i < magnitudes.length; i++) {
-                magnitudes[i] = Float.NEGATIVE_INFINITY;
-            }
-
-            phases = new float[bands];
-            gstSetBands(refMedia, bands, magnitudes, phases);
-        } else {
-            magnitudes = EMPTY_FLOAT_ARRAY;
-            phases = EMPTY_FLOAT_ARRAY;
-
-            throw new IllegalArgumentException("Number of bands must at least be 2");
-        }
-    }
-
-    public double getInterval() {
-        return gstGetInterval(refMedia);
-    }
-
-    public void setInterval(double interval) {
-        if (interval * GSTMediaPlayer.ONE_SECOND >= 1) {
-            gstSetInterval(refMedia, interval);
-        } else {
-            throw new IllegalArgumentException("Interval can't be less that 1 nanosecond");
-        }
-    }
-
-    public int getSensitivityThreshold() {
-        return gstGetThreshold(refMedia);
-    }
-
-    public void setSensitivityThreshold(int threshold) {
-        if (threshold <= 0) {
-            gstSetThreshold(refMedia, threshold);
-        } else {
-            throw new IllegalArgumentException(String.format("Sensitivity threshold must be less than 0: %d", threshold));
-        }
-    }
-
-    public float[] getMagnitudes(float[] mag) {
-        int size = magnitudes.length;
-        if(mag == null || mag.length < size) {
-            mag = new float[size];
-        }
-        System.arraycopy(magnitudes, 0, mag, 0, size);
-        return mag;
-    }
-
-    public float[] getPhases(float[] phs) {
-        int size = phases.length;
-        if(phs == null || phs.length < size) {
-            phs = new float[size];
-        }
-        System.arraycopy(phases, 0, phs, 0, size);
-        return phs;
-    }
-
-    //**************************************************************************
-    //***** JNI functions
-    //**************************************************************************
-    private native boolean gstGetEnabled(long refMedia);
-    private native void    gstSetEnabled(long refMedia, boolean enable);
-    private native void    gstSetBands(long refMedia, int bands, float[] magnitudes, float[] phases);
-    private native double  gstGetInterval(long refMedia);
-    private native void    gstSetInterval(long refMedia, double interval);
-    private native int     gstGetThreshold(long refMedia);
-    private native void    gstSetThreshold(long refMedia, int threshold);
-}
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTEqualizerBand.java	Mon Oct 06 08:15:37 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-package com.sun.media.jfxmediaimpl.platform.gstreamer;
-
-import com.sun.media.jfxmedia.effects.EqualizerBand;
-
-final class GSTEqualizerBand implements EqualizerBand {
-
-    private long bandRef; // Native band backend
-
-    private native double gstGetCenterFrequency(long bandRef);
-    private native void   gstSetCenterFrequency(long bandRef, double centerFrequency);
-    private native double gstGetBandwidth(long bandRef);
-    private native void   gstSetBandwidth(long bandRef, double bandwidth);
-    private native double gstGetGain(long bandRef);
-    private native void   gstSetGain(long bandRef, double gain);
-
-    private GSTEqualizerBand(long bandRef) {
-        if (bandRef != 0) {
-            this.bandRef = bandRef;
-        } else {
-            throw new IllegalArgumentException("bandRef == 0");
-        }
-    }
-
-    public double getCenterFrequency() {
-        return gstGetCenterFrequency(bandRef);
-    }
-
-    public void setCenterFrequency(double centerFrequency) {
-        gstSetCenterFrequency(bandRef, centerFrequency);
-    }
-
-    public double getBandwidth() {
-        return gstGetBandwidth(bandRef);
-    }
-
-    public void setBandwidth(double bandwidth) {
-        gstSetBandwidth(bandRef, bandwidth);
-    }
-
-    public double getGain() {
-        return gstGetGain(bandRef);
-    }
-
-    public void setGain(double gain) {
-        if (gain >= MIN_GAIN && gain <= MAX_GAIN) {
-            gstSetGain(bandRef, gain);
-        }
-    }
-}
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMedia.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMedia.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,11 +28,9 @@
 import com.sun.media.jfxmedia.Media;
 import com.sun.media.jfxmedia.MediaError;
 import com.sun.media.jfxmedia.locator.Locator;
-import com.sun.media.jfxmedia.logging.Logger;
 import com.sun.media.jfxmediaimpl.MediaUtils;
 import com.sun.media.jfxmediaimpl.NativeMedia;
 import com.sun.media.jfxmediaimpl.platform.Platform;
-import java.util.Map;
 
 /**
  * GStreamer implementation of Media
@@ -95,11 +93,5 @@
                                                String contentType,
                                                long sizeHint,
                                                long[] nativeMediaHandle);
-    private native int gstAddMarker(long refNativeMedia, String markerName,
-            double presentationTime);
-    private native int gstRemoveMarker(long refNativeMedia, String markerName,
-            double[] markerTime);
-    private native int gstRemoveAllMarkers(long refNativeMedia);
-    private native int gstGetMarkers(long refNativeMedia, Map<String,Double> markers);
     private native void gstDispose(long refNativeMedia);
 }
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMediaPlayer.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTMediaPlayer.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -53,8 +53,9 @@
             throwMediaErrorException(rc, null);
         }
 
-        audioSpectrum = new GSTAudioSpectrum(gstMedia.getNativeMediaRef());
-        audioEqualizer = new GSTAudioEqualizer(gstMedia.getNativeMediaRef());
+        long mediaRef = gstMedia.getNativeMediaRef();
+        audioSpectrum = createNativeAudioSpectrum(gstGetAudioSpectrum(mediaRef));
+        audioEqualizer = createNativeAudioEqualizer(gstGetAudioEqualizer(mediaRef));
     }
 
     GSTMediaPlayer(Locator source) {
@@ -79,6 +80,7 @@
         throw new MediaException(message, null, me);
     }
 
+    @Override
     protected long playerGetAudioSyncDelay() throws MediaException {
         long[] audioSyncDelay = new long[1];
         int rc = gstGetAudioSyncDelay(gstMedia.getNativeMediaRef(), audioSyncDelay);
@@ -88,6 +90,7 @@
         return audioSyncDelay[0];
     }
 
+    @Override
     protected void playerSetAudioSyncDelay(long delay) throws MediaException {
         int rc = gstSetAudioSyncDelay(gstMedia.getNativeMediaRef(), delay);
         if (0 != rc) {
@@ -95,6 +98,7 @@
         }
     }
 
+    @Override
     protected void playerPlay() throws MediaException {
         int rc = gstPlay(gstMedia.getNativeMediaRef());
         if (0 != rc) {
@@ -102,6 +106,7 @@
         }
     }
 
+    @Override
     protected void playerStop() throws MediaException {
         int rc = gstStop(gstMedia.getNativeMediaRef());
         if (0 != rc) {
@@ -109,6 +114,7 @@
         }
     }
 
+    @Override
     protected void playerPause() throws MediaException {
         int rc = gstPause(gstMedia.getNativeMediaRef());
         if (0 != rc) {
@@ -116,6 +122,7 @@
         }
     }
 
+    @Override
     protected void playerFinish() throws MediaException {
         int rc = gstFinish(gstMedia.getNativeMediaRef());
         if (0 != rc) {
@@ -123,6 +130,7 @@
         }
     }
 
+    @Override
     protected float playerGetRate() throws MediaException {
         float[] rate = new float[1];
         int rc = gstGetRate(gstMedia.getNativeMediaRef(), rate);
@@ -132,6 +140,7 @@
         return rate[0];
     }
 
+    @Override
     protected void playerSetRate(float rate) throws MediaException {
         int rc = gstSetRate(gstMedia.getNativeMediaRef(), rate);
         if (0 != rc) {
@@ -139,6 +148,7 @@
         }
     }
 
+    @Override
     protected double playerGetPresentationTime() throws MediaException {
         double[] presentationTime = new double[1];
         int rc = gstGetPresentationTime(gstMedia.getNativeMediaRef(), presentationTime);
@@ -148,10 +158,12 @@
         return presentationTime[0];
     }
 
+    @Override
     protected boolean playerGetMute() throws MediaException {
         return muteEnabled;
     }
 
+    @Override
     protected synchronized void playerSetMute(boolean enable) throws MediaException {
         if (enable != muteEnabled) {
             if (enable) {
@@ -181,6 +193,7 @@
         }
     }
 
+    @Override
     protected float playerGetVolume() throws MediaException {
         synchronized(this) {
             if (muteEnabled)
@@ -194,6 +207,7 @@
         return volume[0];
     }
 
+    @Override
     protected synchronized void playerSetVolume(float volume) throws MediaException {
         if (!muteEnabled) {
             int rc = gstSetVolume(gstMedia.getNativeMediaRef(), volume);
@@ -207,6 +221,7 @@
         }
     }
 
+    @Override
     protected float playerGetBalance() throws MediaException {
         float[] balance = new float[1];
         int rc = gstGetBalance(gstMedia.getNativeMediaRef(), balance);
@@ -216,6 +231,7 @@
         return balance[0];
     }
 
+    @Override
     protected void playerSetBalance(float balance) throws MediaException {
         int rc = gstSetBalance(gstMedia.getNativeMediaRef(), balance);
         if (0 != rc) {
@@ -223,6 +239,7 @@
         }
     }
 
+    @Override
     protected double playerGetDuration() throws MediaException {
         double[] duration = new double[1];
         int rc = gstGetDuration(gstMedia.getNativeMediaRef(), duration);
@@ -236,6 +253,7 @@
         }
     }
 
+    @Override
     protected void playerSeek(double streamTime) throws MediaException {
         int rc = gstSeek(gstMedia.getNativeMediaRef(), streamTime);
         if (0 != rc) {
@@ -243,9 +261,11 @@
         }
     }
 
+    @Override
     protected void playerInit() throws MediaException {
     }
 
+    @Override
     protected void playerDispose() {
         audioEqualizer = null;
         audioSpectrum = null;
@@ -254,6 +274,8 @@
 
     // Native methods
     private native int gstInitPlayer(long refNativeMedia);
+    private native long gstGetAudioEqualizer(long refNativeMedia);
+    private native long gstGetAudioSpectrum(long refNativeMedia);
     private native int gstGetAudioSyncDelay(long refNativeMedia, long[] syncDelay);
     private native int gstSetAudioSyncDelay(long refNativeMedia, long delay);
     private native int gstPlay(long refNativeMedia);
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTPlatform.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/gstreamer/GSTPlatform.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -109,24 +109,25 @@
         return contentTypesCopy;
     }
 
+    @Override
     public Media createMedia(Locator source) {
         return new GSTMedia(source);
     }
 
     @Override
-    public Object prerollMediaPlayer(Locator source) {
+    public MediaPlayer createMediaPlayer(Locator source) {
         GSTMediaPlayer player;
         try {
             player = new GSTMediaPlayer(source);
         } catch (Exception e) {
             if (Logger.canLog(Logger.DEBUG)) {
-                Logger.logMsg(Logger.DEBUG, "GSTPlatform caught exception while prerolling: "+e);
+                Logger.logMsg(Logger.DEBUG, "GSTPlatform caught exception while creating media player: "+e);
             }
             return null;
         }
 
         // Special case for H.264 decoding on Mac OS X.
-        if (player != null && HostUtils.isMacOSX()) {
+        if (HostUtils.isMacOSX()) {
             String contentType = source.getContentType();
             if ("video/mp4".equals(contentType) || "video/x-m4v".equals(contentType)
                   || source.getStringLocation().endsWith(".m3u8"))
@@ -166,16 +167,6 @@
         return player;
     }
 
-    public MediaPlayer createMediaPlayer(Locator source, Object cookie) {
-        if(cookie == null) {
-            throw new NullPointerException("null player!");
-        } else if(!(cookie instanceof GSTMediaPlayer)) {
-            throw new IllegalArgumentException("!(cookie instanceof GSTMediaPlayer)");
-        }
-
-        return (MediaPlayer)cookie;
-    }
-
     /**
      * Initialize the native peer of this media manager.
      *
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSPlatform.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/ios/IOSPlatform.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -99,22 +99,15 @@
     }
 
     @Override
-    public Object prerollMediaPlayer(Locator source) {
-        // attempt the actual player creation, then preroll here
-        // on success we return a reference to the native player as the cookie
-        return new IOSMediaPlayer(source);
-    }
-
-    @Override
-    public MediaPlayer createMediaPlayer(Locator source, Object cookie) {
-        if (cookie == null) {
-            throw new NullPointerException("null player!");
+    public MediaPlayer createMediaPlayer(Locator source) {
+        try {
+            return new IOSMediaPlayer(source);
+        } catch (Exception e) {
+            if (Logger.canLog(Logger.DEBUG)) {
+                Logger.logMsg(Logger.DEBUG, "IOSPlatform caught exception while creating media player: "+e);
+            }
         }
-        else if (!(cookie instanceof IOSMediaPlayer)) {
-            throw new IllegalArgumentException("cookie is not an instance of IOSMediaPlayer");
-        }
-
-        return (MediaPlayer) cookie;
+        return null;
     }
 
     private static native void iosPlatformInit();
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/java/JavaPlatform.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/java/JavaPlatform.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -48,6 +48,7 @@
 
     JavaPlatform() {}
 
+    @Override
     public boolean loadPlatform() {
         return true;
     }
@@ -72,12 +73,7 @@
     }
 
     @Override
-    public Object prerollMediaPlayer(Locator source) {
-        return null;
-    }
-
-    @Override
-    public MediaPlayer createMediaPlayer(Locator source, Object cookie) {
+    public MediaPlayer createMediaPlayer(Locator source) {
         return null;
     }
 }
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXMediaPlayer.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXMediaPlayer.java	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -28,27 +28,26 @@
 import com.sun.media.jfxmedia.MediaException;
 import com.sun.media.jfxmedia.effects.AudioEqualizer;
 import com.sun.media.jfxmedia.effects.AudioSpectrum;
-import com.sun.media.jfxmedia.effects.EqualizerBand;
 import com.sun.media.jfxmedia.locator.Locator;
 import com.sun.media.jfxmediaimpl.NativeMedia;
 import com.sun.media.jfxmediaimpl.NativeMediaPlayer;
-import java.util.HashMap;
-import java.util.Map;
 
 /**
  * Mac OS X MediaPlayer implementation.
  */
 final class OSXMediaPlayer extends NativeMediaPlayer {
-    private NullAudioEQ audioEq;
-    private NullAudioSpectrum audioSpectrum;
+    private final AudioEqualizer audioEq;
+    private final AudioSpectrum audioSpectrum;
     private final Locator mediaLocator;
 
     OSXMediaPlayer(NativeMedia sourceMedia) {
         super(sourceMedia);
         init();
         mediaLocator = sourceMedia.getLocator();
-        audioEq = new NullAudioEQ();
-        audioSpectrum = new NullAudioSpectrum();
+        // This will throw an exception if we can't create the player
+        osxCreatePlayer(mediaLocator.getStringLocation());
+        audioEq = createNativeAudioEqualizer(osxGetAudioEqualizerRef());
+        audioSpectrum = createNativeAudioSpectrum(osxGetAudioSpectrumRef());
     }
 
     OSXMediaPlayer(Locator source) {
@@ -65,10 +64,6 @@
         return audioSpectrum;
     }
 
-    void initializePlayer() {
-        osxCreatePlayer(mediaLocator.getStringLocation());
-    }
-
     @Override
     protected long playerGetAudioSyncDelay() throws MediaException {
         return osxGetAudioSyncDelay();
@@ -164,7 +159,14 @@
         osxDispose();
     }
 
+    @Override
+    public void playerInit() throws MediaException {
+    }
+
     private native void osxCreatePlayer(String sourceURI) throws MediaException;
+    // Have to use native references for these two things
+    private native long osxGetAudioEqualizerRef();
+    private native long osxGetAudioSpectrumRef();
     private native long osxGetAudioSyncDelay() throws MediaException;
     private native void osxSetAudioSyncDelay(long delay) throws MediaException;
     private native void osxPlay() throws MediaException;
@@ -183,137 +185,4 @@
     private native double osxGetDuration() throws MediaException;
     private native void osxSeek(double streamTime) throws MediaException;
     private native void osxDispose();
-
-    @Override
-    public void playerInit() throws MediaException {
-    }
-
-    private static final class NullAudioEQ implements AudioEqualizer {
-        private boolean enabled = false;
-        private Map<Double, EqualizerBand> bands
-                = new HashMap<Double,EqualizerBand>();
-
-        public boolean getEnabled() {
-            return enabled;
-        }
-
-        public void setEnabled(boolean bEnable) {
-            enabled = bEnable;
-        }
-
-        public EqualizerBand addBand(double centerFrequency, double bandwidth, double gain) {
-            Double key = new Double(centerFrequency);
-            if (bands.containsKey(key)) {
-                removeBand(centerFrequency);
-            }
-
-            EqualizerBand newBand = new NullEQBand(centerFrequency, bandwidth, gain);
-            bands.put(key, newBand);
-            return newBand;
-        }
-
-        public boolean removeBand(double centerFrequency) {
-            Double key = new Double(centerFrequency);
-            if (bands.containsKey(key)) {
-                bands.remove(key);
-                return true;
-            }
-            return false;
-        }
-    }
-
-    private static final class NullAudioSpectrum implements AudioSpectrum {
-        private boolean enabled = false;
-        private int bandCount = 128;
-        private double interval = 0.1;
-        private int threshold = 60;
-        private float[] fakeData;
-
-        public boolean getEnabled() {
-            return enabled;
-        }
-
-        public void setEnabled(boolean enabled) {
-            this.enabled = enabled;
-        }
-
-        public int getBandCount() {
-            return bandCount;
-        }
-
-        public void setBandCount(int bands) {
-            bandCount = bands;
-            fakeData = new float[bandCount];
-        }
-
-        public double getInterval() {
-            return interval;
-        }
-
-        public void setInterval(double interval) {
-            this.interval = interval;
-        }
-
-        public int getSensitivityThreshold() {
-            return threshold;
-        }
-
-        public void setSensitivityThreshold(int threshold) {
-            this.threshold = threshold;
-        }
-
-        public float[] getMagnitudes(float[] mag) {
-            int size = fakeData.length;
-            if (mag == null || mag.length < size) {
-                mag = new float[size];
-            }
-            System.arraycopy(fakeData, 0, mag, 0, size);
-            return mag;
-        }
-
-        public float[] getPhases(float[] phs) {
-            int size = fakeData.length;
-            if (phs == null || phs.length < size) {
-                phs = new float[size];
-            }
-            System.arraycopy(fakeData, 0, phs, 0, size);
-            return phs;
-        }
-    }
-
-    private static final class NullEQBand implements EqualizerBand {
-        private double center;
-        private double bandwidth;
-        private double gain;
-
-        NullEQBand(double center, double bandwidth, double gain) {
-            this.center = center;
-            this.bandwidth = bandwidth;
-            this.gain = gain;
-        }
-
-        public double getCenterFrequency() {
-            return center;
-        }
-
-        public void setCenterFrequency(double centerFrequency) {
-            center = centerFrequency;
-        }
-
-        public double getBandwidth() {
-            return bandwidth;
-        }
-
-        public void setBandwidth(double bandwidth) {
-            this.bandwidth = bandwidth;
-        }
-
-        public double getGain() {
-            return gain;
-        }
-
-        public void setGain(double gain) {
-            this.gain = gain;
-        }
-    }
 }
--- a/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/java/com/sun/media/jfxmediaimpl/platform/osx/OSXPlatform.java	Mon Oct 06 09:32:41 2014 -0700
@@ -36,15 +36,22 @@
 import java.security.PrivilegedAction;
 
 /**
- * Mac OS X Platform implementation.
+ * Mac OS X Platform implementation. This class implements both the QTKit based
+ * platform and the AVFoundation based platforms.
+ * 
+ * NOTE: The QTKit based platform is deprecated and will be removed in a future
+ * release.
  */
 public final class OSXPlatform extends Platform {
     /**
      * The MIME types of all supported media.
      */
     private static final String[] CONTENT_TYPES = {
+        "audio/x-aiff",
+        "audio/mp3",
+        "audio/mpeg",
+        "audio/x-m4a",
         "video/mp4",
-        "audio/x-m4a",
         "video/x-m4v",
         "application/vnd.apple.mpegurl",
         "audio/mpegurl"
@@ -58,13 +65,20 @@
             boolean isLoaded = false;
             try {
                 isLoaded = AccessController.doPrivileged((PrivilegedAction<Boolean>) () -> {
+                    boolean avf = false;
+                    boolean qtk = false;
+                    // attempt to load the AVFoundation based player first
+                    // AVFoundation will have precedence
+                    try {
+                        NativeLibLoader.loadLibrary("jfxmedia_avf");
+                        avf = true;
+                    } catch (UnsatisfiedLinkError ule) {}
                     try {
                         NativeLibLoader.loadLibrary("jfxmedia_qtkit");
-                    } catch (UnsatisfiedLinkError ule) {
-                        // non-fatal condition, keep quiet about it
-                        return Boolean.FALSE;
-                    }
-                    return Boolean.TRUE;
+                        qtk = true;
+                    } catch (UnsatisfiedLinkError ule) {}
+
+                    return avf || qtk;
                 });
             } catch (Exception e) {
                 // Ignore
@@ -95,15 +109,14 @@
 
         // ULE should not happen here, but just in case
         try {
-            osxPlatformInit();
+            return osxPlatformInit();
         } catch (UnsatisfiedLinkError ule) {
             if (Logger.canLog(Logger.DEBUG)) {
                 Logger.logMsg(Logger.DEBUG, "Unable to load OSX platform.");
             }
-//                MediaUtils.nativeError(OSXPlatform.class, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL);
+//            MediaUtils.nativeError(OSXPlatform.class, MediaError.ERROR_MANAGER_ENGINEINIT_FAIL);
             return false;
         }
-        return true;
     }
 
     @Override
@@ -119,22 +132,17 @@
     }
 
     @Override
-    public Object prerollMediaPlayer(Locator source) {
-        // attempt the actual player creation, then preroll here
-        // on success we return a reference to the native player as the cookie
-        return new OSXMediaPlayer(source);
-    }
-
-    @Override
-    public MediaPlayer createMediaPlayer(Locator source, Object cookie) {
-        if (cookie instanceof OSXMediaPlayer) {
-            OSXMediaPlayer player = (OSXMediaPlayer)cookie;
-            // do native initialization
-            player.initializePlayer();
-            return player;
+    public MediaPlayer createMediaPlayer(Locator source) {
+        try {
+            return new OSXMediaPlayer(source);
+        } catch (Exception ex) {
+            if (Logger.canLog(Logger.DEBUG)) {
+                Logger.logMsg(Logger.DEBUG, "OSXPlatform caught exception while creating media player: "+ex);
+                ex.printStackTrace();
+            }
         }
         return null;
     }
 
-    private static native void osxPlatformInit();
+    private static native boolean osxPlatformInit();
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/PipelineManagement/NullAudioEqualizer.h	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __JFXMedia__NullAudioEqualizer__
+#define __JFXMedia__NullAudioEqualizer__
+
+#include "AudioEqualizer.h"
+#include <map>
+
+/*
+ * Audio Equalizer that does nothing, but provides behavior expected by the stack.
+ */
+
+class CNullEqualizerBand : public CEqualizerBand {
+public:
+    CNullEqualizerBand() : CEqualizerBand() {}
+    CNullEqualizerBand(double frequency, double bandwidth, double gain)
+        : CEqualizerBand(bandwidth, gain), mFrequency(frequency) {}
+    virtual ~CNullEqualizerBand() {}
+
+    virtual double  GetCenterFrequency() {
+        return mFrequency;
+    }
+
+    virtual void SetCenterFrequency(double centerFrequency) {
+        mFrequency = centerFrequency;
+    }
+
+    virtual double  GetBandwidth() {
+        return m_Bandwidth;
+    }
+
+    virtual void    SetBandwidth(double bandwidth) {
+        m_Bandwidth = bandwidth;
+    }
+
+    virtual double  GetGain() {
+        return m_Gain;
+    }
+
+    virtual void    SetGain(double gain) {
+        m_Gain = gain;
+    }
+
+private:
+    double mFrequency;
+};
+
+class CNullAudioEqualizer : public CAudioEqualizer {
+public:
+    CNullAudioEqualizer() : mEnabled(false) {}
+    virtual ~CNullAudioEqualizer() {}
+
+    virtual bool IsEnabled() {
+        return mEQBands.size() > 0 && mEnabled;
+    }
+
+    virtual void SetEnabled(bool isEnabled) {
+        mEnabled = isEnabled;
+    }
+
+    virtual int GetNumBands() {
+        return (int)mEQBands.size();
+    }
+
+    // TODO: critical section?
+    virtual CEqualizerBand*  AddBand(double frequency, double bandwidth, double gain) {
+        BandMap::iterator band_it = mEQBands.find(frequency);
+        if (band_it == mEQBands.end()) {
+            // add new band
+            mEQBands[frequency] = CNullEqualizerBand(frequency, bandwidth, gain);
+            return &mEQBands[frequency];
+        }
+
+        // Update an existing band
+        return NULL;
+    }
+
+    virtual bool RemoveBand(double frequency) {
+        BandMap::iterator band = mEQBands.find(frequency);
+        if (band != mEQBands.end()) {
+            mEQBands.erase(band);
+        }
+        return true;
+    }
+
+private:
+    typedef std::map<double,CNullEqualizerBand> BandMap; // freq -> [bandwidth, gain]
+
+    bool mEnabled;
+    BandMap mEQBands;
+};
+
+#endif /* defined(__JFXMedia__NullAudioEqualizer__) */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/PipelineManagement/NullAudioSpectrum.h	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,85 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#ifndef __JFXMedia__NullAudioSpectrum__
+#define __JFXMedia__NullAudioSpectrum__
+
+#include "AudioSpectrum.h"
+
+/*
+ * Audio spectrum class that does nothing, since the stack does not allow one to NOT exist.
+ */
+
+class CNullAudioSpectrum : public CAudioSpectrum {
+public:
+    CNullAudioSpectrum() : CAudioSpectrum(), mEnabled(false) {}
+    virtual ~CNullAudioSpectrum() {}
+
+    virtual bool IsEnabled() {
+        return mEnabled;
+    }
+
+    virtual void SetEnabled(bool isEnabled) {
+        mEnabled = isEnabled;
+    }
+
+    virtual void SetBands(int bands, CBandsHolder* holder) {
+        mBandCount = bands;
+        mBandsHolder = holder;
+    }
+
+    virtual size_t GetBands() {
+        return (size_t)mBandCount;
+    }
+
+    virtual double GetInterval() {
+        return mInterval;
+    }
+
+    virtual void SetInterval(double interval) {
+        mInterval = interval;
+    }
+
+    virtual int GetThreshold() {
+        return mThreshold;
+    }
+
+    virtual void SetThreshold(int threshold) {
+        mThreshold = threshold;
+    }
+
+    virtual void UpdateBands(int size, const float* magnitudes, const float* phases) {
+        // Do nothing...
+    }
+
+private:
+    bool mEnabled;
+    CBandsHolder *mBandsHolder;
+    int mBandCount;
+    double mInterval;
+    int mThreshold;
+};
+
+#endif /* defined(__JFXMedia__NullAudioSpectrum__) */
--- a/modules/media/src/main/native/jfxmedia/PipelineManagement/VideoFrame.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/PipelineManagement/VideoFrame.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -32,13 +32,17 @@
 CVideoFrame::CVideoFrame()
 :   m_iWidth(0),
     m_iHeight(0),
+    m_iEncodedWidth(0),
+    m_iEncodedHeight(0),
     m_typeFrame(UNKNOWN),
     m_bHasAlpha(false),
     m_dTime(0.0),
-    m_ulSize(0),
-    m_pvData(0),
-    m_ulFrameNumber(0)
+    m_FrameDirty(false),
+    m_iPlaneCount(1)
 {
+    m_piPlaneStrides[0] = m_piPlaneStrides[1] = m_piPlaneStrides[2] = m_piPlaneStrides[3] = 0;
+    m_pulPlaneSize[0] = m_pulPlaneSize[1] = m_pulPlaneSize[2] = m_pulPlaneSize[3] = 0;
+    m_pvPlaneData[0] = m_pvPlaneData[1] = m_pvPlaneData[2] = m_pvPlaneData[3] = NULL;
 }
 
 CVideoFrame::~CVideoFrame()
@@ -75,15 +79,28 @@
     return m_bHasAlpha;
 }
 
+double CVideoFrame::GetTime()
+{
+    return m_dTime;
+}
+
 int CVideoFrame::GetPlaneCount()
 {
     return m_iPlaneCount;
 }
 
-int CVideoFrame::GetOffsetForPlane(int planeIndex)
+void* CVideoFrame::GetDataForPlane(int planeIndex)
 {
     if (planeIndex < 4 && planeIndex >= 0) {
-        return m_piPlaneOffsets[planeIndex];
+        return m_pvPlaneData[planeIndex];
+    }
+    return NULL;
+}
+
+unsigned long CVideoFrame::GetSizeForPlane(int planeIndex)
+{
+    if (planeIndex < 4 && planeIndex >= 0) {
+        return m_pulPlaneSize[planeIndex];
     }
     return 0;
 }
@@ -96,27 +113,24 @@
     return 0;
 }
 
-double CVideoFrame::GetTime()
-{
-    return m_dTime;
-}
-
-unsigned long CVideoFrame::GetSize()
-{
-    return m_ulSize;
-}
-
-void* CVideoFrame::GetData()
-{
-    return m_pvData;
-}
-
-unsigned long CVideoFrame::GetFrameNumber()
-{
-    return m_ulFrameNumber;
-}
-
 CVideoFrame *CVideoFrame::ConvertToFormat(FrameType type)
 {
     return NULL;
 }
+
+void CVideoFrame::SwapPlanes(int aa, int bb)
+{
+    if (aa != bb && aa >= 0 && aa < m_iPlaneCount && bb >= 0 && bb < m_iPlaneCount) {
+        int stride = m_piPlaneStrides[aa];
+        m_piPlaneStrides[aa] = m_piPlaneStrides[bb];
+        m_piPlaneStrides[bb] = stride;
+
+        unsigned long size = m_pulPlaneSize[aa];
+        m_pulPlaneSize[aa] = m_pulPlaneSize[bb];
+        m_pulPlaneSize[bb] = size;
+
+        void *vptr = m_pvPlaneData[aa];
+        m_pvPlaneData[aa] = m_pvPlaneData[bb];
+        m_pvPlaneData[bb] = vptr;
+    }
+}
--- a/modules/media/src/main/native/jfxmedia/PipelineManagement/VideoFrame.h	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/PipelineManagement/VideoFrame.h	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -44,7 +44,8 @@
         ARGB = 1,
         BGRA_PRE = 2,
         YCbCr_420p = 100,
-        YCbCr_422 = 101
+        YCbCr_422 = 101,
+        YCbCr_422_rev = 102
     };
 
 public:
@@ -54,21 +55,19 @@
     virtual void        Dispose() {}
 
     double              GetTime();
-    unsigned long       GetFrameNumber();
 
     int                 GetWidth();
     int                 GetHeight();
     int                 GetEncodedWidth();
     int                 GetEncodedHeight();
-    int                 GetPlaneCount();
-    int                 GetOffsetForPlane(int planeIndex);
-    int                 GetStrideForPlane(int planeIndex);
 
     FrameType           GetType();
     bool                HasAlpha();
 
-    unsigned long       GetSize();
-    void*               GetData();
+    int                 GetPlaneCount();
+    void*               GetDataForPlane(int planeIndex);
+    unsigned long       GetSizeForPlane(int planeIndex);
+    int                 GetStrideForPlane(int planeIndex);
 
     virtual CVideoFrame *ConvertToFormat(FrameType type);
 
@@ -82,14 +81,16 @@
     int                 m_iEncodedHeight;
     FrameType           m_typeFrame;
     bool                m_bHasAlpha;
+    double              m_dTime;
+    bool                m_FrameDirty;
+
+    // frame data buffers
     int                 m_iPlaneCount;
-    int                 m_piPlaneOffsets[4];
+    void*               m_pvPlaneData[4];
+    unsigned long       m_pulPlaneSize[4];
     int                 m_piPlaneStrides[4];
-    double              m_dTime;
-    unsigned long       m_ulSize;
-    void*               m_pvData;
-    unsigned long       m_ulFrameNumber;
-    bool                m_FrameDirty;
+
+    void SwapPlanes(int aa, int bb);
 };
 
 #endif  //_VIDEO_FRAME_H_
--- a/modules/media/src/main/native/jfxmedia/jni/JniUtils.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/jni/JniUtils.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -31,6 +31,36 @@
 #include <platform/gstreamer/GstJniUtils.h>
 #endif // ENABLE_PLATFORM_GSTREAMER
 
+void ThrowJavaException(JNIEnv *env, const char* type, const char* message)
+{
+    // First check if there's a pending exception, if there is then do nothing
+    if (env->ExceptionCheck()) {
+        return;
+    }
+
+    jclass klass = NULL;
+    if (type) {
+        klass = env->FindClass(type);
+        if (!klass) {
+            // might have caused an exception
+            if (env->ExceptionOccurred()) {
+                env->ExceptionClear();
+            }
+        }
+    }
+    if (!klass) {
+        klass = env->FindClass("java/lang/Exception");
+        if (!klass) {
+            if (env->ExceptionOccurred()) {
+                env->ExceptionClear();
+            }
+            // This shouldn't happen...
+            return;
+        }
+    }
+    env->ThrowNew(klass, message);
+}
+
 JNIEnv *GetJavaEnvironment(JavaVM *jvm, jboolean &didAttach)
 {
     JNIEnv *env = NULL;
--- a/modules/media/src/main/native/jfxmedia/jni/JniUtils.h	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/jni/JniUtils.h	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -27,6 +27,7 @@
 #define _JNI_UTILS_H_
 
 #include <jni.h>
+#include <string>
 
 #if defined (_LP64) || defined(_WIN64)
 #define jlong_to_ptr(a) ((void*)(a))
@@ -36,6 +37,10 @@
 #define ptr_to_jlong(a) ((jlong)(int)(a))
 #endif
 
+// Throws an exception of the given type (class name)
+// if type is NULL, then will throw a generic Exception
+void ThrowJavaException(JNIEnv *env, const char* type, const char* message);
+
 // Gets a valid, usable JNIEnv for the current thread
 // if didAttach is true on return then you should call
 // jvm->DetachCurrentThread() when done
@@ -55,12 +60,14 @@
 class CJavaEnvironment {
 public:
     CJavaEnvironment(JavaVM *);
+    CJavaEnvironment(JNIEnv *); // create with an existing JNIEnv
     ~CJavaEnvironment();
 
     JNIEnv *getEnvironment();
     bool hasException();    // return true if an exception is raised (but do nothing with it)
     bool clearException();  // if an exception is raised, clear it and return true
     bool reportException(); // as above but log the exception to Logger
+    void throwException(std::string message); // Throw an exception with the given message
 
 private:
     JNIEnv *environment;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/jni/NativeAudioEqualizer.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "com_sun_media_jfxmediaimpl_NativeAudioEqualizer.h"
+#include <PipelineManagement/AudioEqualizer.h>
+#include "JniUtils.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jboolean JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioEqualizer_nativeGetEnabled(JNIEnv *env, jobject obj, jlong nativeRef)
+{
+    // nativeRef is a pointer to a CAudioEqualizer object
+    CAudioEqualizer *pEqualizer = (CAudioEqualizer*)jlong_to_ptr(nativeRef);
+    return (NULL != pEqualizer) ? pEqualizer->IsEnabled() : JNI_FALSE;
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioEqualizer_nativeSetEnabled(JNIEnv *env, jobject obj, jlong nativeRef, jboolean enabled)
+{
+    CAudioEqualizer *pEqualizer = (CAudioEqualizer*)jlong_to_ptr(nativeRef);
+    if (NULL != pEqualizer)
+        pEqualizer->SetEnabled(enabled==JNI_TRUE);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioEqualizer_nativeGetNumBands(JNIEnv *env, jobject obj, jlong nativeRef)
+{
+    CAudioEqualizer *pEqualizer = (CAudioEqualizer*)jlong_to_ptr(nativeRef);
+    return (NULL != pEqualizer) ? pEqualizer->GetNumBands() : 0;
+}
+
+JNIEXPORT jobject JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioEqualizer_nativeAddBand(JNIEnv *env, jobject obj, jlong nativeRef,
+                                                                                jdouble centerFrequency, jdouble bandWidth, jdouble gain)
+{
+    static jmethodID mid_EqualizerBandConstructor = NULL;
+
+    CAudioEqualizer *pEqualizer = (CAudioEqualizer*)jlong_to_ptr(nativeRef);
+    if (NULL != pEqualizer) {
+        CEqualizerBand *band = pEqualizer->AddBand(centerFrequency, bandWidth, gain);
+        if (NULL != band) {
+            jclass bandClass = env->FindClass("com/sun/media/jfxmediaimpl/NativeEqualizerBand");
+
+            if (NULL == mid_EqualizerBandConstructor)
+                mid_EqualizerBandConstructor = env->GetMethodID(bandClass, "<init>", "(J)V");
+
+            jobject band_instance = env->NewObject(bandClass, mid_EqualizerBandConstructor, ptr_to_jlong(band));
+            env->DeleteLocalRef(bandClass);
+
+            return band_instance;
+        }
+    }
+
+    return  NULL;
+}
+
+JNIEXPORT jboolean JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioEqualizer_nativeRemoveBand(JNIEnv *env, jobject obj, jlong nativeRef,
+                                                                                   jdouble centerFrequency)
+{
+    CAudioEqualizer *pEqualizer = (CAudioEqualizer*)jlong_to_ptr(nativeRef);
+    return (NULL != pEqualizer) ? pEqualizer->RemoveBand(centerFrequency) : JNI_FALSE;
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/jni/NativeAudioSpectrum.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,97 @@
+/*
+ * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "com_sun_media_jfxmediaimpl_NativeAudioSpectrum.h"
+#include <PipelineManagement/AudioSpectrum.h>
+#include "JavaBandsHolder.h"
+#include <jni.h>
+#include "JniUtils.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jboolean JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeGetEnabled(JNIEnv *env, jobject obj, jlong nativeRef)
+{
+    CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
+    return (NULL != pSpectrum) ? pSpectrum->IsEnabled() : JNI_FALSE;
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeSetEnabled(JNIEnv *env, jobject obj, jlong nativeRef,
+                                                                                  jboolean enabled)
+{
+    CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
+    if (pSpectrum != NULL)
+        pSpectrum->SetEnabled(enabled);
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeSetBands(JNIEnv *env, jobject obj, jlong nativeRef,
+                                                                                jint bands, jfloatArray magnitudes, jfloatArray phases)
+{
+    CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
+    CBandsHolder *pHolder = new (std::nothrow) CJavaBandsHolder(env, bands, magnitudes, phases);
+
+    if (pSpectrum != NULL && pHolder != NULL)
+        pSpectrum->SetBands(bands, pHolder);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeGetInterval(JNIEnv *env, jobject obj, jlong nativeRef)
+{
+    CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
+    return (NULL != pSpectrum) ? pSpectrum->GetInterval() : 0.0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeSetInterval(JNIEnv *env, jobject obj, jlong nativeRef,
+                                                                                                          jdouble interval)
+{
+    CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
+    if (pSpectrum != NULL)
+        pSpectrum->SetInterval(interval);
+}
+
+JNIEXPORT jint JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeGetThreshold(JNIEnv *env, jobject obj, jlong nativeRef)
+{
+    CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
+    return (NULL != pSpectrum) ? pSpectrum->GetThreshold() : 0;
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeAudioSpectrum_nativeSetThreshold(JNIEnv *env, jobject obj, jlong nativeRef,
+                                                                                    jint threshold)
+{
+    CAudioSpectrum *pSpectrum = (CAudioSpectrum*)jlong_to_ptr(nativeRef);
+    if (pSpectrum != NULL)
+        pSpectrum->SetThreshold(threshold);
+}
+
+#ifdef __cplusplus
+}
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/jni/NativeEqualizerBand.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.  Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+#include "com_sun_media_jfxmediaimpl_NativeEqualizerBand.h"
+
+#include <jni/JniUtils.h>
+#include <PipelineManagement/AudioEqualizer.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+JNIEXPORT jdouble JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeEqualizerBand_nativeGetCenterFrequency(JNIEnv *env, jobject obj, jlong band_ref)
+{
+    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
+    return (jdouble)pBand->GetCenterFrequency();
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeEqualizerBand_nativeSetCenterFrequency(JNIEnv *env, jobject obj, jlong band_ref,
+    jdouble centerFrequency)
+{
+    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
+    pBand->SetCenterFrequency(centerFrequency);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeEqualizerBand_nativeGetBandwidth(JNIEnv *env, jobject obj, jlong band_ref)
+{
+    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
+    return (jdouble)pBand->GetBandwidth();
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeEqualizerBand_nativeSetBandwidth(JNIEnv *env, jobject obj, jlong band_ref,
+    jdouble bandwidth)
+{
+    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
+    pBand->SetBandwidth(bandwidth);
+}
+
+JNIEXPORT jdouble JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeEqualizerBand_nativeGetGain(JNIEnv *env, jobject obj, jlong band_ref)
+{
+    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
+    return (jdouble)pBand->GetGain();
+}
+
+JNIEXPORT void JNICALL
+Java_com_sun_media_jfxmediaimpl_NativeEqualizerBand_nativeSetGain(JNIEnv *env, jobject obj, jlong band_ref, jdouble gain)
+{
+    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
+    pBand->SetGain(gain);
+}
+
+#ifdef __cplusplus
+}
+#endif
--- a/modules/media/src/main/native/jfxmedia/jni/NativeVideoBuffer.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/jni/NativeVideoBuffer.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -62,17 +62,17 @@
 /*
  * Class:     com_sun_media_jfxmediaimpl_NativeVideoBuffer
  * Method:    nativeGetBuffer
- * Signature: (J)Ljava/nio/ByteBuffer;
+ * Signature: (JI)Ljava/nio/ByteBuffer;
  *
  * WARNING: This method will create a new ByteBuffer object, you should cache this object to avoid multiple allocations.
  */
-JNIEXPORT jobject JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetBuffer
-    (JNIEnv *env, jobject obj, jlong nativeHandle)
+JNIEXPORT jobject JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetBufferForPlane
+    (JNIEnv *env, jobject obj, jlong nativeHandle, jint plane)
 {
     CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle);
     if (frame) {
-        void *dataPtr = frame->GetData();
-        jlong capacity = (jlong)frame->GetSize();
+        void *dataPtr = frame->GetDataForPlane((int)plane);
+        jlong capacity = (jlong)frame->GetSizeForPlane((int)plane);
         return env->NewDirectByteBuffer(dataPtr, capacity);
     }
     return NULL;
@@ -80,21 +80,6 @@
 
 /*
  * Class:     com_sun_media_jfxmediaimpl_NativeVideoBuffer
- * Method:    nativeGetFrameNumber
- * Signature: (J)J
- */
-JNIEXPORT jlong JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetFrameNumber
-    (JNIEnv *env, jobject obj, jlong nativeHandle)
-{
-    CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle);
-    if (frame) {
-        return (jlong)frame->GetFrameNumber();
-    }
-    return 0;
-}
-
-/*
- * Class:     com_sun_media_jfxmediaimpl_NativeVideoBuffer
  * Method:    nativeGetWidth
  * Signature: (J)I
  */
@@ -201,32 +186,6 @@
 
 /*
  * Class:     com_sun_media_jfxmediaimpl_NativeVideoBuffer
- * Method:    nativeGetPlaneOffsets
- * Signature: (J)[I
- */
-JNIEXPORT jintArray JNICALL Java_com_sun_media_jfxmediaimpl_NativeVideoBuffer_nativeGetPlaneOffsets
-    (JNIEnv *env, jobject obj, jlong nativeHandle)
-{
-    CVideoFrame *frame = (CVideoFrame*)jlong_to_ptr(nativeHandle);
-    if (frame) {
-        jint count = frame->GetPlaneCount();
-        jintArray offsets = env->NewIntArray(count);
-        jint *offsetArray = new jint[count];
-
-        for (int ii=0; ii < count; ii++) {
-            offsetArray[ii] = frame->GetOffsetForPlane(ii);
-        }
-
-        env->SetIntArrayRegion(offsets, 0, count, offsetArray);
-        delete [] offsetArray;
-
-        return offsets;
-    }
-    return NULL;
-}
-
-/*
- * Class:     com_sun_media_jfxmediaimpl_NativeVideoBuffer
  * Method:    nativeGetPlaneStrides
  * Signature: (J)[I
  */
--- a/modules/media/src/main/native/jfxmedia/jni/com_sun_media_jfxmediaimpl_NativeVideoConverter.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/jni/com_sun_media_jfxmediaimpl_NativeVideoConverter.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -96,11 +96,6 @@
             throw "Internal Error: Can't find VideoDataBuffer.getPlaneCount()";
         }
 
-        vdbGetPlaneOffsetsID = env->GetMethodID(vdbClass, "getPlaneOffsets", "()[I");
-        if (!vdbGetPlaneOffsetsID) {
-            throw "Internal Error: Can't find VideoDataBuffer.getPlaneOffsets()";
-        }
-
         vdbGetPlaneStridesID = env->GetMethodID(vdbClass, "getPlaneStrides", "()[I");
         if (!vdbGetPlaneStridesID) {
             throw "Internal Error: Can't find VideoDataBuffer.getPlaneStrides()";
@@ -111,12 +106,6 @@
             throw "Internal Error: Can't find VideoDataBuffer.getFormat()";
         }
 
-        vdbGetFrameNumberID = env->GetMethodID(vdbClass, "getFrameNumber", "()J");
-        if (!vdbGetFrameNumberID) {
-            throw "Internal Error: Can't find VideoDataBuffer.getFrameNumber()";
-        }
-
-
         formatGetNativeTypeID = env->GetMethodID(formatClass, "getNativeType", "()I");
         if (!formatGetNativeTypeID) {
             throw "Internal Error: Can't find VideoDataBuffer.Format.getNativeType()";
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAVPlaybackPipeline.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAVPlaybackPipeline.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -260,9 +260,10 @@
     else
     {
         delete pVideoFrame;
-
-        pPipeline->m_pEventDispatcher->Warning(WARNING_GSTREAMER_INVALID_FRAME,
-                                               "Invalid frame");
+        if (pPipeline->m_pEventDispatcher != NULL) {
+            pPipeline->m_pEventDispatcher->Warning(WARNING_GSTREAMER_INVALID_FRAME,
+                                                   "Invalid frame");
+        }
 
     }
 
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioEqualizer.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioEqualizer.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,87 +25,11 @@
 
 #include "GstAudioEqualizer.h"
 
-#include <com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioEqualizer.h>
-
 #include <jni/JniUtils.h>
 #include <MediaManagement/Media.h>
 #include <PipelineManagement/Pipeline.h>
 #include <PipelineManagement/AudioEqualizer.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioEqualizer_gstGetEnabled(JNIEnv *env, jobject obj, jlong ref_media)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioEqualizer *pEqualizer = pMedia->GetPipeline()->GetAudioEqualizer();
-
-    return (NULL != pEqualizer) ? pEqualizer->IsEnabled() : JNI_FALSE;
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioEqualizer_gstSetEnabled(JNIEnv *env, jobject obj, jlong ref_media, jboolean enabled)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioEqualizer *pEqualizer = pMedia->GetPipeline()->GetAudioEqualizer();
-
-    if (NULL != pEqualizer)
-        pEqualizer->SetEnabled(enabled==JNI_TRUE);
-}
-
-JNIEXPORT jint JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioEqualizer_gstGetNumBands(JNIEnv *env, jobject obj, jlong ref_media)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioEqualizer *pEqualizer = pMedia->GetPipeline()->GetAudioEqualizer();
-
-    return (NULL != pEqualizer) ? pEqualizer->GetNumBands() : 0;
-}
-
-JNIEXPORT jobject JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioEqualizer_gstAddBand(JNIEnv *env, jobject obj, jlong ref_media,
-                                                                                jdouble centerFrequency, jdouble bandWidth, jdouble gain)
-{
-    static jmethodID mid_EqualizerBandConstructor = NULL;
-
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioEqualizer *pEqualizer = pMedia->GetPipeline()->GetAudioEqualizer();
-    if (NULL != pEqualizer)
-    {
-        CEqualizerBand *band = pEqualizer->AddBand(centerFrequency, bandWidth, gain);
-        if (NULL != band)
-        {
-            jclass bandClass = env->FindClass("com/sun/media/jfxmediaimpl/platform/gstreamer/GSTEqualizerBand");
-
-            if (NULL == mid_EqualizerBandConstructor)
-                mid_EqualizerBandConstructor = env->GetMethodID(bandClass, "<init>", "(J)V");
-
-            jobject band_instance = env->NewObject(bandClass, mid_EqualizerBandConstructor, ptr_to_jlong(band));
-            env->DeleteLocalRef(bandClass);
-
-            return band_instance;
-        }
-    }
-
-    return  NULL;
-}
-
-JNIEXPORT jboolean JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioEqualizer_gstRemoveBand(JNIEnv *env, jobject obj, jlong ref_media,
-                                                                                   jdouble centerFrequency)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioEqualizer *pEqualizer = pMedia->GetPipeline()->GetAudioEqualizer();
-
-    return (NULL != pEqualizer) ? pEqualizer->RemoveBand(centerFrequency) : JNI_FALSE;
-}
-
-#ifdef __cplusplus
-}
-#endif
-
 /***********************************************************************************
  * CGstEqualizerBand
  ***********************************************************************************/
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioEqualizer.h	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioEqualizer.h	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioPlaybackPipeline.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioPlaybackPipeline.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -50,9 +50,9 @@
 CGstAudioPlaybackPipeline::CGstAudioPlaybackPipeline(const GstElementContainer& elements, int flags, CPipelineOptions* pOptions)
 :   CPipeline(pOptions),
     m_Elements(elements),
-    m_AudioFlags(flags),
     m_pAudioEqualizer(NULL),
-    m_pAudioSpectrum(NULL)
+    m_pAudioSpectrum(NULL),
+    m_AudioFlags(flags)
 {
     m_dResumeDeltaTime = m_Elements[VIDEO_SINK] ? VIDEO_RESUME_DELTA_TIME : AUDIO_RESUME_DELTA_TIME;
 
@@ -1399,7 +1399,7 @@
                         magnitudes[i] = g_value_get_float( gst_value_list_get_value (magnitudes_value, i));
                         phases[i] = g_value_get_float( gst_value_list_get_value (phases_value, i));
                     }
-                    pPipeline->GetAudioSpectrum()->UpdateBands(bandsNum, magnitudes, phases);
+                    pPipeline->GetAudioSpectrum()->UpdateBands((int)bandsNum, magnitudes, phases);
 
                     delete [] magnitudes;
                     delete [] phases;
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioSpectrum.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstAudioSpectrum.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -22,7 +22,6 @@
  * or visit www.oracle.com if you need additional information or have any
  * questions.
  */
-#include <com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum.h>
 
 #include "GstAudioSpectrum.h"
 #include <MediaManagement/Media.h>
@@ -31,84 +30,6 @@
 #include <jni/JavaBandsHolder.h>
 #include <jni/JniUtils.h>
 
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jboolean JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum_gstGetEnabled(JNIEnv *env, jobject obj, jlong ref_media)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioSpectrum *pSpectrum = pMedia->GetPipeline()->GetAudioSpectrum();
-
-    return (NULL != pSpectrum) ? pSpectrum->IsEnabled() : JNI_FALSE;
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum_gstSetEnabled(JNIEnv *env, jobject obj, jlong ref_media,
-                                                                                  jboolean enabled)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioSpectrum *pSpectrum = pMedia->GetPipeline()->GetAudioSpectrum();
-
-    if (pSpectrum != NULL)
-        pSpectrum->SetEnabled(enabled);
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum_gstSetBands(JNIEnv *env, jobject obj, jlong ref_media,
-                                                                                jint bands, jfloatArray magnitudes, jfloatArray phases)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioSpectrum *pSpectrum = pMedia->GetPipeline()->GetAudioSpectrum();
-    CBandsHolder *pHolder = new (nothrow) CJavaBandsHolder(env, bands, magnitudes, phases);
-
-    if (pSpectrum != NULL && pHolder != NULL)
-        pSpectrum->SetBands(bands, pHolder);
-}
-
-JNIEXPORT jdouble JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum_gstGetInterval(JNIEnv *env, jobject obj, jlong ref_media)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioSpectrum *pSpectrum = pMedia->GetPipeline()->GetAudioSpectrum();
-
-    return (NULL != pSpectrum) ? pSpectrum->GetInterval() : 0.0;
-}
-
-JNIEXPORT void JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum_gstSetInterval(JNIEnv *env, jobject obj, jlong ref_media,
-                                                                                                          jdouble interval)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioSpectrum *pSpectrum = pMedia->GetPipeline()->GetAudioSpectrum();
-
-    if (pSpectrum != NULL)
-        pSpectrum->SetInterval(interval);
-}
-
-JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum_gstGetThreshold(JNIEnv *env, jobject obj, jlong ref_media)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioSpectrum *pSpectrum = pMedia->GetPipeline()->GetAudioSpectrum();
-
-    return (NULL != pSpectrum) ? pSpectrum->GetThreshold() : 0;
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTAudioSpectrum_gstSetThreshold(JNIEnv *env, jobject obj, jlong ref_media,
-                                                                                    jint threshold)
-{
-    CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media);
-    CAudioSpectrum *pSpectrum = pMedia->GetPipeline()->GetAudioSpectrum();
-
-    if (pSpectrum != NULL)
-        pSpectrum->SetThreshold(threshold);
-}
-
-#ifdef __cplusplus
-}
-#endif
-
 /************************************************************************
  *
  *************************************************************************/
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstEqualizerBand.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,81 +0,0 @@
-/*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * This code is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License version 2 only, as
- * published by the Free Software Foundation.  Oracle designates this
- * particular file as subject to the "Classpath" exception as provided
- * by Oracle in the LICENSE file that accompanied this code.
- *
- * This code is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * version 2 for more details (a copy is included in the LICENSE file that
- * accompanied this code).
- *
- * You should have received a copy of the GNU General Public License version
- * 2 along with this work; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
- * or visit www.oracle.com if you need additional information or have any
- * questions.
- */
-
-#include "com_sun_media_jfxmediaimpl_platform_gstreamer_GSTEqualizerBand.h"
-
-#include <jni/JniUtils.h>
-#include <PipelineManagement/AudioEqualizer.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-JNIEXPORT jdouble JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTEqualizerBand_gstGetCenterFrequency(JNIEnv *env, jobject obj, jlong band_ref)
-{
-    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
-    return (jdouble)pBand->GetCenterFrequency();
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTEqualizerBand_gstSetCenterFrequency(JNIEnv *env, jobject obj, jlong band_ref,
-    jdouble centerFrequency)
-{
-    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
-    pBand->SetCenterFrequency(centerFrequency);
-}
-
-JNIEXPORT jdouble JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTEqualizerBand_gstGetBandwidth(JNIEnv *env, jobject obj, jlong band_ref)
-{
-    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
-    return (jdouble)pBand->GetBandwidth();
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTEqualizerBand_gstSetBandwidth(JNIEnv *env, jobject obj, jlong band_ref,
-    jdouble bandwidth)
-{
-    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
-    pBand->SetBandwidth(bandwidth);
-}
-
-JNIEXPORT jdouble JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTEqualizerBand_gstGetGain(JNIEnv *env, jobject obj, jlong band_ref)
-{
-    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
-    return (jdouble)pBand->GetGain();
-}
-
-JNIEXPORT void JNICALL
-Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTEqualizerBand_gstSetGain(JNIEnv *env, jobject obj, jlong band_ref, jdouble gain)
-{
-    CEqualizerBand* pBand = (CEqualizerBand*)jlong_to_ptr(band_ref);
-    pBand->SetGain(gain);
-}
-
-#ifdef __cplusplus
-}
-#endif
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstMediaPlayer.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstMediaPlayer.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -34,6 +34,8 @@
 #include <jfxmedia_errors.h>
 #include <Utils/LowLevelPerf.h>
 
+#include "GstAudioEqualizer.h"
+
 using namespace std;
 
 //*************************************************************************************************
@@ -76,6 +78,38 @@
     return iRet;
 }
 
+/*
+ * Class:     com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer
+ * Method:    gstGetAudioEqualizer
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstGetAudioEqualizer
+(JNIEnv *env, jobject playerObject, jlong nativeRef)
+{
+    CMedia* pMedia = (CMedia*)jlong_to_ptr(nativeRef);
+    if (NULL == pMedia) {
+        return 0;
+    }
+    CAudioEqualizer *eq = pMedia->GetPipeline()->GetAudioEqualizer();
+    return ptr_to_jlong(eq);
+}
+
+/*
+ * Class:     com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer
+ * Method:    gstGetAudioSpectrum
+ * Signature: (J)J
+ */
+JNIEXPORT jlong JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstGetAudioSpectrum
+(JNIEnv *env, jobject playerObject, jlong nativeRef)
+{
+    CMedia* pMedia = (CMedia*)jlong_to_ptr(nativeRef);
+    if (NULL == pMedia) {
+        return 0;
+    }
+    CAudioSpectrum *spectrum = pMedia->GetPipeline()->GetAudioSpectrum();
+    return ptr_to_jlong(spectrum);
+}
+
 /**
  * gstGetAudioSyncDelay()
  *
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstVideoFrame.cpp	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstVideoFrame.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -86,6 +86,8 @@
         red_mask    = 0x0000FF00;
         green_mask  = 0x00FF0000;
         blue_mask   = 0xFF000000;
+    } else {
+        return NULL; // unsupported format..
     }
 
     newCaps = gst_caps_new_simple("video/x-raw-rgb",
@@ -124,10 +126,8 @@
 
     GstCaps* caps = GST_BUFFER_CAPS(m_pBuffer);
 
-    m_ulSize        = (unsigned long)GST_BUFFER_SIZE(m_pBuffer);
-    m_pvData        = (void*)GST_BUFFER_DATA(m_pBuffer);
-    m_ulFrameNumber = (unsigned long) GST_BUFFER_OFFSET(m_pBuffer);
-
+    m_ulBufferSize = (unsigned long)GST_BUFFER_SIZE(m_pBuffer);
+    m_pvBufferBaseAddress = (void*)GST_BUFFER_DATA(m_pBuffer);
 
     if (GST_BUFFER_TIMESTAMP_IS_VALID (m_pBuffer)) {
         m_dTime = (double)GST_BUFFER_TIMESTAMP(m_pBuffer) / GST_SECOND;
@@ -223,11 +223,13 @@
         m_iEncodedHeight = m_iHeight;
     }
 
-    m_piPlaneOffsets[0] = m_piPlaneOffsets[1] = m_piPlaneOffsets[2] = m_piPlaneOffsets[3] = 0;
+    m_pvPlaneData[0] = m_pvPlaneData[1] = m_pvPlaneData[2] = m_pvPlaneData[3] = NULL;
+    m_pulPlaneSize[0] = m_pulPlaneSize[1] = m_pulPlaneSize[2] = m_pulPlaneSize[3] = 0;
     m_piPlaneStrides[0] = m_piPlaneStrides[1] = m_piPlaneStrides[2] = m_piPlaneStrides[3] = 0;
 
     switch (m_typeFrame) {
         case YCbCr_420p: {
+            int offset;
             m_iPlaneCount = 3;
 
             if (!gst_structure_get_int(str, "stride-y", &m_piPlaneStrides[0])) {
@@ -240,37 +242,43 @@
                 m_piPlaneStrides[2] = m_piPlaneStrides[1];
             }
 
-            if(!gst_structure_get_int(str, "offset-y", &m_piPlaneOffsets[0])) {
-                m_piPlaneOffsets[0] = 0;
-            }
+            offset = 0;
+            gst_structure_get_int(str, "offset-y", &offset);
+            m_pulPlaneSize[0] = m_piPlaneStrides[0] * m_iEncodedHeight;
+            m_pvPlaneData[0] = (void*)((intptr_t)m_pvBufferBaseAddress + offset);
+
             //
             // Chroma offsets assume YV12 ordering
             //
-            if(!gst_structure_get_int(str, "offset-v", &m_piPlaneOffsets[1])) {
-                m_piPlaneOffsets[1] = m_piPlaneOffsets[0] + m_iEncodedHeight * m_piPlaneStrides[0];
-            }
-            if(!gst_structure_get_int(str, "offset-u", &m_piPlaneOffsets[2])) {
-                m_piPlaneOffsets[2] = m_piPlaneOffsets[1] + (m_iEncodedHeight/2) * m_piPlaneStrides[1];
+            offset += m_pulPlaneSize[0];
+            gst_structure_get_int(str, "offset-v", &offset);
+            m_pulPlaneSize[1] = m_piPlaneStrides[1] * (m_iEncodedHeight/2);
+            m_pvPlaneData[1] = (void*)((intptr_t)m_pvBufferBaseAddress + offset);
+
+            offset += m_pulPlaneSize[1];
+            gst_structure_get_int(str, "offset-u", &offset);
+            m_pulPlaneSize[2] = m_piPlaneStrides[2] * (m_iEncodedHeight/2);
+            m_pvPlaneData[2] = (void*)((intptr_t)m_pvBufferBaseAddress + offset);
+
+            // process alpha channel (before we potentially swap Cb/Cr)
+            if (m_bHasAlpha) {
+                m_iPlaneCount++;
+                if (!gst_structure_get_int(str, "stride-a", &m_piPlaneStrides[3])) {
+                    m_piPlaneStrides[3] = m_piPlaneStrides[0];
+                }
+
+                offset += m_pulPlaneSize[2];
+                gst_structure_get_int(str, "offset-a", &offset);
+                m_pulPlaneSize[3] = m_piPlaneStrides[3] * m_iEncodedHeight;
+                m_pvPlaneData[3] = (void*)((intptr_t)m_pvBufferBaseAddress + offset);
             }
 
             //
             // Swap chroma planes for I420.
             //
             if(FOURCC_I420 == m_uFormatFourCC) {
-                int tmp_index = m_piPlaneOffsets[1];
-                m_piPlaneOffsets[1] = m_piPlaneOffsets[2];
-                m_piPlaneOffsets[2] = tmp_index;
-            }
-
-            // process alpha channel
-            if (m_bHasAlpha) {
-                m_iPlaneCount++;
-                if (!gst_structure_get_int(str, "stride-a", &m_piPlaneStrides[3])) {
-                    m_piPlaneStrides[3] = m_piPlaneStrides[0];
-                }
-                if(!gst_structure_get_int(str, "offset-a", &m_piPlaneOffsets[3])) {
-                    m_piPlaneOffsets[3] = m_piPlaneOffsets[2] + (m_iEncodedHeight/2) * m_piPlaneStrides[2];
-                }
+                // Swap Cb/Cr plane data
+                SwapPlanes(1, 2);
             }
             break;
         }
@@ -284,6 +292,8 @@
                     m_piPlaneStrides[0] = m_iEncodedWidth * 4; // 32 bpp
                 }
             }
+            m_pulPlaneSize[0] = m_piPlaneStrides[0] * m_iEncodedHeight;
+            m_pvPlaneData[0] = m_pvBufferBaseAddress;
             break;
     }
 
@@ -387,19 +397,19 @@
             status = ColorConvert_YCbCr420p_to_ARGB32(
                         GST_BUFFER_DATA(destBuffer), stride,
                         m_iEncodedWidth, m_iEncodedHeight,
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[v_index],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[u_index],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[3],
+                        (const uint8_t*)m_pvPlaneData[0],
+                        (const uint8_t*)m_pvPlaneData[v_index],
+                        (const uint8_t*)m_pvPlaneData[u_index],
+                        (const uint8_t*)m_pvPlaneData[3],
                         m_piPlaneStrides[0], m_piPlaneStrides[v_index],
                         m_piPlaneStrides[u_index], m_piPlaneStrides[3]);
         } else {
             status = ColorConvert_YCbCr420p_to_ARGB32_no_alpha(
                         GST_BUFFER_DATA(destBuffer), stride,
                         m_iEncodedWidth, m_iEncodedHeight,
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[v_index],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[u_index],
+                        (const uint8_t*)m_pvPlaneData[0],
+                        (const uint8_t*)m_pvPlaneData[v_index],
+                        (const uint8_t*)m_pvPlaneData[u_index],
                         m_piPlaneStrides[0], m_piPlaneStrides[v_index],
                         m_piPlaneStrides[u_index]);
         }
@@ -408,19 +418,19 @@
             status = ColorConvert_YCbCr420p_to_BGRA32(
                         GST_BUFFER_DATA(destBuffer), stride,
                         m_iEncodedWidth, m_iEncodedHeight,
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[v_index],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[u_index],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[3],
+                        (const uint8_t*)m_pvPlaneData[0],
+                        (const uint8_t*)m_pvPlaneData[v_index],
+                        (const uint8_t*)m_pvPlaneData[u_index],
+                        (const uint8_t*)m_pvPlaneData[3],
                         m_piPlaneStrides[0], m_piPlaneStrides[v_index],
                         m_piPlaneStrides[u_index], m_piPlaneStrides[3]);
         } else {
             status = ColorConvert_YCbCr420p_to_BGRA32_no_alpha(
                         GST_BUFFER_DATA(destBuffer), stride,
                         m_iEncodedWidth, m_iEncodedHeight,
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[v_index],
-                        GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[u_index],
+                        (const uint8_t*)m_pvPlaneData[0],
+                        (const uint8_t*)m_pvPlaneData[v_index],
+                        (const uint8_t*)m_pvPlaneData[u_index],
                         m_piPlaneStrides[0], m_piPlaneStrides[v_index],
                         m_piPlaneStrides[u_index]);
         }
@@ -472,16 +482,16 @@
     if (destType == ARGB) {
         status = ColorConvert_YCbCr422p_to_ARGB32_no_alpha(GST_BUFFER_DATA(destBuffer), stride,
                                                            m_iEncodedWidth, m_iEncodedHeight,
-                                                           GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0] + 1,
-                                                           GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0] + 2,
-                                                           GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0],
+                                                           (uint8_t*)m_pvPlaneData[0] + 1,
+                                                           (uint8_t*)m_pvPlaneData[0] + 2,
+                                                           (uint8_t*)m_pvPlaneData[0],
                                                            m_piPlaneStrides[0], m_piPlaneStrides[0]);
     } else {
         status = ColorConvert_YCbCr422p_to_BGRA32_no_alpha(GST_BUFFER_DATA(destBuffer), stride,
                                                            m_iEncodedWidth, m_iEncodedHeight,
-                                                           GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0] + 1,
-                                                           GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0] + 2,
-                                                           GST_BUFFER_DATA(m_pBuffer) + m_piPlaneOffsets[0],
+                                                           (uint8_t*)m_pvPlaneData[0] + 1,
+                                                           (uint8_t*)m_pvPlaneData[0] + 2,
+                                                           (uint8_t*)m_pvPlaneData[0],
                                                            m_piPlaneStrides[0], m_piPlaneStrides[0]);
     }
 
--- a/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstVideoFrame.h	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/gstreamer/GstVideoFrame.h	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -69,6 +69,8 @@
     bool        m_bIsValid;
     bool        m_bHasAlpha;
     GstBuffer*  m_pBuffer;
+    void*       m_pvBufferBaseAddress;
+    unsigned long m_ulBufferSize;
     guint32     m_uFormatFourCC;
 
     CGstVideoFrame *ConvertSwapRGB(FrameType destType);
--- a/modules/media/src/main/native/jfxmedia/platform/osx/CVVideoFrame.h	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CVVideoFrame.h	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -30,7 +30,9 @@
 
 class CVVideoFrame : public CVideoFrame {
 public:
-    CVVideoFrame(CVPixelBufferRef buf, double frameTime, uint64_t frameHostTime, unsigned long frameNumber);
+    static bool IsFormatSupported(OSType format);
+
+    CVVideoFrame(CVPixelBufferRef buf, double frameTime, uint64_t frameHostTime);
     virtual ~CVVideoFrame();
 
     virtual void Dispose();
@@ -40,4 +42,7 @@
 private:
     CVPixelBufferRef pixelBuffer;
     uint64_t frameHostTime;
+
+    void PrepareChunky();
+    void PreparePlanar();
 };
--- a/modules/media/src/main/native/jfxmedia/platform/osx/CVVideoFrame.mm	Mon Oct 06 08:15:37 2014 -0700
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CVVideoFrame.mm	Mon Oct 06 09:32:41 2014 -0700
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -26,65 +26,76 @@
 #import "CVVideoFrame.h"
 #include <Utils/ColorConverter.h>
 
-CVVideoFrame::CVVideoFrame(CVPixelBufferRef buf, double frameTime, uint64_t frameHostTime, unsigned long frameNumber)
+OSType gLastFormat = -1;
+
+bool CVVideoFrame::IsFormatSupported(OSType format) {
+    switch (format) {
+        case kCVPixelFormatType_32BGRA:           // 'BGRA': 32 bit BGRA
+        case kCVPixelFormatType_422YpCbCr8:       // '2vuy': Y'CbCr 4:2:2, ordered Cb Y'0 Cr Y'1
+//        case kCVPixelFormatType_422YpCbCr8_yuvs:  // 'yuvs': Y'CbCr 4:2:2, ordered Y'0 Cb Y'1 Cr
+        case kCVPixelFormatType_420YpCbCr8Planar: // 'y420': planar Y'CbCr 4:2:0
+            return true;
+    }
+    return false;
+}
+
+CVVideoFrame::CVVideoFrame(CVPixelBufferRef buf, double frameTime, uint64_t frameHostTime)
 : 
-  pixelBuffer(0),
+  pixelBuffer(buf),
   frameHostTime(frameHostTime)
 {
-    pixelBuffer = CVPixelBufferRetain(buf);
+    // We can assume that buf is retained at least for the duration of this ctor
+    // So postpone retaining it until we're absolutely sure we'll use it
+
+    // fail fast
+    OSType type = CVPixelBufferGetPixelFormatType(buf);
+    if (!IsFormatSupported(type)) {
+        throw "CVVideoFrame: Invalid PixelFormat";
+    }
+
+    m_dTime = frameTime;
+    m_iWidth = (int)CVPixelBufferGetWidth(pixelBuffer);
+    m_iHeight = (int)CVPixelBufferGetHeight(pixelBuffer);
+
+    size_t extLeft, extRight, extTop, extBottom;
+    CVPixelBufferGetExtendedPixels(pixelBuffer, &extLeft, &extRight, &extTop, &extBottom);
+    m_iEncodedWidth = m_iWidth + (int)extLeft + (int)extRight;
+    m_iEncodedHeight = m_iHeight + (int)extBottom; // ignore top, since 0,0 is where base addr starts
+
+    m_pvPlaneData[0] = m_pvPlaneData[1] = m_pvPlaneData[2] = m_pvPlaneData[3] = NULL;
+    m_piPlaneStrides[0] = m_piPlaneStrides[1] = m_piPlaneStrides[2] = m_piPlaneStrides[3] = 0;
+    m_pulPlaneSize[0] = m_pulPlaneSize[1] = m_pulPlaneSize[2] = m_pulPlaneSize[3] = 0;
+    m_FrameDirty = false;
+
+    if (type != gLastFormat) {
+        gLastFormat = type;
+    }
     
     // determine frame type, throw an exception if it's unsupported
-    if (CVPixelBufferIsPlanar(buf)) {
-        throw "CVVideoFrame: Planar buffers not supported";
-    }
-    
-    OSType type = CVPixelBufferGetPixelFormatType(buf);
     switch (type) {
-        case k32ARGBPixelFormat:
+        case kCVPixelFormatType_32BGRA:            // 'BGRA': 32 bit BGRA
             m_typeFrame = BGRA_PRE;
             break;
-        case '2vuy':
-//        case 'yuvs':
+        case kCVPixelFormatType_422YpCbCr8: // '2vuy':
+//        case kCVPixelFormatType_422YpCbCr8_yuvs: // 'yuvs'
             m_typeFrame = YCbCr_422;
             break;
-        
+        case kCVPixelFormatType_420YpCbCr8Planar:
+            m_typeFrame = YCbCr_420p;
+            break;
         default:
-            throw "CVVideoFrame: Invalid PixelFormat";
+            // ?? should've been caught already
             break;
     }
-    
-    // Set up CVideoFrame data members
-        // FIXME: encoded width/height??
-    m_iWidth = (int)CVPixelBufferGetWidth(pixelBuffer);
-    m_iHeight = (int)CVPixelBufferGetHeight(pixelBuffer);
-    m_bHasAlpha = (m_typeFrame == BGRA_PRE);
-    
-    size_t extLeft, extRight, extTop, extBottom;
-    CVPixelBufferGetExtendedPixels(pixelBuffer, &extLeft, &extRight, &extTop, &extBottom);
-    m_iEncodedWidth = m_iWidth + extLeft + extRight;
-    m_iEncodedHeight = m_iHeight + extBottom; // ignore top, since 0,0 is where base addr starts
-    
-    // Change this if we ever encounter planar CVPixelBuffers
-    m_iPlaneCount = 1;
-    
-    m_piPlaneOffsets[0] = m_piPlaneOffsets[1] = m_piPlaneOffsets[2] = m_piPlaneOffsets[3] = 0;
-    
-    m_piPlaneStrides[0] = CVPixelBufferGetBytesPerRow(pixelBuffer);
-    m_piPlaneStrides[1] = m_piPlaneStrides[2] = m_piPlaneStrides[3] = 0;
-    
-    m_dTime = frameTime;
-    m_ulSize = m_piPlaneStrides[0] * m_iEncodedHeight;
-    
-    // We MUST lock the base address during the lifetime of this object
-    // or else we could cause a crash
-    CVReturn cr = CVPixelBufferLockBaseAddress(pixelBuffer, 0);
-    if (kCVReturnSuccess != cr) {
-        throw "CVVideoFrame: Unable to lock PixelBuffer base address";
+
+    if (CVPixelBufferIsPlanar(pixelBuffer)) {
+        PreparePlanar();
+    } else {
+        PrepareChunky();
     }
-    m_pvData = CVPixelBufferGetBaseAddress(pixelBuffer);
-    
-    m_ulFrameNumber = frameNumber;
-    m_FrameDirty = false;
+
+    // Now retain the pixelBuffer so it doesn't go away
+    CVPixelBufferRetain(pixelBuffer);
 }
 
 CVVideoFrame::~CVVideoFrame()
@@ -92,10 +103,53 @@
     Dispose();
 }
 
+void CVVideoFrame::PrepareChunky()
+{
+    m_iPlaneCount = 1;
+    m_iWidth = (int)CVPixelBufferGetWidth(pixelBuffer);
+    m_iHeight = (int)CVPixelBufferGetHeight(pixelBuffer);
+    m_bHasAlpha = (m_typeFrame == BGRA_PRE);
+
+    // We MUST lock the base address during the lifetime of this object
+    // or else we could cause a crash
+    CVReturn cr = CVPixelBufferLockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
+    if (kCVReturnSuccess != cr) {
+        throw "CVVideoFrame: Unable to lock PixelBuffer base address";
+    }
+    
+    m_pvPlaneData[0] = CVPixelBufferGetBaseAddress(pixelBuffer);
+    m_piPlaneStrides[0] = (int)CVPixelBufferGetBytesPerRow(pixelBuffer);
+    m_pulPlaneSize[0] = m_piPlaneStrides[0] * m_iEncodedHeight;
+}
+
+void CVVideoFrame::PreparePlanar()
+{
+    m_iPlaneCount = (int)CVPixelBufferGetPlaneCount(pixelBuffer);
+    m_bHasAlpha = false;
+
+    // We MUST lock the base address during the lifetime of this object
+    // or else we could cause a crash
+    CVReturn cr = CVPixelBufferLockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
+    if (kCVReturnSuccess != cr) {
+        throw "CVVideoFrame: Unable to lock PixelBuffer base address";
+    }
+
+    for (int index = 0; index < m_iPlaneCount; index++) {
+        m_piPlaneStrides[index] = (int)CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, index);
+        m_pulPlaneSize[index] = CVPixelBufferGetHeightOfPlane(pixelBuffer, index) * m_piPlaneStrides[index];
+        m_pvPlaneData[index] = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, index);
+    }
+
+    if (m_typeFrame == YCbCr_420p) {
+        // Need to swap the Cb/Cr planes (like I420)
+        SwapPlanes(1, 2);
+    }
+}
+
 void CVVideoFrame::Dispose()
 {
     if (pixelBuffer) {
-        CVPixelBufferUnlockBaseAddress(pixelBuffer, 0);
+        CVPixelBufferUnlockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
         CVPixelBufferRelease(pixelBuffer);
         pixelBuffer = 0;
     }
@@ -110,7 +164,7 @@
             if(kCVReturnSuccess == CVPixelBufferLockBaseAddress(destPixelBuffer, 0)) {
                 uint8_t* bgra = (uint8_t*)CVPixelBufferGetBaseAddress(destPixelBuffer);
                 int32_t bgraStride = (int32_t)CVPixelBufferGetBytesPerRow(destPixelBuffer);
-                uint8_t* srcData = (uint8_t*)m_pvData + m_piPlaneOffsets[0];
+                uint8_t* srcData = (uint8_t*)m_pvPlaneData[0];
                 
                 if(0 == ColorConvert_YCbCr422p_to_BGRA32_no_alpha(bgra,
                                                                   bgraStride,
@@ -121,7 +175,7 @@
                                                                   srcData,
                                                                   m_piPlaneStrides[0],
                                                                   m_piPlaneStrides[0])) {
-                    return new CVVideoFrame(destPixelBuffer, m_dTime, frameHostTime, m_ulFrameNumber);
+                    return new CVVideoFrame(destPixelBuffer, m_dTime, frameHostTime);
                 }
             }
         }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,2395 @@
+/*
+     File: AUBase.cpp
+ Abstract: AUBase.h
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#include "AUBase.h"
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+    #include "AUDispatch.h"
+#endif
+#include "AUInputElement.h"
+#include "AUOutputElement.h"
+#include <algorithm>
+#include <syslog.h>
+#include "CAAudioChannelLayout.h"
+#include "CAHostTimeBase.h"
+#include "CAVectorUnit.h"
+#include "CAXException.h"
+
+
+
+#if TARGET_OS_MAC && (TARGET_CPU_X86 || TARGET_CPU_X86_64)
+	// our compiler does ALL floating point with SSE
+	inline int  GETCSR ()    { int _result; asm volatile ("stmxcsr %0" : "=m" (*&_result) ); return _result; }
+	inline void SETCSR (int a)    { int _temp = a; asm volatile( "ldmxcsr %0" : : "m" (*&_temp ) ); }
+
+	#define DISABLE_DENORMALS int _savemxcsr = GETCSR(); SETCSR(_savemxcsr | 0x8040);
+	#define RESTORE_DENORMALS SETCSR(_savemxcsr);
+#else
+	#define DISABLE_DENORMALS
+	#define RESTORE_DENORMALS
+#endif
+
+static bool sAUBaseCFStringsInitialized = false;
+// this is used for the presets
+static CFStringRef kUntitledString = NULL;
+//these are the current keys for the class info document
+static CFStringRef kVersionString = NULL;
+static CFStringRef kTypeString = NULL;
+static CFStringRef kSubtypeString = NULL;
+static CFStringRef kManufacturerString = NULL;
+static CFStringRef kDataString = NULL;
+static CFStringRef kNameString = NULL;
+static CFStringRef kRenderQualityString = NULL;
+static CFStringRef kCPULoadString = NULL;
+static CFStringRef kElementNameString = NULL;
+static CFStringRef kPartString = NULL;
+
+SInt32 AUBase::sVectorUnitType = kVecUninitialized;
+
+//_____________________________________________________________________________
+//
+AUBase::AUBase(	AudioComponentInstance			inInstance, 
+				UInt32							numInputElements,
+				UInt32							numOutputElements,
+				UInt32							numGroupElements) :
+	ComponentBase(inInstance),
+	mElementsCreated(false),
+	mInitialized(false),
+	mHasBegunInitializing(false),
+	mInitNumInputEls(numInputElements), mInitNumOutputEls(numOutputElements), 
+#if !CA_BASIC_AU_FEATURES
+	mInitNumGroupEls(numGroupElements),
+#endif
+	mRenderCallbacksTouched(false),
+	mRenderThreadID (NULL),
+	mWantsRenderThreadID (false),
+	mLastRenderError(0),
+	mUsesFixedBlockSize(false),
+	mBuffersAllocated(false),
+	mLogString (NULL),
+    mNickName (NULL),
+	mAUMutex(NULL)
+	#if !CA_NO_AU_UI_FEATURES
+		,
+		mContextName(NULL)
+	#endif
+{
+	ResetRenderTime ();
+	
+	if(!sAUBaseCFStringsInitialized)
+	{
+		kUntitledString = CFSTR("Untitled");
+		kVersionString = CFSTR(kAUPresetVersionKey);
+		kTypeString = CFSTR(kAUPresetTypeKey);
+		kSubtypeString = CFSTR(kAUPresetSubtypeKey);
+		kManufacturerString = CFSTR(kAUPresetManufacturerKey);
+		kDataString = CFSTR(kAUPresetDataKey);
+		kNameString = CFSTR(kAUPresetNameKey);
+		kRenderQualityString = CFSTR(kAUPresetRenderQualityKey);
+		kCPULoadString = CFSTR(kAUPresetCPULoadKey);
+		kElementNameString = CFSTR(kAUPresetElementNameKey);
+		kPartString = CFSTR(kAUPresetPartKey);
+		sAUBaseCFStringsInitialized = true;
+	}
+
+	if (sVectorUnitType == kVecUninitialized) {
+		sVectorUnitType = CAVectorUnit::GetVectorUnitType() ;
+	}
+
+	mAudioUnitAPIVersion = 2;
+	
+	SetMaxFramesPerSlice(kAUDefaultMaxFramesPerSlice);
+
+	GlobalScope().Initialize(this, kAudioUnitScope_Global, 1);
+	
+#if !CA_NO_AU_UI_FEATURES
+	memset (&mHostCallbackInfo, 0, sizeof (mHostCallbackInfo));
+#endif
+
+
+	mCurrentPreset.presetNumber = -1;
+	mCurrentPreset.presetName = kUntitledString;
+	CFRetain (mCurrentPreset.presetName);
+}
+
+//_____________________________________________________________________________
+//
+AUBase::~AUBase()
+{
+	if (mCurrentPreset.presetName) CFRelease (mCurrentPreset.presetName);
+#if !CA_NO_AU_UI_FEATURES
+	if (mContextName) CFRelease (mContextName);
+#endif
+	if (mLogString) delete [] mLogString;
+    if (mNickName) CFRelease(mNickName);
+}
+
+//_____________________________________________________________________________
+//
+void	AUBase::CreateElements()
+{
+	if (!mElementsCreated) {
+		Inputs().Initialize(this, kAudioUnitScope_Input, mInitNumInputEls);
+		Outputs().Initialize(this, kAudioUnitScope_Output, mInitNumOutputEls);
+#if !CA_BASIC_AU_FEATURES
+		Groups().Initialize(this, kAudioUnitScope_Group, mInitNumGroupEls);
+#endif
+		CreateExtendedElements();
+		
+		mElementsCreated = true;
+	}
+}
+
+//_____________________________________________________________________________
+//
+void	AUBase::SetMaxFramesPerSlice(UInt32 nFrames)
+{
+	mMaxFramesPerSlice = nFrames;
+	if (mBuffersAllocated)
+		ReallocateBuffers();
+	PropertyChanged(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::CanSetMaxFrames() const
+{
+	return IsInitialized() ? kAudioUnitErr_Initialized : OSStatus(noErr);
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::ReallocateBuffers()
+{
+	CreateElements();
+	
+	UInt32 nOutputs = Outputs().GetNumberOfElements();
+	for (UInt32 i = 0; i < nOutputs; ++i) {
+		AUOutputElement *output = GetOutput(i);
+		output->AllocateBuffer();	// does no work if already allocated
+	}
+	UInt32 nInputs = Inputs().GetNumberOfElements();
+	for (UInt32 i = 0; i < nInputs; ++i) {
+		AUInputElement *input = GetInput(i);
+		input->AllocateBuffer();	// does no work if already allocated
+	}
+	mBuffersAllocated = true;
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::DeallocateIOBuffers()
+{
+	if (!mBuffersAllocated)
+		return;
+
+	UInt32 nOutputs = Outputs().GetNumberOfElements();
+	for (UInt32 i = 0; i < nOutputs; ++i) {
+		AUOutputElement *output = GetOutput(i);
+		output->DeallocateBuffer();
+	}
+	UInt32 nInputs = Inputs().GetNumberOfElements();
+	for (UInt32 i = 0; i < nInputs; ++i) {
+		AUInputElement *input = GetInput(i);
+		input->DeallocateBuffer();
+	}
+	mBuffersAllocated = false;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::DoInitialize()
+{
+	OSStatus result = noErr;
+	
+	if (!mInitialized) {
+		result = Initialize();
+		if (result == noErr) {
+			if (CanScheduleParameters())
+				mParamList.reserve(24);
+			mHasBegunInitializing = true;
+			ReallocateBuffers();	// calls CreateElements()
+			mInitialized = true;	// signal that it's okay to render
+			CAMemoryBarrier();
+		}
+	}
+
+	return result;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::Initialize()
+{
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::PreDestructor()
+{
+	// this is called from the ComponentBase dispatcher, which doesn't know anything about our (optional) lock
+	CAMutex::Locker lock(mAUMutex);
+	DoCleanup();
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::DoCleanup()
+{
+	if (mInitialized)
+		Cleanup();
+	
+	DeallocateIOBuffers();
+	ResetRenderTime ();
+
+	mInitialized = false;
+	mHasBegunInitializing = false;
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::Cleanup()
+{
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::Reset(					AudioUnitScope 					inScope,
+													AudioUnitElement 				inElement)
+{
+	ResetRenderTime ();
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::DispatchGetPropertyInfo(AudioUnitPropertyID				inID,
+													AudioUnitScope					inScope,
+													AudioUnitElement				inElement,
+													UInt32 &						outDataSize,
+													Boolean &						outWritable)
+{
+	OSStatus result = noErr;
+	bool validateElement = true;
+	
+	switch (inID) {
+	case kAudioUnitProperty_MakeConnection:
+		ca_require(inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(AudioUnitConnection);
+		outWritable = true;
+		break;
+		
+		
+	case kAudioUnitProperty_SetRenderCallback:
+		ca_require(AudioUnitAPIVersion() > 1, InvalidProperty);
+		ca_require(inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(AURenderCallbackStruct);
+		outWritable = true;
+		break;
+		
+	case kAudioUnitProperty_StreamFormat:
+		outDataSize = sizeof(CAStreamBasicDescription);
+		outWritable = IsStreamFormatWritable(inScope, inElement);
+		break;
+
+	case kAudioUnitProperty_SampleRate:
+		outDataSize = sizeof(Float64);
+		outWritable = IsStreamFormatWritable(inScope, inElement);
+		break;
+
+	case kAudioUnitProperty_ClassInfo:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(CFPropertyListRef);
+		outWritable = true;
+		break;
+
+	case kAudioUnitProperty_FactoryPresets:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		result = GetPresets(NULL);
+		if (!result) {
+			outDataSize = sizeof(CFArrayRef);
+			outWritable = false;
+		}
+		break;
+		
+	case kAudioUnitProperty_PresentPreset:
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+	case kAudioUnitProperty_CurrentPreset:
+#endif
+#endif
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(AUPreset);
+		outWritable = true;
+		break;
+	
+	case kAudioUnitProperty_ElementName:
+		outDataSize = sizeof (CFStringRef);
+		outWritable = true;
+		break;
+	
+	case kAudioUnitProperty_ParameterList:
+		{
+			UInt32 nparams = 0;
+			result = GetParameterList(inScope, NULL, nparams);
+			
+			outDataSize = sizeof(AudioUnitParameterID) * nparams;
+			outWritable = false;
+			validateElement = false;
+		}
+		break;
+		
+	case kAudioUnitProperty_ParameterInfo:
+		outDataSize = sizeof(AudioUnitParameterInfo);
+		outWritable = false;
+		validateElement = false;
+		break;
+
+	case kAudioUnitProperty_ParameterHistoryInfo:
+		outDataSize = sizeof(AudioUnitParameterHistoryInfo);
+		outWritable = false;
+		validateElement = false;
+		break;
+
+	case kAudioUnitProperty_ElementCount:
+		outDataSize = sizeof(UInt32);
+		outWritable = BusCountWritable(inScope);
+		validateElement = false;
+		break;
+	
+	case kAudioUnitProperty_Latency:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(Float64);
+		outWritable = false;
+		break;
+	
+	case kAudioUnitProperty_TailTime:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		if (SupportsTail()) {
+			outDataSize = sizeof(Float64);
+			outWritable = false;
+		} else
+			goto InvalidProperty;
+		break;
+	
+	case kAudioUnitProperty_MaximumFramesPerSlice:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(UInt32);
+		outWritable = true;
+		break;
+	
+	case kAudioUnitProperty_LastRenderError:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(OSStatus);
+		outWritable = false;
+		break;
+		
+	case kAudioUnitProperty_SupportedNumChannels:
+	{
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		UInt32 num = SupportedNumChannels (NULL);
+		if (num) {
+			outDataSize = sizeof (AUChannelInfo) * num;
+			result = noErr;
+		} else
+			goto InvalidProperty;
+		outWritable = false;
+		break;
+	}
+	
+	case kAudioUnitProperty_SupportedChannelLayoutTags:
+	{
+		UInt32 numLayouts = GetChannelLayoutTags(inScope, inElement, NULL);
+		if (numLayouts) {
+			outDataSize = numLayouts * sizeof(AudioChannelLayoutTag);
+			result = noErr;
+		} else
+			goto InvalidProperty;
+		outWritable = false;
+		validateElement = false; //already done it
+		break;
+	}
+	
+	case kAudioUnitProperty_AudioChannelLayout:
+	{
+		outWritable = false;
+		outDataSize = GetAudioChannelLayout(inScope, inElement, NULL, outWritable);
+		if (outDataSize) {
+			result = noErr;
+		} else {
+			if (GetChannelLayoutTags(inScope, inElement, NULL) == 0)
+				goto InvalidProperty;
+			else
+				result = kAudioUnitErr_InvalidPropertyValue;
+		}
+		validateElement = false; //already done it
+		break;
+	}
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
+	case kAudioUnitProperty_ShouldAllocateBuffer:
+		ca_require((inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Output), InvalidScope);
+		outWritable = true;
+		outDataSize = sizeof(UInt32);
+		break;
+#endif
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+	case kAudioUnitProperty_FastDispatch:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		if (!IsCMgrObject()) goto InvalidProperty;
+		outDataSize = sizeof(void *);
+		outWritable = false;
+		validateElement = false;
+		break;
+
+	case kAudioUnitProperty_GetUIComponentList:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = GetNumCustomUIComponents();
+		if (outDataSize == 0)
+			goto InvalidProperty;
+		outDataSize *= sizeof (AudioComponentDescription);
+		
+		outWritable = false;
+		break;
+#endif
+	
+	case kAudioUnitProperty_ParameterValueStrings:
+		result = GetParameterValueStrings(inScope, inElement, NULL);
+		if (result == noErr) {
+			outDataSize = sizeof(CFArrayRef);
+			outWritable = false;
+			validateElement = false;
+		}
+		break;
+
+#if !CA_NO_AU_HOST_CALLBACKS
+	case kAudioUnitProperty_HostCallbacks:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(mHostCallbackInfo);
+		outWritable = true;
+		break;
+#endif
+#if !CA_NO_AU_UI_FEATURES
+	case kAudioUnitProperty_ContextName:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outDataSize = sizeof(CFStringRef);
+		outWritable = true;
+		break;
+	
+	case kAudioUnitProperty_IconLocation:
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		outWritable = false;
+		if (!HasIcon())
+			goto InvalidProperty;
+		outDataSize = sizeof(CFURLRef);
+		break;
+
+	case kAudioUnitProperty_ParameterClumpName:
+		outDataSize = sizeof(AudioUnitParameterNameInfo );
+		outWritable = false;
+		break;
+
+#endif // !CA_NO_AU_UI_FEATURES
+
+	case 'lrst' :  // kAudioUnitProperty_LastRenderedSampleTime
+		outDataSize = sizeof(Float64);
+		outWritable = false;
+		break;
+	
+    case 54:// kAudioUnitProperty_NickName -> is not defined in Xcode 4.5
+        ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+        outDataSize = sizeof(CFStringRef);
+        outWritable = true;
+        break;
+
+	default:
+		result = GetPropertyInfo(inID, inScope, inElement, outDataSize, outWritable);
+		validateElement = false;
+		break;
+	}
+
+	if (result == noErr && validateElement) {
+		ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);	
+	}
+	
+	return result;
+InvalidProperty:
+	return kAudioUnitErr_InvalidProperty;
+InvalidScope:
+	return kAudioUnitErr_InvalidScope;
+InvalidElement:
+	return kAudioUnitErr_InvalidElement;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::DispatchGetProperty(	AudioUnitPropertyID 			inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement			 	inElement,
+													void *							outData)
+{
+	// NOTE: We're currently only called from AUBase::ComponentEntryDispatch, which
+	// calls DispatchGetPropertyInfo first, which performs validation of the scope/element,
+	// and ensures that the outData buffer is non-null and large enough.
+	OSStatus result = noErr;
+
+	switch (inID) {
+	case kAudioUnitProperty_StreamFormat:
+		*(CAStreamBasicDescription *)outData = GetStreamFormat(inScope, inElement);
+		break;
+	
+	case kAudioUnitProperty_SampleRate:
+		*(Float64 *)outData = GetStreamFormat(inScope, inElement).mSampleRate;
+		break;
+	
+	case kAudioUnitProperty_ParameterList:
+		{
+			UInt32 nparams = 0;
+			result = GetParameterList(inScope, (AudioUnitParameterID *)outData, nparams);
+		}
+		break;
+
+	case kAudioUnitProperty_ParameterInfo:
+		result = GetParameterInfo(inScope, inElement, *(AudioUnitParameterInfo *)outData);
+		break;
+
+	case kAudioUnitProperty_ParameterHistoryInfo:
+		{
+			AudioUnitParameterHistoryInfo* info = (AudioUnitParameterHistoryInfo*)outData;
+			result = GetParameterHistoryInfo(inScope, inElement, info->updatesPerSecond, info->historyDurationInSeconds);
+		}
+		break;
+
+	case kAudioUnitProperty_ClassInfo:
+		{
+			*(CFPropertyListRef *)outData = NULL;
+			result = SaveState((CFPropertyListRef *)outData);
+		}
+		break;
+
+	case kAudioUnitProperty_FactoryPresets:
+		{
+			*(CFArrayRef *)outData = NULL;
+			result = GetPresets ((CFArrayRef *)outData);
+		}
+		break;
+	
+	case kAudioUnitProperty_PresentPreset:
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+	case kAudioUnitProperty_CurrentPreset:
+#endif
+#endif
+		{
+			*(AUPreset *)outData = mCurrentPreset;
+				
+				// retain current string (as client owns a reference to it and will release it)
+			if (inID == kAudioUnitProperty_PresentPreset && mCurrentPreset.presetName) 
+				CFRetain (mCurrentPreset.presetName);
+
+			result = noErr;
+		}
+		break;
+	
+	case kAudioUnitProperty_ElementName:
+		{
+			AUElement * element = GetElement(inScope, inElement);
+			if (element->HasName()) {
+				*(CFStringRef *)outData = element->GetName();
+				CFRetain (element->GetName());
+				result = noErr;
+			} else
+				result = kAudioUnitErr_InvalidPropertyValue;
+		}
+		break;
+
+	case kAudioUnitProperty_ElementCount:
+		*(UInt32 *)outData = GetScope(inScope).GetNumberOfElements();
+		break;
+	
+	case kAudioUnitProperty_Latency:
+		*(Float64 *)outData = GetLatency();
+		break;
+
+	case kAudioUnitProperty_TailTime:
+		if (SupportsTail())
+			*(Float64 *)outData = GetTailTime();
+		else
+			result = kAudioUnitErr_InvalidProperty;
+		break;
+	
+	case kAudioUnitProperty_MaximumFramesPerSlice:
+		*(UInt32 *)outData = mMaxFramesPerSlice;
+		break;
+
+	case kAudioUnitProperty_LastRenderError:
+		*(OSStatus *)outData = mLastRenderError;
+		mLastRenderError = 0;
+		break;
+
+	case kAudioUnitProperty_SupportedNumChannels:
+		{
+			const AUChannelInfo* infoPtr = NULL;
+			UInt32 num = SupportedNumChannels (&infoPtr);
+			if(num != 0 && infoPtr != NULL)
+				memcpy (outData, infoPtr, num * sizeof (AUChannelInfo));
+		}
+		break;
+
+	case kAudioUnitProperty_SupportedChannelLayoutTags:
+		{
+			AudioChannelLayoutTag* ptr = outData ? static_cast<AudioChannelLayoutTag*>(outData) : NULL;
+			UInt32 numLayouts = GetChannelLayoutTags (inScope, inElement, ptr);
+			if (numLayouts == 0)
+				result = kAudioUnitErr_InvalidProperty;
+		}
+		break;
+		
+	case kAudioUnitProperty_AudioChannelLayout:
+	{	
+		AudioChannelLayout* ptr = outData ? static_cast<AudioChannelLayout*>(outData) : NULL;
+		Boolean writable;
+		UInt32 dataSize = GetAudioChannelLayout(inScope, inElement, ptr, writable);
+		if (!dataSize) {
+			result = kAudioUnitErr_InvalidProperty;
+		}
+		break;
+	}
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
+	case kAudioUnitProperty_ShouldAllocateBuffer:
+	{
+		AUIOElement * element = GetIOElement(inScope, inElement);
+		*(UInt32*)outData = element->WillAllocateBuffer();
+		break;
+	}
+#endif
+
+ 	case kAudioUnitProperty_ParameterValueStrings:
+		result = GetParameterValueStrings(inScope, inElement, (CFArrayRef *)outData);
+		break;
+		
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+	case kAudioUnitProperty_FastDispatch:
+		if (!IsCMgrObject()) result = kAudioUnitErr_InvalidProperty;
+		else {
+			switch (inElement) {
+			case kAudioUnitGetParameterSelect:
+				*(AudioUnitGetParameterProc *)outData = (AudioUnitGetParameterProc)CMgr_AudioUnitBaseGetParameter;
+				break;
+			case kAudioUnitSetParameterSelect:
+				*(AudioUnitSetParameterProc *)outData = (AudioUnitSetParameterProc)CMgr_AudioUnitBaseSetParameter;
+				break;
+			case kAudioUnitRenderSelect:
+				if (AudioUnitAPIVersion() > 1)
+					*(AudioUnitRenderProc *)outData = (AudioUnitRenderProc)CMgr_AudioUnitBaseRender;
+				else result = kAudioUnitErr_InvalidElement;
+				break;
+			default:
+				result = GetProperty(inID, inScope, inElement, outData);
+				break;
+			}
+		}
+		break;
+
+	case kAudioUnitProperty_GetUIComponentList:
+		GetUIComponentDescs ((ComponentDescription*)outData);
+		break;
+#endif
+
+#if !CA_NO_AU_HOST_CALLBACKS
+	case kAudioUnitProperty_HostCallbacks:
+		memcpy(outData, &mHostCallbackInfo, sizeof(mHostCallbackInfo));
+		break;
+#endif
+#if !CA_NO_AU_UI_FEATURES
+	case kAudioUnitProperty_IconLocation:
+		{
+			CFURLRef iconLocation = CopyIconLocation();
+			if (iconLocation) {
+				*(CFURLRef*)outData = iconLocation;
+			} else
+				result = kAudioUnitErr_InvalidProperty;
+		}
+		break;
+
+	case kAudioUnitProperty_ContextName:
+		*(CFStringRef *)outData = mContextName;
+		if (mContextName) {
+			CFRetain(mContextName);
+			// retain CFString (if exists) since client will be responsible for its release
+			result = noErr;
+		} else {
+			result = kAudioUnitErr_InvalidPropertyValue;
+		}
+		break;
+		
+	case kAudioUnitProperty_ParameterClumpName:
+		{
+			AudioUnitParameterNameInfo * ioClumpInfo = (AudioUnitParameterNameInfo*) outData;
+			if (ioClumpInfo->inID == kAudioUnitClumpID_System)	// this ID value is reserved
+				result = kAudioUnitErr_InvalidPropertyValue;
+			else 
+			{
+				result = CopyClumpName(inScope, ioClumpInfo->inID, ioClumpInfo->inDesiredLength, &ioClumpInfo->outName);
+					
+					// this is provided for compatbility with existing implementations that don't know
+					// about this new mechanism
+				if (result == kAudioUnitErr_InvalidProperty)
+					result = GetProperty (inID, inScope, inElement, outData);
+			}	
+		}
+		break;
+
+#endif  // !CA_NO_AU_UI_FEATURES
+
+	case 'lrst' : // kAudioUnitProperty_LastRenderedSampleTime
+		*(Float64*)outData = mCurrentRenderTime.mSampleTime;
+		break;
+
+    case 54:// kAudioUnitProperty_NickName -> is not defined in Xcode 4.5
+        // Ownership follows Core Foundation's 'Copy Rule'
+        if (mNickName) CFRetain(mNickName);
+        *(CFStringRef*)outData = mNickName;
+        break;
+            
+	default:
+		result = GetProperty(inID, inScope, inElement, outData);
+		break;
+	}
+	return result;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::DispatchSetProperty(	AudioUnitPropertyID 			inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement 				inElement,
+													const void *					inData,
+													UInt32 							inDataSize)
+{
+	OSStatus result = noErr;
+
+	switch (inID) {
+	case kAudioUnitProperty_MakeConnection:
+		ca_require(inDataSize >= sizeof(AudioUnitConnection), InvalidPropertyValue);
+		{
+			AudioUnitConnection &connection = *(AudioUnitConnection *)inData;
+			result = SetConnection(connection);
+		}
+		break;
+
+		
+	case kAudioUnitProperty_SetRenderCallback:
+		{
+			ca_require(inDataSize >= sizeof(AURenderCallbackStruct), InvalidPropertyValue);
+			ca_require(AudioUnitAPIVersion() > 1, InvalidProperty);
+			AURenderCallbackStruct &callback = *(AURenderCallbackStruct*)inData;
+			result = SetInputCallback(kAudioUnitProperty_SetRenderCallback, inElement, callback.inputProc, callback.inputProcRefCon);
+		}
+		break;
+
+	case kAudioUnitProperty_ElementCount:
+		ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
+		ca_require(BusCountWritable(inScope), NotWritable);
+		result = SetBusCount(inScope, *(UInt32*)inData);
+		if (result == noErr) {
+			PropertyChanged(inID, inScope, inElement);
+		}
+		break;
+	
+	case kAudioUnitProperty_MaximumFramesPerSlice:
+		ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
+		result = CanSetMaxFrames();
+		if (result) return result;
+		SetMaxFramesPerSlice(*(UInt32 *)inData);
+		break;
+
+	case kAudioUnitProperty_StreamFormat:
+		{
+			if (inDataSize < 36) goto InvalidPropertyValue;
+			ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+
+			CAStreamBasicDescription newDesc;
+				// now we're going to be ultra conservative! because of discrepancies between
+				// sizes of this struct based on aligment padding inconsistencies
+			memset (&newDesc, 0, sizeof(newDesc));
+			memcpy (&newDesc, inData, 36);
+
+			ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
+
+			const CAStreamBasicDescription curDesc = GetStreamFormat(inScope, inElement);
+			
+			if ( !curDesc.IsEqual(newDesc, false) ) {
+				ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
+				result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
+			}
+		}
+		break;
+	
+	case kAudioUnitProperty_SampleRate:
+		{
+			ca_require(inDataSize == sizeof(Float64), InvalidPropertyValue);
+			ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+
+			const CAStreamBasicDescription curDesc = GetStreamFormat(inScope, inElement);
+			CAStreamBasicDescription newDesc = curDesc;
+			newDesc.mSampleRate = *(Float64 *)inData;
+			
+			ca_require(ValidFormat(inScope, inElement, newDesc), InvalidFormat);
+			
+			if ( !curDesc.IsEqual(newDesc, false) ) {
+				ca_require(IsStreamFormatWritable(inScope, inElement), NotWritable);
+				result = ChangeStreamFormat(inScope, inElement, curDesc, newDesc);
+			}
+		}
+		break;
+
+	case kAudioUnitProperty_AudioChannelLayout:
+		{
+			const AudioChannelLayout *layout = static_cast<const AudioChannelLayout *>(inData);
+			size_t headerSize = sizeof(AudioChannelLayout) - sizeof(AudioChannelDescription);
+			
+			ca_require(inDataSize >= headerSize + layout->mNumberChannelDescriptions * sizeof(AudioChannelDescription), InvalidPropertyValue);
+			result = SetAudioChannelLayout(inScope, inElement, layout);
+			if (result == noErr)
+				PropertyChanged(inID, inScope, inElement);
+			break;
+		}
+	
+	case kAudioUnitProperty_ClassInfo:
+		ca_require(inDataSize == sizeof(CFPropertyListRef *), InvalidPropertyValue);
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		result = RestoreState(*(CFPropertyListRef *)inData);
+		break;
+
+	case kAudioUnitProperty_PresentPreset:
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+	case kAudioUnitProperty_CurrentPreset:
+#endif
+#endif
+		{
+			ca_require(inDataSize == sizeof(AUPreset), InvalidPropertyValue);
+			ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+			AUPreset & newPreset = *(AUPreset *)inData;
+			
+			if (newPreset.presetNumber >= 0)
+			{
+				result = NewFactoryPresetSet(newPreset);
+				// NewFactoryPresetSet SHOULD call SetAFactoryPreset if the preset is valid
+				// from its own list of preset number->name
+				if (!result)
+					PropertyChanged(inID, inScope, inElement);
+			}
+			else if (newPreset.presetName)
+			{
+				result = NewCustomPresetSet(newPreset);
+                if (!result)
+                    PropertyChanged(inID, inScope, inElement);
+			}
+			else
+				result = kAudioUnitErr_InvalidPropertyValue;
+		}
+		break;
+	
+	case kAudioUnitProperty_ElementName:
+		{
+			ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+			ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
+			AUElement * element = GetScope(inScope).GetElement (inElement);
+			element->SetName (*(CFStringRef *)inData);
+			PropertyChanged(inID, inScope, inElement);
+		}
+		break;
+
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || TARGET_OS_IPHONE
+	case kAudioUnitProperty_ShouldAllocateBuffer:
+		{
+			ca_require((inScope == kAudioUnitScope_Input || inScope == kAudioUnitScope_Output), InvalidScope);
+			ca_require(GetElement(inScope, inElement) != NULL, InvalidElement);
+			ca_require(inDataSize == sizeof(UInt32), InvalidPropertyValue);
+			ca_require(!IsInitialized(), Initialized);
+
+			AUIOElement * element = GetIOElement(inScope, inElement);
+			element->SetWillAllocateBuffer(*(UInt32 *)inData != 0);
+		}
+		break;
+#endif
+
+#if !CA_NO_AU_HOST_CALLBACKS
+	case kAudioUnitProperty_HostCallbacks:
+	{
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		UInt32 availSize = std::min(inDataSize, (UInt32)sizeof(HostCallbackInfo));
+		bool hasChanged = !memcmp (&mHostCallbackInfo, inData, availSize);
+		memset (&mHostCallbackInfo, 0, sizeof (mHostCallbackInfo));
+		memcpy (&mHostCallbackInfo, inData, availSize);
+		if (hasChanged)
+			PropertyChanged(inID, inScope, inElement);
+		break;
+	}
+#endif
+#if !CA_NO_AU_UI_FEATURES
+	case kAudioUnitProperty_SetExternalBuffer:
+		ca_require(inDataSize >= sizeof(AudioUnitExternalBuffer), InvalidPropertyValue);
+		ca_require(IsInitialized(), Uninitialized);
+		{
+			AudioUnitExternalBuffer &buf = *(AudioUnitExternalBuffer*)inData;
+			if (intptr_t(buf.buffer) & 0x0F) result = kAudio_ParamError;
+			else if (inScope == kAudioUnitScope_Input) {
+				AUInputElement *input = GetInput(inElement);
+				input->UseExternalBuffer(buf);
+			} else {
+				AUOutputElement *output = GetOutput(inElement);
+				output->UseExternalBuffer(buf);
+			}
+		}
+		break;
+
+	case kAudioUnitProperty_ContextName:
+		{
+			ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
+			ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+			CFStringRef inStr = *(CFStringRef *)inData;
+			if (mContextName) CFRelease(mContextName);
+			if (inStr) CFRetain(inStr);
+			mContextName = inStr;
+			PropertyChanged(inID, inScope, inElement);
+		}
+		break;
+
+#endif // !CA_NO_AU_UI_FEATURES
+	
+    case 54:// kAudioUnitProperty_NickName -> is not defined in Xcode 4.5
+    {
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+        ca_require(inDataSize == sizeof(CFStringRef), InvalidPropertyValue);
+        CFStringRef inStr = *(CFStringRef *)inData;
+        if (mNickName) CFRelease(mNickName);
+        if (inStr) CFRetain(inStr);
+        mNickName = inStr;
+        PropertyChanged(inID, inScope, inElement);
+        break;
+    }
+            
+	default:
+		result = SetProperty(inID, inScope, inElement, inData, inDataSize);
+		if (result == noErr)
+			PropertyChanged(inID, inScope, inElement);
+		
+		break;
+	}
+	return result;
+NotWritable:
+	return kAudioUnitErr_PropertyNotWritable;
+InvalidFormat:
+	return kAudioUnitErr_FormatNotSupported;
+#if !CA_NO_AU_UI_FEATURES
+Uninitialized:
+	return kAudioUnitErr_Uninitialized;
+#endif
+#if (MAC_OS_X_VERSION_MIN_REQUIRED > MAC_OS_X_VERSION_10_5) || CA_USE_AUDIO_PLUGIN_ONLY
+Initialized:
+	return kAudioUnitErr_Initialized;
+#endif
+InvalidScope:
+	return kAudioUnitErr_InvalidScope;
+InvalidProperty:
+	return kAudioUnitErr_InvalidProperty;
+InvalidPropertyValue:
+	return kAudioUnitErr_InvalidPropertyValue;
+InvalidElement:
+	return kAudioUnitErr_InvalidElement;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::DispatchRemovePropertyValue (AudioUnitPropertyID		inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement 				inElement)
+{
+	OSStatus result = noErr;
+	switch (inID)
+	{
+	case kAudioUnitProperty_AudioChannelLayout:
+	{
+		result = RemoveAudioChannelLayout(inScope, inElement);
+		if (result == noErr)
+			PropertyChanged(inID, inScope, inElement);
+		break;
+	}
+	
+#if !CA_NO_AU_HOST_CALLBACKS
+	case kAudioUnitProperty_HostCallbacks:
+	{
+		ca_require(inScope == kAudioUnitScope_Global, InvalidScope);
+		bool hasValue = false;
+		void* ptr = &mHostCallbackInfo;
+		for (unsigned int i = 0; i <  sizeof (HostCallbackInfo); ++i) {
+			if (static_cast<char*>(ptr)[i]) {
+				hasValue = true;
+				break;
+			}
+		}
+		if (hasValue) {
+			memset (&mHostCallbackInfo, 0, sizeof (HostCallbackInfo));
+			PropertyChanged(inID, inScope, inElement);
+		}
+		break;
+	}
+#endif
+#if !CA_NO_AU_UI_FEATURES
+	case kAudioUnitProperty_ContextName:
+		if (mContextName) CFRelease(mContextName);
+		mContextName = NULL;
+		result = noErr;
+		break;
+	
+#endif // !CA_NO_AU_UI_FEATURES
+
+    case 54:// kAudioUnitProperty_NickName -> is not defined in Xcode 4.5
+    {
+        if(inScope == kAudioUnitScope_Global) {
+            if (mNickName) CFRelease(mNickName);
+            mNickName = NULL;
+            PropertyChanged(inID, inScope, inElement);
+        } else {
+            result = kAudioUnitErr_InvalidScope;
+        }
+        break;
+    }
+
+	default:
+		result = RemovePropertyValue (inID, inScope, inElement);		
+		break;
+	}
+		
+	return result;
+#if !CA_NO_AU_UI_FEATURES || !CA_NO_AU_HOST_CALLBACKS
+InvalidScope:
+	return kAudioUnitErr_InvalidScope;
+#endif
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::GetPropertyInfo(		AudioUnitPropertyID				inID,
+													AudioUnitScope					inScope,
+													AudioUnitElement				inElement,
+													UInt32 &						outDataSize,
+													Boolean &						outWritable)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::GetProperty(			AudioUnitPropertyID 			inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement			 	inElement,
+													void *							outData)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::SetProperty(			AudioUnitPropertyID 			inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement 				inElement,
+													const void *					inData,
+													UInt32 							inDataSize)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::RemovePropertyValue (	AudioUnitPropertyID		 		inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement 				inElement)
+{
+	return kAudioUnitErr_InvalidPropertyValue;
+}
+												
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::AddPropertyListener(	AudioUnitPropertyID				inID,
+													AudioUnitPropertyListenerProc	inProc,
+													void *							inProcRefCon)
+{
+	PropertyListener pl;
+	
+	pl.propertyID = inID;
+	pl.listenerProc = inProc;
+	pl.listenerRefCon = inProcRefCon;
+	
+	if (mPropertyListeners.empty())
+		mPropertyListeners.reserve(32);
+	mPropertyListeners.push_back(pl);
+
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::RemovePropertyListener(		AudioUnitPropertyID				inID,
+														AudioUnitPropertyListenerProc	inProc,
+														void *							inProcRefCon,
+														bool							refConSpecified)
+{
+	// iterate in reverse so that it's safe to erase in the middle of the vector
+	for (int i = (int)mPropertyListeners.size(); --i >=0; ) {
+		PropertyListeners::iterator it = mPropertyListeners.begin() + i;
+		if ((*it).propertyID == inID && (*it).listenerProc == inProc && (!refConSpecified || (*it).listenerRefCon == inProcRefCon))
+			mPropertyListeners.erase(it);
+	}
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::PropertyChanged(			AudioUnitPropertyID				inID,
+														AudioUnitScope					inScope, 
+														AudioUnitElement				inElement)
+{
+	for (PropertyListeners::iterator it = mPropertyListeners.begin(); it != mPropertyListeners.end(); ++it)
+		if ((*it).propertyID == inID)
+			((*it).listenerProc)((*it).listenerRefCon, mComponentInstance, inID, inScope, inElement);
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::SetRenderNotification(	AURenderCallback		 		inProc,
+													void *							inRefCon)
+{
+	if (inProc == NULL)
+		return kAudio_ParamError;
+
+	mRenderCallbacksTouched = true;
+	mRenderCallbacks.deferred_add(RenderCallback(inProc, inRefCon));
+			// this will do nothing if it's already in the list
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::RemoveRenderNotification(	AURenderCallback			inProc,
+														void *						inRefCon)
+{
+	mRenderCallbacks.deferred_remove(RenderCallback(inProc, inRefCon));
+	return noErr;	// error?
+}
+
+//_____________________________________________________________________________
+//
+OSStatus 	AUBase::GetParameter(			AudioUnitParameterID			inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement 				inElement,
+													AudioUnitParameterValue &		outValue)
+{
+	AUElement *elem = SafeGetElement(inScope, inElement);
+	outValue = elem->GetParameter(inID);
+	return noErr;
+}
+
+											
+//_____________________________________________________________________________
+//
+OSStatus 	AUBase::SetParameter(			AudioUnitParameterID			inID,
+													AudioUnitScope 					inScope,
+													AudioUnitElement 				inElement,
+													AudioUnitParameterValue			inValue,
+													UInt32							inBufferOffsetInFrames)
+{
+	AUElement *elem = SafeGetElement(inScope, inElement);
+	elem->SetParameter(inID, inValue);
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus 	AUBase::ScheduleParameter (	const AudioUnitParameterEvent 		*inParameterEvent,
+													UInt32							inNumEvents)
+{
+	bool canScheduleParameters = CanScheduleParameters();
+		
+	for (UInt32 i = 0; i < inNumEvents; ++i) 
+	{
+		if (inParameterEvent[i].eventType == kParameterEvent_Immediate)
+		{
+			SetParameter (inParameterEvent[i].parameter,
+							inParameterEvent[i].scope, 
+							inParameterEvent[i].element,
+							inParameterEvent[i].eventValues.immediate.value, 
+							inParameterEvent[i].eventValues.immediate.bufferOffset);
+		}
+		if (canScheduleParameters) {
+			mParamList.push_back (inParameterEvent[i]);
+		}
+	}
+	
+	return noErr;
+}
+
+// ____________________________________________________________________________
+//
+static bool SortParameterEventList(const AudioUnitParameterEvent &ev1, const AudioUnitParameterEvent &ev2 )
+{
+	int offset1 = ev1.eventType == kParameterEvent_Immediate ?  ev1.eventValues.immediate.bufferOffset : ev1.eventValues.ramp.startBufferOffset;
+	int offset2 = ev2.eventType == kParameterEvent_Immediate ?  ev2.eventValues.immediate.bufferOffset : ev2.eventValues.ramp.startBufferOffset;
+
+	if(offset1 < offset2) return true;
+	return false;
+}
+
+
+// ____________________________________________________________________________
+//
+OSStatus 	AUBase::ProcessForScheduledParams(	ParameterEventList		&inParamList,
+														UInt32					inFramesToProcess,
+														void					*inUserData )
+{
+	OSStatus result = noErr;
+	
+	int totalFramesToProcess = inFramesToProcess;
+	
+	int framesRemaining = totalFramesToProcess;
+
+	unsigned int currentStartFrame = 0;	// start of the whole buffer
+
+
+
+	// sort the ParameterEventList by startBufferOffset
+	std::sort(inParamList.begin(), inParamList.end(), SortParameterEventList);
+
+	ParameterEventList::iterator iter = inParamList.begin();
+	
+	
+	while(framesRemaining > 0 )
+	{
+		// first of all, go through the ramped automation events and find out where the next
+		// division of our whole buffer will be
+		
+		int currentEndFrame = totalFramesToProcess;	// start out assuming we'll process all the way to
+													// the end of the buffer
+		
+		iter = inParamList.begin();
+		
+		// find the next break point
+		while(iter != inParamList.end() )
+		{
+			AudioUnitParameterEvent &event = *iter;
+			
+			int offset = event.eventType == kParameterEvent_Immediate ?  event.eventValues.immediate.bufferOffset : event.eventValues.ramp.startBufferOffset;
+
+			if(offset > (int)currentStartFrame && offset < currentEndFrame )
+			{
+				currentEndFrame = offset;
+				break;
+			}
+
+			// consider ramp end to be a possible choice (there may be gaps in the supplied ramp events)
+			if(event.eventType == kParameterEvent_Ramped )
+			{
+				offset = event.eventValues.ramp.startBufferOffset + event.eventValues.ramp.durationInFrames;
+	
+				if(offset > (int)currentStartFrame && offset < currentEndFrame )
+				{
+					currentEndFrame = offset;
+				}
+			}
+
+			iter++;
+		}
+	
+		int framesThisTime = currentEndFrame - currentStartFrame;
+
+		// next, setup the parameter maps to be current for the ramp parameters active during 
+		// this time segment...
+		
+		for(ParameterEventList::iterator iter2 = inParamList.begin(); iter2 != inParamList.end(); iter2++ )
+		{
+			AudioUnitParameterEvent &event = *iter2;
+			
+			bool eventFallsInSlice;
+			
+			
+			if(event.eventType == kParameterEvent_Ramped)
+				eventFallsInSlice = event.eventValues.ramp.startBufferOffset < currentEndFrame 
+					&& event.eventValues.ramp.startBufferOffset + event.eventValues.ramp.durationInFrames > currentStartFrame;
+			else /* kParameterEvent_Immediate */
+				// actually, for the same parameter, there may be future immediate events which override this one,
+				// but it's OK since the event list is sorted in time order, we're guaranteed to end up with the current one
+				eventFallsInSlice = event.eventValues.immediate.bufferOffset <= currentStartFrame;
+				
+			if(eventFallsInSlice)
+			{
+				AUElement *element = GetElement(event.scope, event.element );
+				
+				if(element) element->SetScheduledEvent(	event.parameter,
+														event,
+														currentStartFrame,
+														currentEndFrame - currentStartFrame );
+			}
+		}
+
+
+
+		// Finally, actually do the processing for this slice.....
+		
+		result = ProcessScheduledSlice(	inUserData,
+										currentStartFrame,
+										framesThisTime,
+										inFramesToProcess );
+								
+		if(result != noErr) break;
+		
+		framesRemaining -= framesThisTime;
+		currentStartFrame = currentEndFrame;	// now start from where we left off last time
+	}
+	
+	return result;
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::SetWantsRenderThreadID (bool inFlag)
+{
+	if (inFlag == mWantsRenderThreadID)	
+		return;
+	
+	mWantsRenderThreadID = inFlag;
+	if (!mWantsRenderThreadID)
+		mRenderThreadID = NULL;
+}
+
+//_____________________________________________________________________________
+//
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::DoRender(		AudioUnitRenderActionFlags &	ioActionFlags,
+											const AudioTimeStamp &			inTimeStamp,
+											UInt32							inBusNumber,
+											UInt32							inFramesToProcess,
+											AudioBufferList &				ioData)
+{
+	OSStatus theError;
+	RenderCallbackList::iterator rcit;
+	
+	AUTRACE(kCATrace_AUBaseRenderStart, mComponentInstance, (uintptr_t)this, inBusNumber, inFramesToProcess, (uintptr_t)ioData.mBuffers[0].mData);
+	DISABLE_DENORMALS
+	
+	try {
+		ca_require(IsInitialized(), Uninitialized);
+		ca_require(mAudioUnitAPIVersion >= 2, ParamErr);
+		if (inFramesToProcess > mMaxFramesPerSlice) {
+			static time_t lastTimeMessagePrinted = 0;
+			time_t now = time(NULL);
+			if (now != lastTimeMessagePrinted) {
+				lastTimeMessagePrinted = now;
+				syslog(LOG_ERR, "kAudioUnitErr_TooManyFramesToProcess : inFramesToProcess=%u, mMaxFramesPerSlice=%u", (unsigned)inFramesToProcess, (unsigned)mMaxFramesPerSlice);
+				DebugMessageN4("%s:%d inFramesToProcess=%u, mMaxFramesPerSlice=%u; TooManyFrames", __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)mMaxFramesPerSlice);
+			}
+			goto TooManyFrames;
+		}
+		ca_require (!UsesFixedBlockSize() || inFramesToProcess == GetMaxFramesPerSlice(), ParamErr);
+
+		AUOutputElement *output = GetOutput(inBusNumber);	// will throw if non-existant
+		if (output->GetStreamFormat().NumberChannelStreams() != ioData.mNumberBuffers) {
+			DebugMessageN4("%s:%d ioData.mNumberBuffers=%u, output->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+				__FILE__, __LINE__, (unsigned)ioData.mNumberBuffers, (unsigned)output->GetStreamFormat().NumberChannelStreams());
+			goto ParamErr;
+		}
+
+		unsigned expectedBufferByteSize = inFramesToProcess * output->GetStreamFormat().mBytesPerFrame;
+		for (unsigned ibuf = 0; ibuf < ioData.mNumberBuffers; ++ibuf) {
+			AudioBuffer &buf = ioData.mBuffers[ibuf];
+			if (buf.mData != NULL) {
+				// only care about the size if the buffer is non-null
+				if (buf.mDataByteSize < expectedBufferByteSize) {
+					// if the buffer is too small, we cannot render safely. kAudio_ParamError.
+					DebugMessageN7("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioData.mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+						__FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)output->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibuf, (unsigned)buf.mDataByteSize);
+					goto ParamErr;
+				}
+				// Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
+				// We will generally set the buffer size at the end of rendering, before we return.
+				// However we should ensure that no one, DURING rendering, READS a
+				// potentially incorrect size. This can lead to doing too much work, or
+				// reading past the end of an input buffer into unmapped memory.
+				buf.mDataByteSize = expectedBufferByteSize;
+			}
+		}
+		
+		if (WantsRenderThreadID())
+		{
+			#if TARGET_OS_MAC
+				mRenderThreadID = pthread_self();
+			#elif TARGET_OS_WIN32
+				mRenderThreadID = GetCurrentThreadId();
+			#endif
+		}
+		
+		AudioUnitRenderActionFlags flags;
+		if (mRenderCallbacksTouched) {
+			mRenderCallbacks.update();
+			flags = ioActionFlags | kAudioUnitRenderAction_PreRender;
+			for (rcit = mRenderCallbacks.begin(); rcit != mRenderCallbacks.end(); ++rcit) {
+				RenderCallback &rc = *rcit;
+				AUTRACE(kCATrace_AUBaseRenderCallbackStart, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 1, 0);
+				(*(AURenderCallback)rc.mRenderNotify)(rc.mRenderNotifyRefCon, 
+								&flags,
+								&inTimeStamp, inBusNumber, inFramesToProcess, &ioData);
+				AUTRACE(kCATrace_AUBaseRenderCallbackEnd, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 1, 0);
+			}
+		}
+		
+		theError = DoRenderBus(ioActionFlags, inTimeStamp, inBusNumber, output, inFramesToProcess, ioData);
+		
+		if (mRenderCallbacksTouched) {
+			flags = ioActionFlags | kAudioUnitRenderAction_PostRender;
+			
+			if (SetRenderError (theError)) {
+				flags |= kAudioUnitRenderAction_PostRenderError;		
+			}
+			
+			for (rcit = mRenderCallbacks.begin(); rcit != mRenderCallbacks.end(); ++rcit) {
+				RenderCallback &rc = *rcit;
+				AUTRACE(kCATrace_AUBaseRenderCallbackStart, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 2, 0);
+				(*(AURenderCallback)rc.mRenderNotify)(rc.mRenderNotifyRefCon, 
+								&flags,
+								&inTimeStamp, inBusNumber, inFramesToProcess, &ioData);
+				AUTRACE(kCATrace_AUBaseRenderCallbackEnd, mComponentInstance, (intptr_t)this, (intptr_t)rc.mRenderNotify, 2, 0);
+			}
+		}
+
+		// The vector's being emptied
+		// because these events should only apply to this Render cycle, so anything
+		// left over is from a preceding cycle and should be dumped.  New scheduled
+		// parameters must be scheduled from the next pre-render callback.
+		if (!mParamList.empty())
+			mParamList.clear();
+
+	}
+	catch (OSStatus err) {
+		theError = err;
+		goto errexit;
+	}
+	catch (...) {
+		theError = -1;
+		goto errexit;
+	}
+done:	
+	RESTORE_DENORMALS
+	AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace::ablData(ioData));
+	
+	return theError;
+	
+Uninitialized:	theError = kAudioUnitErr_Uninitialized;				goto errexit;
+ParamErr:		theError = kAudio_ParamError;						goto errexit;
+TooManyFrames:	theError = kAudioUnitErr_TooManyFramesToProcess;	goto errexit;
+errexit:
+	DebugMessageN2 ("  from %s, render err: %d", GetLoggingString(), (int)theError);
+	SetRenderError(theError);
+	goto done;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus	AUBase::DoProcess (	AudioUnitRenderActionFlags  &		ioActionFlags,
+								const AudioTimeStamp &				inTimeStamp,
+								UInt32								inFramesToProcess,
+								AudioBufferList &					ioData)
+{
+	OSStatus theError;
+	AUTRACE(kCATrace_AUBaseRenderStart, mComponentInstance, (intptr_t)this, -1, inFramesToProcess, 0);
+	DISABLE_DENORMALS
+
+	try {		
+	
+		if (!(ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)) {
+			ca_require(IsInitialized(), Uninitialized);
+			ca_require(inFramesToProcess <= mMaxFramesPerSlice, TooManyFrames);
+			ca_require(!UsesFixedBlockSize() || inFramesToProcess == GetMaxFramesPerSlice(), ParamErr);
+
+			AUInputElement *input = GetInput(0);	// will throw if non-existant
+			if (input->GetStreamFormat().NumberChannelStreams() != ioData.mNumberBuffers) {
+				DebugMessageN4("%s:%d ioData.mNumberBuffers=%u, input->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+					__FILE__, __LINE__, (unsigned)ioData.mNumberBuffers, (unsigned)input->GetStreamFormat().NumberChannelStreams());
+				goto ParamErr;
+			}
+
+			unsigned expectedBufferByteSize = inFramesToProcess * input->GetStreamFormat().mBytesPerFrame;
+			for (unsigned ibuf = 0; ibuf < ioData.mNumberBuffers; ++ibuf) {
+				AudioBuffer &buf = ioData.mBuffers[ibuf];
+				if (buf.mData != NULL) {
+					// only care about the size if the buffer is non-null
+					if (buf.mDataByteSize < expectedBufferByteSize) {
+						// if the buffer is too small, we cannot render safely. kAudio_ParamError.
+						DebugMessageN7("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioData.mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+							__FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)input->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibuf, (unsigned)buf.mDataByteSize);
+						goto ParamErr;
+					}
+					// Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
+					// We will generally set the buffer size at the end of rendering, before we return.
+					// However we should ensure that no one, DURING rendering, READS a
+					// potentially incorrect size. This can lead to doing too much work, or
+					// reading past the end of an input buffer into unmapped memory.
+					buf.mDataByteSize = expectedBufferByteSize;
+				}
+			}
+		}
+		
+		if (WantsRenderThreadID())
+		{
+			#if TARGET_OS_MAC
+				mRenderThreadID = pthread_self();
+			#elif TARGET_OS_WIN32
+				mRenderThreadID = GetCurrentThreadId();
+			#endif
+		}
+		
+		if (NeedsToRender (inTimeStamp)) {
+			theError = ProcessBufferLists (ioActionFlags, ioData, ioData, inFramesToProcess);
+		} else
+			theError = noErr;
+			
+	}
+	catch (OSStatus err) {
+		theError = err;
+		goto errexit;
+	}
+	catch (...) {
+		theError = -1;
+		goto errexit;
+	}
+done:	
+	RESTORE_DENORMALS
+	AUTRACE(kCATrace_AUBaseRenderEnd, mComponentInstance, (intptr_t)this, theError, ioActionFlags, CATrace::ablData(ioData));
+	
+	return theError;
+	
+Uninitialized:	theError = kAudioUnitErr_Uninitialized;				goto errexit;
+ParamErr:		theError = kAudio_ParamError;						goto errexit;
+TooManyFrames:	theError = kAudioUnitErr_TooManyFramesToProcess;	goto errexit;
+errexit:
+	DebugMessageN2 ("  from %s, process err: %d", GetLoggingString(), (int)theError);
+	SetRenderError(theError);
+	goto done;
+}
+
+OSStatus	AUBase::DoProcessMultiple (	AudioUnitRenderActionFlags  & ioActionFlags,
+							   const AudioTimeStamp &				inTimeStamp,
+							   UInt32								inFramesToProcess,
+							   UInt32								inNumberInputBufferLists,
+							   const AudioBufferList **				inInputBufferLists,
+							   UInt32								inNumberOutputBufferLists,
+							   AudioBufferList **					ioOutputBufferLists)
+{
+	OSStatus theError;
+	DISABLE_DENORMALS
+	
+	try {
+		
+		if (!(ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)) {
+			ca_require(IsInitialized(), Uninitialized);
+			ca_require(inFramesToProcess <= mMaxFramesPerSlice, TooManyFrames);
+			ca_require (!UsesFixedBlockSize() || inFramesToProcess == GetMaxFramesPerSlice(), ParamErr);
+			
+			for (unsigned ibl = 0; ibl < inNumberInputBufferLists; ++ibl) {
+				if (inInputBufferLists[ibl] != NULL) {
+					AUInputElement *input = GetInput(ibl);	// will throw if non-existant
+					unsigned expectedBufferByteSize = inFramesToProcess * input->GetStreamFormat().mBytesPerFrame;
+					
+					if (input->GetStreamFormat().NumberChannelStreams() != inInputBufferLists[ibl]->mNumberBuffers) {
+						DebugMessageN5("%s:%d inInputBufferLists[%u]->mNumberBuffers=%u, input->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+									   __FILE__, __LINE__, ibl, (unsigned)inInputBufferLists[ibl]->mNumberBuffers, (unsigned)input->GetStreamFormat().NumberChannelStreams());
+						goto ParamErr;
+					}
+					
+					for (unsigned ibuf = 0; ibuf < inInputBufferLists[ibl]->mNumberBuffers; ++ibuf) {
+						const AudioBuffer &buf = inInputBufferLists[ibl]->mBuffers[ibuf];
+						if (buf.mData != NULL) {
+							if (buf.mDataByteSize < expectedBufferByteSize) {
+								// the buffer is too small
+								DebugMessageN8("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; inInputBufferLists[%u].mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+											   __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)input->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, ibl, ibuf, (unsigned)buf.mDataByteSize);
+								goto ParamErr;
+							}
+						} else {
+							// the buffer must exist
+							goto ParamErr;
+						}
+					}
+				} else {
+					// skip NULL input audio buffer list
+				}
+			}
+			
+			for (unsigned obl = 0; obl < inNumberOutputBufferLists; ++obl) {
+				if (ioOutputBufferLists[obl] != NULL) {
+					AUOutputElement *output = GetOutput(obl);	// will throw if non-existant
+					unsigned expectedBufferByteSize = inFramesToProcess * output->GetStreamFormat().mBytesPerFrame;
+
+					if (output->GetStreamFormat().NumberChannelStreams() != ioOutputBufferLists[obl]->mNumberBuffers) {
+						DebugMessageN5("%s:%d ioOutputBufferLists[%u]->mNumberBuffers=%u, output->GetStreamFormat().NumberChannelStreams()=%u; kAudio_ParamError",
+									   __FILE__, __LINE__, obl, (unsigned)ioOutputBufferLists[obl]->mNumberBuffers, (unsigned)output->GetStreamFormat().NumberChannelStreams());
+						goto ParamErr;
+					}
+					
+					for (unsigned obuf = 0; obuf < ioOutputBufferLists[obl]->mNumberBuffers; ++obuf) {
+						AudioBuffer &buf = ioOutputBufferLists[obl]->mBuffers[obuf];
+						if (buf.mData != NULL) {
+							// only care about the size if the buffer is non-null
+							if (buf.mDataByteSize < expectedBufferByteSize) {
+								// if the buffer is too small, we cannot render safely. kAudio_ParamError.
+								DebugMessageN8("%s:%d %u frames, %u bytes/frame, expected %u-byte buffer; ioOutputBufferLists[%u]->mBuffers[%u].mDataByteSize=%u; kAudio_ParamError",
+											   __FILE__, __LINE__, (unsigned)inFramesToProcess, (unsigned)output->GetStreamFormat().mBytesPerFrame, expectedBufferByteSize, obl, obuf, (unsigned)buf.mDataByteSize);
+								goto ParamErr;
+							}
+							// Some clients incorrectly pass bigger buffers than expectedBufferByteSize.
+							// We will generally set the buffer size at the end of rendering, before we return.
+							// However we should ensure that no one, DURING rendering, READS a
+							// potentially incorrect size. This can lead to doing too much work, or
+							// reading past the end of an input buffer into unmapped memory.
+							buf.mDataByteSize = expectedBufferByteSize;
+						}
+					}
+				} else {
+					// skip NULL output audio buffer list
+				}
+			}
+		}
+		
+		if (WantsRenderThreadID())
+		{
+#if TARGET_OS_MAC
+			mRenderThreadID = pthread_self();
+#elif TARGET_OS_WIN32
+			mRenderThreadID = GetCurrentThreadId();
+#endif
+		}
+		
+		if (NeedsToRender (inTimeStamp)) {
+			theError = ProcessMultipleBufferLists (ioActionFlags, inFramesToProcess, inNumberInputBufferLists, inInputBufferLists, inNumberOutputBufferLists, ioOutputBufferLists);
+		} else
+			theError = noErr;
+	}
+	catch (OSStatus err) {
+		theError = err;
+		goto errexit;
+	}
+	catch (...) {
+		theError = -1;
+		goto errexit;
+	}
+done:	
+	RESTORE_DENORMALS
+	
+	return theError;
+	
+Uninitialized:	theError = kAudioUnitErr_Uninitialized;				goto errexit;
+ParamErr:		theError = kAudio_ParamError;						goto errexit;
+TooManyFrames:	theError = kAudioUnitErr_TooManyFramesToProcess;	goto errexit;
+errexit:
+	DebugMessageN2 ("  from %s, processmultiple err: %d", GetLoggingString(), (int)theError);
+	SetRenderError(theError);
+	goto done;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::SetInputCallback(		UInt32							inPropertyID,
+													AudioUnitElement 				inElement, 
+													AURenderCallback				inProc,
+													void *							inRefCon)
+{
+	AUInputElement *input = GetInput(inElement);	// may throw
+	
+	input->SetInputCallback(inProc, inRefCon);
+	PropertyChanged(inPropertyID, kAudioUnitScope_Input, inElement);
+	
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::SetConnection(			const AudioUnitConnection &		inConnection)
+{
+
+	OSStatus err;
+	AUInputElement *input = GetInput(inConnection.destInputNumber);	// may throw
+		
+	if (inConnection.sourceAudioUnit) {
+		// connecting, not disconnecting
+		CAStreamBasicDescription sourceDesc;
+		UInt32 size = sizeof(CAStreamBasicDescription);
+		ca_require_noerr(err = AudioUnitGetProperty(
+										inConnection.sourceAudioUnit,
+										kAudioUnitProperty_StreamFormat,
+										kAudioUnitScope_Output,
+										inConnection.sourceOutputNumber,
+										&sourceDesc,
+										&size), errexit);
+		ca_require_noerr(err = DispatchSetProperty (kAudioUnitProperty_StreamFormat, 
+								kAudioUnitScope_Input, inConnection.destInputNumber, 
+								&sourceDesc, sizeof(CAStreamBasicDescription)), errexit);
+	}
+	input->SetConnection(inConnection);
+		
+	PropertyChanged(kAudioUnitProperty_MakeConnection, kAudioUnitScope_Input, inConnection.destInputNumber);
+	return noErr;
+
+errexit:
+	return err;
+}
+ 
+//_____________________________________________________________________________
+//
+UInt32				AUBase::SupportedNumChannels (	const AUChannelInfo** 			outInfo)
+{
+	return 0;
+}
+
+//_____________________________________________________________________________
+//
+bool				AUBase::ValidFormat(			AudioUnitScope					inScope,
+													AudioUnitElement				inElement,
+													const CAStreamBasicDescription &		inNewFormat)
+{
+	return FormatIsCanonical(inNewFormat);
+}
+
+//_____________________________________________________________________________
+//
+bool				AUBase::IsStreamFormatWritable(	AudioUnitScope					scope,
+													AudioUnitElement				element)
+{
+	switch (scope) {
+	case kAudioUnitScope_Input:
+		{
+			AUInputElement *input = GetInput(element);
+			if (input->HasConnection()) return false;	// can't write format when input comes from connection
+		}
+		// ... fall ...
+	case kAudioUnitScope_Output:
+		return StreamFormatWritable(scope, element);
+
+//#warning "aliasing of global scope format should be pushed to subclasses"
+	case kAudioUnitScope_Global:
+		return StreamFormatWritable(kAudioUnitScope_Output, 0);
+	}
+	return false;
+}
+
+//_____________________________________________________________________________
+//
+const CAStreamBasicDescription &
+					AUBase::GetStreamFormat(		AudioUnitScope					inScope,
+													AudioUnitElement				inElement)
+{
+//#warning "aliasing of global scope format should be pushed to subclasses"
+	AUIOElement *element;
+	
+	switch (inScope) {
+	case kAudioUnitScope_Input:
+		element = Inputs().GetIOElement(inElement);
+		break;
+	case kAudioUnitScope_Output:
+		element = Outputs().GetIOElement(inElement);
+		break;
+	case kAudioUnitScope_Global:	// global stream description is an alias for that of output 0
+		element = Outputs().GetIOElement(0);
+		break;
+	default:
+		COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+	}
+	return element->GetStreamFormat();
+}
+
+OSStatus			AUBase::SetBusCount(	AudioUnitScope					inScope,
+											UInt32 							inCount)
+{
+	if (IsInitialized()) 
+		return kAudioUnitErr_Initialized;
+		
+	GetScope(inScope).SetNumberOfElements(inCount);
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::ChangeStreamFormat(		AudioUnitScope					inScope,
+													AudioUnitElement				inElement,
+													const CAStreamBasicDescription & inPrevFormat,
+													const CAStreamBasicDescription &	inNewFormat)
+{
+//#warning "aliasing of global scope format should be pushed to subclasses"
+	AUIOElement *element;
+	
+	switch (inScope) {
+	case kAudioUnitScope_Input:
+		element = Inputs().GetIOElement(inElement);
+		break;
+	case kAudioUnitScope_Output:
+		element = Outputs().GetIOElement(inElement);
+		break;
+	case kAudioUnitScope_Global:
+		element = Outputs().GetIOElement(0);
+		break;
+	default:
+		COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+	}
+	element->SetStreamFormat(inNewFormat);
+	PropertyChanged(kAudioUnitProperty_StreamFormat, inScope, inElement);
+	return noErr;
+}
+
+UInt32		AUBase::GetChannelLayoutTags(	AudioUnitScope				inScope,
+											AudioUnitElement 			inElement,
+											AudioChannelLayoutTag *		outLayoutTags)
+{
+	return GetIOElement(inScope, inElement)->GetChannelLayoutTags(outLayoutTags);
+}
+
+UInt32		AUBase::GetAudioChannelLayout(	AudioUnitScope				scope,
+											AudioUnitElement 			element,
+											AudioChannelLayout *		outLayoutPtr,
+											Boolean &					outWritable)
+{
+	AUIOElement * el = GetIOElement(scope, element);
+	return el->GetAudioChannelLayout(outLayoutPtr, outWritable);
+}
+
+OSStatus	AUBase::RemoveAudioChannelLayout(			AudioUnitScope				inScope,
+														AudioUnitElement			inElement)
+{
+	OSStatus result = noErr;
+	AUIOElement * el = GetIOElement(inScope, inElement);
+	Boolean writable;
+	if (el->GetAudioChannelLayout(NULL, writable)) {
+		result = el->RemoveAudioChannelLayout();
+	}
+	return result;
+}
+
+OSStatus 	AUBase::SetAudioChannelLayout(				AudioUnitScope 				inScope, 
+														AudioUnitElement 			inElement,
+														const AudioChannelLayout *	inLayout)
+{
+	AUIOElement* ioEl = GetIOElement (inScope, inElement);
+
+	// the num channels of the layout HAS TO MATCH the current channels of the Element's stream format
+	UInt32 currentChannels = ioEl->GetStreamFormat().NumberChannels();
+	UInt32 numChannelsInLayout = CAAudioChannelLayout::NumberChannels(*inLayout);
+	if (currentChannels != numChannelsInLayout)
+		return kAudioUnitErr_InvalidPropertyValue;
+
+	UInt32 numLayouts = GetChannelLayoutTags (inScope, inElement, NULL);
+	if (numLayouts == 0)
+		return kAudioUnitErr_InvalidProperty;
+	AudioChannelLayoutTag *tags = (AudioChannelLayoutTag *)CA_malloc (numLayouts * sizeof (AudioChannelLayoutTag));
+	GetChannelLayoutTags (inScope, inElement, tags);
+	bool foundTag = false;
+	for (unsigned int i = 0; i < numLayouts; ++i) {
+		if (tags[i] == inLayout->mChannelLayoutTag || tags[i] == kAudioChannelLayoutTag_UseChannelDescriptions) {
+			foundTag = true;
+			break;
+		}
+	}
+	free(tags);
+	
+	if (foundTag == false)
+		return kAudioUnitErr_InvalidPropertyValue;
+
+	return ioEl->SetAudioChannelLayout(*inLayout);
+}
+
+static void AddNumToDictionary (CFMutableDictionaryRef dict, CFStringRef key, SInt32 value)
+{
+	CFNumberRef num = CFNumberCreate (NULL, kCFNumberSInt32Type, &value);
+	CFDictionarySetValue (dict, key, num);
+	CFRelease (num);
+}
+
+#define kCurrentSavedStateVersion 0
+
+OSStatus			AUBase::SaveState(		CFPropertyListRef * outData)
+{
+	AudioComponentDescription desc = GetComponentDescription();
+
+	CFMutableDictionaryRef dict = CFDictionaryCreateMutable	(NULL, 0, 
+								&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+
+// first step -> save the version to the data ref
+	SInt32 value = kCurrentSavedStateVersion;
+	AddNumToDictionary (dict, kVersionString, value);
+
+// second step -> save the component type, subtype, manu to the data ref
+	value = desc.componentType;
+	AddNumToDictionary (dict, kTypeString, value);
+
+	value = desc.componentSubType;
+	AddNumToDictionary (dict, kSubtypeString, value);
+	
+	value = desc.componentManufacturer;
+	AddNumToDictionary (dict, kManufacturerString, value);
+	
+// fourth step -> save the state of all parameters on all scopes and elements
+	CFMutableDataRef data = CFDataCreateMutable(NULL, 0);
+	for (AudioUnitScope iscope = 0; iscope < 3; ++iscope) {
+		AUScope &scope = GetScope(iscope);
+		scope.SaveState (data);
+	}
+    
+    SaveExtendedScopes(data);
+
+// save all this in the data section of the dictionary
+	CFDictionarySetValue(dict, kDataString, data);
+	CFRelease (data);
+	
+//OK - now we're going to do some properties 	
+//save the preset name...
+	CFDictionarySetValue (dict, kNameString, mCurrentPreset.presetName);
+
+// Does the unit support the RenderQuality property - if so, save it...
+	value = 0;
+	OSStatus result = DispatchGetProperty (kAudioUnitProperty_RenderQuality,
+								kAudioUnitScope_Global,
+								0,
+								&value);
+	
+	if (result == noErr) {
+		AddNumToDictionary (dict, kRenderQualityString, value);
+	}
+	
+// Does the unit support the CPULoad Quality property - if so, save it...
+	Float32 cpuLoad;
+	result = DispatchGetProperty (6/*kAudioUnitProperty_CPULoad*/,
+								kAudioUnitScope_Global,
+								0,
+								&cpuLoad);
+	
+	if (result == noErr) {
+		CFNumberRef num = CFNumberCreate (NULL, kCFNumberFloatType, &cpuLoad);
+		CFDictionarySetValue (dict, kCPULoadString, num);
+		CFRelease (num);
+	}
+
+// Do we have any element names for any of our scopes?	
+	// first check to see if we have any names...
+	bool foundName = false;
+	for (AudioUnitScope i = 0; i < kNumScopes; ++i) {
+		foundName = GetScope (i).HasElementWithName();
+		if (foundName) 
+			break;
+	}
+		// OK - we found a name away we go...
+	if (foundName) {
+		CFMutableDictionaryRef nameDict = CFDictionaryCreateMutable	(NULL, 0, 
+								&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+		for (AudioUnitScope i = 0; i < kNumScopes; ++i) {
+			GetScope (i).AddElementNamesToDict (nameDict);
+		}
+		
+		CFDictionarySetValue (dict, kElementNameString, nameDict);
+		CFRelease (nameDict);
+	}
+	
+// we're done!!!
+	*outData = dict;
+
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::RestoreState(	CFPropertyListRef	plist)
+{
+	if (CFGetTypeID(plist) != CFDictionaryGetTypeID()) return kAudioUnitErr_InvalidPropertyValue;
+	
+	AudioComponentDescription desc = GetComponentDescription();
+	
+	CFDictionaryRef dict = static_cast<CFDictionaryRef>(plist);
+
+// zeroeth step - make sure the Part key is NOT present, as this method is used
+// to restore the GLOBAL state of the dictionary	
+	if (CFDictionaryContainsKey (dict, kPartString))
+		return kAudioUnitErr_InvalidPropertyValue;
+		
+// first step -> check the saved version in the data ref
+// at this point we're only dealing with version==0
+	CFNumberRef cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue (dict, kVersionString));
+	if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
+	SInt32 value;
+	CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+	if (value != kCurrentSavedStateVersion) return kAudioUnitErr_InvalidPropertyValue;
+
+// second step -> check that this data belongs to this kind of audio unit
+// by checking the component subtype and manuID
+// We're not checking the type, since there may be different versions (effect, format-converter, offline)
+// of essentially the same AU
+	cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue (dict, kSubtypeString));
+	if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
+	CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+	if (UInt32(value) != desc.componentSubType) return kAudioUnitErr_InvalidPropertyValue;
+
+	cfnum = reinterpret_cast<CFNumberRef>(CFDictionaryGetValue (dict, kManufacturerString));
+	if (cfnum == NULL) return kAudioUnitErr_InvalidPropertyValue;
+	CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+	if (UInt32(value) != desc.componentManufacturer) return kAudioUnitErr_InvalidPropertyValue;
+
+// fourth step -> restore the state of all of the parameters for each scope and element	
+	CFDataRef data = reinterpret_cast<CFDataRef>(CFDictionaryGetValue (dict, kDataString));
+	if (data != NULL) 
+	{
+		const UInt8 *p, *pend;
+		
+		p = CFDataGetBytePtr(data);
+		pend = p + CFDataGetLength(data);
+		
+		// we have a zero length data, which may just mean there were no parameters to save!
+		//	if (p >= pend) return noErr; 
+	
+		while (p < pend) {
+            UInt32 scopeIdx = CFSwapInt32BigToHost(*(UInt32 *)p);
+            p += sizeof(UInt32);
+            
+			AUScope &scope = GetScope(scopeIdx);
+            p = scope.RestoreState(p);
+        }
+	}
+
+//OK - now we're going to do some properties
+//restore the preset name...
+	CFStringRef name = reinterpret_cast<CFStringRef>(CFDictionaryGetValue (dict, kNameString));
+	if (mCurrentPreset.presetName) CFRelease (mCurrentPreset.presetName);
+	if (name)
+	{
+		mCurrentPreset.presetName = name;
+		mCurrentPreset.presetNumber = -1;
+	} 
+	else { // no name entry make the default one
+		mCurrentPreset.presetName = kUntitledString;
+		mCurrentPreset.presetNumber = -1;
+	}
+	
+	CFRetain (mCurrentPreset.presetName);
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+#ifndef __LP64__
+	PropertyChanged(kAudioUnitProperty_CurrentPreset, kAudioUnitScope_Global, 0);
+#endif
+#endif
+	PropertyChanged(kAudioUnitProperty_PresentPreset, kAudioUnitScope_Global, 0);
+
+// Does the dict contain render quality information?		
+	if (CFDictionaryGetValueIfPresent (dict, kRenderQualityString, reinterpret_cast<const void**>(&cfnum))) 
+	{
+		CFNumberGetValue (cfnum, kCFNumberSInt32Type, &value);
+		DispatchSetProperty (kAudioUnitProperty_RenderQuality,
+								kAudioUnitScope_Global,
+								0,
+								&value,
+								sizeof(value));
+	}
+	
+// Does the unit support the CPULoad Quality property - if so, save it...
+	if (CFDictionaryGetValueIfPresent (dict, kCPULoadString, reinterpret_cast<const void**>(&cfnum))) 
+	{
+		Float32 floatValue;
+		CFNumberGetValue (cfnum, kCFNumberFloatType, &floatValue);
+		DispatchSetProperty (6/*kAudioUnitProperty_CPULoad*/,
+								kAudioUnitScope_Global,
+								0,
+								&floatValue,
+								sizeof(floatValue));
+	}
+
+// Do we have any element names for any of our scopes?
+	CFDictionaryRef nameDict;
+	if (CFDictionaryGetValueIfPresent (dict, kElementNameString, reinterpret_cast<const void**>(&nameDict))) 
+	{
+		char string[64];
+		for (int i = 0; i < kNumScopes; ++i) 
+		{
+			snprintf (string, sizeof(string), "%d", i);
+			CFStringRef key = CFStringCreateWithCString (NULL, string, kCFStringEncodingASCII);
+			CFDictionaryRef elementDict;
+			if (CFDictionaryGetValueIfPresent (nameDict, key, reinterpret_cast<const void**>(&elementDict))) 
+			{
+				bool didAddElements = GetScope (i).RestoreElementNames (elementDict);
+				if (didAddElements)
+					PropertyChanged (kAudioUnitProperty_ElementCount, i, 0);
+			}
+			CFRelease (key);				
+		}
+	}
+	
+	return noErr;
+}
+
+OSStatus			AUBase::GetPresets (			CFArrayRef * 					outData) const
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+OSStatus			AUBase::NewFactoryPresetSet (const AUPreset & inNewFactoryPreset)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+OSStatus            AUBase::NewCustomPresetSet (const AUPreset & inNewCustomPreset)
+{
+    CFRelease (mCurrentPreset.presetName);
+    mCurrentPreset = inNewCustomPreset;
+    CFRetain (mCurrentPreset.presetName);
+    return noErr;
+}
+
+		// set the default preset for the unit -> the number of the preset MUST be >= 0
+		// and the name should be valid, or the preset WON'T take
+bool				AUBase::SetAFactoryPresetAsCurrent (const AUPreset & inPreset)
+{
+	if (inPreset.presetNumber < 0 || inPreset.presetName == NULL) return false;
+	CFRelease (mCurrentPreset.presetName);
+	mCurrentPreset = inPreset;
+	CFRetain (mCurrentPreset.presetName);
+	return true;
+}
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+int			AUBase::GetNumCustomUIComponents () 
+{
+	return 0;
+}
+
+void		AUBase::GetUIComponentDescs (ComponentDescription* inDescArray) {}
+#endif
+	
+bool		AUBase::HasIcon () 
+{
+#if !CA_NO_AU_UI_FEATURES
+	CFURLRef url = CopyIconLocation(); 
+	if (url) {
+		CFRelease (url);
+		return true;
+	}
+#endif
+	return false;
+}
+
+CFURLRef	AUBase::CopyIconLocation () 
+{
+	return NULL;
+}
+	
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::GetParameterList(		AudioUnitScope					inScope,
+													AudioUnitParameterID *			outParameterList,
+													UInt32 &						outNumParameters)
+{
+	AUScope &scope = GetScope(inScope);
+	AUElement *elementWithMostParameters = NULL;
+	UInt32 maxNumParams = 0;
+	
+	int nElems = scope.GetNumberOfElements();
+	for (int ielem = 0; ielem < nElems; ++ielem) {
+		AUElement *element = scope.GetElement(ielem);
+		UInt32 nParams = element->GetNumberOfParameters();
+		if (nParams > maxNumParams) {
+			maxNumParams = nParams;
+			elementWithMostParameters = element;
+		}
+	}
+	
+	if (outParameterList != NULL && elementWithMostParameters != NULL)
+		elementWithMostParameters->GetParameterList(outParameterList);
+	
+	outNumParameters = maxNumParams;
+	return noErr;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::GetParameterInfo(		AudioUnitScope			inScope,
+													AudioUnitParameterID	inParameterID,
+													AudioUnitParameterInfo	&outParameterInfo )
+{
+	return kAudioUnitErr_InvalidParameter;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::GetParameterValueStrings(AudioUnitScope			inScope,
+													AudioUnitParameterID	inParameterID,
+													CFArrayRef *			outStrings)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::GetParameterHistoryInfo(	AudioUnitScope					inScope,
+														AudioUnitParameterID			inParameterID,
+														Float32 &						outUpdatesPerSecond,
+														Float32 &						outHistoryDurationInSeconds)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+
+//_____________________________________________________________________________
+//
+OSStatus			AUBase::CopyClumpName(			AudioUnitScope			inScope, 
+													UInt32					inClumpID, 
+													UInt32					inDesiredNameLength,
+													CFStringRef *			outClumpName)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+//_____________________________________________________________________________
+//
+void				AUBase::SetNumberOfElements(	AudioUnitScope					inScope,
+													UInt32							numElements)
+{
+	if (inScope == kAudioUnitScope_Global && numElements != 1)
+		COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+
+	GetScope(inScope).SetNumberOfElements(numElements);
+}
+
+//_____________________________________________________________________________
+//
+AUElement *			AUBase::CreateElement(			AudioUnitScope					scope,
+													AudioUnitElement				element)
+{
+	switch (scope) {
+	case kAudioUnitScope_Global:
+		return new AUElement(this);
+	case kAudioUnitScope_Input:
+		return new AUInputElement(this);
+	case kAudioUnitScope_Output:
+		return new AUOutputElement(this);
+#if !CA_BASIC_AU_FEATURES
+	case kAudioUnitScope_Group:
+		return new AUElement(this);
+	case kAudioUnitScope_Part:
+		return new AUElement(this);
+#endif
+	}
+	COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+	
+	return NULL;	// get rid of compiler warning
+}
+
+//_____________________________________________________________________________
+//
+bool	AUBase::FormatIsCanonical(		const CAStreamBasicDescription &f)
+{
+	return (f.mFormatID == kAudioFormatLinearPCM
+		&&	f.mFramesPerPacket == 1
+		&&	f.mBytesPerPacket == f.mBytesPerFrame
+//		&&	f.mChannelsPerFrame >= 0	-- this is always true since it's unsigned
+		// so far, it's a valid PCM format
+#if CA_PREFER_FIXED_POINT
+		&&	(f.mFormatFlags & kLinearPCMFormatFlagIsFloat) == 0
+		&&	(((f.mFormatFlags & kLinearPCMFormatFlagsSampleFractionMask) >> kLinearPCMFormatFlagsSampleFractionShift) == kAudioUnitSampleFractionBits)
+#else
+		&&	(f.mFormatFlags & kLinearPCMFormatFlagIsFloat) != 0
+#endif
+		&&	((f.mChannelsPerFrame == 1) || ((f.mFormatFlags & kAudioFormatFlagIsNonInterleaved) == 0) == (mAudioUnitAPIVersion == 1))
+#if TARGET_RT_BIG_ENDIAN
+		&&	(f.mFormatFlags & kLinearPCMFormatFlagIsBigEndian) != 0
+#else
+		&&	(f.mFormatFlags & kLinearPCMFormatFlagIsBigEndian) == 0
+#endif
+		&&	f.mBitsPerChannel == 8 * sizeof(AudioUnitSampleType)
+		&&	f.mBytesPerFrame == f.NumberInterleavedChannels() * sizeof(AudioUnitSampleType)
+		);
+}
+
+//_____________________________________________________________________________
+//
+void	AUBase::MakeCanonicalFormat(	CAStreamBasicDescription &		f,
+										int								nChannels)
+{
+	f.SetAUCanonical(nChannels, mAudioUnitAPIVersion < 2);	// interleaved for v1, non for v2
+	f.mSampleRate = 0.0;
+}
+
+const Float64 AUBase::kNoLastRenderedSampleTime = -1.;
+
+#include "AUBaseHelper.h"
+
+char*	AUBase::GetLoggingString () const
+{
+	if (mLogString) return mLogString;
+	
+	AudioComponentDescription desc = GetComponentDescription();
+	
+	const size_t logStringSize = 256;
+	const_cast<AUBase*>(this)->mLogString = new char[logStringSize];
+	char str[24];
+	char str1[24];
+	char str2[24];
+	snprintf (const_cast<AUBase*>(this)->mLogString, logStringSize, "AU (%p): %s %s %s",
+		GetComponentInstance(),
+		CAStringForOSType(desc.componentType, str, sizeof(str)),
+		CAStringForOSType(desc.componentSubType, str1, sizeof(str1)),
+		CAStringForOSType(desc.componentManufacturer, str2, sizeof(str2)));
+
+	return mLogString;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.h	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,1048 @@
+/*
+     File: AUBase.h
+ Abstract: Part of CoreAudio Utility Classes
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#ifndef __AUBase_h__
+#define __AUBase_h__
+
+#include <TargetConditionals.h>
+
+#if TARGET_OS_MAC
+	#include <pthread.h>
+#elif TARGET_OS_WIN32
+	#include <windows.h>
+#else
+	#error Unsupported Operating System
+#endif
+
+#include <vector>
+
+#include "AUScopeElement.h"
+#include "AUInputElement.h"
+#include "AUOutputElement.h"
+#include "AUBuffer.h"
+#include "CAMath.h"
+#include "CAThreadSafeList.h"
+#include "CAVectorUnit.h"
+#include "CAMutex.h"
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+	#include <AudioUnit/AudioUnit.h>
+	#if !CA_BASIC_AU_FEATURES
+		#include <AudioUnit/MusicDevice.h>
+	#endif
+#else
+	#include "AudioUnit.h"
+	#if !CA_BASIC_AU_FEATURES
+		#include "MusicDevice.h"
+	#endif
+#endif
+
+#ifndef AUTRACE
+	#define AUTRACE(code, obj, a, b, c, d)
+#endif	
+
+#include "AUPlugInDispatch.h"
+
+
+
+// ________________________________________________________________________
+// These are to be moved to the public AudioUnit headers
+
+#define kAUDefaultSampleRate		44100.0
+#if !TARGET_OS_WIN32
+#define kAUDefaultMaxFramesPerSlice	1156 
+//this allows enough default frames for a 512 dest 44K and SRC from 96K
+// add a padding of 4 frames for any altivec rounding
+#else
+#define kAUDefaultMaxFramesPerSlice	2048 
+#endif
+
+// ________________________________________________________________________
+
+/*! @class AUBase */
+class AUBase : public ComponentBase {
+public:
+
+	/*! @ctor AUBase */
+								AUBase(					AudioComponentInstance			inInstance, 
+														UInt32							numInputElements,
+														UInt32							numOutputElements,
+														UInt32							numGroupElements = 0);
+	/*! @dtor AUBase */
+	virtual						~AUBase();
+	
+	/*! @method PostConstructor */
+	virtual void				PostConstructor() { CreateElements(); }
+								
+	/*! @method PreDestructor */
+	virtual void				PreDestructor();
+
+	/*! @method CreateElements */
+	void						CreateElements();
+									// Called immediately after construction, when virtual methods work.
+									// Or, a subclass may call this in order to have access to elements
+									// in its constructor.
+
+	/*! @method CreateExtendedElements */
+	virtual void CreateExtendedElements() {}
+
+#pragma mark -
+#pragma mark AU dispatch
+	// ________________________________________________________________________
+	// Virtual methods (mostly) directly corresponding to the entry points.  Many of these
+	// have useful implementations here and will not need overriding.
+	
+	/*! @method DoInitialize */
+			OSStatus			DoInitialize();
+				// this implements the entry point and makes sure that initialization
+				// is only attempted exactly once...
+
+	/*! @method Initialize */
+	virtual OSStatus			Initialize();
+				// ... so that overrides to this method can assume that they will only
+				// be called exactly once.
+	
+	/*! @method IsInitialized */
+			bool				IsInitialized() const { return mInitialized; }
+	/*! @method HasBegunInitializing */
+			bool				HasBegunInitializing() const { return mHasBegunInitializing; }
+			
+	/*! @method DoCleanup */
+			void				DoCleanup();
+				// same pattern as with Initialize
+	
+	/*! @method Cleanup */
+	virtual void				Cleanup();
+
+	/*! @method Reset */
+	virtual OSStatus			Reset(					AudioUnitScope 					inScope,
+														AudioUnitElement 				inElement);
+
+	// Note about GetPropertyInfo, GetProperty, SetProperty:
+	// Certain properties are trapped out in these dispatch functions and handled with different virtual 
+	// methods.  (To discourage hacks and keep vtable size down, these are non-virtual)
+
+	/*! @method DispatchGetPropertyInfo */
+			OSStatus			DispatchGetPropertyInfo(AudioUnitPropertyID				inID,
+														AudioUnitScope					inScope,
+														AudioUnitElement				inElement,
+														UInt32 &						outDataSize,
+														Boolean &						outWritable);
+
+	/*! @method DispatchGetProperty */
+			OSStatus			DispatchGetProperty(	AudioUnitPropertyID 			inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement			 	inElement,
+														void *							outData);
+
+	/*! @method DispatchSetProperty */
+			OSStatus			DispatchSetProperty(	AudioUnitPropertyID 			inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement 				inElement,
+														const void *					inData,
+														UInt32 							inDataSize);
+													
+			OSStatus			DispatchRemovePropertyValue(	AudioUnitPropertyID 	inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement 				inElement);
+
+	/*! @method GetPropertyInfo */
+	virtual OSStatus			GetPropertyInfo(		AudioUnitPropertyID				inID,
+														AudioUnitScope					inScope,
+														AudioUnitElement				inElement,
+														UInt32 &						outDataSize,
+														Boolean &						outWritable);
+
+	/*! @method GetProperty */
+	virtual OSStatus			GetProperty(			AudioUnitPropertyID 			inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement			 	inElement,
+														void *							outData);
+
+	/*! @method SetProperty */
+	virtual OSStatus			SetProperty(			AudioUnitPropertyID 			inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement 				inElement,
+														const void *					inData,
+														UInt32 							inDataSize);
+													
+	/*! @method ClearPropertyUsage */
+	virtual OSStatus			RemovePropertyValue (	AudioUnitPropertyID		 		inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement 				inElement);
+
+	/*! @method AddPropertyListener */
+	virtual OSStatus			AddPropertyListener(	AudioUnitPropertyID				inID,
+														AudioUnitPropertyListenerProc	inProc,
+														void *							inProcRefCon);
+														
+	/*! @method RemovePropertyListener */
+	virtual OSStatus			RemovePropertyListener(	AudioUnitPropertyID				inID,
+														AudioUnitPropertyListenerProc	inProc,
+														void *							inProcRefCon,
+														bool							refConSpecified);
+	
+	/*! @method SetRenderNotification */
+	virtual OSStatus			SetRenderNotification(	AURenderCallback		 		inProc,
+														void *							inRefCon);
+	
+	/*! @method RemoveRenderNotification */
+	virtual OSStatus			RemoveRenderNotification(
+														AURenderCallback		 		inProc,
+														void *							inRefCon);
+	
+	/*! @method GetParameter */
+	virtual OSStatus 	GetParameter(			AudioUnitParameterID			inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement 				inElement,
+														AudioUnitParameterValue &		outValue);
+												
+	/*! @method SetParameter */
+	virtual OSStatus 	SetParameter(			AudioUnitParameterID			inID,
+														AudioUnitScope 					inScope,
+														AudioUnitElement 				inElement,
+														AudioUnitParameterValue			inValue,
+														UInt32							inBufferOffsetInFrames);
+
+	/*! @method CanScheduleParams */
+	virtual bool CanScheduleParameters() const = 0;
+
+	/*! @method ScheduleParameter */
+	virtual OSStatus 	ScheduleParameter (		const AudioUnitParameterEvent 	*inParameterEvent,
+														UInt32							inNumEvents);
+	
+
+	/*! @method DoRender */
+	OSStatus 	DoRender(								AudioUnitRenderActionFlags &	ioActionFlags,
+														const AudioTimeStamp &			inTimeStamp,
+														UInt32							inBusNumber,
+														UInt32							inNumberFrames,
+														AudioBufferList &				ioData);
+	
+
+	/*! @method Process */
+	OSStatus	DoProcess (							AudioUnitRenderActionFlags  &		ioActionFlags,
+													const AudioTimeStamp &				inTimeStamp,
+													UInt32								inFramesToProcess,
+													AudioBufferList &					ioData);
+	
+	/*! @method ProcessMultiple */
+	OSStatus	DoProcessMultiple (					AudioUnitRenderActionFlags  &		ioActionFlags,
+													const AudioTimeStamp &				inTimeStamp,
+													UInt32								inFramesToProcess,
+													UInt32								inNumberInputBufferLists,
+													const AudioBufferList **			inInputBufferLists,
+													UInt32 								inNumberOutputBufferLists,
+													AudioBufferList **					ioOutputBufferLists);
+		
+	/*! @method ProcessBufferLists */
+	virtual OSStatus	ProcessBufferLists(			AudioUnitRenderActionFlags &		ioActionFlags,
+													const AudioBufferList &				inBuffer,
+													AudioBufferList &					outBuffer,
+													UInt32								inFramesToProcess )
+						{
+							return kAudio_UnimplementedError;
+						}
+
+	/*! @method ProcessMultipleBufferLists */
+	virtual OSStatus	ProcessMultipleBufferLists(	AudioUnitRenderActionFlags &		ioActionFlags,
+													UInt32								inFramesToProcess, 
+												    UInt32								inNumberInputBufferLists,
+												    const AudioBufferList **			inInputBufferLists,
+												    UInt32							 	inNumberOutputBufferLists,
+												    AudioBufferList **					ioOutputBufferLists)	
+						{
+							return kAudio_UnimplementedError;
+						}
+	
+	/*! @method ComplexRender */
+	virtual OSStatus	ComplexRender(				AudioUnitRenderActionFlags &		ioActionFlags, 
+													const AudioTimeStamp &				inTimeStamp, 
+													UInt32								inOutputBusNumber, 
+													UInt32								inNumberOfPackets, 
+													UInt32 *							outNumberOfPackets, 
+													AudioStreamPacketDescription *		outPacketDescriptions, 
+													AudioBufferList &					ioData, 
+													void *								outMetadata, 
+													UInt32 *							outMetadataByteSize) 
+						{	
+							return kAudio_UnimplementedError;
+						}
+
+	// Override this method if your AU processes multiple output busses completely independently --
+	// you'll want to just call Render without the NeedsToRender check.
+	// Otherwise, override Render().
+	//
+	// N.B. Implementations of this method can assume that the output's buffer list has already been
+	// prepared and access it with GetOutput(inBusNumber)->GetBufferList() instead of 
+	// GetOutput(inBusNumber)->PrepareBuffer(nFrames) -- if PrepareBuffer is called, a
+	// copy may occur after rendering.
+	/*! @method RenderBus */
+	virtual OSStatus			RenderBus(				AudioUnitRenderActionFlags &	ioActionFlags,
+														const AudioTimeStamp &			inTimeStamp,
+														UInt32							inBusNumber,
+														UInt32							inNumberFrames)
+								{
+									if (NeedsToRender(inTimeStamp))
+										return Render(ioActionFlags, inTimeStamp, inNumberFrames);
+									return noErr;	// was presumably already rendered via another bus
+								}
+
+	// N.B. For a unit with only one output bus, it can assume in its implementation of this
+	// method that the output's buffer list has already been prepared and access it with 
+	// GetOutput(0)->GetBufferList() instead of GetOutput(0)->PrepareBuffer(nFrames)
+	//  -- if PrepareBuffer is called, a copy may occur after rendering.
+	/*! @method Render */
+	virtual OSStatus			Render(					AudioUnitRenderActionFlags &	ioActionFlags,
+														const AudioTimeStamp &			inTimeStamp,
+														UInt32							inNumberFrames)
+								{
+									return noErr;
+								}
+
+								
+#pragma mark -
+#pragma mark Property Dispatch
+
+	static const Float64 kNoLastRenderedSampleTime;
+
+	// ________________________________________________________________________
+	// These are generated from DispatchGetProperty/DispatchGetPropertyInfo/DispatchSetProperty
+
+	/*! @method BusCountWritable */
+	virtual bool				BusCountWritable(		AudioUnitScope					inScope)
+								{
+									return false;
+								}
+	virtual OSStatus			SetBusCount(		AudioUnitScope					inScope,
+													UInt32							inCount);
+
+	/*! @method SetConnection */
+	virtual OSStatus			SetConnection(			const AudioUnitConnection &		inConnection);
+	
+	/*! @method SetInputCallback */
+	virtual OSStatus			SetInputCallback(		UInt32							inPropertyID,
+														AudioUnitElement 				inElement, 
+														AURenderCallback				inProc,
+														void *							inRefCon);
+
+	/*! @method GetParameterList */
+	virtual OSStatus			GetParameterList(		AudioUnitScope					inScope,
+														AudioUnitParameterID *			outParameterList,
+														UInt32 &						outNumParameters);
+															// outParameterList may be a null pointer
+
+	/*! @method GetParameterInfo */
+	virtual OSStatus			GetParameterInfo(		AudioUnitScope					inScope,
+														AudioUnitParameterID			inParameterID,
+														AudioUnitParameterInfo &		outParameterInfo);
+
+	virtual OSStatus			GetParameterHistoryInfo(AudioUnitScope					inScope,
+														AudioUnitParameterID			inParameterID,
+														Float32 &						outUpdatesPerSecond,
+														Float32 &						outHistoryDurationInSeconds);
+
+	/*! @method SaveState */
+	virtual OSStatus			SaveState(				CFPropertyListRef *				outData);
+    
+    /*! @method SaveExtendedScopes */
+	virtual void                SaveExtendedScopes(		CFMutableDataRef				outData) {};
+
+	/*! @method RestoreState */
+	virtual OSStatus			RestoreState(			CFPropertyListRef				inData);
+
+	/*! @method GetParameterValueStrings */
+	virtual OSStatus			GetParameterValueStrings(AudioUnitScope					inScope,
+														AudioUnitParameterID			inParameterID,
+														CFArrayRef *					outStrings);
+
+	/*! @method CopyClumpName */
+	virtual OSStatus			CopyClumpName(			AudioUnitScope					inScope, 
+														UInt32							inClumpID, 
+														UInt32							inDesiredNameLength,
+														CFStringRef *					outClumpName);
+
+	/*! @method GetPresets */
+	virtual OSStatus			GetPresets (			CFArrayRef * 					outData) const;
+
+		// set the default preset for the unit -> the number of the preset MUST be >= 0
+		// and the name should be valid, or the preset WON'T take
+	/*! @method SetAFactoryPresetAsCurrent */
+	bool						SetAFactoryPresetAsCurrent (const AUPreset & inPreset);
+		
+		// Called when someone sets a new, valid preset
+		// If this is a valid preset, then the subclass sets its state to that preset
+		// and returns noErr.
+		// If not a valid preset, return an error, and the pre-existing preset is restored
+	/*! @method NewFactoryPresetSet */
+	virtual OSStatus			NewFactoryPresetSet (const AUPreset & inNewFactoryPreset);
+	
+	/*! @method NewCustomPresetSet */
+	virtual OSStatus            NewCustomPresetSet (const AUPreset & inNewCustomPreset);
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+	/*! @method GetNumCustomUIComponents */
+	virtual int					GetNumCustomUIComponents ();
+
+	/*! @method GetUIComponentDescs */
+	virtual void				GetUIComponentDescs (ComponentDescription* inDescArray);
+#endif
+	
+	/*! @method CopyIconLocation */
+	virtual CFURLRef			CopyIconLocation ();
+	
+	// default is no latency, and unimplemented tail time
+	/*! @method GetLatency */
+    virtual Float64				GetLatency() {return 0.0;}
+	/*! @method GetTailTime */
+    virtual Float64				GetTailTime() {return 0;}
+	/*! @method SupportsRampAndTail */
+	virtual	bool				SupportsTail () { return false; }
+
+	/*! @method IsStreamFormatWritable */
+			bool				IsStreamFormatWritable(	AudioUnitScope					scope,
+														AudioUnitElement				element);
+	
+	/*! @method StreamFormatWritable */
+	virtual bool				StreamFormatWritable(	AudioUnitScope					scope,
+														AudioUnitElement				element) = 0;
+															// scope will always be input or output
+			
+			// pass in a pointer to get the struct, and num channel infos
+			// you can pass in NULL to just get the number
+			// a return value of 0 (the default in AUBase) means the property is not supported...
+	/*! @method SupportedNumChannels */
+	virtual UInt32				SupportedNumChannels (	const AUChannelInfo**			outInfo);
+																												
+	/*! @method ValidFormat */
+	virtual bool				ValidFormat(			AudioUnitScope					inScope,
+														AudioUnitElement				inElement,
+														const CAStreamBasicDescription & inNewFormat);
+															// Will only be called after StreamFormatWritable
+															// has succeeded.
+															// Default implementation requires canonical format:
+															// native-endian 32-bit float, any sample rate,
+															// any number of channels; override when other
+															// formats are supported.  A subclass's override can
+															// choose to always return true and trap invalid 
+															// formats in ChangeStreamFormat.
+
+
+	/*! @method FormatIsCanonical */
+			bool				FormatIsCanonical(		const CAStreamBasicDescription &format);
+
+	/*! @method MakeCanonicalFormat */
+			void				MakeCanonicalFormat(	CAStreamBasicDescription &	outDesc,
+														int							numChannels = 2);
+
+	/*! @method GetStreamFormat */
+	virtual const CAStreamBasicDescription &
+								GetStreamFormat(		AudioUnitScope					inScope,
+														AudioUnitElement				inElement);
+
+	/*! @method ChangeStreamFormat */
+	virtual	OSStatus			ChangeStreamFormat(		AudioUnitScope					inScope,
+														AudioUnitElement				inElement,
+														const CAStreamBasicDescription & inPrevFormat,
+														const CAStreamBasicDescription & inNewFormat);
+															// Will only be called after StreamFormatWritable
+															// and ValidFormat have succeeded.
+															
+	// ________________________________________________________________________
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+	/*! @method ComponentEntryDispatch */
+	static OSStatus			ComponentEntryDispatch(	ComponentParameters *			params,
+														AUBase *						This);
+#endif
+
+	// ________________________________________________________________________
+	// Methods useful for subclasses
+	
+	/*! @method GetScope */
+	AUScope &					GetScope(				AudioUnitScope					inScope)
+	{
+		if (inScope >= kNumScopes) {
+			AUScope * scope = GetScopeExtended(inScope);
+			if (!scope) COMPONENT_THROW(kAudioUnitErr_InvalidScope);
+			return *scope;
+		}
+		return mScopes[inScope];
+	}
+	
+	/*! @method GetScopeExtended */
+	virtual AUScope *			GetScopeExtended (AudioUnitScope inScope) { return NULL; }
+	
+	/*! @method GlobalScope */
+	AUScope &					GlobalScope() { return mScopes[kAudioUnitScope_Global]; }
+	/*! @method Inputs */
+	AUScope &					Inputs()	{ return mScopes[kAudioUnitScope_Input]; }
+	/*! @method Outputs */
+	AUScope &					Outputs()	{ return mScopes[kAudioUnitScope_Output]; }
+#if !CA_BASIC_AU_FEATURES
+	/*! @method Groups */
+	AUScope &					Groups()	{ return mScopes[kAudioUnitScope_Group]; }
+#endif
+	/*! @method Globals */
+	AUElement *					Globals()	{ return mScopes[kAudioUnitScope_Global].GetElement(0); }
+	
+	/*! @method SetNumberOfElements */
+	void						SetNumberOfElements(	AudioUnitScope					inScope,
+														UInt32							numElements);
+
+	/*! @method GetElement */
+	AUElement *					GetElement(				AudioUnitScope 					inScope,
+														AudioUnitElement			 	inElement)
+	{
+		return GetScope(inScope).GetElement(inElement);
+	}
+	
+	/*! @method GetIOElement */
+	AUIOElement *				GetIOElement(			AudioUnitScope 					inScope,
+														AudioUnitElement			 	inElement)
+	{
+		return GetScope(inScope).GetIOElement(inElement);
+	}
+	
+	/*! @method SafeGetElement */
+	AUElement *					SafeGetElement(			AudioUnitScope 					inScope,
+														AudioUnitElement			 	inElement)
+	{
+		return GetScope(inScope).SafeGetElement(inElement);
+	}
+
+	/*! @method GetInput */
+	AUInputElement *			GetInput(				AudioUnitElement				inElement)
+	{
+		return static_cast<AUInputElement *>(Inputs().SafeGetElement(inElement));
+	}
+	
+	/*! @method GetOutput */
+	AUOutputElement *			GetOutput(				AudioUnitElement				inElement)
+	{
+		return static_cast<AUOutputElement *>(Outputs().SafeGetElement(inElement));
+	}
+	
+#if !CA_BASIC_AU_FEATURES
+	/*! @method GetGroup */
+	AUElement *					GetGroup(				AudioUnitElement				inElement)
+	{
+		return Groups().SafeGetElement(inElement);
+	}
+#endif
+	
+	/*! @method PullInput */
+	OSStatus					PullInput(				UInt32	 					inBusNumber,
+														AudioUnitRenderActionFlags &ioActionFlags,
+														const AudioTimeStamp &		inTimeStamp,
+														UInt32						inNumberFrames)
+	{
+		AUInputElement *input = GetInput(inBusNumber);	// throws if error
+		return input->PullInput(ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames);
+	}
+
+	/*! @method GetMaxFramesPerSlice */
+	UInt32						GetMaxFramesPerSlice() const { return mMaxFramesPerSlice; }
+	/*! @method UsesFixedBlockSize */
+	bool						UsesFixedBlockSize() const { return mUsesFixedBlockSize; }
+	/*! @method SetUsesFixedBlockSize */
+	void						SetUsesFixedBlockSize(bool inUsesFixedBlockSize) { mUsesFixedBlockSize = inUsesFixedBlockSize; }
+	
+	/*! @method GetVectorUnitType */
+	static SInt32				GetVectorUnitType() { return sVectorUnitType; }
+	/*! @method HasVectorUnit */
+	static bool					HasVectorUnit() { return sVectorUnitType > 0; }
+	/*! @method HasAltivec */
+	static bool					HasAltivec() { return sVectorUnitType == kVecAltivec; }
+	/*! @method HasSSE2 */
+	static bool					HasSSE2() { return sVectorUnitType >= kVecSSE2; }
+	/*! @method HasSSE3 */
+	static bool					HasSSE3() { return sVectorUnitType >= kVecSSE3; }
+	
+	/*! @method AudioUnitAPIVersion */
+	UInt8						AudioUnitAPIVersion() const { return mAudioUnitAPIVersion; }
+	
+	/*! @method IsRenderThread */
+	bool						InRenderThread () const 
+								{
+#if TARGET_OS_MAC
+									return (mRenderThreadID ? pthread_equal (mRenderThreadID, pthread_self()) : false);
+#elif TARGET_OS_WIN32
+									return (mRenderThreadID ? mRenderThreadID == GetCurrentThreadId() : false);
+#endif
+								}
+
+	/*! @method HasInput */
+	bool						HasInput(				AudioUnitElement				inElement) {
+									AUInputElement *in = static_cast<AUInputElement *>(Inputs().GetElement(inElement));
+									return in != NULL && in->IsActive();
+								}
+									// says whether an input is connected or has a callback
+
+	/*! @method PropertyChanged */
+	virtual void				PropertyChanged(		AudioUnitPropertyID				inID,
+														AudioUnitScope					inScope, 
+														AudioUnitElement				inElement);
+
+#if !CA_NO_AU_UI_FEATURES
+	// These calls can be used to call a Host's Callbacks. The method returns -1 if the host
+	// hasn't supplied the callback. Any other result is returned by the host.
+	// As in the API contract, for a parameter's value, you specify a pointer
+	// to that data type. Specify NULL for a parameter that you are not interested
+	// as this can save work in the host.
+
+	/*! @method CallHostBeatAndTempo */
+	OSStatus	CallHostBeatAndTempo (Float64				*outCurrentBeat,  
+										Float64				*outCurrentTempo)
+	{
+		return (mHostCallbackInfo.beatAndTempoProc 
+						? (*mHostCallbackInfo.beatAndTempoProc) (mHostCallbackInfo.hostUserData, 
+																	outCurrentBeat, 
+																	outCurrentTempo)
+						: -1);
+	}
+
+	/*! @method CallHostMusicalTimeLocation */
+	OSStatus	CallHostMusicalTimeLocation (UInt32  		*outDeltaSampleOffsetToNextBeat,
+										Float32           	*outTimeSig_Numerator,
+										UInt32            	*outTimeSig_Denominator,
+										Float64           	*outCurrentMeasureDownBeat)
+	{
+		return (mHostCallbackInfo.musicalTimeLocationProc 
+						? (*mHostCallbackInfo.musicalTimeLocationProc) (mHostCallbackInfo.hostUserData,
+																			outDeltaSampleOffsetToNextBeat,
+																			outTimeSig_Numerator,
+																			outTimeSig_Denominator,
+																			outCurrentMeasureDownBeat)
+						: -1);
+	}											
+
+	/*! @method CallHostTransportState */
+	OSStatus	CallHostTransportState (Boolean 			*outIsPlaying,
+										Boolean 			*outTransportStateChanged,
+										Float64 			*outCurrentSampleInTimeLine,
+										Boolean 			*outIsCycling,
+										Float64 			*outCycleStartBeat,
+										Float64 			*outCycleEndBeat)
+	{
+		return (mHostCallbackInfo.transportStateProc 
+						? (*mHostCallbackInfo.transportStateProc) (mHostCallbackInfo.hostUserData,
+																		outIsPlaying,
+																		outTransportStateChanged,
+																		outCurrentSampleInTimeLine,
+																		outIsCycling,
+																		outCycleStartBeat,
+																		outCycleEndBeat)
+						: -1);
+	}
+#endif
+
+	char*						GetLoggingString () const;
+	
+	CAMutex*					GetMutex() { return mAUMutex; }
+
+	// ________________________________________________________________________
+	/*! @method CreateElement */
+	virtual AUElement *			CreateElement(			AudioUnitScope					scope,
+														AudioUnitElement				element);
+
+#pragma mark -
+#pragma mark AU Output Base Dispatch
+	// ________________________________________________________________________
+	// ________________________________________________________________________
+	// ________________________________________________________________________
+	// output unit methods
+	/*! @method Start */
+	virtual OSStatus	Start() { return kAudio_UnimplementedError; }
+	/*! @method Stop */
+	virtual OSStatus	Stop() { return kAudio_UnimplementedError; }
+	
+#if !CA_BASIC_AU_FEATURES
+#pragma mark -
+#pragma mark AU Music Base Dispatch
+
+#if !TARGET_OS_IPHONE
+// these methods are deprecated, so we don't include them except for compatability
+	/*! @method PrepareInstrument */
+	virtual OSStatus			PrepareInstrument(MusicDeviceInstrumentID inInstrument) { return kAudio_UnimplementedError; }
+
+	/*! @method PrepareInstrument */
+	virtual OSStatus			ReleaseInstrument(MusicDeviceInstrumentID inInstrument) { return kAudio_UnimplementedError; }
+#endif
+	
+	// ________________________________________________________________________
+	// ________________________________________________________________________
+	// ________________________________________________________________________
+	// music device/music effect methods -- incomplete
+	/*! @method MIDIEvent */
+	virtual OSStatus	MIDIEvent(		UInt32 						inStatus, 
+										UInt32 						inData1, 
+										UInt32 						inData2, 
+										UInt32 						inOffsetSampleFrame) { return kAudio_UnimplementedError; }
+
+	/*! @method SysEx */
+	virtual OSStatus	SysEx(			const UInt8 *				inData, 
+										UInt32 						inLength) { return kAudio_UnimplementedError;}
+										
+	/*! @method StartNote */
+	virtual OSStatus	StartNote(		MusicDeviceInstrumentID 	inInstrument, 
+										MusicDeviceGroupID 			inGroupID, 
+										NoteInstanceID *			outNoteInstanceID, 
+										UInt32 						inOffsetSampleFrame, 
+										const MusicDeviceNoteParams &inParams) { return kAudio_UnimplementedError; }
+
+	/*! @method StopNote */
+	virtual OSStatus	StopNote(		MusicDeviceGroupID 			inGroupID, 
+										NoteInstanceID 				inNoteInstanceID, 
+										UInt32 						inOffsetSampleFrame) { return kAudio_UnimplementedError; }
+#endif
+
+	// ________________________________________________________________________
+	// ________________________________________________________________________
+	// ________________________________________________________________________
+	
+protected:
+#pragma mark -
+#pragma mark Implementation methods
+
+	/*! @method ReallocateBuffers */
+	virtual void				ReallocateBuffers();
+									// needs to be called when mMaxFramesPerSlice changes
+	virtual void				DeallocateIOBuffers();
+		
+	/*! @method FillInParameterName */
+	static void					FillInParameterName (AudioUnitParameterInfo& ioInfo, CFStringRef inName, bool inShouldRelease)
+	{
+		ioInfo.cfNameString = inName;
+		ioInfo.flags |= kAudioUnitParameterFlag_HasCFNameString;
+		if (inShouldRelease)
+			ioInfo.flags |= kAudioUnitParameterFlag_CFNameRelease;
+		CFStringGetCString (inName, ioInfo.name, offsetof (AudioUnitParameterInfo, clumpID), kCFStringEncodingUTF8);
+	}
+	
+	static void					HasClump (AudioUnitParameterInfo& ioInfo, UInt32 inClumpID)				
+	{
+		ioInfo.clumpID = inClumpID;
+		ioInfo.flags |= kAudioUnitParameterFlag_HasClump;
+	}
+	
+	/*! @method SetMaxFramesPerSlice */
+	virtual void				SetMaxFramesPerSlice(UInt32 nFrames);
+
+	/*! @method CanSetMaxFrames */
+	virtual OSStatus			CanSetMaxFrames() const;
+	
+	/*! @method WantsRenderThreadID */
+	bool						WantsRenderThreadID () const { return mWantsRenderThreadID; }
+	
+	/*! @method SetWantsRenderThreadID */
+	void						SetWantsRenderThreadID (bool inFlag);
+	
+	/*! @method SetRenderError */
+	OSStatus					SetRenderError (OSStatus inErr)
+	{
+		if (inErr && mLastRenderError == 0) {
+			mLastRenderError = inErr;
+			PropertyChanged(kAudioUnitProperty_LastRenderError, kAudioUnitScope_Global, 0);
+		}
+		return inErr;
+	}
+	
+private:
+	/*! @method DoRenderBus */
+	// shared between Render and RenderSlice, inlined to minimize function call overhead
+	OSStatus					DoRenderBus(			AudioUnitRenderActionFlags &	ioActionFlags,
+														const AudioTimeStamp &			inTimeStamp,
+														UInt32							inBusNumber,
+														AUOutputElement *				theOutput,
+														UInt32							inNumberFrames,
+														AudioBufferList &				ioData)
+	{
+		if (ioData.mBuffers[0].mData == NULL || (theOutput->WillAllocateBuffer() && Outputs().GetNumberOfElements() > 1))
+			// will render into cache buffer
+			theOutput->PrepareBuffer(inNumberFrames);
+		else
+			// will render into caller's buffer
+			theOutput->SetBufferList(ioData);
+		OSStatus result = RenderBus(ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames);
+		if (result == noErr) {
+			if (ioData.mBuffers[0].mData == NULL) {
+				theOutput->CopyBufferListTo(ioData);
+				AUTRACE(kCATrace_AUBaseDoRenderBus, mComponentInstance, inNumberFrames, (intptr_t)theOutput->GetBufferList().mBuffers[0].mData, 0, *(UInt32 *)ioData.mBuffers[0].mData);
+			} else {
+				theOutput->CopyBufferContentsTo(ioData);
+				AUTRACE(kCATrace_AUBaseDoRenderBus, mComponentInstance, inNumberFrames, (intptr_t)theOutput->GetBufferList().mBuffers[0].mData, (intptr_t)ioData.mBuffers[0].mData, *(UInt32 *)ioData.mBuffers[0].mData);
+				theOutput->InvalidateBufferList();
+			}
+		}
+		return result;
+	}
+
+	/*! @method HasIcon */
+	bool						HasIcon ();
+
+	/*! @method ResetRenderTime */
+	void						ResetRenderTime ()
+								{
+									memset (&mCurrentRenderTime, 0, sizeof(mCurrentRenderTime));
+									mCurrentRenderTime.mSampleTime = kNoLastRenderedSampleTime;
+								}
+				
+protected:
+	/*! @method GetAudioChannelLayout */
+	virtual UInt32				GetChannelLayoutTags(	AudioUnitScope				scope,
+														AudioUnitElement 			element,
+														AudioChannelLayoutTag *		outLayoutTags);
+														
+	/*! @method GetAudioChannelLayout */
+	virtual UInt32				GetAudioChannelLayout(	AudioUnitScope				scope,
+														AudioUnitElement 			element,
+														AudioChannelLayout *		outLayoutPtr,
+														Boolean &					outWritable);
+
+	/*! @method SetAudioChannelLayout */
+	virtual OSStatus			SetAudioChannelLayout(	AudioUnitScope 				scope, 
+														AudioUnitElement 			element,
+														const AudioChannelLayout *	inLayout);
+
+	/*! @method RemoveAudioChannelLayout */
+	virtual OSStatus			RemoveAudioChannelLayout(AudioUnitScope scope, AudioUnitElement element);
+	
+	/*! @method NeedsToRender */
+	bool						NeedsToRender(			const AudioTimeStamp &		inTimeStamp)
+								{
+									bool needsToRender = fnotequal(inTimeStamp.mSampleTime, mCurrentRenderTime.mSampleTime);
+									if (needsToRender)	// only copy this if we need to render
+										mCurrentRenderTime = inTimeStamp;
+									return needsToRender;
+								}
+	
+	// Scheduled parameter implementation:
+
+	typedef std::vector<AudioUnitParameterEvent> ParameterEventList;
+
+	// Usually, you won't override this method.  You only need to call this if your DSP code
+	// is prepared to handle scheduled immediate and ramped parameter changes.
+	// Before calling this method, it is assumed you have already called PullInput() on the input busses
+	// for which the DSP code depends.  ProcessForScheduledParams() will call (potentially repeatedly)
+	// virtual method ProcessScheduledSlice() to perform the actual DSP for a given sub-division of
+	// the buffer.  The job of ProcessForScheduledParams() is to sub-divide the buffer into smaller
+	// pieces according to the scheduled times found in the ParameterEventList (usually coming 
+	// directly from a previous call to ScheduleParameter() ), setting the appropriate immediate or
+	// ramped parameter values for the corresponding scopes and elements, then calling ProcessScheduledSlice()
+	// to do the actual DSP for each of these divisions.
+	virtual OSStatus 	ProcessForScheduledParams(	ParameterEventList		&inParamList,
+															UInt32					inFramesToProcess,
+															void					*inUserData );
+	
+	//	This method is called (potentially repeatedly) by ProcessForScheduledParams()
+	//	in order to perform the actual DSP required for this portion of the entire buffer
+	//	being processed.  The entire buffer can be divided up into smaller "slices"
+	//	according to the timestamps on the scheduled parameters...
+	//
+	//	sub-classes wishing to handle scheduled parameter changes should override this method
+	//  in order to do the appropriate DSP.  AUEffectBase already overrides this for standard
+	//	effect AudioUnits.
+	virtual OSStatus			ProcessScheduledSlice(	void				*inUserData,
+														UInt32				inStartFrameInBuffer,
+														UInt32				inSliceFramesToProcess,
+														UInt32				inTotalBufferFrames ) {return noErr;};	// default impl does nothing...
+	
+	
+	/*! @method CurrentRenderTime */
+	const AudioTimeStamp &		CurrentRenderTime () const { return mCurrentRenderTime; }
+	
+	// ________________________________________________________________________
+	//	Private data members to discourage hacking in subclasses
+private:
+	struct RenderCallback {
+		RenderCallback(AURenderCallback proc, void *ref) :
+			mRenderNotify(proc),
+			mRenderNotifyRefCon(ref)
+		{ }
+		
+		AURenderCallback			mRenderNotify;
+		void *						mRenderNotifyRefCon;
+		
+		bool operator == (const RenderCallback &other) {
+			return this->mRenderNotify == other.mRenderNotify &&
+					this->mRenderNotifyRefCon == other.mRenderNotifyRefCon;
+		}
+	};
+	typedef TThreadSafeList<RenderCallback>	RenderCallbackList;
+	
+#if !CA_BASIC_AU_FEATURES
+	enum { kNumScopes = 4 };
+#else
+	enum { kNumScopes = 3 };
+#endif
+	
+	/*! @var mElementsCreated */
+	bool						mElementsCreated;
+protected:
+	/*! @var mInitialized */
+	bool						mInitialized;
+	/*! @var mHasBegunInitializing */
+	bool						mHasBegunInitializing;
+private:
+	/*! @var mAudioUnitAPIVersion */
+	UInt8						mAudioUnitAPIVersion;
+	
+	/*! @var mInitNumInputEls */
+	const UInt32				mInitNumInputEls;
+	/*! @var mInitNumOutputEls */
+	const UInt32				mInitNumOutputEls;
+#if !CA_BASIC_AU_FEATURES
+	/*! @var mInitNumGroupEls */
+	const UInt32				mInitNumGroupEls;
+#endif
+	/*! @var mScopes */
+	AUScope						mScopes[kNumScopes];
+	
+	/*! @var mRenderCallbacks */
+	RenderCallbackList			mRenderCallbacks;
+	bool						mRenderCallbacksTouched;
+	
+	/*! @var mRenderThreadID */
+#if TARGET_OS_MAC
+	pthread_t					mRenderThreadID;
+#elif TARGET_OS_WIN32
+	UInt32						mRenderThreadID;
+#endif
+	
+	/*! @var mWantsRenderThreadID */
+	bool						mWantsRenderThreadID;
+		
+	/*! @var mCurrentRenderTime */
+	AudioTimeStamp				mCurrentRenderTime;
+	
+	/*! @var mMaxFramesPerSlice */
+	UInt32						mMaxFramesPerSlice;
+	
+	/*! @var mLastRenderError */
+	OSStatus					mLastRenderError;
+	/*! @var mCurrentPreset */
+	AUPreset					mCurrentPreset;
+	
+protected:
+	/*! @var mUsesFixedBlockSize */
+	bool						mUsesFixedBlockSize;
+	
+	struct PropertyListener {
+		AudioUnitPropertyID				propertyID;
+		AudioUnitPropertyListenerProc	listenerProc;
+		void *							listenerRefCon;
+	};
+	typedef std::vector<PropertyListener>	PropertyListeners;
+
+	/*! @var mParamList */
+	ParameterEventList			mParamList;
+	/*! @var mPropertyListeners */
+	PropertyListeners			mPropertyListeners;
+	
+	/*! @var mBuffersAllocated */
+	bool						mBuffersAllocated;
+	
+	/*! @var mLogString */
+	// if this is NOT null, it will contain identifying info about this AU.
+	char*						mLogString;
+
+	/*! @var mNickName */
+	CFStringRef					mNickName;
+
+	/*! @var mAUMutex */
+	CAMutex *					mAUMutex;
+
+private:
+	/*! @var sVectorUnitType */
+	static SInt32	sVectorUnitType;
+
+#if !CA_NO_AU_HOST_CALLBACKS
+protected:
+	/*! @var mHostCallbackInfo */
+	HostCallbackInfo 			mHostCallbackInfo;
+
+#endif
+#if !CA_NO_AU_UI_FEATURES
+protected:
+	/*! @var mContextInfo */
+	CFStringRef					mContextName;
+#endif
+};
+
+inline 	OSStatus	AUInputElement::PullInputWithBufferList(	
+												AudioUnitRenderActionFlags &  	ioActionFlags,
+												const AudioTimeStamp &			inTimeStamp,
+												AudioUnitElement				inElement,
+												UInt32							nFrames,
+												AudioBufferList *				inBufferList)
+{
+	OSStatus theResult;
+	
+	if (HasConnection()) {
+			// only support connections for V2 audio units
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+		if (mConnRenderProc != NULL)
+			theResult = reinterpret_cast<AudioUnitRenderProc>(mConnRenderProc)(
+							mConnInstanceStorage, &ioActionFlags, &inTimeStamp, mConnection.sourceOutputNumber, nFrames, inBufferList);
+		else
+#endif
+			theResult = AudioUnitRender(
+							mConnection.sourceAudioUnit, &ioActionFlags, &inTimeStamp, mConnection.sourceOutputNumber, nFrames, inBufferList);
+	} else {
+		// kFromCallback:
+			theResult = (mInputProc)(
+							mInputProcRefCon, &ioActionFlags, &inTimeStamp, inElement, nFrames, inBufferList);
+	}
+	
+	if (mInputType == kNoInput)	// defense: the guy upstream could have disconnected
+								// it's a horrible thing to do, but may happen!
+		return kAudioUnitErr_NoConnection;
+
+
+	return theResult;
+}
+
+#endif // __AUBase_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,151 @@
+/*
+     File: AUInputElement.cpp
+ Abstract: AUInputElement.h
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#include "AUBase.h"
+
+inline bool	HasGoodBufferPointers(const AudioBufferList &abl, UInt32 nBytes)
+{
+	const AudioBuffer *buf = abl.mBuffers;
+	for (UInt32 i = abl.mNumberBuffers; i--;++buf) {
+		if (buf->mData == NULL || buf->mDataByteSize < nBytes)
+			return false;
+	}
+	return true;
+}
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//	AUInputElement::AUInputElement
+//
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+AUInputElement::AUInputElement(AUBase *audioUnit) :
+	AUIOElement(audioUnit),
+	mInputType(kNoInput)
+{
+}
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//	AUInputElement::SetConnection
+//
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+void	AUInputElement::SetConnection(const AudioUnitConnection &conn)
+{
+	if (conn.sourceAudioUnit == 0) {
+		Disconnect();
+		return;
+	}	
+	
+	mInputType = kFromConnection;
+	mConnection = conn;
+	AllocateBuffer();
+
+	mConnInstanceStorage = NULL;
+
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+	mConnRenderProc = NULL;
+	UInt32 size = sizeof(AudioUnitRenderProc);
+	OSStatus result = AudioUnitGetProperty(	conn.sourceAudioUnit,
+							kAudioUnitProperty_FastDispatch,
+							kAudioUnitScope_Global,
+							kAudioUnitRenderSelect,
+							&mConnRenderProc,
+							&size);
+	if (result == noErr)
+		mConnInstanceStorage = CMgr_GetComponentInstanceStorage (conn.sourceAudioUnit);
+	else
+		mConnRenderProc = NULL;
+#endif
+}
+
+void	AUInputElement::Disconnect()
+{
+	mInputType = kNoInput;
+	mIOBuffer.Deallocate();
+}
+
+
+
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//	AUInputElement::SetInputCallback
+//
+//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+void	AUInputElement::SetInputCallback(AURenderCallback proc, void *refCon)
+{
+	if (proc == NULL)
+		Disconnect();
+	else {
+		mInputType = kFromCallback;
+		mInputProc = proc;
+		mInputProcRefCon = refCon;
+		AllocateBuffer();
+	}
+}
+
+OSStatus	AUInputElement::SetStreamFormat(const CAStreamBasicDescription &fmt)
+{
+	OSStatus err = AUIOElement::SetStreamFormat(fmt);
+	if (err == AUBase::noErr)
+		AllocateBuffer();
+	return err;
+}
+
+OSStatus		AUInputElement::PullInput(	AudioUnitRenderActionFlags &  	ioActionFlags,
+											const AudioTimeStamp &			inTimeStamp,
+											AudioUnitElement				inElement,
+											UInt32							nFrames)
+{	
+	if (!IsActive())
+		return kAudioUnitErr_NoConnection;
+		
+	AudioBufferList *pullBuffer;
+	
+	if (HasConnection() || !WillAllocateBuffer())
+		pullBuffer = &mIOBuffer.PrepareNullBuffer(mStreamFormat, nFrames);
+	else
+		pullBuffer = &mIOBuffer.PrepareBuffer(mStreamFormat, nFrames);
+	
+	return PullInputWithBufferList (ioActionFlags, inTimeStamp, inElement, nFrames, pullBuffer);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.h	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,119 @@
+/*
+     File: AUInputElement.h
+ Abstract: Part of CoreAudio Utility Classes
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#ifndef __AUInput_h__
+#define __AUInput_h__
+
+#include "AUScopeElement.h"
+#include "AUBuffer.h"
+
+/*! @class AUInputElement */
+class AUInputElement : public AUIOElement {
+public:
+	
+	/*! @ctor AUInputElement */
+						AUInputElement(AUBase *audioUnit);
+	/*! @dtor ~AUInputElement */
+	virtual				~AUInputElement() { }
+
+	// AUElement override
+	/*! @method SetStreamFormat */
+	virtual OSStatus	SetStreamFormat(const CAStreamBasicDescription &desc);
+	/*! @method NeedsBufferSpace */
+	virtual bool		NeedsBufferSpace() const { return IsCallback(); }
+
+	/*! @method SetConnection */
+	void				SetConnection(const AudioUnitConnection &conn);
+	/*! @method SetInputCallback */
+	void				SetInputCallback(AURenderCallback proc, void *refCon);
+
+	/*! @method IsActive */
+	bool				IsActive() const { return mInputType != kNoInput; }
+	/*! @method IsCallback */
+	bool				IsCallback() const { return mInputType == kFromCallback; }
+	/*! @method HasConnection */
+	bool				HasConnection() const { return mInputType == kFromConnection; }
+
+	/*! @method PullInput */
+	OSStatus			PullInput(	AudioUnitRenderActionFlags &  	ioActionFlags,
+									const AudioTimeStamp &			inTimeStamp,
+									AudioUnitElement				inElement,
+									UInt32							inNumberFrames);
+
+	/*! @method PullInputWithBufferList */
+	OSStatus			PullInputWithBufferList(	AudioUnitRenderActionFlags &  	ioActionFlags,
+													const AudioTimeStamp &			inTimeStamp,
+													AudioUnitElement				inElement,
+													UInt32							nFrames,
+													AudioBufferList *				inBufferList);
+protected:
+	/*! @method Disconnect */
+	void				Disconnect();
+
+	enum EInputType { kNoInput, kFromConnection, kFromCallback };
+
+	/*! @var mInputType */
+	EInputType					mInputType;
+
+	// if from callback:
+	/*! @var mInputProc */
+	AURenderCallback			mInputProc;
+	/*! @var mInputProcRefCon */
+	void *						mInputProcRefCon;
+	
+	// if from connection:
+	/*! @var mConnection */
+	AudioUnitConnection			mConnection;
+#if !CA_USE_AUDIO_PLUGIN_ONLY
+	/*! @var mConnRenderProc */
+	AudioUnitRenderProc			mConnRenderProc;
+#endif
+	/*! @var mConnInstanceStorage */
+	void *						mConnInstanceStorage;		// for the input component
+};
+
+
+#endif // __AUInput_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,62 @@
+/*
+     File: AUOutputElement.cpp
+ Abstract: AUOutputElement.h
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#include "AUOutputElement.h"
+#include "AUBase.h"
+
+AUOutputElement::AUOutputElement(AUBase *audioUnit) : 
+	AUIOElement(audioUnit)
+{
+	AllocateBuffer();
+}
+
+OSStatus	AUOutputElement::SetStreamFormat(const CAStreamBasicDescription &desc)
+{
+	OSStatus result = AUIOElement::SetStreamFormat(desc);	// inherited
+	if (result == AUBase::noErr)
+		AllocateBuffer();
+	return result;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.h	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,66 @@
+/*
+     File: AUOutputElement.h
+ Abstract: Part of CoreAudio Utility Classes
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#ifndef __AUOutput_h__
+#define __AUOutput_h__
+
+#include "AUScopeElement.h"
+#include "AUBuffer.h"
+
+	/*! @class AUOutputElement */
+class AUOutputElement : public AUIOElement {
+public:
+	/*! @ctor AUOutputElement */
+						AUOutputElement(AUBase *audioUnit);
+
+	// AUElement override
+	/*! @method SetStreamFormat */
+	virtual OSStatus	SetStreamFormat(const CAStreamBasicDescription &desc);
+	/*! @method NeedsBufferSpace */
+	virtual bool		NeedsBufferSpace() const { return true; }
+};
+
+#endif // __AUOutput_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,669 @@
+/*
+     File: AUPlugInDispatch.cpp
+ Abstract: AUPlugInDispatch.h
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#include "AUPlugInDispatch.h"
+#include "CAXException.h"
+#include "ComponentBase.h"
+#include "AUBase.h"
+
+#define ACPI ((AudioComponentPlugInInstance *)self)
+#define AUI	((AUBase *)&ACPI->mInstanceStorage)
+
+#define AUI_LOCK CAMutex::Locker auLock(AUI->GetMutex());
+
+// ------------------------------------------------------------------------------------------------
+static OSStatus AUMethodInitialize(void *self)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->DoInitialize();
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodUninitialize(void *self)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		AUI->DoCleanup();
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodGetPropertyInfo(void *self, AudioUnitPropertyID prop, AudioUnitScope scope, AudioUnitElement elem, UInt32 *outDataSize, Boolean *outWritable)
+{
+	OSStatus result = noErr;
+	try {
+		UInt32 dataSize = 0;        // 13517289 GetPropetyInfo was returning an uninitialized value when there is an error. This is a problem for auval.
+		Boolean writable = false;
+		
+		AUI_LOCK
+		result = AUI->DispatchGetPropertyInfo(prop, scope, elem, dataSize, writable);
+		if (outDataSize != NULL)
+			*outDataSize = dataSize;
+		if (outWritable != NULL)
+			*outWritable = writable;
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodGetProperty(void *self, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, void *outData, UInt32 *ioDataSize)
+{
+	OSStatus result = noErr;
+	try {
+		UInt32 actualPropertySize, clientBufferSize;
+		Boolean writable;
+		char *tempBuffer;
+		void *destBuffer;
+		
+		AUI_LOCK
+		if (ioDataSize == NULL) {
+			ca_debug_string("AudioUnitGetProperty: null size pointer");
+			result = kAudio_ParamError;
+			goto finishGetProperty;
+		}
+		if (outData == NULL) {
+			UInt32 dataSize;
+			
+			result = AUI->DispatchGetPropertyInfo(inID, inScope, inElement, dataSize, writable);
+			*ioDataSize = dataSize;
+			goto finishGetProperty;
+		}
+		
+		clientBufferSize = *ioDataSize;
+		if (clientBufferSize == 0)
+		{
+			ca_debug_string("AudioUnitGetProperty: *ioDataSize == 0 on entry");
+			// $$$ or should we allow this as a shortcut for finding the size?
+			result = kAudio_ParamError;
+			goto finishGetProperty;
+		}
+		
+		result = AUI->DispatchGetPropertyInfo(inID, inScope, inElement, actualPropertySize, writable);
+		if (result != noErr) 
+			goto finishGetProperty;
+		
+		if (clientBufferSize < actualPropertySize) 
+		{
+			tempBuffer = new char[actualPropertySize];
+			destBuffer = tempBuffer;
+		} else {
+			tempBuffer = NULL;
+			destBuffer = outData;
+		}
+		
+		result = AUI->DispatchGetProperty(inID, inScope, inElement, destBuffer);
+		
+		if (result == noErr) {
+			if (clientBufferSize < actualPropertySize && tempBuffer != NULL)
+			{
+				memcpy(outData, tempBuffer, clientBufferSize);
+				delete[] tempBuffer;
+				// ioDataSize remains correct, the number of bytes we wrote
+			} else
+				*ioDataSize = actualPropertySize;
+		} else
+			*ioDataSize = 0;
+	}
+	COMPONENT_CATCH
+finishGetProperty:
+	return result;
+}
+
+static OSStatus AUMethodSetProperty(void *self, AudioUnitPropertyID inID, AudioUnitScope inScope, AudioUnitElement inElement, const void *inData, UInt32 inDataSize)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		if (inData && inDataSize)
+			result = AUI->DispatchSetProperty(inID, inScope, inElement, inData, inDataSize);
+		else {
+			if (inData == NULL && inDataSize == 0) {
+				result = AUI->DispatchRemovePropertyValue(inID, inScope, inElement);
+			} else {
+				if (inData == NULL) {
+					ca_debug_string("AudioUnitSetProperty: inData == NULL");
+					result = kAudio_ParamError;
+					goto finishSetProperty;
+				}
+
+				if (inDataSize == 0) {
+					ca_debug_string("AudioUnitSetProperty: inDataSize == 0");
+					result = kAudio_ParamError;
+					goto finishSetProperty;
+				}
+			}
+		}
+	}
+	COMPONENT_CATCH
+finishSetProperty:
+	return result;
+}
+
+static OSStatus AUMethodAddPropertyListener(void *self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc, void *userData)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->AddPropertyListener(prop, proc, userData);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodRemovePropertyListener(void *self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->RemovePropertyListener(prop, proc, NULL, false);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodRemovePropertyListenerWithUserData(void *self, AudioUnitPropertyID prop, AudioUnitPropertyListenerProc proc, void *userData)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->RemovePropertyListener(prop, proc, userData, true);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodAddRenderNotify(void *self, AURenderCallback proc, void *userData)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->SetRenderNotification(proc, userData);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodRemoveRenderNotify(void *self, AURenderCallback proc, void *userData)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->RemoveRenderNotification(proc, userData);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodGetParameter(void *self, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement elem, AudioUnitParameterValue *value)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = (value == NULL ? kAudio_ParamError : AUI->GetParameter(param, scope, elem, *value));
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodSetParameter(void *self, AudioUnitParameterID param, AudioUnitScope scope, AudioUnitElement elem, AudioUnitParameterValue value, UInt32 bufferOffset)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a (potentially) realtime method; no lock
+		result = AUI->SetParameter(param, scope, elem, value, bufferOffset);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodScheduleParameters(void *self, const AudioUnitParameterEvent *events, UInt32 numEvents)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a (potentially) realtime method; no lock
+		result = AUI->ScheduleParameter(events, numEvents);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodRender(void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberFrames, AudioBufferList *ioData)
+{
+	OSStatus result = noErr;
+
+#if !TARGET_OS_IPHONE
+	try {
+#endif
+		// this is a processing method; no lock
+		AudioUnitRenderActionFlags tempFlags;
+		
+		if (inTimeStamp == NULL || ioData == NULL)
+			result = kAudio_ParamError;
+		else {
+			if (ioActionFlags == NULL) {
+				tempFlags = 0;
+				ioActionFlags = &tempFlags;
+			}
+			result = AUI->DoRender(*ioActionFlags, *inTimeStamp, inOutputBusNumber, inNumberFrames, *ioData);
+		}
+
+#if !TARGET_OS_IPHONE
+	}
+	COMPONENT_CATCH
+#endif
+
+	return result;
+}
+
+static OSStatus AUMethodComplexRender(void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inOutputBusNumber, UInt32 inNumberOfPackets, UInt32 *outNumberOfPackets, AudioStreamPacketDescription *outPacketDescriptions, AudioBufferList *ioData, void *outMetadata, UInt32 *outMetadataByteSize)
+{
+	OSStatus result = noErr;
+
+#if !TARGET_OS_IPHONE
+	try {
+#endif
+		// this is a processing method; no lock
+		AudioUnitRenderActionFlags tempFlags;
+		
+		if (inTimeStamp == NULL || ioData == NULL)
+			result = kAudio_ParamError;
+		else {
+			if (ioActionFlags == NULL) {
+				tempFlags = 0;
+				ioActionFlags = &tempFlags;
+			}
+			result = AUI->ComplexRender(*ioActionFlags, *inTimeStamp, inOutputBusNumber, inNumberOfPackets, outNumberOfPackets, outPacketDescriptions, *ioData, outMetadata, outMetadataByteSize);
+		}
+
+#if !TARGET_OS_IPHONE
+	}
+	COMPONENT_CATCH
+#endif
+
+	return result;
+}
+
+static OSStatus AUMethodReset(void *self, AudioUnitScope scope, AudioUnitElement elem)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->Reset(scope, elem);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodProcess (void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, AudioBufferList *ioData)
+{
+	OSStatus result = noErr;
+
+#if !TARGET_OS_IPHONE
+	try {
+#endif
+		// this is a processing method; no lock
+		bool doParamCheck = true;
+
+		AudioUnitRenderActionFlags tempFlags;
+
+		if (ioActionFlags == NULL) {
+			tempFlags = 0;
+			ioActionFlags = &tempFlags;
+		} else {
+			if (*ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)
+				doParamCheck = false;
+		}
+		
+		if (doParamCheck && (inTimeStamp == NULL || ioData == NULL))
+			result = kAudio_ParamError;
+		else {
+			result = AUI->DoProcess(*ioActionFlags, *inTimeStamp, inNumberFrames, *ioData);
+		}
+
+#if !TARGET_OS_IPHONE
+	}
+	COMPONENT_CATCH
+#endif
+
+	return result;
+}
+
+static OSStatus AUMethodProcessMultiple (void *self, AudioUnitRenderActionFlags *ioActionFlags, const AudioTimeStamp *inTimeStamp, UInt32 inNumberFrames, UInt32 inNumberInputBufferLists, const AudioBufferList **inInputBufferLists, UInt32 inNumberOutputBufferLists, AudioBufferList **ioOutputBufferLists)
+{
+	OSStatus result = noErr;
+	
+#if !TARGET_OS_IPHONE
+	try {
+#endif
+		// this is a processing method; no lock
+		bool doParamCheck = true;
+		
+		AudioUnitRenderActionFlags tempFlags;
+		
+		if (ioActionFlags == NULL) {
+			tempFlags = 0;
+			ioActionFlags = &tempFlags;
+		} else {
+			if (*ioActionFlags & (1 << 9)/*kAudioUnitRenderAction_DoNotCheckRenderArgs*/)
+				doParamCheck = false;
+		}
+
+		if (doParamCheck && (inTimeStamp == NULL || inInputBufferLists == NULL || ioOutputBufferLists == NULL))
+			result = kAudio_ParamError;
+		else {
+			result = AUI->DoProcessMultiple(*ioActionFlags, *inTimeStamp, inNumberFrames, inNumberInputBufferLists, inInputBufferLists, inNumberOutputBufferLists, ioOutputBufferLists);
+		}
+		
+#if !TARGET_OS_IPHONE
+	}
+	COMPONENT_CATCH
+#endif
+
+	return result;
+}
+// ------------------------------------------------------------------------------------------------
+
+static OSStatus AUMethodStart(void *self)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->Start();
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodStop(void *self)
+{
+	OSStatus result = noErr;
+	try {
+		AUI_LOCK
+		result = AUI->Stop();
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+// ------------------------------------------------------------------------------------------------
+
+#if !CA_BASIC_AU_FEATURES
+// I don't know what I'm doing here; conflicts with the multiple inheritence in MusicDeviceBase.
+static OSStatus AUMethodMIDIEvent(void *self, UInt32 inStatus, UInt32 inData1, UInt32 inData2, UInt32 inOffsetSampleFrame)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a potential render-time method; no lock
+		result = AUI->MIDIEvent(inStatus, inData1, inData2, inOffsetSampleFrame);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodSysEx(void *self, const UInt8 *inData, UInt32 inLength)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a potential render-time method; no lock
+		result = AUI->SysEx(inData, inLength);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodStartNote(void *self, MusicDeviceInstrumentID inInstrument, MusicDeviceGroupID inGroupID, NoteInstanceID *outNoteInstanceID, UInt32 inOffsetSampleFrame, const MusicDeviceNoteParams *inParams)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a potential render-time method; no lock
+		if (inParams == NULL || outNoteInstanceID == NULL) 
+			result = kAudio_ParamError;
+		else
+			result = AUI->StartNote(inInstrument, inGroupID, outNoteInstanceID, inOffsetSampleFrame, *inParams);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodStopNote(void *self, MusicDeviceGroupID inGroupID, NoteInstanceID inNoteInstanceID, UInt32 inOffsetSampleFrame)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a potential render-time method; no lock
+		result = AUI->StopNote(inGroupID, inNoteInstanceID, inOffsetSampleFrame);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+#if !TARGET_OS_IPHONE
+static OSStatus AUMethodPrepareInstrument (void *self, MusicDeviceInstrumentID inInstrument)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a potential render-time method; no lock
+		result = AUI->PrepareInstrument(inInstrument);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+
+static OSStatus AUMethodReleaseInstrument (void *self, MusicDeviceInstrumentID inInstrument)
+{
+	OSStatus result = noErr;
+	try {
+		// this is a potential render-time method; no lock
+		result = AUI->ReleaseInstrument(inInstrument);
+	}
+	COMPONENT_CATCH
+	return result;
+}
+#endif // TARGET_OS_IPHONE
+#endif // CA_BASIC_AU_FEATURES
+
+
+//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+#pragma mark -
+#pragma mark Lookup Methods
+
+AudioComponentMethod AUBaseLookup::Lookup (SInt16 selector)
+{
+	switch (selector) {
+		case kAudioUnitInitializeSelect:		return (AudioComponentMethod)AUMethodInitialize;
+		case kAudioUnitUninitializeSelect:		return (AudioComponentMethod)AUMethodUninitialize;
+		case kAudioUnitGetPropertyInfoSelect:	return (AudioComponentMethod)AUMethodGetPropertyInfo;
+		case kAudioUnitGetPropertySelect:		return (AudioComponentMethod)AUMethodGetProperty;
+		case kAudioUnitSetPropertySelect:		return (AudioComponentMethod)AUMethodSetProperty;
+		case kAudioUnitAddPropertyListenerSelect:return (AudioComponentMethod)AUMethodAddPropertyListener;
+		case kAudioUnitRemovePropertyListenerSelect:
+												return (AudioComponentMethod)AUMethodRemovePropertyListener;
+		case kAudioUnitRemovePropertyListenerWithUserDataSelect:
+												return (AudioComponentMethod)AUMethodRemovePropertyListenerWithUserData;
+		case kAudioUnitAddRenderNotifySelect:	return (AudioComponentMethod)AUMethodAddRenderNotify;
+		case kAudioUnitRemoveRenderNotifySelect:return (AudioComponentMethod)AUMethodRemoveRenderNotify;
+		case kAudioUnitGetParameterSelect:		return (AudioComponentMethod)AUMethodGetParameter;
+		case kAudioUnitSetParameterSelect:		return (AudioComponentMethod)AUMethodSetParameter;
+		case kAudioUnitScheduleParametersSelect:return (AudioComponentMethod)AUMethodScheduleParameters;
+		case kAudioUnitRenderSelect:			return (AudioComponentMethod)AUMethodRender;
+		case kAudioUnitResetSelect:				return (AudioComponentMethod)AUMethodReset;
+		default:
+			break;
+	}
+	return NULL;
+}
+
+AudioComponentMethod AUOutputLookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+	if (method) return method;
+
+	switch (selector) {
+		case kAudioOutputUnitStartSelect:	return (AudioComponentMethod)AUMethodStart;
+		case kAudioOutputUnitStopSelect:	return (AudioComponentMethod)AUMethodStop;
+		default:
+			break;
+	}
+	return NULL;
+}
+
+AudioComponentMethod AUComplexOutputLookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+	if (method) return method;
+	
+	method = AUOutputLookup::Lookup(selector);
+	if (method) return method;
+	
+	if (selector == kAudioUnitComplexRenderSelect)
+		return (AudioComponentMethod)AUMethodComplexRender;
+	return NULL;
+}
+
+AudioComponentMethod AUBaseProcessLookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+	if (method) return method;
+	
+	if (selector == kAudioUnitProcessSelect)
+		return (AudioComponentMethod)AUMethodProcess;
+	
+	return NULL;
+}
+
+AudioComponentMethod AUBaseProcessMultipleLookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+	if (method) return method;
+    
+	if (selector == kAudioUnitProcessMultipleSelect)
+		return (AudioComponentMethod)AUMethodProcessMultiple;
+	
+	return NULL;
+}
+
+AudioComponentMethod AUBaseProcessAndMultipleLookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+	if (method) return method;
+
+	method = AUBaseProcessMultipleLookup::Lookup(selector);
+	if (method) return method;
+    
+	method = AUBaseProcessLookup::Lookup(selector);
+	if (method) return method;
+
+	return NULL;
+}
+
+#if !CA_BASIC_AU_FEATURES
+inline AudioComponentMethod MIDI_Lookup (SInt16 selector)
+{
+	switch (selector) {
+		case kMusicDeviceMIDIEventSelect:	return (AudioComponentMethod)AUMethodMIDIEvent;
+		case kMusicDeviceSysExSelect:		return (AudioComponentMethod)AUMethodSysEx;
+		default:
+			break;
+	}
+	return NULL;
+}
+
+AudioComponentMethod AUMIDILookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+	if (method) return method;
+	
+	return MIDI_Lookup(selector);
+}
+
+AudioComponentMethod AUMIDIProcessLookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseProcessLookup::Lookup(selector);
+	if (method) return method;
+	
+	return MIDI_Lookup(selector);
+}
+
+AudioComponentMethod AUMusicLookup::Lookup (SInt16 selector)
+{
+	AudioComponentMethod method = AUBaseLookup::Lookup(selector);
+	if (method) return method;
+
+	switch (selector) {
+		case kMusicDeviceStartNoteSelect:	return (AudioComponentMethod)AUMethodStartNote;
+		case kMusicDeviceStopNoteSelect:	return (AudioComponentMethod)AUMethodStopNote;
+#if !TARGET_OS_IPHONE
+		case kMusicDevicePrepareInstrumentSelect:	return (AudioComponentMethod)AUMethodPrepareInstrument;
+		case kMusicDeviceReleaseInstrumentSelect:	return (AudioComponentMethod)AUMethodReleaseInstrument;
+#endif
+		default:		
+			break;
+	}
+	return MIDI_Lookup (selector);
+}
+
+AudioComponentMethod AUAuxBaseLookup::Lookup (SInt16 selector)
+{
+	switch (selector) {
+		case kAudioUnitGetPropertyInfoSelect:	return (AudioComponentMethod)AUMethodGetPropertyInfo;
+		case kAudioUnitGetPropertySelect:		return (AudioComponentMethod)AUMethodGetProperty;
+		case kAudioUnitSetPropertySelect:		return (AudioComponentMethod)AUMethodSetProperty;
+            
+		case kAudioUnitGetParameterSelect:		return (AudioComponentMethod)AUMethodGetParameter;
+		case kAudioUnitSetParameterSelect:		return (AudioComponentMethod)AUMethodSetParameter;
+            
+		default:
+			break;
+	}
+	return NULL;
+}
+#endif
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.h	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,144 @@
+/*
+     File: AUPlugInDispatch.h
+ Abstract: Part of CoreAudio Utility Classes
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#ifndef __AUPlugInBase_h__
+#define __AUPlugInBase_h__
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+	#include <AudioUnit/AudioComponent.h>
+	#if !CA_BASIC_AU_FEATURES
+		#include <AudioUnit/MusicDevice.h>
+	#endif
+#else
+	#include "AudioComponent.h"
+	#include "MusicDevice.h"
+#endif
+
+#include "ComponentBase.h"
+
+struct AUBaseLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUBaseFactory : public APFactory<AUBaseLookup, Implementor>
+{
+};
+
+struct AUOutputLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUOutputBaseFactory : public APFactory<AUOutputLookup, Implementor>
+{
+};
+
+struct AUComplexOutputLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUOutputComplexBaseFactory : public APFactory<AUComplexOutputLookup, Implementor>
+{
+};
+
+struct AUBaseProcessLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUBaseProcessFactory : public APFactory<AUBaseProcessLookup, Implementor>
+{
+};
+
+struct AUBaseProcessMultipleLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUBaseProcessMultipleFactory : public APFactory<AUBaseProcessMultipleLookup, Implementor>
+{
+};
+
+struct AUBaseProcessAndMultipleLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUBaseProcessAndMultipleFactory : public APFactory<AUBaseProcessAndMultipleLookup, Implementor>
+{
+};
+
+#if !CA_BASIC_AU_FEATURES
+struct AUMIDILookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUMIDIEffectFactory : public APFactory<AUMIDILookup, Implementor>
+{
+};
+
+struct AUMIDIProcessLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUMIDIProcessFactory : public APFactory<AUMIDIProcessLookup, Implementor>
+{
+};
+
+struct AUMusicLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUMusicDeviceFactory : public APFactory<AUMusicLookup, Implementor>
+{
+};
+
+struct AUAuxBaseLookup {
+	static AudioComponentMethod Lookup (SInt16 selector);
+};
+template <class Implementor>
+class AUAuxBaseFactory : public APFactory<AUAuxBaseLookup, Implementor>
+{
+};
+#endif // CA_BASIC_AU_FEATURES
+
+#endif // __AUPlugInBase_h__
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,565 @@
+/*
+     File: AUScopeElement.cpp
+ Abstract: AUScopeElement.h
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#include "AUScopeElement.h"
+#include "AUBase.h"
+
+//_____________________________________________________________________________
+//
+//	By default, parameterIDs may be arbitrarily spaced, and an STL map
+//  will be used for access.  Calling UseIndexedParameters() will
+//	instead use an STL vector for faster indexed access.
+//	This assumes the paramIDs are numbered 0.....inNumberOfParameters-1
+//	Call this before defining/adding any parameters with SetParameter()
+//
+void	AUElement::UseIndexedParameters(int inNumberOfParameters)
+{
+	mIndexedParameters.resize (inNumberOfParameters);	
+	mUseIndexedParameters = true;
+}
+
+//_____________________________________________________________________________
+//
+//	Helper method.
+//	returns the ParameterMapEvent object associated with the paramID
+//
+inline ParameterMapEvent&	AUElement::GetParamEvent(AudioUnitParameterID paramID)
+{
+	ParameterMapEvent *event;
+	
+	if(mUseIndexedParameters)
+	{
+		if(paramID >= mIndexedParameters.size() )
+			COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+		
+		event = &mIndexedParameters[paramID];
+	}
+	else
+	{
+		ParameterMap::iterator i = mParameters.find(paramID);
+		if (i == mParameters.end())
+			COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+			
+		event = &(*i).second;
+	}
+	
+	return *event;
+}
+
+//_____________________________________________________________________________
+//
+//	Helper method.
+//	returns whether the specified paramID is known to the element
+//
+bool		AUElement::HasParameterID (AudioUnitParameterID paramID) const
+{	
+	if(mUseIndexedParameters)
+	{
+		if(paramID >= mIndexedParameters.size() )
+			return false;
+		
+		return true;
+	}
+	
+	ParameterMap::const_iterator i = mParameters.find(paramID);
+	if (i == mParameters.end())
+		return false;
+		
+	return true;
+}
+
+//_____________________________________________________________________________
+//
+//	caller assumes that this is actually an immediate parameter
+//
+AudioUnitParameterValue		AUElement::GetParameter(AudioUnitParameterID paramID)
+{
+	ParameterMapEvent &event = GetParamEvent(paramID);
+	
+	return event.GetValue();
+}
+
+
+//_____________________________________________________________________________
+//
+void			AUElement::GetRampSliceStartEnd(	AudioUnitParameterID		paramID,
+													AudioUnitParameterValue &	outStartValue,
+													AudioUnitParameterValue &	outEndValue,
+													AudioUnitParameterValue &	outValuePerFrameDelta )
+
+{
+	ParameterMapEvent &event = GetParamEvent(paramID);
+		
+	// works even if the value is constant (immediate parameter value)
+	event.GetRampSliceStartEnd(outStartValue, outEndValue, outValuePerFrameDelta );
+}
+
+//_____________________________________________________________________________
+//
+AudioUnitParameterValue			AUElement::GetEndValue(	AudioUnitParameterID		paramID)
+
+{
+	ParameterMapEvent &event = GetParamEvent(paramID);
+		
+	// works even if the value is constant (immediate parameter value)
+	return event.GetEndValue();
+}
+
+//_____________________________________________________________________________
+//
+void			AUElement::SetParameter(AudioUnitParameterID paramID, AudioUnitParameterValue inValue, bool okWhenInitialized)
+{
+	if(mUseIndexedParameters)
+	{
+		ParameterMapEvent &event = GetParamEvent(paramID);
+		event.SetValue(inValue);
+	}
+	else
+	{
+		ParameterMap::iterator i = mParameters.find(paramID);
+	
+		if (i == mParameters.end())
+		{
+			if (mAudioUnit->IsInitialized() && !okWhenInitialized) {
+				// The AU should not be creating new parameters once initialized.
+				// If a client tries to set an undefined parameter, we could throw as follows, 
+				// but this might cause a regression. So it is better to just fail silently.
+				// COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+#if DEBUG
+				fprintf(stderr, "WARNING: %s SetParameter for undefined param ID %d while initialized. Ignoring..\n", 
+								mAudioUnit->GetLoggingString(), (int)paramID);
+#endif
+			} else {
+				// create new entry in map for the paramID (only happens first time)
+				ParameterMapEvent event(inValue);		
+				mParameters[paramID] = event;
+			}
+		}
+		else
+		{
+			// paramID already exists in map so simply change its value
+			ParameterMapEvent &event = (*i).second;
+			event.SetValue(inValue);
+		}
+	}
+}
+
+//_____________________________________________________________________________
+//
+void			AUElement::SetScheduledEvent(	AudioUnitParameterID 			paramID,
+												const AudioUnitParameterEvent 	&inEvent,
+												UInt32 							inSliceOffsetInBuffer,
+												UInt32							inSliceDurationFrames,
+												bool							okWhenInitialized )
+{
+	if(mUseIndexedParameters)
+	{
+		ParameterMapEvent &event = GetParamEvent(paramID);
+		event.SetScheduledEvent(inEvent, inSliceOffsetInBuffer, inSliceDurationFrames );
+	}
+	else
+	{
+		ParameterMap::iterator i = mParameters.find(paramID);
+	
+		if (i == mParameters.end())
+		{
+			if (mAudioUnit->IsInitialized() && !okWhenInitialized) {
+				// The AU should not be creating new parameters once initialized.
+				// If a client tries to set an undefined parameter, we could throw as follows, 
+				// but this might cause a regression. So it is better to just fail silently.
+				// COMPONENT_THROW(kAudioUnitErr_InvalidParameter);
+#if DEBUG
+				fprintf(stderr, "WARNING: %s SetScheduledEvent for undefined param ID %d while initialized. Ignoring..\n", 
+								mAudioUnit->GetLoggingString(), (int)paramID);
+#endif
+			} else {
+				// create new entry in map for the paramID (only happens first time)
+				ParameterMapEvent event(inEvent, inSliceOffsetInBuffer, inSliceDurationFrames);		
+				mParameters[paramID] = event;
+			}
+		}
+		else
+		{
+			// paramID already exists in map so simply change its value
+			ParameterMapEvent &event = (*i).second;
+			
+			event.SetScheduledEvent(inEvent, inSliceOffsetInBuffer, inSliceDurationFrames );
+		}
+	}
+}
+
+
+
+//_____________________________________________________________________________
+//
+void			AUElement::GetParameterList(AudioUnitParameterID *outList)
+{
+	if(mUseIndexedParameters)
+	{
+		UInt32 nparams = static_cast<UInt32>(mIndexedParameters.size());
+		for (UInt32 i = 0; i < nparams; i++ )
+			*outList++ = (AudioUnitParameterID)i;
+	}
+	else
+	{
+		for (ParameterMap::iterator i = mParameters.begin(); i != mParameters.end(); ++i)
+			*outList++ = (*i).first;
+	}
+}
+
+//_____________________________________________________________________________
+//
+void			AUElement::SaveState(CFMutableDataRef data)
+{
+	if(mUseIndexedParameters)
+	{
+		UInt32 nparams = static_cast<UInt32>(mIndexedParameters.size());
+		UInt32 theData = CFSwapInt32HostToBig(nparams);
+		CFDataAppendBytes(data, (UInt8 *)&theData, sizeof(nparams));
+	
+		for (UInt32 i = 0; i < nparams; i++)
+		{
+			struct {
+				UInt32				paramID;
+				//CFSwappedFloat32	value; crashes gcc3 PFE
+				UInt32				value;	// really a big-endian float
+			} entry;
+			
+			entry.paramID = CFSwapInt32HostToBig(i);
+	
+			AudioUnitParameterValue v = mIndexedParameters[i].GetValue();
+			entry.value = CFSwapInt32HostToBig(*(UInt32 *)&v );
+	
+			CFDataAppendBytes(data, (UInt8 *)&entry, sizeof(entry));
+		}
+	}
+	else
+	{
+		UInt32 nparams = CFSwapInt32HostToBig(static_cast<uint32_t>(mParameters.size()));
+		CFDataAppendBytes(data, (UInt8 *)&nparams, sizeof(nparams));
+	
+		for (ParameterMap::iterator i = mParameters.begin(); i != mParameters.end(); ++i) {
+			struct {
+				UInt32				paramID;
+				//CFSwappedFloat32	value; crashes gcc3 PFE
+				UInt32				value;	// really a big-endian float
+			} entry;
+			
+			entry.paramID = CFSwapInt32HostToBig((*i).first);
+	
+			AudioUnitParameterValue v = (*i).second.GetValue();
+			entry.value = CFSwapInt32HostToBig(*(UInt32 *)&v );
+	
+			CFDataAppendBytes(data, (UInt8 *)&entry, sizeof(entry));
+		}
+	}
+}
+
+//_____________________________________________________________________________
+//
+const UInt8 *	AUElement::RestoreState(const UInt8 *state)
+{
+	union FloatInt32 { UInt32 i; AudioUnitParameterValue f; };
+	const UInt8 *p = state;
+	UInt32 nparams = CFSwapInt32BigToHost(*(UInt32 *)p);
+	p += sizeof(UInt32);
+	
+	for (UInt32 i = 0; i < nparams; ++i) {
+		struct {
+			AudioUnitParameterID		paramID;
+			AudioUnitParameterValue		value;
+		} entry;
+		
+		entry.paramID = CFSwapInt32BigToHost(*(UInt32 *)p);
+		p += sizeof(UInt32);
+		FloatInt32 temp;
+		temp.i = CFSwapInt32BigToHost(*(UInt32 *)p);
+		entry.value = temp.f;
+		p += sizeof(AudioUnitParameterValue);
+		
+		SetParameter(entry.paramID, entry.value);
+	}
+	return p;
+}
+
+//_____________________________________________________________________________
+//
+void	AUElement::SetName (CFStringRef inName) 
+{ 
+	if (mElementName) CFRelease (mElementName);
+	mElementName = inName; 
+	if (mElementName) CFRetain (mElementName);
+}
+
+
+//_____________________________________________________________________________
+//
+AUIOElement::AUIOElement(AUBase *audioUnit) :
+	AUElement(audioUnit),
+	mWillAllocate (true)
+{
+	mStreamFormat.SetAUCanonical(2,	// stereo
+		audioUnit->AudioUnitAPIVersion() == 1);
+		// interleaved if API version 1, deinterleaved if version 2
+	mStreamFormat.mSampleRate = kAUDefaultSampleRate;
+}
+
+//_____________________________________________________________________________
+//
+OSStatus		AUIOElement::SetStreamFormat(const CAStreamBasicDescription &desc)
+{
+	mStreamFormat = desc;
+	return AUBase::noErr;
+}
+
+//_____________________________________________________________________________
+// inFramesToAllocate == 0 implies the AudioUnit's max-frames-per-slice will be used
+void			AUIOElement::AllocateBuffer(UInt32 inFramesToAllocate)
+{
+	if (GetAudioUnit()->HasBegunInitializing())
+	{
+		UInt32 framesToAllocate = inFramesToAllocate > 0 ? inFramesToAllocate : GetAudioUnit()->GetMaxFramesPerSlice();
+		
+//		printf ("will allocate: %d\n", (int)((mWillAllocate && NeedsBufferSpace()) ? framesToAllocate : 0));
+		
+		mIOBuffer.Allocate(mStreamFormat, (mWillAllocate && NeedsBufferSpace()) ? framesToAllocate : 0);
+	}
+}
+
+//_____________________________________________________________________________
+//
+void			AUIOElement::DeallocateBuffer()
+{
+	mIOBuffer.Deallocate();
+}
+
+//_____________________________________________________________________________
+//
+//		AudioChannelLayout support
+
+// outLayoutTagsPtr WILL be NULL if called to find out how many
+// layouts that Audio Unit will report 
+// return 0 (ie. NO channel layouts) if the AU doesn't require channel layout knowledge
+UInt32		AUIOElement::GetChannelLayoutTags (AudioChannelLayoutTag		*outLayoutTagsPtr)
+{
+	return 0;
+}
+		
+// As the AudioChannelLayout can be a variable length structure 
+// (though in most cases it won't be!!!)
+// The size of the ACL is always returned by the method
+// if outMapPtr is NOT-NULL, then AU should copy into this pointer (outMapPtr) the current ACL that it has in use. 
+// the AU should also return whether the property is writable (that is the client can provide any arbitrary ACL that the audio unit will then honour)
+// or if the property is read only - which is the generally preferred mode.
+// If the AU doesn't require an AudioChannelLayout, then just return 0.
+UInt32		AUIOElement::GetAudioChannelLayout (AudioChannelLayout		*outMapPtr, 
+											Boolean				&outWritable)
+{
+	return 0;
+}
+
+// the incoming channel map will be at least as big as a basic AudioChannelLayout
+// but its contents will determine its actual size
+// Subclass should overide if channel map is writable
+OSStatus	AUIOElement::SetAudioChannelLayout (const AudioChannelLayout &inData)
+{
+	return kAudioUnitErr_InvalidProperty;
+}
+
+// Some units support optional usage of channel maps - typically converter units
+// that can do channel remapping between different maps. In that optional case
+// the user should be able to remove a channel map if that is possible.
+// Typically this is NOT the case (e.g., the 3DMixer even in the stereo case
+// needs to know if it is rendering to speakers or headphones)
+OSStatus	AUIOElement::RemoveAudioChannelLayout ()
+{
+	return kAudioUnitErr_InvalidPropertyValue;
+}
+
+
+//_____________________________________________________________________________
+//
+AUScope::~AUScope()
+{
+	for (ElementVector::iterator it = mElements.begin(); it != mElements.end(); ++it)
+		delete *it;
+}
+
+//_____________________________________________________________________________
+//
+void	AUScope::SetNumberOfElements(UInt32 numElements)
+{
+	if (mDelegate)
+		return mDelegate->SetNumberOfElements(numElements);
+
+	if (numElements > mElements.size()) {
+		mElements.reserve(numElements);
+		while (numElements > mElements.size()) {
+			AUElement *elem = mCreator->CreateElement(GetScope(), static_cast<UInt32>(mElements.size()));
+			mElements.push_back(elem);
+		}
+	} else
+		while (numElements < mElements.size()) {
+			AUElement *elem = mElements.back();
+			mElements.pop_back();
+			delete elem;
+		}
+}
+
+//_____________________________________________________________________________
+//
+bool	AUScope::HasElementWithName () const
+{
+	for (UInt32 i = 0; i < GetNumberOfElements(); ++i) {
+		AUElement *	el = const_cast<AUScope*>(this)->GetElement (i);
+		if (el && el->HasName()) {
+			return true;
+		}
+	}
+	return false;
+}
+
+//_____________________________________________________________________________
+//
+
+void	AUScope::AddElementNamesToDict (CFMutableDictionaryRef & inNameDict)
+{
+	if (HasElementWithName())
+	{
+		static char string[32];
+		CFMutableDictionaryRef elementDict = CFDictionaryCreateMutable	(NULL, 0,
+								&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+		CFStringRef str;
+		for (UInt32 i = 0; i < GetNumberOfElements(); ++i) {
+			AUElement *	el = GetElement (i);
+			if (el && el->HasName()) {
+				snprintf (string, sizeof(string), "%d", int(i));
+				str = CFStringCreateWithCString (NULL, string, kCFStringEncodingASCII);
+				CFDictionarySetValue (elementDict, str, el->GetName());
+				CFRelease (str);
+			}
+		}
+
+		snprintf (string, sizeof(string), "%d", int(mScope));
+		str = CFStringCreateWithCString (NULL, string, kCFStringEncodingASCII);
+		CFDictionarySetValue (inNameDict, str, elementDict);
+		CFRelease (str);
+		CFRelease (elementDict);
+	}
+}
+
+//_____________________________________________________________________________
+//
+bool	AUScope::RestoreElementNames (CFDictionaryRef& inNameDict)
+{
+	static char string[32];
+
+	//first we have to see if we have enough elements
+	bool didAddElements = false;
+	unsigned int maxElNum = GetNumberOfElements();
+	
+	int dictSize = static_cast<int>(CFDictionaryGetCount(inNameDict));
+	CFStringRef * keys = (CFStringRef*)CA_malloc (dictSize * sizeof (CFStringRef));
+	CFDictionaryGetKeysAndValues (inNameDict, reinterpret_cast<const void**>(keys), NULL);
+	for (int i = 0; i < dictSize; i++)
+	{
+		unsigned int intKey = 0;
+		CFStringGetCString (keys[i], string, 32, kCFStringEncodingASCII);
+		int result = sscanf (string, "%u", &intKey);
+        // check if sscanf succeeded and element index is less than max elements.
+		if (result && UInt32(intKey) < maxElNum)
+        {
+            CFStringRef elName = reinterpret_cast<CFStringRef>(CFDictionaryGetValue (inNameDict,  keys[i]));
+            AUElement* element = GetElement (intKey);
+            if (element)
+                element->SetName (elName);
+        }
+	}
+	free (keys);
+	
+	return didAddElements;
+}
+
+void    AUScope::SaveState(CFMutableDataRef data)
+{
+    AudioUnitElement nElems = GetNumberOfElements();
+    for (AudioUnitElement ielem = 0; ielem < nElems; ++ielem) {
+        AUElement *element = GetElement(ielem);
+        UInt32 nparams = element->GetNumberOfParameters();
+        if (nparams > 0) {
+            struct {
+                UInt32	scope;
+                UInt32	element;
+            } hdr;
+            
+            hdr.scope = CFSwapInt32HostToBig(GetScope());
+            hdr.element = CFSwapInt32HostToBig(ielem);
+            CFDataAppendBytes(data, (UInt8 *)&hdr, sizeof(hdr));
+            
+            element->SaveState(data);
+        }
+    }
+}
+
+const UInt8 *	AUScope::RestoreState(const UInt8 *state)
+{
+    const UInt8 *p = state;
+    UInt32 elementIdx = CFSwapInt32BigToHost(*(UInt32 *)p);	p += sizeof(UInt32);
+    AUElement *element = GetElement(elementIdx);
+    if (!element) {
+        struct {
+            AudioUnitParameterID		paramID;
+            AudioUnitParameterValue		value;
+        } entry;
+        UInt32 nparams = CFSwapInt32BigToHost(*(UInt32 *)p);
+        p += sizeof(UInt32);
+        
+        p += nparams * sizeof(entry);
+    } else
+        p = element->RestoreState(p);
+    
+    return p;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/modules/media/src/main/native/jfxmedia/platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.h	Mon Oct 06 09:32:41 2014 -0700
@@ -0,0 +1,553 @@
+/*
+     File: AUScopeElement.h
+ Abstract: Part of CoreAudio Utility Classes
+  Version: 1.1
+ 
+ Disclaimer: IMPORTANT:  This Apple software is supplied to you by Apple
+ Inc. ("Apple") in consideration of your agreement to the following
+ terms, and your use, installation, modification or redistribution of
+ this Apple software constitutes acceptance of these terms.  If you do
+ not agree with these terms, please do not use, install, modify or
+ redistribute this Apple software.
+ 
+ In consideration of your agreement to abide by the following terms, and
+ subject to these terms, Apple grants you a personal, non-exclusive
+ license, under Apple's copyrights in this original Apple software (the
+ "Apple Software"), to use, reproduce, modify and redistribute the Apple
+ Software, with or without modifications, in source and/or binary forms;
+ provided that if you redistribute the Apple Software in its entirety and
+ without modifications, you must retain this notice and the following
+ text and disclaimers in all such redistributions of the Apple Software.
+ Neither the name, trademarks, service marks or logos of Apple Inc. may
+ be used to endorse or promote products derived from the Apple Software
+ without specific prior written permission from Apple.  Except as
+ expressly stated in this notice, no other rights or licenses, express or
+ implied, are granted by Apple herein, including but not limited to any
+ patent rights that may be infringed by your derivative works or by other
+ works in which the Apple Software may be incorporated.
+ 
+ The Apple Software is provided by Apple on an "AS IS" basis.  APPLE
+ MAKES NO WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION
+ THE IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS
+ FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND
+ OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
+ 
+ IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL
+ OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION,
+ MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED
+ AND WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE),
+ STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE
+ POSSIBILITY OF SUCH DAMAGE.
+ 
+ Copyright (C) 2014 Apple Inc. All Rights Reserved.
+ 
+*/
+#ifndef __AUScopeElement_h__
+#define __AUScopeElement_h__
+
+#include <map>
+#include <vector>
+
+#if !defined(__COREAUDIO_USE_FLAT_INCLUDES__)
+	#include <AudioUnit/AudioUnit.h>
+#else
+	#include <AudioUnit.h>
+#endif
+#include "ComponentBase.h"
+#include "AUBuffer.h"
+
+
+class AUBase;
+
+// ____________________________________________________________________________
+//
+// represents a parameter's value (either constant or ramped)
+/*! @class ParameterMapEvent */
+class ParameterMapEvent
+{
+public:
+/*! @ctor ParameterMapEvent */
+	ParameterMapEvent() 
+		: mEventType(kParameterEvent_Immediate), mBufferOffset(0), mDurationInFrames(0), mValue1(0.0f), mValue2(0.0f), mSliceDurationFrames(0) 
+		{}
+
+/*! @ctor ParameterMapEvent */
+	ParameterMapEvent(AudioUnitParameterValue inValue)
+		: mEventType(kParameterEvent_Immediate), mBufferOffset(0), mDurationInFrames(0), mValue1(inValue), mValue2(inValue), mSliceDurationFrames(0) 
+		{}
+		
+	// constructor for scheduled event
+/*! @ctor ParameterMapEvent */
+	ParameterMapEvent(	const AudioUnitParameterEvent 	&inEvent,
+						UInt32 							inSliceOffsetInBuffer,
+						UInt32							inSliceDurationFrames )
+	{
+		SetScheduledEvent(inEvent, inSliceOffsetInBuffer, inSliceDurationFrames );
+	};
+	
+/*! @method SetScheduledEvent */
+	void SetScheduledEvent(	const AudioUnitParameterEvent 	&inEvent,
+							UInt32 							inSliceOffsetInBuffer,
+							UInt32							inSliceDurationFrames )
+	{
+		mEventType = inEvent.eventType;
+		mSliceDurationFrames = inSliceDurationFrames;
+		
+		if(mEventType == kParameterEvent_Immediate )
+		{
+			// constant immediate value for the whole slice
+			mValue1 = inEvent.eventValues.immediate.value;
+			mValue2 = mValue1;
+