frameworks/av: Add ifdefs for QCOM_HARDWARE features

Change-Id: Iebe0da91f0b761bba8eb8c0e181c47bbd0d0703d
diff --git a/include/media/AudioParameter.h b/include/media/AudioParameter.h
index 100d2e1..bce7f21 100644
--- a/include/media/AudioParameter.h
+++ b/include/media/AudioParameter.h
@@ -51,7 +51,7 @@
     static const char * const keyFrameCount;
     static const char * const keyInputSource;
     static const char * const keyScreenState;
-#ifdef QCOM_FM_ENABLED
+#ifdef QCOM_HARDWARE
     static const char * const keyHandleFm;
     static const char * const keyVoipCheck;
     static const char * const keyFluenceType;
diff --git a/include/media/AudioRecord.h b/include/media/AudioRecord.h
index fe1b35b..e4cb560 100644
--- a/include/media/AudioRecord.h
+++ b/include/media/AudioRecord.h
@@ -210,8 +210,13 @@
             audio_format_t format() const   { return mFormat; }
             uint32_t    channelCount() const    { return mChannelCount; }
             size_t      frameCount() const  { return mFrameCount; }
+#ifdef QCOM_HARDWARE
             size_t      frameSize() const;
             audio_source_t inputSource() const;
+#else
+            size_t      frameSize() const   { return mFrameSize; }
+            audio_source_t inputSource() const  { return mInputSource; }
+#endif
 
     /* After it's created the track is not active. Call start() to
      * make it active. If set, the callback will start being called.
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 78fad3c..cad455d 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -25,7 +25,9 @@
 #include <system/audio_policy.h>
 #include <utils/Errors.h>
 #include <utils/Mutex.h>
+#ifdef QCOM_HARDWARE
 #include <media/AudioParameter.h>
+#endif
 
 namespace android {
 
@@ -150,7 +152,9 @@
         INPUT_CLOSED,
         INPUT_CONFIG_CHANGED,
         STREAM_CONFIG_CHANGED,
+#ifdef QCOM_HARDWARE
         EFFECT_CONFIG_CHANGED,
+#endif
         NUM_CONFIG_EVENTS
     };
 
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index f74825c..3ef68fb 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -24,8 +24,10 @@
 #include <media/AudioTimestamp.h>
 #include <media/IAudioTrack.h>
 #include <utils/threads.h>
+#ifdef QCOM_HARDWARE
 #include <media/IDirectTrack.h>
 #include <media/IDirectTrackClient.h>
+#endif
 namespace android {
 
 // ----------------------------------------------------------------------------
@@ -36,8 +38,12 @@
 
 // ----------------------------------------------------------------------------
 
+#ifdef QCOM_HARDWARE
 class AudioTrack : public BnDirectTrackClient,
                    virtual public RefBase
+#else
+class AudioTrack : public RefBase
+#endif
 {
 public:
     enum channel_index {
@@ -70,7 +76,9 @@
         EVENT_NEW_TIMESTAMP = 8,    // Delivered periodically and when there's a significant change
                                     // in the mapping from frame position to presentation time.
                                     // See AudioTimestamp for the information included with event.
+#ifdef QCOM_HARDWARE
         EVENT_HW_FAIL = 9,          // ADSP failure.
+#endif
     };
 
     /* Client should declare Buffer on the stack and pass address to obtainBuffer()
@@ -265,7 +273,11 @@
      * This includes the latency due to AudioTrack buffer size, AudioMixer (if any)
      * and audio hardware driver.
      */
+#ifdef QCOM_HARDWARE
             uint32_t    latency() const;
+#else
+            uint32_t    latency() const     { return mLatency; }
+#endif
 
     /* getters, see constructors and set() */
 
@@ -584,8 +596,10 @@
      * Returns NO_ERROR if timestamp is valid.
      */
       virtual status_t    getTimestamp(AudioTimestamp& timestamp);
+#ifdef QCOM_HARDWARE
       virtual void notify(int msg);
       virtual status_t    getTimeStamp(uint64_t *tstamp);
+#endif
 
 protected:
     /* copying audio tracks is not allowed */
@@ -656,7 +670,9 @@
             bool     isOffloaded() const
                 { return (mFlags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) != 0; }
 
+#ifdef QCOM_HARDWARE
     sp<IDirectTrack>        mDirectTrack;
+#endif
     // Next 3 fields may be changed if IAudioTrack is re-created, but always != 0
     sp<IAudioTrack>         mAudioTrack;
     sp<IMemory>             mCblkMemory;
@@ -724,13 +740,18 @@
     uint32_t                mUpdatePeriod;          // in frames, zero means no EVENT_NEW_POS
 
     audio_output_flags_t    mFlags;
+#ifdef QCOM_HARDWARE
     sp<IAudioFlinger>       mAudioFlinger;
     audio_io_handle_t       mAudioDirectOutput;
+#endif
     int                     mSessionId;
     int                     mAuxEffectId;
 
     mutable Mutex           mLock;
+
+#ifdef QCOM_HARDWARE
     void*                   mObserver;
+#endif
     bool                    mIsTimed;
     int                     mPreviousPriority;          // before start()
     SchedPolicy             mPreviousSchedulingGroup;
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index abd7754..75fae77 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -26,8 +26,10 @@
 #include <utils/RefBase.h>
 #include <utils/Errors.h>
 #include <binder/IInterface.h>
+#ifdef QCOM_HARDWARE
 #include <media/IDirectTrack.h>
 #include <media/IDirectTrackClient.h>
+#endif
 #include <media/IAudioTrack.h>
 #include <media/IAudioRecord.h>
 #include <media/IAudioFlingerClient.h>
@@ -54,7 +56,9 @@
         TRACK_TIMED   = 1,  // client requests a TimedAudioTrack
         TRACK_FAST    = 2,  // client requests a fast AudioTrack or AudioRecord
         TRACK_OFFLOAD = 4,  // client requests offload to hw codec
+#ifdef QCOM_HARDWARE
         TRACK_VOICE_COMMUNICATION = 8, //client uses voice communication
+#endif
     };
     typedef uint32_t track_flags_t;
 
@@ -81,6 +85,7 @@
                                 String8& name,
                                 status_t *status) = 0;
 
+#ifdef QCOM_HARDWARE
     /* create a direct audio track and registers it with AudioFlinger.
      * return null if the track cannot be created.
      */
@@ -93,6 +98,7 @@
                                 IDirectTrackClient* client,
                                 audio_stream_type_t streamType,
                                 status_t *status) = 0;
+#endif
 
     virtual sp<IAudioRecord> openRecord(
                                 audio_io_handle_t input,
diff --git a/include/media/MediaPlayerInterface.h b/include/media/MediaPlayerInterface.h
index edf198a..0aad0a2 100644
--- a/include/media/MediaPlayerInterface.h
+++ b/include/media/MediaPlayerInterface.h
@@ -83,8 +83,10 @@
                                     // back (after stop is called)
             CB_EVENT_TEAR_DOWN,      // The AudioTrack was invalidated due to use case change:
                                     // Need to re-evaluate offloading options
+#ifdef QCOM_HARDWARE
             CB_EVENT_UNDERRUN,
             CB_EVENT_HW_FAIL
+#endif
         };
 
         // Callback returns the number of bytes actually written to the buffer.
@@ -100,7 +102,9 @@
         virtual ssize_t     channelCount() const = 0;
         virtual ssize_t     frameSize() const = 0;
         virtual uint32_t    latency() const = 0;
+#ifdef QCOM_HARDWARE
         virtual audio_stream_type_t    streamType() const {return AUDIO_STREAM_DEFAULT;}
+#endif
         virtual float       msecsPerFrame() const = 0;
         virtual status_t    getPosition(uint32_t *position) const = 0;
         virtual status_t    getFramesWritten(uint32_t *frameswritten) const = 0;
@@ -129,8 +133,10 @@
         virtual status_t    setParameters(const String8& keyValuePairs) { return NO_ERROR; };
         virtual String8     getParameters(const String8& keys) { return String8::empty(); };
 
+#ifdef QCOM_HARDWARE
         virtual ssize_t     sampleRate() const {return 0;};
         virtual status_t    getTimeStamp(uint64_t *tstamp) {return 0;};
+#endif
     };
 
                         MediaPlayerBase() : mCookie(0), mNotify(0) {}
diff --git a/include/media/MediaProfiles.h b/include/media/MediaProfiles.h
index 74fc247..ec3eb9b 100644
--- a/include/media/MediaProfiles.h
+++ b/include/media/MediaProfiles.h
@@ -32,6 +32,7 @@
     CAMCORDER_QUALITY_480P = 4,
     CAMCORDER_QUALITY_720P = 5,
     CAMCORDER_QUALITY_1080P = 6,
+#ifdef QCOM_HARDWARE
     CAMCORDER_QUALITY_QVGA = 7,
     CAMCORDER_QUALITY_FWVGA = 8,
     CAMCORDER_QUALITY_WVGA = 9,
@@ -40,6 +41,14 @@
     CAMCORDER_QUALITY_4kUHD = 12,
     CAMCORDER_QUALITY_4kDCI = 13,
     CAMCORDER_QUALITY_LIST_END = 13,
+#else
+    CAMCORDER_QUALITY_QVGA = 11,
+    CAMCORDER_QUALITY_FWVGA = 7,
+    CAMCORDER_QUALITY_WVGA = 8,
+    CAMCORDER_QUALITY_VGA = 9,
+    CAMCORDER_QUALITY_WQVGA = 10,
+    CAMCORDER_QUALITY_LIST_END = 11,
+#endif
 
     CAMCORDER_QUALITY_TIME_LAPSE_LIST_START = 1000,
     CAMCORDER_QUALITY_TIME_LAPSE_LOW  = 1000,
@@ -50,11 +59,15 @@
     CAMCORDER_QUALITY_TIME_LAPSE_720P = 1005,
     CAMCORDER_QUALITY_TIME_LAPSE_1080P = 1006,
     CAMCORDER_QUALITY_TIME_LAPSE_QVGA = 1007,
+#ifdef QCOM_HARDWARE
     CAMCORDER_QUALITY_TIME_LAPSE_FWVGA = 1008,
     CAMCORDER_QUALITY_TIME_LAPSE_WVGA = 1009,
     CAMCORDER_QUALITY_TIME_LAPSE_VGA = 1010,
     CAMCORDER_QUALITY_TIME_LAPSE_WQVGA = 1011,
     CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1011,
+#else
+    CAMCORDER_QUALITY_TIME_LAPSE_LIST_END = 1007,
+#endif
 };
 
 /**
@@ -466,8 +479,10 @@
     static VideoEncoderCap* createDefaultH263VideoEncoderCap();
     static VideoEncoderCap* createDefaultM4vVideoEncoderCap();
     static AudioEncoderCap* createDefaultAmrNBEncoderCap();
+#ifdef QCOM_HARDWARE
     static AudioEncoderCap* createDefaultAacEncoderCap();
     static AudioEncoderCap* createDefaultLpcmEncoderCap();
+#endif
 
     static int findTagForName(const NameToTagMap *map, size_t nMappings, const char *name);
 
diff --git a/include/media/mediaplayer.h b/include/media/mediaplayer.h
index 1fe34e5..24583ef 100644
--- a/include/media/mediaplayer.h
+++ b/include/media/mediaplayer.h
@@ -50,7 +50,9 @@
     MEDIA_ERROR             = 100,
     MEDIA_INFO              = 200,
     MEDIA_SUBTITLE_DATA     = 201,
+#ifdef QCOM_HARDWARE
     MEDIA_QOE               = 300,
+#endif
 };
 
 // Generic error codes for the media player framework.  Errors are fatal, the
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h
index b3109ed..24dfa0f 100644
--- a/include/media/mediarecorder.h
+++ b/include/media/mediarecorder.h
@@ -67,9 +67,11 @@
     /* H.264/AAC data encapsulated in MPEG2/TS */
     OUTPUT_FORMAT_MPEG2TS = 8,
 
+#ifdef QCOM_HARDWARE
     OUTPUT_FORMAT_QCP = 9, // QCP file format
     OUTPUT_FORMAT_THREE_GPP2 = 10, /*3GPP2*/
     OUTPUT_FORMAT_WAVE = 11, /*WAVE*/
+#endif
     OUTPUT_FORMAT_LIST_END // must be last - used to validate format type
 };
 
@@ -80,9 +82,11 @@
     AUDIO_ENCODER_AAC = 3,
     AUDIO_ENCODER_HE_AAC = 4,
     AUDIO_ENCODER_AAC_ELD = 5,
+#ifdef QCOM_HARDWARE
     AUDIO_ENCODER_EVRC = 6,
     AUDIO_ENCODER_QCELP = 7,
     AUDIO_ENCODER_LPCM = 8,
+#endif
     AUDIO_ENCODER_LIST_END // must be the last - used to validate the audio encoder type
 };
 
diff --git a/include/media/stagefright/ACodec.h b/include/media/stagefright/ACodec.h
index a2d5cb1..c92d147 100644
--- a/include/media/stagefright/ACodec.h
+++ b/include/media/stagefright/ACodec.h
@@ -196,7 +196,9 @@
 
     bool mChannelMaskPresent;
     int32_t mChannelMask;
+#ifdef QCOM_HARDWARE
     bool mInSmoothStreamingMode;
+#endif
     unsigned mDequeueCounter;
     bool mStoreMetaDataInOutputBuffers;
     int32_t mMetaDataBuffersToSubmit;
diff --git a/include/media/stagefright/AudioPlayer.h b/include/media/stagefright/AudioPlayer.h
index 422148f..1295eaa 100644
--- a/include/media/stagefright/AudioPlayer.h
+++ b/include/media/stagefright/AudioPlayer.h
@@ -103,7 +103,9 @@
     int64_t mSeekTimeUs;
 
     bool mStarted;
+#ifdef QCOM_HARDWARE
     bool mSourcePaused;
+#endif
 
     bool mIsFirstBuffer;
     status_t mFirstBufferResult;
diff --git a/include/media/stagefright/AudioSource.h b/include/media/stagefright/AudioSource.h
index 161b64ff..3b79d0a 100644
--- a/include/media/stagefright/AudioSource.h
+++ b/include/media/stagefright/AudioSource.h
@@ -104,6 +104,7 @@
 
     AudioSource(const AudioSource &);
     AudioSource &operator=(const AudioSource &);
+#ifdef QCOM_HARDWARE
 public:
     AudioSource(
         audio_source_t inputSource, const sp<MetaData>& meta );
@@ -112,6 +113,7 @@
     String8 mMime;
     int32_t mMaxBufferSize;
     int64_t bufferDurationUs( ssize_t n );
+#endif
 };
 
 }  // namespace android
diff --git a/include/media/stagefright/MediaCodecList.h b/include/media/stagefright/MediaCodecList.h
index 947f123..05ed696 100644
--- a/include/media/stagefright/MediaCodecList.h
+++ b/include/media/stagefright/MediaCodecList.h
@@ -100,7 +100,9 @@
     status_t addTypeFromAttributes(const char **attrs);
     void addType(const char *name);
 
+#ifdef QCOM_HARDWARE
     friend class ExtendedUtils;
+#endif
 
     DISALLOW_EVIL_CONSTRUCTORS(MediaCodecList);
 };
diff --git a/include/media/stagefright/MediaDefs.h b/include/media/stagefright/MediaDefs.h
index 11e6988..170e587 100644
--- a/include/media/stagefright/MediaDefs.h
+++ b/include/media/stagefright/MediaDefs.h
@@ -32,7 +32,9 @@
 
 extern const char *MEDIA_MIMETYPE_AUDIO_AMR_NB;
 extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB;
+#ifdef QCOM_HARDWARE
 extern const char *MEDIA_MIMETYPE_AUDIO_AMR_WB_PLUS;
+#endif
 extern const char *MEDIA_MIMETYPE_AUDIO_MPEG;           // layer III
 extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_I;
 extern const char *MEDIA_MIMETYPE_AUDIO_MPEG_LAYER_II;
diff --git a/include/media/stagefright/MetaData.h b/include/media/stagefright/MetaData.h
index a92ba61..9918225 100644
--- a/include/media/stagefright/MetaData.h
+++ b/include/media/stagefright/MetaData.h
@@ -164,7 +164,9 @@
     kKeyCryptoDefaultIVSize = 'cryS',  // int32_t
 
     kKeyPssh              = 'pssh',  // raw data
+#ifdef QCOM_HARDWARE
     kKeyTunnelException   = 'Ntnl', // not tunnel
+#endif
 };
 
 enum {
diff --git a/include/media/stagefright/OMXCodec.h b/include/media/stagefright/OMXCodec.h
index 6e3d5a4..1247356 100644
--- a/include/media/stagefright/OMXCodec.h
+++ b/include/media/stagefright/OMXCodec.h
@@ -103,8 +103,10 @@
 #if defined(OMAP_ENHANCEMENT)
         kAvoidMemcopyInputRecordingFrames     = 0x20000000,
 #endif
+#ifdef QCOM_HARDWARE
         kRequiresGlobalFlush                  = 0x20000000, // 2^29
         kRequiresWMAProComponent              = 0x40000000, //2^30
+#endif
     };
 
     struct CodecNameAndQuirks {
@@ -144,14 +146,18 @@
         EXECUTING_TO_IDLE,
         IDLE_TO_LOADED,
         RECONFIGURING,
+#ifdef QCOM_HARDWARE
         PAUSING,
         FLUSHING,
         PAUSED,
+#endif
         ERROR
     };
 
     enum {
+#ifdef QCOM_HARDWARE
         kPortIndexBoth   = -1,
+#endif
         kPortIndexInput  = 0,
         kPortIndexOutput = 1
     };
@@ -374,8 +380,10 @@
     OMXCodec(const OMXCodec &);
     OMXCodec &operator=(const OMXCodec &);
 
+#ifdef QCOM_HARDWARE
     int32_t mNumBFrames;
     bool mInSmoothStreamingMode;
+#endif
 };
 
 struct CodecCapabilities {
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk
index 8a7f1b3..331e4dc 100644
--- a/media/libmedia/Android.mk
+++ b/media/libmedia/Android.mk
@@ -9,6 +9,7 @@
 
 include $(BUILD_STATIC_LIBRARY)
 
+ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES:= AudioParameter.cpp
@@ -17,6 +18,7 @@
 LOCAL_SHARED_LIBRARIES := libutils libcutils
 
 include $(BUILD_SHARED_LIBRARY)
+endif
 
 include $(CLEAR_VARS)
 
diff --git a/media/libmedia/AudioParameter.cpp b/media/libmedia/AudioParameter.cpp
index cf4d8c3..4240a9a 100644
--- a/media/libmedia/AudioParameter.cpp
+++ b/media/libmedia/AudioParameter.cpp
@@ -35,7 +35,7 @@
 const char * const AudioParameter::keyFrameCount = AUDIO_PARAMETER_STREAM_FRAME_COUNT;
 const char * const AudioParameter::keyInputSource = AUDIO_PARAMETER_STREAM_INPUT_SOURCE;
 const char * const AudioParameter::keyScreenState = AUDIO_PARAMETER_KEY_SCREEN_STATE;
-#ifdef QCOM_FM_ENABLED
+#ifdef QCOM_HARDWARE
 const char * const AudioParameter::keyHandleFm = AUDIO_PARAMETER_KEY_HANDLE_FM;
 const char * const AudioParameter::keyVoipCheck = AUDIO_PARAMETER_KEY_VOIP_CHECK;
 const char * const AudioParameter::keyFluenceType = AUDIO_PARAMETER_KEY_FLUENCE_TYPE;
diff --git a/media/libmedia/AudioRecord.cpp b/media/libmedia/AudioRecord.cpp
index 0e33805..84df353 100644
--- a/media/libmedia/AudioRecord.cpp
+++ b/media/libmedia/AudioRecord.cpp
@@ -60,10 +60,14 @@
     // We double the size of input buffer for ping pong use of record buffer.
     size <<= 1;
 
+#ifdef QCOM_HARDWARE
     if (audio_is_linear_pcm(format) || format == AUDIO_FORMAT_AMR_WB) {
+#endif
     uint32_t channelCount = popcount(channelMask);
     size /= channelCount * audio_bytes_per_sample(format);
+#ifdef QCOM_HARDWARE
     }
+#endif
 
     *frameCount = size;
     return NO_ERROR;
@@ -195,6 +199,13 @@
         ALOGE("Invalid format %d", format);
         return BAD_VALUE;
     }
+#ifndef QCOM_HARDWARE
+    // Temporary restriction: AudioFlinger currently supports 16-bit PCM only
+    if (format != AUDIO_FORMAT_PCM_16_BIT) {
+        ALOGE("Format %d is not supported", format);
+        return BAD_VALUE;
+    }
+#endif
     mFormat = format;
 
     if (!audio_is_input_channel(channelMask)) {
@@ -203,9 +214,14 @@
     }
     mChannelMask = channelMask;
     uint32_t channelCount = popcount(channelMask
+#ifdef QCOM_HARDWARE
         &(AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_5POINT1));
+#else
+    );
+#endif
     mChannelCount = channelCount;
 
+#ifdef QCOM_HARDWARE
     mFrameSize = frameSize();
 
     size_t inputBuffSizeInBytes = -1;
@@ -222,6 +238,19 @@
     }
 
     int minFrameCount = (inputBuffSizeInBytes * 2)/mFrameSize;
+#else
+    // Assumes audio_is_linear_pcm(format), else sizeof(uint8_t)
+    mFrameSize = channelCount * audio_bytes_per_sample(format);
+
+    // validate framecount
+    size_t minFrameCount = 0;
+    status_t status = AudioRecord::getMinFrameCount(&minFrameCount,
+            sampleRate, format, channelMask);
+    if (status != NO_ERROR) {
+        ALOGE("getMinFrameCount() failed; status %d", status);
+        return status;
+    }
+#endif
 
     ALOGV("AudioRecord::set() minFrameCount = %d", minFrameCount);
 
@@ -279,10 +308,12 @@
     return NO_ERROR;
 }
 
+#ifdef QCOM_HARDWARE
 audio_source_t AudioRecord::inputSource() const
 {
     return mInputSource;
 }
+#endif
 
 // -------------------------------------------------------------------------
 
@@ -471,10 +502,12 @@
     }
 
     int originalSessionId = mSessionId;
+#ifdef QCOM_HARDWARE
     if (inputSource() == AUDIO_SOURCE_VOICE_COMMUNICATION) {
         ALOGV("Notify use of Voice Communication");
         trackFlags |= IAudioFlinger::TRACK_VOICE_COMMUNICATION;
     }
+#endif
     sp<IAudioRecord> record = audioFlinger->openRecord(input,
                                                        mSampleRate, mFormat,
                                                        mChannelMask,
@@ -964,6 +997,7 @@
     return result;
 }
 
+#ifdef QCOM_HARDWARE
 size_t AudioRecord::frameSize() const
 {
     if (inputSource() == AUDIO_SOURCE_VOICE_COMMUNICATION) {
@@ -993,6 +1027,7 @@
         }
    }
 }
+#endif
 
 // =========================================================================
 
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 234ec71..1a1bfda 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -316,9 +316,25 @@
                                  audio_stream_type_t streamType,
                                  uint32_t* latency)
 {
+#ifdef QCOM_HARDWARE
     const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
     if (af == 0) return PERMISSION_DENIED;
     *latency = af->latency(output);
+#else
+    OutputDescriptor *outputDesc;
+
+    gLock.lock();
+    outputDesc = AudioSystem::gOutputs.valueFor(output);
+    if (outputDesc == NULL) {
+        gLock.unlock();
+        const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
+        if (af == 0) return PERMISSION_DENIED;
+        *latency = af->latency(output);
+    } else {
+        *latency = outputDesc->latency;
+        gLock.unlock();
+    }
+#endif
 
     ALOGV("getLatency() streamType %d, output %d, latency %d", streamType, output, *latency);
 
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index f626f6f..17b1f2c 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -89,10 +89,14 @@
     : mStatus(NO_INIT),
       mIsTimed(false),
       mPreviousPriority(ANDROID_PRIORITY_NORMAL),
+#ifdef QCOM_HARDWARE
       mPreviousSchedulingGroup(SP_DEFAULT),
       mAudioFlinger(NULL),
       mObserver(NULL),
       mCblk(NULL)
+#else
+      mPreviousSchedulingGroup(SP_DEFAULT)
+#endif
 {
 }
 
@@ -112,10 +116,14 @@
     : mStatus(NO_INIT),
       mIsTimed(false),
       mPreviousPriority(ANDROID_PRIORITY_NORMAL),
+#ifdef QCOM_HARDWARE
       mPreviousSchedulingGroup(SP_DEFAULT),
       mAudioFlinger(NULL),
       mObserver(NULL),
       mCblk(NULL)
+#else
+      mPreviousSchedulingGroup(SP_DEFAULT)
+#endif
 {
     mStatus = set(streamType, sampleRate, format, channelMask,
             frameCount, flags, cbf, user, notificationFrames,
@@ -138,11 +146,15 @@
     : mStatus(NO_INIT),
       mIsTimed(false),
       mPreviousPriority(ANDROID_PRIORITY_NORMAL),
+#ifdef QCOM_HARDWARE
       mPreviousSchedulingGroup(SP_DEFAULT),
       mProxy(NULL),
       mAudioFlinger(NULL),
       mObserver(NULL),
       mCblk(NULL)
+#else
+      mPreviousSchedulingGroup(SP_DEFAULT)
+#endif
 {
     mStatus = set(streamType, sampleRate, format, channelMask,
             0 /*frameCount*/, flags, cbf, user, notificationFrames,
@@ -162,6 +174,7 @@
             mAudioTrackThread->requestExitAndWait();
             mAudioTrackThread.clear();
         }
+#ifdef QCOM_HARDWARE
         if (mAudioTrack != 0) {
             mAudioTrack->asBinder()->unlinkToDeath(mDeathNotifier, this);
             mAudioTrack.clear();
@@ -172,6 +185,12 @@
             mDirectTrack.clear();
         }
         IPCThreadState::self()->flushCommands();
+#else
+        mAudioTrack->asBinder()->unlinkToDeath(mDeathNotifier, this);
+        mAudioTrack.clear();
+        IPCThreadState::self()->flushCommands();
+        AudioSystem::releaseAudioSessionId(mSessionId);
+#endif
     }
 }
 
@@ -306,6 +325,7 @@
     uint32_t channelCount = popcount(channelMask);
     mChannelCount = channelCount;
 
+#ifdef QCOM_HARDWARE
     if ((streamType == AUDIO_STREAM_VOICE_CALL)
          && (channelCount == 1)
          && ((sampleRate == 8000 || sampleRate == 16000)))
@@ -331,6 +351,15 @@
             mFrameSizeAF = sizeof(uint8_t);
         }
     }
+#else
+    if (audio_is_linear_pcm(format)) {
+        mFrameSize = channelCount * audio_bytes_per_sample(format);
+        mFrameSizeAF = channelCount * sizeof(int16_t);
+    } else {
+        mFrameSize = sizeof(uint8_t);
+        mFrameSizeAF = sizeof(uint8_t);
+    }
+#endif
 
     audio_io_handle_t output = AudioSystem::getOutput(
                                     streamType,
@@ -354,6 +383,7 @@
     mAuxEffectId = 0;
     mFlags = flags;
     mCbf = cbf;
+#ifdef QCOM_HARDWARE
     mSampleRate = sampleRate;
 
     if (flags & AUDIO_OUTPUT_FLAG_LPA || flags & AUDIO_OUTPUT_FLAG_TUNNEL) {
@@ -382,6 +412,7 @@
         mSharedBuffer = NULL;
     }
     else {
+#endif
         if (cbf != NULL) {
             mAudioTrackThread = new AudioTrackThread(*this, threadCanCallJava);
             mAudioTrackThread->run("AudioTrack", ANDROID_PRIORITY_AUDIO, 0 /*stack*/);
@@ -409,15 +440,20 @@
             AudioSystem::releaseOutput(output);
             return status;
         }
+#ifdef QCOM_HARDWARE
         AudioSystem::acquireAudioSessionId(mSessionId);
         mAudioDirectOutput = -1;
         mDirectTrack = NULL;
         mSharedBuffer = sharedBuffer;
     }
     mUserData = user;
+#endif
     mStatus = NO_ERROR;
     mStreamType = streamType;
     mFormat = format;
+#ifndef QCOM_HARDWARE
+    mSharedBuffer = sharedBuffer;
+#endif
     mState = STATE_STOPPED;
     mUserData = user;
     mLoopPeriod = 0;
@@ -425,6 +461,9 @@
     mMarkerReached = false;
     mNewPosition = 0;
     mUpdatePeriod = 0;
+#ifndef QCOM_HARDWARE
+    AudioSystem::acquireAudioSessionId(mSessionId);
+#endif
     mSequence = 1;
     mObservedSequence = mSequence;
     mInUnderrun = false;
@@ -435,6 +474,7 @@
 
 // -------------------------------------------------------------------------
 
+#ifdef QCOM_HARDWARE
 uint32_t AudioTrack::latency() const
 {
     if (mAudioDirectOutput != -1) {
@@ -451,6 +491,7 @@
     }
     return mLatency;
 }
+#endif
 
 status_t AudioTrack::start()
 {
@@ -468,10 +509,12 @@
     } else {
         mState = STATE_ACTIVE;
     }
+#ifdef QCOM_HARDWARE
     if (mDirectTrack != NULL) {
         mDirectTrack->start();
         return status;
     }
+#endif
     if (previousState == STATE_STOPPED || previousState == STATE_FLUSHED) {
         // reset current position as seen by client to 0
         mProxy->setEpoch(mProxy->getEpoch() - mProxy->getPosition());
@@ -535,9 +578,11 @@
         mState = STATE_STOPPED;
     }
 
+#ifdef QCOM_HARDWARE
     if(mDirectTrack != NULL) {
         mDirectTrack->stop();
     } else if (mAudioTrack != NULL) {
+#endif
         mProxy->interrupt();
         mAudioTrack->stop();
         // the playback head position will reset to 0, so if a marker is set, we need
@@ -561,7 +606,9 @@
             setpriority(PRIO_PROCESS, 0, mPreviousPriority);
             set_sched_policy(0, mPreviousSchedulingGroup);
         }
+#ifdef QCOM_HARDWARE
     }
+#endif
 }
 
 bool AudioTrack::stopped() const
@@ -572,11 +619,18 @@
 
 void AudioTrack::flush()
 {
+#ifdef QCOM_HARDWARE
     if(mDirectTrack != NULL) {
         ALOGE("mdirect track flush");
         mDirectTrack->flush();
         return ;
     }
+#else
+    if (mSharedBuffer != 0) {
+        return;
+    }
+    AutoMutex lock(mLock);
+#endif
     if (mState == STATE_ACTIVE || mState == STATE_FLUSHED) {
         return;
     }
@@ -611,13 +665,17 @@
     } else {
         return;
     }
+#ifdef QCOM_HARDWARE
     if(mDirectTrack != NULL) {
         ALOGV("mDirectTrack pause");
         mDirectTrack->pause();
     } else {
+#endif
         mProxy->interrupt();
         mAudioTrack->pause();
+#ifdef QCOM_HARDWARE
     }
+#endif
 }
 
 status_t AudioTrack::setVolume(float left, float right)
@@ -629,12 +687,16 @@
     AutoMutex lock(mLock);
     mVolume[LEFT] = left;
     mVolume[RIGHT] = right;
+#ifdef QCOM_HARDWARE
     if(mDirectTrack != NULL) {
         ALOGV("mDirectTrack->setVolume(left = %f , right = %f)", left,right);
         mDirectTrack->setVolume(left, right);
     } else {
+#endif
        mProxy->setVolumeLR((uint32_t(uint16_t(right * 0x1000)) << 16) | uint16_t(left * 0x1000));
+#ifdef QCOM_HARDWARE
     }
+#endif
 
     if (isOffloaded()) {
         mAudioTrack->signal();
@@ -649,9 +711,11 @@
 
 status_t AudioTrack::setAuxEffectSendLevel(float level)
 {
+#ifdef QCOM_HARDWARE
     if (mDirectTrack != NULL) {
         return NO_ERROR;
     }
+#endif
     if (level < 0.0f || level > 1.0f) {
         return BAD_VALUE;
     }
@@ -699,9 +763,11 @@
     }
 
     AutoMutex lock(mLock);
+#ifdef QCOM_HARDWARE
     if(mAudioDirectOutput != -1) {
         return mAudioFlinger->sampleRate(mAudioDirectOutput);
     }
+#endif
     return mSampleRate;
 }
 
@@ -1322,11 +1388,13 @@
 
 ssize_t AudioTrack::write(const void* buffer, size_t userSize)
 {
+#ifdef QCOM_HARDWARE
     if (mDirectTrack != NULL) {
         ssize_t written = 0;
         written = mDirectTrack->write(buffer,userSize);
         return written;
     }
+#endif
     if (mTransfer != TRANSFER_SYNC || mIsTimed) {
         return INVALID_OPERATION;
     }
@@ -1883,9 +1951,13 @@
     result.append(buffer);
     snprintf(buffer, 255, "  sample rate(%u), status(%d)\n", mSampleRate, mStatus);
     result.append(buffer);
+#ifdef QCOM_HARDWARE
     uint32_t afLatency = 0;
     AudioSystem::getLatency(mOutput, mStreamType, &afLatency);
     snprintf(buffer, 255, "  state(%d), latency (%d)\n", mState, afLatency + (1000*mCblk->frameCount_) / mSampleRate);
+#else
+    snprintf(buffer, 255, "  state(%d), latency (%d)\n", mState, mLatency);
+#endif
     result.append(buffer);
     ::write(fd, result.string(), result.size());
     return NO_ERROR;
@@ -1908,6 +1980,7 @@
     }
 }
 
+#ifdef QCOM_HARDWARE
 void AudioTrack::notify(int msg) {
     if (msg == EVENT_UNDERRUN) {
         ALOGV("Posting event underrun to Audio Sink.");
@@ -1926,6 +1999,7 @@
     }
     return NO_ERROR;
 }
+#endif
 
 // =========================================================================
 
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index d248d19..9bf3643 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -75,7 +75,9 @@
     GET_PRIMARY_OUTPUT_SAMPLING_RATE,
     GET_PRIMARY_OUTPUT_FRAME_COUNT,
     SET_LOW_RAM_DEVICE,
+#ifdef QCOM_HARDWARE
     CREATE_DIRECT_TRACK,
+#endif
 };
 
 class BpAudioFlinger : public BpInterface<IAudioFlinger>
@@ -145,6 +147,7 @@
         return track;
     }
 
+#ifdef QCOM_HARDWARE
     virtual sp<IDirectTrack> createDirectTrack(
                                 pid_t pid,
                                 uint32_t sampleRate,
@@ -185,6 +188,7 @@
         }
         return track;
     }
+#endif
 
     virtual sp<IAudioRecord> openRecord(
                                 audio_io_handle_t input,
@@ -825,6 +829,7 @@
             reply->writeStrongBinder(track->asBinder());
             return NO_ERROR;
         } break;
+#ifdef QCOM_HARDWARE
         case CREATE_DIRECT_TRACK: {
             CHECK_INTERFACE(IAudioFlinger, data, reply);
             pid_t pid = data.readInt32();
@@ -843,6 +848,7 @@
             reply->writeStrongBinder(track->asBinder());
             return NO_ERROR;
         } break;
+#endif
         case OPEN_RECORD: {
             CHECK_INTERFACE(IAudioFlinger, data, reply);
             audio_io_handle_t input = (audio_io_handle_t) data.readInt32();
diff --git a/media/libmedia/IAudioFlingerClient.cpp b/media/libmedia/IAudioFlingerClient.cpp
index 5e4da5d..65dc3f6 100644
--- a/media/libmedia/IAudioFlingerClient.cpp
+++ b/media/libmedia/IAudioFlingerClient.cpp
@@ -52,8 +52,11 @@
             uint32_t stream = *(const uint32_t *)param2;
             ALOGV("ioConfigChanged stream %d", stream);
             data.writeInt32(stream);
-        } else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED &&
-                   event != AudioSystem::EFFECT_CONFIG_CHANGED) {
+        } else if (event != AudioSystem::OUTPUT_CLOSED && event != AudioSystem::INPUT_CLOSED
+#ifdef QCOM_HARDWARE
+                && event != AudioSystem::EFFECT_CONFIG_CHANGED
+#endif
+        ) {
             const AudioSystem::OutputDescriptor *desc = (const AudioSystem::OutputDescriptor *)param2;
             data.writeInt32(desc->samplingRate);
             data.writeInt32(desc->format);
diff --git a/media/libmedia/MediaProfiles.cpp b/media/libmedia/MediaProfiles.cpp
index 50ff5d0..2837bab 100644
--- a/media/libmedia/MediaProfiles.cpp
+++ b/media/libmedia/MediaProfiles.cpp
@@ -46,7 +46,9 @@
     {"aac",    AUDIO_ENCODER_AAC},
     {"heaac",  AUDIO_ENCODER_HE_AAC},
     {"aaceld", AUDIO_ENCODER_AAC_ELD},
+#ifdef QCOM_HARDWARE
     {"lpcm",  AUDIO_ENCODER_LPCM}
+#endif
 };
 
 const MediaProfiles::NameToTagMap MediaProfiles::sFileFormatMap[] = {
@@ -75,8 +77,10 @@
     {"wvga", CAMCORDER_QUALITY_WVGA},
     {"vga", CAMCORDER_QUALITY_VGA},
     {"wqvga", CAMCORDER_QUALITY_WQVGA},
+#ifdef QCOM_HARDWARE
     {"4kuhd", CAMCORDER_QUALITY_4kUHD},
     {"4kdci", CAMCORDER_QUALITY_4kDCI},
+#endif
 
     {"timelapselow",  CAMCORDER_QUALITY_TIME_LAPSE_LOW},
     {"timelapsehigh", CAMCORDER_QUALITY_TIME_LAPSE_HIGH},
@@ -86,10 +90,12 @@
     {"timelapse720p", CAMCORDER_QUALITY_TIME_LAPSE_720P},
     {"timelapse1080p", CAMCORDER_QUALITY_TIME_LAPSE_1080P},
     {"timelapseqvga", CAMCORDER_QUALITY_TIME_LAPSE_QVGA},
+#ifdef QCOM_HARDWARE
     {"timelapsevga", CAMCORDER_QUALITY_TIME_LAPSE_VGA},
     {"timelapsewvga", CAMCORDER_QUALITY_TIME_LAPSE_WVGA},
     {"timelapsefwvga", CAMCORDER_QUALITY_TIME_LAPSE_FWVGA},
     {"timelapsewqvga", CAMCORDER_QUALITY_TIME_LAPSE_WQVGA},
+#endif
 };
 
 /*static*/ void
@@ -811,8 +817,10 @@
 MediaProfiles::createDefaultAudioEncoders(MediaProfiles *profiles)
 {
     profiles->mAudioEncoders.add(createDefaultAmrNBEncoderCap());
+#ifdef QCOM_HARDWARE
     profiles->mAudioEncoders.add(createDefaultAacEncoderCap());
     profiles->mAudioEncoders.add(createDefaultLpcmEncoderCap());
+#endif
 }
 
 /*static*/ void
@@ -846,6 +854,7 @@
     return new MediaProfiles::AudioEncoderCap(
         AUDIO_ENCODER_AMR_NB, 5525, 12200, 8000, 8000, 1, 1);
 }
+#ifdef QCOM_HARDWARE
 /*static*/ MediaProfiles::AudioEncoderCap*
 MediaProfiles::createDefaultAacEncoderCap()
 {
@@ -858,6 +867,7 @@
     return new MediaProfiles::AudioEncoderCap(
         AUDIO_ENCODER_LPCM, 768000, 4608000, 48000, 48000, 1, 6);
 }
+#endif
 
 /*static*/ void
 MediaProfiles::createDefaultImageEncodingQualityLevels(MediaProfiles *profiles)
diff --git a/media/libmedia/mediaplayer.cpp b/media/libmedia/mediaplayer.cpp
index 6297061..9a8f94e 100644
--- a/media/libmedia/mediaplayer.cpp
+++ b/media/libmedia/mediaplayer.cpp
@@ -683,7 +683,11 @@
     }
 
     // Allows calls from JNI in idle state to notify errors
+#ifdef QCOM_HARDWARE
     if (!((msg == MEDIA_ERROR || msg == MEDIA_QOE) && mCurrentState == MEDIA_PLAYER_IDLE) && mPlayer == 0) {
+#else
+    if (!(msg == MEDIA_ERROR && mCurrentState == MEDIA_PLAYER_IDLE) && mPlayer == 0) {
+#endif
         ALOGV("notify(%d, %d, %d) callback on disconnected mediaplayer", msg, ext1, ext2);
         if (locked) mLock.unlock();   // release the lock when done.
         return;
@@ -758,8 +762,10 @@
         break;
     case MEDIA_SUBTITLE_DATA:
         ALOGV("Received subtitle data message");
+#ifdef QCOM_HARDWARE
     case MEDIA_QOE:
         ALOGV("Received QOE Message for event : %d",ext2);
+#endif
         break;
     default:
         ALOGV("unrecognized message: (%d, %d, %d)", msg, ext1, ext2);
diff --git a/media/libmediaplayerservice/MediaPlayerService.cpp b/media/libmediaplayerservice/MediaPlayerService.cpp
index 951ca97..a5c2950 100644
--- a/media/libmediaplayerservice/MediaPlayerService.cpp
+++ b/media/libmediaplayerservice/MediaPlayerService.cpp
@@ -81,7 +81,9 @@
 #include "HDCP.h"
 #include "HTTPBase.h"
 #include "RemoteDisplay.h"
+#ifdef QCOM_HARDWARE
 #define DEFAULT_SAMPLE_RATE 44100
+#endif
 
 namespace {
 using android::media::Metadata;
@@ -1376,10 +1378,12 @@
     return mTrack->latency();
 }
 
+#ifdef QCOM_HARDWARE
 audio_stream_type_t MediaPlayerService::AudioOutput::streamType () const
 {
     return mStreamType;
 }
+#endif
 
 float MediaPlayerService::AudioOutput::msecsPerFrame() const
 {
@@ -1392,6 +1396,7 @@
     return mTrack->getPosition(position);
 }
 
+#ifdef QCOM_HARDWARE
 ssize_t MediaPlayerService::AudioOutput::sampleRate() const
 {
     if (mTrack == 0) return NO_INIT;
@@ -1405,6 +1410,7 @@
     mTrack->getTimeStamp(tstamp);
     return NO_ERROR;
 }
+#endif
 
 status_t MediaPlayerService::AudioOutput::getFramesWritten(uint32_t *frameswritten) const
 {
@@ -1461,6 +1467,7 @@
 {
     mCallback = cb;
     mCallbackCookie = cookie;
+#ifdef QCOM_HARDWARE
     if (flags & AUDIO_OUTPUT_FLAG_LPA || flags & AUDIO_OUTPUT_FLAG_TUNNEL) {
         ALOGV("AudioOutput open: with flags %x",flags);
         channelMask = audio_channel_out_mask_from_count(channelCount);
@@ -1503,6 +1510,7 @@
         mTrack = audioTrack;
         return NO_ERROR;
     }
+#endif
     // Check argument "bufferCount" against the mininum buffer count
     if (bufferCount < mMinBufferCount) {
         ALOGD("bufferCount (%d) is too small and increased to %d", bufferCount, mMinBufferCount);
@@ -1815,6 +1823,7 @@
 void MediaPlayerService::AudioOutput::CallbackWrapper(
         int event, void *cookie, void *info) {
     //ALOGV("callbackwrapper");
+#ifdef QCOM_HARDWARE
     if (event == AudioTrack::EVENT_UNDERRUN) {
         ALOGW("Event underrun");
         CallbackData *data = (CallbackData*)cookie;
@@ -1854,6 +1863,7 @@
         return;
     }
     if (event == AudioTrack::EVENT_MORE_DATA) {
+#endif
         CallbackData *data = (CallbackData*)cookie;
         data->lock();
         AudioOutput *me = data->getOutput();
@@ -1903,7 +1913,9 @@
         }
 
         data->unlock();
+#ifdef QCOM_HARDWARE
     }
+#endif
 
     return;
 }
@@ -1938,10 +1950,12 @@
     return NO_ERROR;
 }
 
+#ifdef QCOM_HARDWARE
 ssize_t MediaPlayerService::AudioCache::sampleRate() const
 {
     return mSampleRate;
 }
+#endif
 
 status_t MediaPlayerService::AudioCache::getFramesWritten(uint32_t *written) const
 {
diff --git a/media/libmediaplayerservice/MediaPlayerService.h b/media/libmediaplayerservice/MediaPlayerService.h
index 1df311c..63356f2 100644
--- a/media/libmediaplayerservice/MediaPlayerService.h
+++ b/media/libmediaplayerservice/MediaPlayerService.h
@@ -85,7 +85,9 @@
         virtual ssize_t         channelCount() const;
         virtual ssize_t         frameSize() const;
         virtual uint32_t        latency() const;
+#ifdef QCOM_HARDWARE
         virtual audio_stream_type_t streamType() const;
+#endif
         virtual float           msecsPerFrame() const;
         virtual status_t        getPosition(uint32_t *position) const;
         virtual status_t        getFramesWritten(uint32_t *frameswritten) const;
@@ -120,8 +122,10 @@
         virtual status_t        setParameters(const String8& keyValuePairs);
         virtual String8         getParameters(const String8& keys);
 
+#ifdef QCOM_HARDWARE
         virtual ssize_t         sampleRate() const;
         virtual status_t        getTimeStamp(uint64_t *tstamp);
+#endif
 
     private:
         static void             setMinBufferCount();
@@ -216,6 +220,11 @@
                 void            setAudioStreamType(audio_stream_type_t streamType) {}
                 void            setVolume(float left, float right) {}
         virtual status_t        setPlaybackRatePermille(int32_t ratePermille) { return INVALID_OPERATION; }
+#ifdef QCOM_HARDWARE
+        virtual ssize_t         sampleRate() const;
+#else
+                uint32_t        sampleRate() const { return mSampleRate; }
+#endif
                 audio_format_t  format() const { return mFormat; }
                 size_t          size() const { return mSize; }
                 status_t        wait();
@@ -225,7 +234,6 @@
         static  void            notify(void* cookie, int msg,
                                        int ext1, int ext2, const Parcel *obj);
         virtual status_t        dump(int fd, const Vector<String16>& args) const;
-        virtual ssize_t         sampleRate() const;
 
     private:
                                 AudioCache();
diff --git a/media/libmediaplayerservice/StagefrightRecorder.cpp b/media/libmediaplayerservice/StagefrightRecorder.cpp
index c1c6e4a..a3f055c 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.cpp
+++ b/media/libmediaplayerservice/StagefrightRecorder.cpp
@@ -17,7 +17,10 @@
 //#define LOG_NDEBUG 0
 #define LOG_TAG "StagefrightRecorder"
 #include <utils/Log.h>
+
+#ifdef QCOM_HARDWARE
 #include <media/AudioParameter.h>
+#endif
 #include "StagefrightRecorder.h"
 
 #include <binder/IPCThreadState.h>
@@ -29,8 +32,10 @@
 #include <media/stagefright/AudioSource.h>
 #include <media/stagefright/AMRWriter.h>
 #include <media/stagefright/AACWriter.h>
+#ifdef QCOM_HARDWARE
 #include <media/stagefright/ExtendedWriter.h>
 #include <media/stagefright/WAVEWriter.h>
+#endif
 #include <media/stagefright/CameraSource.h>
 #include <media/stagefright/CameraSourceTimeLapse.h>
 #include <media/stagefright/MPEG2TSWriter.h>
@@ -51,11 +56,13 @@
 #include <ctype.h>
 #include <unistd.h>
 
-#include "ExtendedUtils.h"
 #include <system/audio.h>
+#ifdef QCOM_HARDWARE
+#include "ExtendedUtils.h"
 #ifdef ENABLE_AV_ENHANCEMENTS
 #include <QCMediaDefs.h>
 #endif
+#endif
 
 #include "ARTPWriter.h"
 #include <cutils/properties.h>
@@ -110,9 +117,11 @@
         ALOGE("Invalid audio source: %d", as);
         return BAD_VALUE;
     }
+#ifdef QCOM_HARDWARE
     if (ExtendedUtils::ShellProp::isAudioDisabled()) {
         return OK;
     }
+#endif
 
     if (as == AUDIO_SOURCE_DEFAULT) {
         mAudioSource = AUDIO_SOURCE_MIC;
@@ -165,15 +174,18 @@
         return BAD_VALUE;
     }
 
+#ifdef QCOM_HARDWARE
     if (ExtendedUtils::ShellProp::isAudioDisabled()) {
         return OK;
     }
+#endif
     if (ae == AUDIO_ENCODER_DEFAULT) {
         mAudioEncoder = AUDIO_ENCODER_AMR_NB;
     } else {
         mAudioEncoder = ae;
     }
 
+#ifdef QCOM_HARDWARE
     if(mAudioEncoder == AUDIO_ENCODER_AAC) {
         mSampleRate = mSampleRate ? mSampleRate : 48000;
         mAudioChannels = mAudioChannels ? mAudioChannels : 2;
@@ -191,6 +203,7 @@
         mAudioChannels = mAudioChannels ? mAudioChannels : 1;
         mAudioBitRate = mAudioBitRate ? mAudioBitRate : 12200;
     }
+#endif
     return OK;
 }
 
@@ -359,7 +372,11 @@
 
 status_t StagefrightRecorder::setParamAudioNumberOfChannels(int32_t channels) {
     ALOGV("setParamAudioNumberOfChannels: %d", channels);
+#ifdef QCOM_HARDWARE
     if (channels != 1 && channels != 2 && channels != 6) {
+#else
+    if (channels <= 0 || channels >= 3) {
+#endif
         ALOGE("Invalid number of audio channels: %d", channels);
         return BAD_VALUE;
     }
@@ -825,6 +842,7 @@
             status = startMPEG2TSRecording();
             break;
 
+#ifdef QCOM_HARDWARE
 #ifdef ENABLE_AV_ENHANCEMENTS
         case OUTPUT_FORMAT_QCP:
             status = startExtendedRecording( );
@@ -833,6 +851,7 @@
         case OUTPUT_FORMAT_WAVE:
             status = startWAVERecording( );
             break;
+#endif
         default:
             ALOGE("Unsupported output file format: %d", mOutputFormat);
             status = UNKNOWN_ERROR;
@@ -857,6 +876,7 @@
 }
 
 sp<MediaSource> StagefrightRecorder::createAudioSource() {
+#ifdef QCOM_HARDWARE
     bool tunneledSource = false;
     const char *tunnelMime;
     {
@@ -903,6 +923,7 @@
         audioSource = new AudioSource( mAudioSource, meta);
         return audioSource->initCheck( ) == OK ? audioSource : NULL;
     }
+#endif
     sp<AudioSource> audioSource =
         new AudioSource(
                 mAudioSource,
@@ -919,9 +940,11 @@
     sp<MetaData> encMeta = new MetaData;
     const char *mime;
     switch (mAudioEncoder) {
+#ifdef QCOM_HARDWARE
         case AUDIO_ENCODER_LPCM:
             mime = MEDIA_MIMETYPE_AUDIO_RAW;
             break;
+#endif
         case AUDIO_ENCODER_AMR_NB:
         case AUDIO_ENCODER_DEFAULT:
             mime = MEDIA_MIMETYPE_AUDIO_AMR_NB;
@@ -985,6 +1008,7 @@
         OMXCodec::Create(client.interface(), encMeta,
                          true /* createEncoder */, audioSource);
 #endif
+#ifdef QCOM_HARDWARE
     if (audioEncoder == NULL) {
         ALOGD("No encoder is needed, use the AudioSource directly as the MediaSource for LPCM format");
         audioEncoder = audioSource;
@@ -992,6 +1016,7 @@
     if (mAudioSourceNode != NULL) {
         mAudioSourceNode.clear();
     }
+#endif
     mAudioSourceNode = audioSource;
 
     return audioEncoder;
@@ -1059,6 +1084,8 @@
     }
     return status;
 }
+
+#ifdef QCOM_HARDWARE
 status_t StagefrightRecorder::startWAVERecording() {
     CHECK(mOutputFormat == OUTPUT_FORMAT_WAVE);
     CHECK(mAudioEncoder == AUDIO_ENCODER_LPCM);
@@ -1071,6 +1098,7 @@
     }
     return status;
 }
+#endif
 
 status_t StagefrightRecorder::startRawAudioRecording() {
     if (mAudioSource >= AUDIO_SOURCE_CNT) {
@@ -1575,6 +1603,7 @@
         enc_meta->setInt32(kKeyTimeScale, mVideoTimeScale);
     }
 
+#ifdef QCOM_HARDWARE
     status_t retVal = ExtendedUtils::HFR::reCalculateFileDuration(
             meta, enc_meta, mMaxFileDurationUs, mFrameRate, mVideoEncoder);
     if(retVal != OK) {
@@ -1582,6 +1611,7 @@
     }
 
     ExtendedUtils::ShellProp::setEncoderProfile(mVideoEncoder, mVideoEncoderProfile);
+#endif
 
     if (mVideoEncoderProfile != -1) {
         enc_meta->setInt32(kKeyVideoProfile, mVideoEncoderProfile);
@@ -1635,7 +1665,9 @@
         case AUDIO_ENCODER_AAC:
         case AUDIO_ENCODER_HE_AAC:
         case AUDIO_ENCODER_AAC_ELD:
+#ifdef QCOM_HARDWARE
         case AUDIO_ENCODER_LPCM:
+#endif
             break;
 
         default:
@@ -1797,10 +1829,13 @@
         ::close(mOutputFd);
         mOutputFd = -1;
     }
+
+#ifdef QCOM_HARDWARE
     if (mAudioSourceNode != NULL) {
         mAudioSourceNode.clear();
         mAudioSourceNode = NULL;
     }
+#endif
 
     if (mStarted) {
         mStarted = false;
@@ -1843,9 +1878,15 @@
     mVideoHeight   = 144;
     mFrameRate     = -1;
     mVideoBitRate  = 192000;
+#ifdef QCOM_HARDWARE
     mSampleRate    = 0;
     mAudioChannels = 0;
     mAudioBitRate  = 0;
+#else
+    mSampleRate    = 8000;
+    mAudioChannels = 1;
+    mAudioBitRate  = 12200;
+#endif
     mInterleaveDurationUs = 0;
     mIFramesIntervalSec = 1;
     mAudioSourceNode = 0;
diff --git a/media/libmediaplayerservice/StagefrightRecorder.h b/media/libmediaplayerservice/StagefrightRecorder.h
index 04724fe..e16e413 100644
--- a/media/libmediaplayerservice/StagefrightRecorder.h
+++ b/media/libmediaplayerservice/StagefrightRecorder.h
@@ -135,7 +135,9 @@
     status_t startMPEG4Recording();
     status_t startAMRRecording();
     status_t startAACRecording();
+#ifdef QCOM_HARDWARE
     status_t startWAVERecording();
+#endif
     status_t startRawAudioRecording();
     status_t startRTPRecording();
     status_t startMPEG2TSRecording();
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
index 6b27e52..f3fb5a2 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayerDecoder.cpp
@@ -25,7 +25,9 @@
 #include <media/stagefright/foundation/AMessage.h>
 #include <media/stagefright/ACodec.h>
 #include <media/stagefright/MediaDefs.h>
+#ifdef QCOM_HARDWARE
 #include <media/stagefright/ExtendedCodec.h>
+#endif
 
 namespace android {
 
@@ -58,6 +60,7 @@
         mCSD.push(csd);
     }
 
+#ifdef QCOM_HARDWARE
     sp<ABuffer> extendedCSD = ExtendedCodec::getRawCodecSpecificData(format);
     if (extendedCSD != NULL) {
         ALOGV("pushing extended CSD of size %d", extendedCSD->size());
@@ -69,6 +72,7 @@
         ALOGV("pushing AAC CSD of size %d", aacCSD->size());
         mCSD.push(aacCSD);
     }
+#endif
 
     if (mNativeWindow != NULL) {
         format->setObject("native-window", mNativeWindow);
diff --git a/media/libstagefright/ACodec.cpp b/media/libstagefright/ACodec.cpp
index fa45c95..4539224 100755
--- a/media/libstagefright/ACodec.cpp
+++ b/media/libstagefright/ACodec.cpp
@@ -32,7 +32,9 @@
 #include <media/stagefright/NativeWindowWrapper.h>
 #include <media/stagefright/OMXClient.h>
 #include <media/stagefright/OMXCodec.h>
+#ifdef QCOM_HARDWARE
 #include <media/stagefright/ExtendedCodec.h>
+#endif
 
 #include <media/hardware/HardwareAPI.h>
 
@@ -47,7 +49,9 @@
 #endif
 
 #include "include/avc_utils.h"
+#ifdef QCOM_HARDWARE
 #include "include/ExtendedUtils.h"
+#endif
 
 namespace android {
 
@@ -380,8 +384,12 @@
       mDequeueCounter(0),
       mStoreMetaDataInOutputBuffers(false),
       mMetaDataBuffersToSubmit(0),
+#ifdef QCOM_HARDWARE
       mRepeatFrameDelayUs(-1ll),
       mInSmoothStreamingMode(false) {
+#else
+      mRepeatFrameDelayUs(-1ll) {
+#endif
     mUninitializedState = new UninitializedState(this);
     mLoadedState = new LoadedState(this);
     mLoadedToIdleState = new LoadedToIdleState(this);
@@ -1023,7 +1031,11 @@
     }
 
     if (i == kNumMimeToRole) {
+#ifdef QCOM_HARDWARE
         return ExtendedCodec::setSupportedRole(mOMX, mNode, isEncoder, mime);
+#else
+        return ERROR_UNSUPPORTED;
+#endif
     }
 
     const char *role =
@@ -1219,10 +1231,12 @@
                 err = setupVideoDecoder(mime, width, height);
             }
         }
+#ifdef QCOM_HARDWARE
         if (err == OK) {
             const char* componentName = mComponentName.c_str();
             ExtendedCodec::configureVideoDecoder(msg, mime, mOMX, 0, mNode, componentName);
         }
+#endif
     } else if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_MPEG)) {
         int32_t numChannels, sampleRate;
         if (!msg->findInt32("channel-count", &numChannels)
@@ -1305,6 +1319,7 @@
         } else {
             err = setupRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
         }
+#ifdef QCOM_HARDWARE
     } else {
         if (encoder) {
             int32_t numChannels, sampleRate;
@@ -1318,6 +1333,7 @@
        if(err != OK) {
            return err;
        }
+#endif
     }
 
     if (err != OK) {
@@ -1796,8 +1812,10 @@
     status_t err = GetVideoCodingTypeFromMime(mime, &compressionFormat);
 
     if (err != OK) {
+#ifdef QCOM_HARDWARE
         err = ExtendedCodec::setVideoOutputFormat(mime, &compressionFormat);
         if (err != OK)
+#endif
             return err;
     }
 
@@ -1828,8 +1846,10 @@
         return err;
     }
 
+#ifdef QCOM_HARDWARE
     ExtendedCodec::enableSmoothStreaming(
             mOMX, mNode, &mInSmoothStreamingMode, mComponentName.c_str());
+#endif
 
     return OK;
 }
@@ -1924,11 +1944,15 @@
     err = GetVideoCodingTypeFromMime(mime, &compressionFormat);
 
     if (err != OK) {
+#ifdef QCOM_HARDWARE
         err = ExtendedCodec::setVideoInputFormat(mime, &compressionFormat);
         if (err != OK) {
             ALOGE("Not a supported video mime type: %s", mime);
+#endif
             return err;
+#ifdef QCOM_HARDWARE
         }
+#endif
     }
 
     err = setVideoPortFormatType(
@@ -2592,9 +2616,11 @@
                             rect.nTop,
                             rect.nLeft + rect.nWidth,
                             rect.nTop + rect.nHeight);
+#ifdef QCOM_HARDWARE
                     reply->setInt32(
                             "color-format",
                             (int)(videoDef->eColorFormat));
+#endif
                 }
             }
             break;
@@ -2712,6 +2738,7 @@
 
                 default:
                 {
+#ifdef QCOM_HARDWARE
                     AString mimeType;
                     status_t err = ExtendedCodec::handleSupportedAudioFormats(
                         audioDef->eEncoding, &mimeType);
@@ -2727,6 +2754,7 @@
                         notify->setInt32("channel-count", channelCount);
                         break;
                     }
+#endif
                     TRESPASS();
                 }
             }
@@ -3478,6 +3506,7 @@
     android_native_rect_t crop;
     if (msg->findRect("crop",
             &crop.left, &crop.top, &crop.right, &crop.bottom)) {
+#ifdef QCOM_HARDWARE
         if (mCodec->mInSmoothStreamingMode) {
             OMX_COLOR_FORMATTYPE eColorFormat = OMX_COLOR_FormatUnused;
             CHECK(msg->findInt32("color-format", (int32_t*)&eColorFormat));
@@ -3485,6 +3514,7 @@
                     mCodec->mNativeWindow.get(), crop.right,
                     crop.bottom, eColorFormat);
         }
+#endif
         CHECK_EQ(0, native_window_set_crop(
                 mCodec->mNativeWindow.get(), &crop));
     }
@@ -3697,7 +3727,9 @@
             ++matchIndex) {
         componentName = matchingCodecs.itemAt(matchIndex).mName.string();
         quirks = matchingCodecs.itemAt(matchIndex).mQuirks;
+#ifdef QCOM_HARDWARE
         ExtendedCodec::overrideComponentName(quirks, msg, &componentName);
+#endif
 
         pid_t tid = androidGetTid();
         int prevPriority = androidGetThreadPriority(tid);
diff --git a/media/libstagefright/Android.mk b/media/libstagefright/Android.mk
index 84c0552..7aae3c3 100644
--- a/media/libstagefright/Android.mk
+++ b/media/libstagefright/Android.mk
@@ -43,7 +43,6 @@
         NuMediaExtractor.cpp              \
         OMXClient.cpp                     \
         OMXCodec.cpp                      \
-        ExtendedCodec.cpp                 \
         OggExtractor.cpp                  \
         SampleIterator.cpp                \
         SampleTable.cpp                   \
@@ -57,14 +56,11 @@
         Utils.cpp                         \
         VBRISeeker.cpp                    \
         WAVExtractor.cpp                  \
-        WAVEWriter.cpp                    \
         WVMExtractor.cpp                  \
         XINGSeeker.cpp                    \
         avc_utils.cpp                     \
         mp4/FragmentedMP4Parser.cpp       \
         mp4/TrackFragment.cpp             \
-        ExtendedExtractor.cpp             \
-        ExtendedUtils.cpp                 \
 
 LOCAL_C_INCLUDES:= \
         $(TOP)/frameworks/av/include/media/stagefright/timedtext \
@@ -82,6 +78,12 @@
 endif
 
 ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
+    LOCAL_SRC_FILES += \
+        ExtendedCodec.cpp \
+        ExtendedExtractor.cpp \
+        ExtendedUtils.cpp \
+        WAVEWriter.cpp
+
     ifeq ($(BOARD_USES_ALSA_AUDIO),true)
         LOCAL_SRC_FILES += LPAPlayerALSA.cpp
     endif
diff --git a/media/libstagefright/AudioPlayer.cpp b/media/libstagefright/AudioPlayer.cpp
index ffa3475..ec86a25 100644
--- a/media/libstagefright/AudioPlayer.cpp
+++ b/media/libstagefright/AudioPlayer.cpp
@@ -52,7 +52,9 @@
       mFinalStatus(OK),
       mSeekTimeUs(0),
       mStarted(false),
+#ifdef QCOM_HARDWARE
       mSourcePaused(false),
+#endif
       mIsFirstBuffer(false),
       mFirstBufferResult(OK),
       mFirstBuffer(NULL),
@@ -81,7 +83,9 @@
 
     status_t err;
     if (!sourceAlreadyStarted) {
+#ifdef QCOM_HARDWARE
         mSourcePaused = false;
+#endif
         err = mSource->start();
 
         if (err != OK) {
@@ -276,19 +280,23 @@
     }
 
     mPlaying = false;
+#ifdef QCOM_HARDWARE
     CHECK(mSource != NULL);
     if (mSource->pause() == OK) {
         mSourcePaused = true;
     }
+#endif
 }
 
 status_t AudioPlayer::resume() {
     CHECK(mStarted);
+#ifdef QCOM_HARDWARE
     CHECK(mSource != NULL);
     if (mSourcePaused == true) {
         mSourcePaused = false;
         mSource->start();
     }
+#endif
     status_t err;
 
     if (mAudioSink.get() != NULL) {
@@ -350,7 +358,9 @@
         mInputBuffer->release();
         mInputBuffer = NULL;
     }
+#ifdef QCOM_HARDWARE
     mSourcePaused = false;
+#endif
     mSource->stop();
 
     // The following hack is necessary to ensure that the OMX
@@ -426,11 +436,13 @@
         MediaPlayerBase::AudioSink::cb_event_t event) {
     AudioPlayer *me = (AudioPlayer *)cookie;
 
+#ifdef QCOM_HARDWARE
     if (buffer == NULL) {
         //Not applicable for AudioPlayer
         ALOGE("This indicates the event underrun case for LPA/Tunnel");
         return 0;
     }
+#endif
     switch(event) {
     case MediaPlayerBase::AudioSink::CB_EVENT_FILL_BUFFER:
         return me->fillBuffer(buffer, size);
diff --git a/media/libstagefright/AudioSource.cpp b/media/libstagefright/AudioSource.cpp
index 23d6364..3c4f763 100644
--- a/media/libstagefright/AudioSource.cpp
+++ b/media/libstagefright/AudioSource.cpp
@@ -55,31 +55,49 @@
 
 AudioSource::AudioSource(
         audio_source_t inputSource, uint32_t sampleRate, uint32_t channelCount)
+#ifdef QCOM_HARDWARE
     : mRecord(NULL),
       mStarted(false),
+#else
+    : mStarted(false),
+#endif
       mSampleRate(sampleRate),
       mPrevSampleTimeUs(0),
       mNumFramesReceived(0),
+#ifdef QCOM_HARDWARE
       mNumClientOwnedBuffers(0),
       mFormat(AUDIO_FORMAT_PCM_16_BIT),
       mMime(MEDIA_MIMETYPE_AUDIO_RAW) {
+#else
+      mNumClientOwnedBuffers(0) {
+#endif
     ALOGV("sampleRate: %d, channelCount: %d", sampleRate, channelCount);
+#ifdef QCOM_HARDWARE
     CHECK(channelCount == 1 || channelCount == 2 || channelCount == 6);
+#else
+    CHECK(channelCount == 1 || channelCount == 2);
+#endif
 
     size_t minFrameCount;
     status_t status = AudioRecord::getMinFrameCount(&minFrameCount,
                                            sampleRate,
                                            AUDIO_FORMAT_PCM_16_BIT,
                                            audio_channel_in_mask_from_count(channelCount));
+#ifdef QCOM_HARDWARE
     if ( NO_ERROR != AudioSystem::getInputBufferSize(
         sampleRate, mFormat, channelCount, (size_t*)&mMaxBufferSize) ) {
         mMaxBufferSize = kMaxBufferSize;
         ALOGV("mMaxBufferSize = %d", mMaxBufferSize);
     }
+#endif
     if (status == OK) {
         // make sure that the AudioRecord callback never returns more than the maximum
         // buffer size
+#ifdef QCOM_HARDWARE
         int frameCount = mMaxBufferSize / sizeof(int16_t) / channelCount;
+#else
+        int frameCount = kMaxBufferSize / sizeof(int16_t) / channelCount;
+#endif
 
         // make sure that the AudioRecord total buffer size is large enough
         int bufCount = 2;
@@ -90,7 +108,11 @@
         mRecord = new AudioRecord(
                     inputSource, sampleRate, AUDIO_FORMAT_PCM_16_BIT,
                     audio_channel_in_mask_from_count(channelCount),
+#ifdef QCOM_HARDWARE
                     DEFAULT_TUNNEL_BUFFER_COUNT * mMaxBufferSize / sizeof(int16_t), /* Enable ping-pong buffers */
+#else
+                    bufCount * frameCount,
+#endif
                     AudioRecordCallbackFunction,
                     this,
                     frameCount);
@@ -109,6 +131,7 @@
     }
 }
 
+#ifdef QCOM_HARDWARE
 AudioSource::AudioSource( audio_source_t inputSource, const sp<MetaData>& meta )
     : mStarted(false),
       mPrevSampleTimeUs(0),
@@ -162,6 +185,8 @@
                 this);
     mInitCheck = mRecord->initCheck();
 }
+#endif
+
 AudioSource::~AudioSource() {
     if (mStarted) {
         reset();
@@ -243,10 +268,19 @@
     }
 
     sp<MetaData> meta = new MetaData;
+#ifdef QCOM_HARDWARE
     meta->setCString(kKeyMIMEType, mMime);
     meta->setInt32(kKeySampleRate, mRecord->getSampleRate());
+#else
+    meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_RAW);
+    meta->setInt32(kKeySampleRate, mSampleRate);
+#endif
     meta->setInt32(kKeyChannelCount, mRecord->channelCount());
+#ifdef QCOM_HARDWARE
     meta->setInt32(kKeyMaxInputSize, mMaxBufferSize);
+#else
+    meta->setInt32(kKeyMaxInputSize, kMaxBufferSize);
+#endif
 
     return meta;
 }
@@ -310,7 +344,9 @@
     int64_t timeUs;
     CHECK(buffer->meta_data()->findInt64(kKeyTime, &timeUs));
     int64_t elapsedTimeUs = timeUs - mStartTimeUs;
+#ifdef QCOM_HARDWARE
     if ( mFormat == AUDIO_FORMAT_PCM_16_BIT ) {
+#endif
         if (elapsedTimeUs < mAutoRampStartUs) {
         memset((uint8_t *) buffer->data(), 0, buffer->range_length());
         } else if (elapsedTimeUs < mAutoRampStartUs + kAutoRampDurationUs) {
@@ -324,10 +360,16 @@
         rampVolume(nFrames, autoRampDurationFrames,
                 (uint8_t *) buffer->data(), buffer->range_length());
         }
+#ifdef QCOM_HARDWARE
     }
+#endif
 
     // Track the max recording signal amplitude.
+#ifdef QCOM_HARDWARE
     if (mTrackMaxAmplitude && ( mFormat == AUDIO_FORMAT_PCM_16_BIT)) {
+#else
+    if (mTrackMaxAmplitude) {
+#endif
         trackMaxAmplitude(
             (int16_t *) buffer->data(), buffer->range_length() >> 1);
     }
@@ -384,7 +426,9 @@
     }
 
     CHECK_EQ(numLostBytes & 1, 0u);
+#ifdef QCOM_HARDWARE
     if ( mFormat == AUDIO_FORMAT_PCM_16_BIT )
+#endif
     CHECK_EQ(audioBuffer.size & 1, 0u);
     if (numLostBytes > 0) {
         // Loss of audio frames should happen rarely; thus the LOGW should
@@ -423,6 +467,7 @@
 void AudioSource::queueInputBuffer_l(MediaBuffer *buffer, int64_t timeUs) {
     const size_t bufferSize = buffer->range_length();
     const size_t frameSize = mRecord->frameSize();
+#ifdef QCOM_HARDWARE
     int64_t timestampUs = mPrevSampleTimeUs;
     int64_t recordDurationUs = 0;
     if ( mFormat == AUDIO_FORMAT_PCM_16_BIT && mSampleRate){
@@ -432,21 +477,35 @@
        recordDurationUs = bufferDurationUs(bufferSize);
     }
     timestampUs += recordDurationUs;
+#else
+    const int64_t timestampUs =
+                mPrevSampleTimeUs +
+                    ((1000000LL * (bufferSize / frameSize)) +
+                        (mSampleRate >> 1)) / mSampleRate;
+#endif
 
     if (mNumFramesReceived == 0) {
         buffer->meta_data()->setInt64(kKeyAnchorTime, mStartTimeUs);
     }
 
     buffer->meta_data()->setInt64(kKeyTime, mPrevSampleTimeUs);
+#ifdef QCOM_HARDWARE
     if (mFormat == AUDIO_FORMAT_PCM_16_BIT) {
+#endif
     buffer->meta_data()->setInt64(kKeyDriftTime, timeUs - mInitialReadTimeUs);
+#ifdef QCOM_HARDWARE
     } else {
         int64_t wallClockTimeUs = timeUs - mInitialReadTimeUs;
         int64_t mediaTimeUs = mStartTimeUs + mPrevSampleTimeUs;
         buffer->meta_data()->setInt64(kKeyDriftTime, mediaTimeUs - wallClockTimeUs);
     }
+#endif
     mPrevSampleTimeUs = timestampUs;
+#ifdef QCOM_HARDWARE
     mNumFramesReceived += buffer->range_length() / sizeof(int16_t);
+#else
+    mNumFramesReceived += bufferSize / frameSize;
+#endif
     mBuffersReceived.push_back(buffer);
     mFrameAvailableCondition.signal();
 }
@@ -474,6 +533,7 @@
     return value;
 }
 
+#ifdef QCOM_HARDWARE
 int64_t AudioSource::bufferDurationUs( ssize_t n ) {
     int64_t dataDurationMs = 0;
     if (mFormat == AUDIO_FORMAT_AMR_NB) {
@@ -492,4 +552,5 @@
         CHECK(0);
     return dataDurationMs*1000LL;
 }
+#endif
 }  // namespace android
diff --git a/media/libstagefright/AwesomePlayer.cpp b/media/libstagefright/AwesomePlayer.cpp
index a8a4094..952a18e 100644
--- a/media/libstagefright/AwesomePlayer.cpp
+++ b/media/libstagefright/AwesomePlayer.cpp
@@ -42,10 +42,12 @@
 #include <media/stagefright/foundation/ADebug.h>
 #include <media/stagefright/timedtext/TimedTextDriver.h>
 #include <media/stagefright/AudioPlayer.h>
+#ifdef QCOM_HARDWARE
 #include <media/stagefright/LPAPlayer.h>
 #ifdef USE_TUNNEL_MODE
 #include <media/stagefright/TunnelPlayer.h>
 #endif
+#endif
 #include <media/stagefright/DataSource.h>
 #include <media/stagefright/FileSource.h>
 #include <media/stagefright/MediaBuffer.h>
@@ -54,7 +56,9 @@
 #include <media/stagefright/MediaSource.h>
 #include <media/stagefright/MetaData.h>
 #include <media/stagefright/OMXCodec.h>
+#ifdef QCOM_HARDWARE
 #include "include/ExtendedUtils.h"
+#endif
 #include <media/stagefright/Utils.h>
 
 #include <gui/IGraphicBufferProducer.h>
@@ -66,8 +70,10 @@
 
 #define USE_SURFACE_ALLOC 1
 #define FRAME_DROP_FREQ 0
+#ifdef QCOM_HARDWARE
 #define LPA_MIN_DURATION_USEC_ALLOWED 30000000
 #define LPA_MIN_DURATION_USEC_DEFAULT 60000000
+#endif
 
 namespace android {
 
@@ -75,10 +81,12 @@
 static int64_t kHighWaterMarkUs = 5000000ll;  // 5secs
 static const size_t kLowWaterMarkBytes = 40000;
 static const size_t kHighWaterMarkBytes = 200000;
+#ifdef QCOM_HARDWARE
 static const int64_t kInitFrameDurationUs = 16000;
 static const int64_t kScheduleLagGapUs = 1000;
 static const int64_t kDefaultEventDelayUs = 10000;
 int AwesomePlayer::mTunnelAliveAP = 0;
+#endif
 
 // maximum time in paused state when offloading audio decompression. When elapsed, the AudioPlayer
 // is destroyed to allow the audio DSP to power down.
@@ -216,7 +224,9 @@
       mVideoBuffer(NULL),
       mDecryptHandle(NULL),
       mLastVideoTimeUs(-1),
+#ifdef QCOM_HARDWARE
       mFrameDurationUs(kInitFrameDurationUs),
+#endif
       mTextDriver(NULL),
       mOffloadAudio(false),
       mAudioTearDown(false) {
@@ -243,8 +253,10 @@
     mAudioTearDownEventPending = false;
 
     reset();
+#ifdef QCOM_HARDWARE
     mIsTunnelAudio = false;
     mLateAVSyncMargin = ExtendedUtils::ShellProp::getMaxAVSyncLateMargin();
+#endif
 }
 
 AwesomePlayer::~AwesomePlayer() {
@@ -254,6 +266,7 @@
 
     reset();
 
+#ifdef QCOM_HARDWARE
     // Disable Tunnel Mode Audio
     if (mIsTunnelAudio) {
         if (mTunnelAliveAP > 0) {
@@ -262,9 +275,11 @@
         }
     }
     mIsTunnelAudio = false;
+#endif
     mClient.disconnect();
 }
 
+#ifdef QCOM_HARDWARE
 void AwesomePlayer::printStats() {
     char value[PROPERTY_VALUE_MAX];
     property_get("persist.debug.sf.statistics", value, "0");
@@ -304,6 +319,7 @@
             (mFlags & PLAYING) > 0);
     }
 }
+#endif
 
 void AwesomePlayer::cancelPlayerEvents(bool keepNotifications) {
     mQueue.cancelEvent(mVideoEvent->eventID());
@@ -381,6 +397,7 @@
     return OK;
 }
 
+#ifdef QCOM_HARDWARE
 void AwesomePlayer::printFileName(int fd) {
 
     char symName[40] = {0};
@@ -392,6 +409,7 @@
         ALOGD("printFileName fd(%d) -> %s", fd, fileName);
     }
 }
+#endif
 
 status_t AwesomePlayer::setDataSource(
         int fd, int64_t offset, int64_t length) {
@@ -400,8 +418,10 @@
     ALOGD("Before reset_l");
     reset_l();
 
+#ifdef QCOM_HARDWARE
     if(fd)
         printFileName(fd);
+#endif
 
     sp<DataSource> dataSource = new FileSource(fd, offset, length);
 
@@ -648,8 +668,10 @@
 
     mVideoRenderer.clear();
 
+#ifdef QCOM_HARDWARE
     modifyFlags(PLAYING, CLEAR);
     printStats();
+#endif
     if (mVideoSource != NULL) {
         shutdownVideoDecoder_l();
     }
@@ -671,7 +693,9 @@
 
     mBitrate = -1;
     mLastVideoTimeUs = -1;
+#ifdef QCOM_HARDWARE
     mFrameDurationUs = kInitFrameDurationUs;
+#endif
     {
         Mutex::Autolock autoLock(mStatsLock);
         mStats.mFd = -1;
@@ -685,6 +709,7 @@
         mStats.mVideoHeight = -1;
         mStats.mFlags = 0;
         mStats.mTracks.clear();
+#ifdef QCOM_HARDWARE
         mStats.mConsecutiveFramesDropped = 0;
         mStats.mCatchupTimeStart = 0;
         mStats.mNumTimesSyncLoss = 0;
@@ -700,6 +725,7 @@
         mStats.mLastSeekToTimeMs = 0;
         mStats.mResumeDelayStartUs = -1;
         mStats.mSeekDelayStartUs = -1;
+#endif
     }
 
     mWatchForAudioSeekComplete = false;
@@ -1023,10 +1049,12 @@
             // We don't want to post an error notification at this point,
             // the error returned from MediaPlayer::start() will suffice.
             bool sendErrorNotification = false;
+#ifdef QCOM_HARDWARE
             if(mIsTunnelAudio) {
                 // For tunnel Audio error has to be posted to the client
                 sendErrorNotification = true;
             }
+#endif
             status_t err = startAudioPlayer_l(sendErrorNotification);
 
             if ((err != OK) && mOffloadAudio) {
@@ -1079,6 +1107,7 @@
         mTimeSource = &mSystemTimeSource;
     }
 
+#ifdef QCOM_HARDWARE
     {
         Mutex::Autolock autoLock(mStatsLock);
         if (mStats.mVeryFirstFrame) {
@@ -1087,6 +1116,7 @@
             mStats.mResumeDelayStartUs = getTimeOfDayUs();
         }
     }
+#endif
 
     if (mVideoSource != NULL) {
         // Kick off video playback
@@ -1125,11 +1155,13 @@
     uint32_t flags = 0;
     int64_t cachedDurationUs;
     bool eos;
+#ifdef QCOM_HARDWARE
     sp<MetaData> format = mAudioTrack->getFormat();
     const char *mime;
     bool success = format->findCString(kKeyMIMEType, &mime);
     int tunnelObjectsAlive = 0;
     CHECK(success);
+#endif
     if (mOffloadAudio) {
         flags |= AudioPlayer::USE_OFFLOAD;
     } else if (mVideoSource == NULL
@@ -1144,6 +1176,7 @@
     if (mVideoSource != NULL) {
         flags |= AudioPlayer::HAS_VIDEO;
     }
+#ifdef QCOM_HARDWARE
 #ifdef USE_TUNNEL_MODE
     // Create tunnel player if tunnel mode is enabled
     ALOGW("Trying to create tunnel player mIsTunnelAudio %d, \
@@ -1223,6 +1256,9 @@
         ALOGV("AudioPlayer created, Non-LPA mode mime %s duration %lld\n", mime, mDurationUs);
         mAudioPlayer = new AudioPlayer(mAudioSink, flags, this);
     }
+#else
+    mAudioPlayer = new AudioPlayer(mAudioSink, flags, this);
+#endif
     mAudioPlayer->setSource(mAudioSource);
 
     mTimeSource = mAudioPlayer;
@@ -1455,11 +1491,13 @@
                 Playback::PAUSE, 0);
     }
 
+#ifdef QCOM_HARDWARE
     if(!(mFlags & VIDEO_AT_EOS)){
         Mutex::Autolock autoLock(mStatsLock);
         mStats.mLastPausedTimeMs = mVideoTimeUs/1000;
         printStats();
     }
+#endif
 
     uint32_t params = IMediaPlayerService::kBatteryDataTrackDecoder;
     if ((mAudioSource != NULL) && (mAudioSource != mAudioTrack)) {
@@ -1621,10 +1659,12 @@
 
     mSeeking = SEEK;
 
+#ifdef QCOM_HARDWARE
     {
         Mutex::Autolock autoLock(mStatsLock);
         mStats.mSeekDelayStartUs = getTimeOfDayUs();
     }
+#endif
     mSeekNotificationSent = false;
     mSeekTimeUs = timeUs;
     modifyFlags((AT_EOS | AUDIO_AT_EOS | VIDEO_AT_EOS), CLEAR);
@@ -1701,6 +1741,7 @@
     // stream to hardware that doesn't have the necessary codec
     mOffloadAudio = canOffloadStream(meta, (mVideoSource != NULL), isStreamingHTTP());
 
+#ifdef QCOM_HARDWARE
     int32_t nchannels = 0;
     int32_t isADTS = 0;
     meta->findInt32( kKeyChannelCount, &nchannels );
@@ -1812,10 +1853,26 @@
                 mClient.interface(), mAudioTrack->getFormat(),
                 false, // createEncoder
                 mAudioTrack, matchComponentName, flags,NULL);
+#else
+    if (!strcasecmp(mime, MEDIA_MIMETYPE_AUDIO_RAW)) {
+        ALOGV("createAudioPlayer: bypass OMX (raw)");
+        mAudioSource = mAudioTrack;
+    } else {
+        // If offloading we still create a OMX decoder as a fall-back
+        // but we don't start it
+        mOmxSource = OMXCodec::Create(
+                mClient.interface(), mAudioTrack->getFormat(),
+                false, // createEncoder
+                mAudioTrack);
+#endif
 
         if (mOffloadAudio) {
             ALOGV("createAudioPlayer: bypass OMX (offload)");
             mAudioSource = mAudioTrack;
+#ifndef QCOM_HARDWARE
+        } else {
+            mAudioSource = mOmxSource;
+#endif
         }
     }
 
@@ -2012,17 +2069,21 @@
                 Playback::START, videoTimeUs / 1000);
     }
 
+#ifdef QCOM_HARDWARE
     {
         Mutex::Autolock autoLock(mStatsLock);
         mStats.mLastSeekToTimeMs = mSeekTimeUs/1000;
         printStats();
     }
+#endif
 }
 
 void AwesomePlayer::onVideoEvent() {
     ATRACE_CALL();
+#ifdef QCOM_HARDWARE
     int64_t eventStartTimeUs = mSystemTimeSource.getRealTimeUs();
     int64_t earlyGapUs = kScheduleLagGapUs; // gap for in case of event scheduling lag
+#endif
     Mutex::Autolock autoLock(mLock);
     if (!mVideoEventPending) {
         // The event has been cancelled in reset_l() but had already
@@ -2031,6 +2092,7 @@
     }
     mVideoEventPending = false;
 
+#ifdef QCOM_HARDWARE
     {
         Mutex::Autolock autoLock(mStatsLock);
         if(!mStats.mVeryFirstFrame && mSeeking == NO_SEEK){
@@ -2038,6 +2100,7 @@
         }
         mStats.mLastFrameUs = getTimeOfDayUs();
     }
+#endif
 
     if (mSeeking != NO_SEEK) {
         if (mVideoBuffer) {
@@ -2132,11 +2195,13 @@
 
     int64_t timeUs;
     CHECK(mVideoBuffer->meta_data()->findInt64(kKeyTime, &timeUs));
+#ifdef QCOM_HARDWARE
     if ((mLastVideoTimeUs != timeUs)
           && (mLastVideoTimeUs > 0)
           && (mSeeking == NO_SEEK)) {
         mFrameDurationUs = timeUs - mLastVideoTimeUs;
     }
+#endif
     mLastVideoTimeUs = timeUs;
 
     if (mSeeking == SEEK_VIDEO_ONLY) {
@@ -2177,6 +2242,7 @@
         mSinceLastDropped = 0;
         mTimeSourceDeltaUs = ts->getRealTimeUs() - timeUs;
 
+#ifdef QCOM_HARDWARE
         {
             Mutex::Autolock autoLock(mStatsLock);
             if(mStats.mVeryFirstFrame){
@@ -2185,6 +2251,7 @@
                 mStats.mLastFrameUs = getTimeOfDayUs();
             }
         }
+#endif
     }
 
     int64_t realTimeUs, mediaTimeUs, nowUs = 0, latenessUs = 0;
@@ -2238,7 +2305,11 @@
             }
         }
 
+#ifdef QCOM_HARDWARE
         if (latenessUs > mLateAVSyncMargin) {
+#else
+        if (latenessUs > 40000) {
+#endif
             // We're more than 40ms late.
             ALOGV("we're late by %lld us (%.2f secs)",
                  latenessUs, latenessUs / 1E6);
@@ -2257,28 +2328,36 @@
                 {
                     Mutex::Autolock autoLock(mStatsLock);
                     ++mStats.mNumVideoFramesDropped;
+#ifdef QCOM_HARDWARE
                     mStats.mConsecutiveFramesDropped++;
                     if (mStats.mConsecutiveFramesDropped == 1){
                         mStats.mCatchupTimeStart = mTimeSource->getRealTimeUs();
                     }
                     if(!(mFlags & AT_EOS)) logLate(timeUs,nowUs,latenessUs);
+#endif
                 }
 
+#ifdef QCOM_HARDWARE
                 int64_t eventDurationUs = mSystemTimeSource.getRealTimeUs() - eventStartTimeUs;
                 int64_t delayUs = mFrameDurationUs - eventDurationUs - latenessUs - earlyGapUs;
                 delayUs = delayUs > kDefaultEventDelayUs ? kDefaultEventDelayUs : delayUs;
                 postVideoEvent_l(delayUs > 0 ? delayUs : 0);
+#else
+                postVideoEvent_l();
+#endif
                 return;
             }
         }
 
         if (latenessUs < -10000) {
             // We're more than 10ms early.
+#ifdef QCOM_HARDWARE
             logOnTime(timeUs,nowUs,latenessUs);
             {
                 Mutex::Autolock autoLock(mStatsLock);
                 mStats.mConsecutiveFramesDropped = 0;
             }
+#endif
             postVideoEvent_l(10000);
             return;
         }
@@ -2302,6 +2381,7 @@
         if (mFlags & PLAYING) {
             notifyIfMediaStarted_l();
         }
+#ifdef QCOM_HARDWARE
         {
             Mutex::Autolock autoLock(mStatsLock);
             logOnTime(timeUs,nowUs,latenessUs);
@@ -2322,6 +2402,7 @@
                 }
             }
         }
+#endif
     }
 
     mVideoBuffer->release();
@@ -2331,10 +2412,14 @@
         modifyFlags(SEEK_PREVIEW, CLEAR);
         return;
     }
+#ifdef QCOM_HARDWARE
     int64_t eventDurationUs = mSystemTimeSource.getRealTimeUs() - eventStartTimeUs;
     int64_t delayUs = mFrameDurationUs - eventDurationUs - latenessUs - earlyGapUs;
     delayUs = delayUs > kDefaultEventDelayUs ? kDefaultEventDelayUs : delayUs;
     postVideoEvent_l(delayUs > 0 ? delayUs : 0);
+#else
+    postVideoEvent_l();
+#endif
 }
 
 void AwesomePlayer::postVideoEvent_l(int64_t delayUs) {
@@ -3168,6 +3253,7 @@
 
         if ((ssize_t)i == mStats.mVideoTrackIndex) {
             fprintf(out,
+#ifdef QCOM_HARDWARE
                     "   videoDimensions(%d x %d)\n"
                     "   Total Video Frames Decoded(%lld)\n"
                     "   Total Video Frames Rendered(%lld)\n"
@@ -3195,6 +3281,15 @@
                     mStats.mMaxTimeSyncLoss/1000,
                     (mFlags & AT_EOS) > 0,
                     (mFlags & PLAYING) > 0);
+#else
+                    "   videoDimensions(%d x %d), "
+                    "numVideoFramesDecoded(%lld), "
+                    "numVideoFramesDropped(%lld)\n",
+                    mStats.mVideoWidth,
+                    mStats.mVideoHeight,
+                    mStats.mNumVideoFramesDecoded,
+                    mStats.mNumVideoFramesDropped);
+#endif
         }
     }
 
@@ -3276,6 +3371,7 @@
     beginPrepareAsync_l();
 }
 
+#ifdef QCOM_HARDWARE
 bool AwesomePlayer::inSupportedTunnelFormats(const char * mime) {
     const char * tunnelFormats [ ] = {
         MEDIA_MIMETYPE_AUDIO_MPEG,
@@ -3409,4 +3505,5 @@
 
     return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
 }
+#endif
 }  // namespace android
diff --git a/media/libstagefright/CameraSource.cpp b/media/libstagefright/CameraSource.cpp
index 2067420..d054a14 100644
--- a/media/libstagefright/CameraSource.cpp
+++ b/media/libstagefright/CameraSource.cpp
@@ -30,7 +30,9 @@
 #include <gui/Surface.h>
 #include <utils/String8.h>
 #include <cutils/properties.h>
+#ifdef QCOM_HARDWARE
 #include "include/ExtendedUtils.h"
+#endif
 
 #ifdef USE_TI_CUSTOM_DOMX
 #include <OMX_TI_IVCommon.h>
@@ -582,7 +584,9 @@
     mMeta->setInt32(kKeySliceHeight, mVideoSize.height);
     mMeta->setInt32(kKeyFrameRate,   mVideoFrameRate);
 
+#ifdef QCOM_HARDWARE
     ExtendedUtils::HFR::setHFRIfEnabled(params, mMeta);
+#endif
 
     return OK;
 }
diff --git a/media/libstagefright/DataSource.cpp b/media/libstagefright/DataSource.cpp
index ed5b67e..ce994bd 100755
--- a/media/libstagefright/DataSource.cpp
+++ b/media/libstagefright/DataSource.cpp
@@ -32,7 +32,9 @@
 #include "include/OggExtractor.h"
 #include "include/WAVExtractor.h"
 #include "include/WVMExtractor.h"
+#ifdef QCOM_HARDWARE
 #include "include/ExtendedExtractor.h"
+#endif
 
 #include "matroska/MatroskaExtractor.h"
 
@@ -160,7 +162,9 @@
     RegisterSniffer(SniffAAC);
     RegisterSniffer(SniffMPEG2PS);
     RegisterSniffer(SniffWVM);
+#ifdef QCOM_HARDWARE
     RegisterSniffer(ExtendedExtractor::Sniff);
+#endif
 
     char value[PROPERTY_VALUE_MAX];
     if (property_get("drm.service.enabled", value, NULL)
diff --git a/media/libstagefright/MPEG4Extractor.cpp b/media/libstagefright/MPEG4Extractor.cpp
index 3994f1e..f810e53 100644
--- a/media/libstagefright/MPEG4Extractor.cpp
+++ b/media/libstagefright/MPEG4Extractor.cpp
@@ -310,8 +310,10 @@
     switch (fourcc) {
         case FOURCC('m', 'p', '4', 'a'):
             return MEDIA_MIMETYPE_AUDIO_AAC;
+#ifdef QCOM_HARDWARE
         case FOURCC('.', 'm', 'p', '3'):
             return MEDIA_MIMETYPE_AUDIO_MPEG;
+#endif
 
         case FOURCC('s', 'a', 'm', 'r'):
             return MEDIA_MIMETYPE_AUDIO_AMR_NB;
@@ -1262,9 +1264,12 @@
 
         case FOURCC('m', 'p', '4', 'a'):
         case FOURCC('e', 'n', 'c', 'a'):
+#ifdef QCOM_HARDWARE
         case FOURCC('.', 'm', 'p', '3'):
+#endif
         case FOURCC('s', 'a', 'm', 'r'):
         case FOURCC('s', 'a', 'w', 'b'):
+#ifdef QCOM_HARDWARE
         case FOURCC('s', 'e', 'v', 'c'):
         case FOURCC('s', 'q', 'c', 'p'):
         case FOURCC('d', 't', 's', 'c'):
@@ -1273,6 +1278,7 @@
         case FOURCC('d', 't', 's', 'e'):
         case FOURCC('a', 'c', '-', '3'):
         case FOURCC('e', 'c', '-', '3'):
+#endif
         {
             uint8_t buffer[8 + 20];
             if (chunk_data_size < (ssize_t)sizeof(buffer)) {
@@ -1307,12 +1313,16 @@
             mLastTrack->meta->setInt32(kKeySampleRate, sample_rate);
 
             off64_t stop_offset = *offset + chunk_size;
+#ifdef QCOM_HARDWARE
             if (!strcasecmp(MEDIA_MIMETYPE_AUDIO_MPEG, FourCC2MIME(chunk_type)) ||
                 !strcasecmp(MEDIA_MIMETYPE_AUDIO_AMR_WB, FourCC2MIME(chunk_type))) {
                *offset = stop_offset;
             } else {
+#endif
             *offset = data_offset + sizeof(buffer);
+#ifdef QCOM_HARDWARE
             }
+#endif
             while (*offset < stop_offset) {
                 status_t err = parseChunk(offset, depth + 1);
                 if (err != OK) {
@@ -1586,6 +1596,7 @@
             break;
         }
 
+#ifdef QCOM_HARDWARE
         case FOURCC('d', 'd', 't', 's'):
         case FOURCC('d', 'a', 'c', '3'):
         case FOURCC('d', 'e', 'c', '3'):
@@ -1594,6 +1605,7 @@
             *offset += chunk_size;
             break;
         }
+#endif
         case FOURCC('a', 'v', 'c', 'C'):
         {
             sp<ABuffer> buffer = new ABuffer(chunk_data_size);
@@ -2307,13 +2319,14 @@
        mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_EVRC);
        return OK;
     }
+#endif
     if (objectTypeIndication == 0xe1) {
         // This isn't MPEG4 audio at all, it's QCELP 14k...
         mLastTrack->meta->setCString(kKeyMIMEType, MEDIA_MIMETYPE_AUDIO_QCELP);
         return OK;
     }
-#endif
 
+#ifdef QCOM_HARDWARE
     if (objectTypeIndication  == 0x6b
          || objectTypeIndication  == 0x69) {
         // Our software MP3 audio decoder may not be able to handle
@@ -2321,6 +2334,15 @@
          ALOGD("objectTypeIndication:0x%x, set mimetype to mpeg ",objectTypeIndication);
          return OK;
     }
+#else
+    if (objectTypeIndication  == 0x6b) {
+        // The media subtype is MP3 audio
+        // Our software MP3 audio decoder may not be able to handle
+        // packetized MP3 audio; for now, lets just return ERROR_UNSUPPORTED
+        ALOGE("MP3 track in MP4/3GPP file is not supported");
+        return ERROR_UNSUPPORTED;
+    }
+#endif
 
     const uint8_t *csd;
     size_t csd_size;
@@ -3664,8 +3686,10 @@
         return false;
     }
 
-    if (!memcmp(header, "ftyp3g2a", 8) || !memcmp(header, "ftyp3g2b", 8) || !memcmp(header, "ftyp3g2c", 8)
-        || !memcmp(header, "ftyp3gp", 7) || !memcmp(header, "ftypmp42", 8)
+    if (!memcmp(header, "ftyp3gp", 7) || !memcmp(header, "ftypmp42", 8)
+#ifdef QCOM_HARDWARE
+        || !memcmp(header, "ftyp3g2a", 8) || !memcmp(header, "ftyp3g2b", 8) || !memcmp(header, "ftyp3g2c", 8)
+#endif
         || !memcmp(header, "ftyp3gr6", 8) || !memcmp(header, "ftyp3gs6", 8)
         || !memcmp(header, "ftyp3ge6", 8) || !memcmp(header, "ftyp3gg6", 8)
         || !memcmp(header, "ftypisom", 8) || !memcmp(header, "ftypM4V ", 8)
diff --git a/media/libstagefright/MPEG4Writer.cpp b/media/libstagefright/MPEG4Writer.cpp
index 2b1227c..596a069 100644
--- a/media/libstagefright/MPEG4Writer.cpp
+++ b/media/libstagefright/MPEG4Writer.cpp
@@ -40,7 +40,9 @@
 
 #include "include/ESDS.h"
 
+#ifdef QCOM_HARDWARE
 #include "include/ExtendedUtils.h"
+#endif
 
 namespace android {
 
@@ -2266,9 +2268,11 @@
         meta_data->findInt32(kKeyIsSyncFrame, &isSync);
         CHECK(meta_data->findInt64(kKeyTime, &timestampUs));
 
+#ifdef QCOM_HARDWARE
         if (!mIsAudio) {
             ExtendedUtils::HFR::reCalculateTimeStamp(mMeta, timestampUs);
         }
+#endif
 
 ////////////////////////////////////////////////////////////////////////////////
         if (mStszTableEntries->count() == 0) {
@@ -2299,7 +2303,9 @@
              */
             int64_t decodingTimeUs;
             CHECK(meta_data->findInt64(kKeyDecodingTime, &decodingTimeUs));
+#ifdef QCOM_HARDWARE
             ExtendedUtils::HFR::reCalculateTimeStamp(mMeta, decodingTimeUs);
+#endif
 
             decodingTimeUs -= previousPausedDurationUs;
             cttsOffsetTimeUs =
diff --git a/media/libstagefright/MediaCodec.cpp b/media/libstagefright/MediaCodec.cpp
index 5a1d341..31f045d 100755
--- a/media/libstagefright/MediaCodec.cpp
+++ b/media/libstagefright/MediaCodec.cpp
@@ -35,7 +35,9 @@
 #include <media/stagefright/MediaDefs.h>
 #include <media/stagefright/MediaErrors.h>
 #include <media/stagefright/MetaData.h>
+#ifdef QCOM_HARDWARE
 #include <media/stagefright/ExtendedCodec.h>
+#endif
 #include <media/stagefright/NativeWindowWrapper.h>
 
 #include "include/avc_utils.h"
@@ -1416,6 +1418,7 @@
         ++i;
     }
 
+#ifdef QCOM_HARDWARE
     sp<ABuffer> extendedCSD = ExtendedCodec::getRawCodecSpecificData(format);
     if (extendedCSD != NULL) {
         ALOGV("pushing extended CSD of size %d", extendedCSD->size());
@@ -1427,7 +1430,7 @@
         ALOGV("pushing AAC CSD of size %d", aacCSD->size());
         mCSD.push_back(aacCSD);
     }
-
+#endif
 
     ALOGV("Found %u pieces of codec specific data.", mCSD.size());
 }
diff --git a/media/libstagefright/MediaCodecList.cpp b/media/libstagefright/MediaCodecList.cpp
index b8499f9..60e8ea8 100644
--- a/media/libstagefright/MediaCodecList.cpp
+++ b/media/libstagefright/MediaCodecList.cpp
@@ -27,7 +27,9 @@
 #include <utils/threads.h>
 
 #include <libexpat/expat.h>
+#ifdef QCOM_HARDWARE
 #include "include/ExtendedUtils.h"
+#endif
 
 namespace android {
 
@@ -63,15 +65,16 @@
 
         addMediaCodec(true /* encoder */, "AACEncoder", "audio/mp4a-latm");
 
-
         addMediaCodec(
                      false /* encoder */, "OMX.google.raw.decoder", "audio/raw");
 
+#ifdef QCOM_HARDWARE
         Vector<AString> QcomAACQuirks;
         QcomAACQuirks.push(AString("requires-allocate-on-input-ports"));
         QcomAACQuirks.push(AString("requires-allocate-on-output-ports"));
         ExtendedUtils::helper_addMediaCodec(mCodecInfos, mTypes, false, "OMX.qcom.audio.decoder.multiaac",
             "audio/mp4a-latm", ExtendedUtils::helper_getCodecSpecificQuirks(mCodecQuirks, QcomAACQuirks));
+#endif
     }
 
 #if 0
diff --git a/media/libstagefright/MediaExtractor.cpp b/media/libstagefright/MediaExtractor.cpp
index 7c66429..5ebf160 100755
--- a/media/libstagefright/MediaExtractor.cpp
+++ b/media/libstagefright/MediaExtractor.cpp
@@ -39,7 +39,9 @@
 #include <media/stagefright/MetaData.h>
 #include <utils/String8.h>
 
+#ifdef QCOM_HARDWARE
 #include "include/ExtendedUtils.h"
+#endif
 
 namespace android {
 
@@ -128,7 +130,11 @@
        }
     }
 
+#ifdef QCOM_HARDWARE
     return ExtendedUtils::MediaExtractor_CreateIfNeeded(ret, source, mime);
+#else
+    return ret;
+#endif
 }
 
 }  // namespace android
diff --git a/media/libstagefright/OMXCodec.cpp b/media/libstagefright/OMXCodec.cpp
index fd20b6b..3b035d4 100644
--- a/media/libstagefright/OMXCodec.cpp
+++ b/media/libstagefright/OMXCodec.cpp
@@ -22,7 +22,9 @@
 #include <utils/Log.h>
 
 #include "include/AACEncoder.h"
+#ifdef QCOM_HARDWARE
 #include "include/MP3Decoder.h"
+#endif
 
 #include "include/ESDS.h"
 
@@ -45,8 +47,10 @@
 
 #include <OMX_Audio.h>
 #include <OMX_Component.h>
+#ifdef QCOM_HARDWARE
 #include <media/stagefright/ExtendedCodec.h>
 #include "include/ExtendedUtils.h"
+#endif
 #include "include/avc_utils.h"
 
 #ifdef ENABLE_AV_ENHANCEMENTS
@@ -54,7 +58,6 @@
 #include <QCMetaData.h>
 #include <QOMX_AudioExtensions.h>
 #endif
-#include "include/ExtendedUtils.h"
 
 #ifdef USE_SAMSUNG_COLORFORMAT
 #include <sec_format.h>
@@ -111,7 +114,9 @@
 
 #define FACTORY_REF(name) { #name, Make##name },
 
+#ifdef QCOM_HARDWARE
 FACTORY_CREATE(MP3Decoder)
+#endif
 FACTORY_CREATE_ENCODER(AACEncoder)
 
 static sp<MediaSource> InstantiateSoftwareEncoder(
@@ -135,6 +140,7 @@
     return NULL;
 }
 
+#ifdef QCOM_HARDWARE
 static sp<MediaSource> InstantiateSoftwareDecoder(
         const char *name, const sp<MediaSource> &source) {
     struct FactoryInfo {
@@ -152,6 +158,7 @@
     }
     return NULL;
 }
+#endif
 #undef FACTORY_CREATE_ENCODER
 #undef FACTORY_REF
 #undef FACTORY_CREATE
@@ -352,6 +359,7 @@
                 index, "output-buffers-are-unreadable")) {
         quirks |= kOutputBuffersAreUnreadable;
     }
+#ifdef QCOM_HARDWARE
     if (list->codecHasQuirk(
                 index, "requies-loaded-to-idle-after-allocation")) {
         quirks |= kRequiresLoadedToIdleAfterAllocation;
@@ -374,6 +382,7 @@
         quirks |= kRequiresFlushCompleteEmulation;
     }
 #endif // DOLBY_UDC
+#endif
 #ifdef OMAP_ENHANCEMENT
     if (list->codecHasQuirk(
                 index, "avoid-memcopy-input-recording-frames")) {
@@ -385,7 +394,9 @@
     }
 #endif
 
+#ifdef QCOM_HARDWARE
     quirks |= ExtendedCodec::getComponentQuirks(list,index);
+#endif
 
     return quirks;
 }
@@ -438,13 +449,17 @@
 
     Vector<CodecNameAndQuirks> matchingCodecs;
 
+#ifdef QCOM_HARDWARE
     if (ExtendedCodec::useHWAACDecoder(mime)) {
         findMatchingCodecs(mime, createEncoder,
             "OMX.qcom.audio.decoder.multiaac", flags, &matchingCodecs);
     } else {
+#endif
         findMatchingCodecs(
             mime, createEncoder, matchComponentName, flags, &matchingCodecs);
+#ifdef QCOM_HARDWARE
     }
+#endif
 
     if (matchingCodecs.isEmpty()) {
         ALOGV("No matching codecs! (mime: %s, createEncoder: %s, "
@@ -472,18 +487,22 @@
         sp<MediaSource> softwareCodec;
         if (createEncoder) {
             softwareCodec = InstantiateSoftwareEncoder(componentName, source, meta);
+#ifdef QCOM_HARDWARE
         } else {
             softwareCodec = InstantiateSoftwareDecoder(componentName, source);
         }
+#endif
             if (softwareCodec != NULL) {
                 ALOGV("Successfully allocated software codec '%s'", componentName);
 
                 return softwareCodec;
             }
 
+#ifdef QCOM_HARDWARE
         const char* ext_componentName = ExtendedCodec::overrideComponentName(quirks, meta);
         if(ext_componentName != NULL) {
           componentName = ext_componentName;
+#endif
         }
 
         ALOGV("Attempting to allocate OMX node '%s'", componentName);
@@ -627,14 +646,18 @@
             esds.getCodecSpecificInfo(
                     &codec_specific_data, &codec_specific_data_size);
 
+#ifdef QCOM_HARDWARE
             const char * mime_type;
             meta->findCString(kKeyMIMEType, &mime_type);
             if (strncmp(mime_type,
                         MEDIA_MIMETYPE_AUDIO_MPEG,
                         strlen(MEDIA_MIMETYPE_AUDIO_MPEG))) {
+#endif
             addCodecSpecificData(
                     codec_specific_data, codec_specific_data_size);
+#ifdef QCOM_HARDWARE
             }
+#endif
         } else if (meta->findData(kKeyAVCC, &type, &data, &size)) {
             // Parse the AVCDecoderConfigurationRecord
 
@@ -646,7 +669,9 @@
                 return err;
             }
 
+#ifdef QCOM_HARDWARE
             ExtendedUtils::setArbitraryModeIfInterlaced((const uint8_t *)data, meta);
+#endif
 
             CODEC_LOGI(
                     "AVC profile = %u (%s), level = %u",
@@ -656,6 +681,7 @@
 
             CHECK(meta->findData(kKeyVorbisBooks, &type, &data, &size));
             addCodecSpecificData(data, size);
+#ifdef QCOM_HARDWARE
 #ifdef ENABLE_AV_ENHANCEMENTS
         } else if (meta->findData(kKeyRawCodecSpecificData, &type, &data, &size)) {
             ALOGV("OMXCodec::configureCodec found kKeyRawCodecSpecificData of size %d\n", size);
@@ -666,6 +692,7 @@
             if (size) {
                 addCodecSpecificData(data, size);
             }
+#endif
         }
     }
 
@@ -733,6 +760,7 @@
         CHECK(meta->findInt32(kKeySampleRate, &sampleRate));
 
         setRawAudioFormat(kPortIndexInput, sampleRate, numChannels);
+#ifdef QCOM_HARDWARE
     } else {
         if (mIsEncoder && !mIsVideo) {
             int32_t numChannels, sampleRate;
@@ -745,6 +773,7 @@
         if(OK != err) {
             return err;
         }
+#endif
     }
 
     if (!strncasecmp(mMIME, "video/", 6)) {
@@ -762,12 +791,14 @@
                 return err;
             }
 
+#ifdef QCOM_HARDWARE
             ExtendedCodec::configureVideoDecoder(
                     meta, mMIME, mOMX, mFlags, mNode, mComponentName);
             ExtendedCodec::configureFramePackingFormat(
                     meta, mOMX, mNode, mComponentName);
             ExtendedCodec::enableSmoothStreaming(
                     mOMX, mNode, &mInSmoothStreamingMode, mComponentName);
+#endif
         }
     }
 
@@ -1034,7 +1065,9 @@
     CHECK(success);
     CHECK(stride != 0);
 
+#ifdef QCOM_HARDWARE
     ExtendedUtils::HFR::reCalculateHFRParams(meta, frameRate, bitRate);
+#endif
 
     OMX_VIDEO_CODINGTYPE compressionFormat = OMX_VIDEO_CodingUnused;
     if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_AVC, mime)) {
@@ -1044,11 +1077,15 @@
     } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_H263, mime)) {
         compressionFormat = OMX_VIDEO_CodingH263;
     } else {
+#ifdef QCOM_HARDWARE
         status_t err = ExtendedCodec::setVideoInputFormat(mime, &compressionFormat);
         if(err != OK) {
+#endif
         ALOGE("Not a supported video mime type: %s", mime);
         CHECK(!"Should not be here. Not a supported video mime type.");
-    }
+#ifdef QCOM_HARDWARE
+        }
+#endif
     }
 
     OMX_COLOR_FORMATTYPE colorFormat;
@@ -1292,7 +1329,9 @@
     h263type.nAllowedPictureTypes =
         OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
 
+#ifdef QCOM_HARDWARE
     ExtendedUtils::HFR::reCalculateHFRParams(meta, frameRate, bitRate);
+#endif
 
     h263type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate);
     if (h263type.nPFrames == 0) {
@@ -1345,7 +1384,9 @@
     mpeg4type.nAllowedPictureTypes =
         OMX_VIDEO_PictureTypeI | OMX_VIDEO_PictureTypeP;
 
+#ifdef QCOM_HARDWARE
     ExtendedUtils::HFR::reCalculateHFRParams(meta, frameRate, bitRate);
+#endif
 
     mpeg4type.nPFrames = setPFramesSpacing(iFramesInterval, frameRate);
     if (mpeg4type.nPFrames == 0) {
@@ -1368,7 +1409,9 @@
     mpeg4type.eProfile = static_cast<OMX_VIDEO_MPEG4PROFILETYPE>(profileLevel.mProfile);
     mpeg4type.eLevel = static_cast<OMX_VIDEO_MPEG4LEVELTYPE>(profileLevel.mLevel);
 
+#ifdef QCOM_HARDWARE
     ExtendedUtils::setBFrames(mpeg4type, mNumBFrames, mComponentName);
+#endif
     err = mOMX->setParameter(
             mNode, OMX_IndexParamVideoMpeg4, &mpeg4type, sizeof(mpeg4type));
     CHECK_EQ(err, (status_t)OK);
@@ -1406,16 +1449,20 @@
     h264type.eProfile = static_cast<OMX_VIDEO_AVCPROFILETYPE>(profileLevel.mProfile);
     h264type.eLevel = static_cast<OMX_VIDEO_AVCLEVELTYPE>(profileLevel.mLevel);
 
+#ifdef QCOM_HARDWARE
     ExtendedUtils::HFR::reCalculateHFRParams(meta, frameRate, bitRate);
+#endif
 
     // XXX
 #ifdef USE_TI_DUCATI_H264_PROFILE
     if ((strncmp(mComponentName, "OMX.TI.DUCATI1", 14) != 0)
             && (h264type.eProfile != OMX_VIDEO_AVCProfileBaseline)) {
-#else
+#elif defined (QCOM_HARDWARE)
     if (ExtendedUtils::isAVCProfileSupported(h264type.eProfile)){
         ALOGI("Profile type is  %d ",h264type.eProfile);
     } else if (h264type.eProfile != OMX_VIDEO_AVCProfileBaseline) {
+#else
+    if (h264type.eProfile != OMX_VIDEO_AVCProfileBaseline) {
 #endif
         ALOGW("Use baseline profile instead of %d for AVC recording",
             h264type.eProfile);
@@ -1441,8 +1488,10 @@
         h264type.nCabacInitIdc = 0;
     }
 
+#ifdef QCOM_HARDWARE
     ExtendedUtils::setBFrames(
             h264type, mNumBFrames, iFramesInterval, frameRate, mComponentName);
+#endif
     if (h264type.nBFrames != 0) {
         h264type.nAllowedPictureTypes |= OMX_VIDEO_PictureTypeB;
     }
@@ -1488,12 +1537,16 @@
     } else if (!strcasecmp(MEDIA_MIMETYPE_VIDEO_MPEG2, mime)) {
         compressionFormat = OMX_VIDEO_CodingMPEG2;
     } else {
+#ifdef QCOM_HARDWARE
         status_t err = ExtendedCodec::setVideoOutputFormat(mime,&compressionFormat);
 
         if(err != OK) {
+#endif
         ALOGE("Not a supported video mime type: %s", mime);
         CHECK(!"Should not be here. Not a supported video mime type.");
-    }
+#ifdef QCOM_HARDWARE
+        }
+#endif
     }
 
     status_t err = setVideoPortFormatType(
@@ -1654,7 +1707,9 @@
       mState(LOADED),
       mInitialBufferSubmit(true),
       mSignalledEOS(false),
+#ifdef QCOM_HARDWARE
       mFinalStatus(OK),
+#endif
       mNoMoreOutputData(false),
       mOutputPortSettingsHaveChanged(false),
       mSeekTimeUs(-1),
@@ -1667,9 +1722,13 @@
       mNativeWindow(
               (!strncmp(componentName, "OMX.google.", 11)
               || !strcmp(componentName, "OMX.Nvidia.mpeg2v.decode"))
+#ifdef QCOM_HARDWARE
                         ? NULL : nativeWindow),
       mNumBFrames(0),
       mInSmoothStreamingMode(false) {
+#else
+                        ? NULL : nativeWindow) {
+#endif
     mPortStatus[kPortIndexInput] = ENABLED;
     mPortStatus[kPortIndexOutput] = ENABLED;
 
@@ -1754,7 +1813,9 @@
     }
 
     if (i == kNumMimeToRole) {
+#ifdef QCOM_HARDWARE
         ExtendedCodec::setSupportedRole(omx, node, isEncoder, mime);
+#endif
         return;
     }
 
@@ -1841,8 +1902,10 @@
     return state == LOADED_TO_IDLE
         || state == IDLE_TO_EXECUTING
         || state == EXECUTING_TO_IDLE
+#ifdef QCOM_HARDWARE
         || state == PAUSING
         || state == FLUSHING
+#endif
         || state == IDLE_TO_LOADED
         || state == RECONFIGURING;
 }
@@ -2176,6 +2239,7 @@
         return err;
     }
 
+#ifdef QCOM_HARDWARE
     err = mNativeWindow.get()->perform(mNativeWindow.get(),
                              NATIVE_WINDOW_SET_BUFFERS_SIZE, def.nBufferSize);
     if (err != 0) {
@@ -2183,6 +2247,7 @@
                 -err);
         return err;
     }
+#endif
     CODEC_LOGV("allocating %lu buffers from a native window of size %lu on "
             "output port", def.nBufferCountActual, def.nBufferSize);
 
@@ -2943,18 +3008,22 @@
 
             CODEC_LOGV("FLUSH_DONE(%ld)", portIndex);
 
+#ifdef QCOM_HARDWARE
             if (portIndex == (OMX_U32) -1) {
                 CHECK_EQ((int)mPortStatus[kPortIndexInput], (int)SHUTTING_DOWN);
                 mPortStatus[kPortIndexInput] = ENABLED;
                 CHECK_EQ((int)mPortStatus[kPortIndexOutput], (int)SHUTTING_DOWN);
                 mPortStatus[kPortIndexOutput] = ENABLED;
             } else {
+#endif
             CHECK_EQ((int)mPortStatus[portIndex], (int)SHUTTING_DOWN);
             mPortStatus[portIndex] = ENABLED;
 
             CHECK_EQ(countBuffersWeOwn(mPortBuffers[portIndex]),
                      mPortBuffers[portIndex].size());
+#ifdef QCOM_HARDWARE
             }
+#endif
 
             if (mSkipCutBuffer != NULL && mPortStatus[kPortIndexOutput] == ENABLED) {
                 mSkipCutBuffer->clear();
@@ -3061,6 +3130,7 @@
                 mPortStatus[kPortIndexInput] = ENABLED;
                 mPortStatus[kPortIndexOutput] = ENABLED;
 
+#ifdef QCOM_HARDWARE
                 if (mNativeWindow != NULL) {
                     /*
                      * reset buffer size field with SurfaceTexture
@@ -3076,6 +3146,7 @@
                         ALOGE("set_buffers_size failed: %s (%d)", strerror(-err),
                              -err);
                     }
+#endif
 
                     if (mFlags & kEnableGrallocUsageProtected) {
                         // We push enough 1x1 blank buffers to ensure that one of
@@ -3084,7 +3155,9 @@
                         // without the risk of scanning out one of those buffers.
                         pushBlankBuffersToNativeWindow();
                     }
+#ifdef QCOM_HARDWARE
                 }
+#endif
 
                 setState(IDLE_TO_LOADED);
             }
@@ -3119,6 +3192,7 @@
             break;
         }
 
+#ifdef QCOM_HARDWARE
         case OMX_StatePause:
         {
             CODEC_LOGV("Now paused.");
@@ -3126,6 +3200,7 @@
             setState(PAUSED);
             break;
         }
+#endif
 
         case OMX_StateInvalid:
         {
@@ -3241,12 +3316,18 @@
 
 bool OMXCodec::flushPortAsync(OMX_U32 portIndex) {
     CHECK(mState == EXECUTING || mState == RECONFIGURING
+#ifdef QCOM_HARDWARE
             || mState == EXECUTING_TO_IDLE || mState == FLUSHING);
+#else
+            || mState == EXECUTING_TO_IDLE);
+#endif
 
+#ifdef QCOM_HARDWARE
     if (portIndex == (OMX_U32) -1 ) {
         mPortStatus[kPortIndexInput] = SHUTTING_DOWN;
         mPortStatus[kPortIndexOutput] = SHUTTING_DOWN;
     } else {
+#endif
     CODEC_LOGV("flushPortAsync(%ld): we own %d out of %d buffers already.",
          portIndex, countBuffersWeOwn(mPortBuffers[portIndex]),
          mPortBuffers[portIndex].size());
@@ -3261,8 +3342,10 @@
         // flush-complete event in this case.
 
         return false;
-        }
     }
+#ifdef QCOM_HARDWARE
+    }
+#endif
 
     status_t err =
         mOMX->sendCommand(mNode, OMX_CommandFlush, portIndex);
@@ -3296,7 +3379,11 @@
 }
 
 void OMXCodec::fillOutputBuffers() {
+#ifdef QCOM_HARDWARE
     CHECK(mState == EXECUTING || mState == FLUSHING);
+#else
+    CHECK_EQ((int)mState, (int)EXECUTING);
+#endif
 
     // This is a workaround for some decoders not properly reporting
     // end-of-output-stream. If we own all input buffers and also own
@@ -3308,7 +3395,9 @@
     // thumbnail mode calls emptyBuffer with an EOS flag on its first
     // frame and sets mSignalledEOS to true, so without the check for
     // !mThumbnailMode, fillOutputBuffer will never be called.
+#ifdef QCOM_HARDWARE
     if(!ExtendedUtils::checkIsThumbNailMode(mFlags, mComponentName)) {
+#endif
         if (mSignalledEOS
             && countBuffersWeOwn(mPortBuffers[kPortIndexInput])
                 == mPortBuffers[kPortIndexInput].size()
@@ -3319,7 +3408,9 @@
 
             return;
         }
+#ifdef QCOM_HARDWARE
     }
+#endif
 
     Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexOutput];
     for (size_t i = 0; i < buffers->size(); ++i) {
@@ -3331,7 +3422,11 @@
 }
 
 void OMXCodec::drainInputBuffers() {
+#ifdef QCOM_HARDWARE
     CHECK(mState == EXECUTING || mState == RECONFIGURING || mState == FLUSHING);
+#else
+    CHECK(mState == EXECUTING || mState == RECONFIGURING);
+#endif
 
     if (mFlags & kUseSecureInputBuffers) {
         Vector<BufferInfo> *buffers = &mPortBuffers[kPortIndexInput];
@@ -3354,8 +3449,12 @@
                 break;
             }
 
+#ifdef QCOM_HARDWARE
             if ((mFlags & kOnlySubmitOneInputBufferAtOneTime)
                     && (i == mNumBFrames)) {
+#else
+            if (mFlags & kOnlySubmitOneInputBufferAtOneTime) {
+#endif
                 break;
             }
         }
@@ -3458,8 +3557,10 @@
 
     size_t offset = 0;
     int32_t n = 0;
+#ifdef QCOM_HARDWARE
     int32_t InterlaceFormatDetected = false;
     int32_t InterlaceFrameCount = 0;
+#endif
 
 
     for (;;) {
@@ -3507,8 +3608,10 @@
             break;
         }
 
+#ifdef QCOM_HARDWARE
         sp<MetaData> metaData = mSource->getFormat();
         InterlaceFormatDetected = ExtendedUtils::checkIsInterlace(metaData);
+#endif
 
         if (mFlags & kUseSecureInputBuffers) {
             info = findInputBufferByDataPointer(srcBuffer->data());
@@ -3668,12 +3771,15 @@
 
     OMX_U32 flags = OMX_BUFFERFLAG_ENDOFFRAME;
 
+#ifdef QCOM_HARDWARE
     if(InterlaceFormatDetected) {
         InterlaceFrameCount++;
     }
+#endif
 
     if (signalEOS) {
         flags |= OMX_BUFFERFLAG_EOS;
+#ifdef QCOM_HARDWARE
     } else if(ExtendedUtils::checkIsThumbNailMode(mFlags, mComponentName)
                    && (!InterlaceFormatDetected || InterlaceFrameCount>= 2)) {
         // Because we don't get an EOS after getting the first frame, we
@@ -3687,6 +3793,7 @@
         mNoMoreOutputData = false;
         mSignalledEOS = true;
         mFinalStatus = ERROR_END_OF_STREAM;
+#endif
     } else {
         mNoMoreOutputData = false;
     }
@@ -3793,9 +3900,11 @@
         return mBufferFilled.wait(mLock);
     }
     status_t err = mBufferFilled.waitRelative(mLock, kBufferFilledEventTimeOutNs);
+#ifdef QCOM_HARDWARE
     if ((err == -ETIMEDOUT) && (mPaused == true)){
         err = OK;
     }
+#endif
     if (err != OK) {
         CODEC_LOGE("Timed out waiting for output buffers: %d/%d",
             countBuffersWeOwn(mPortBuffers[kPortIndexInput]),
@@ -3811,7 +3920,9 @@
     OMX_PARAM_PORTDEFINITIONTYPE def;
     InitOMXParams(&def);
     def.nPortIndex = portIndex;
+#ifdef QCOM_HARDWARE
     def.format.audio.cMIMEType = NULL;
+#endif
     status_t err = mOMX->getParameter(
             mNode, OMX_IndexParamPortDefinition, &def, sizeof(def));
     CHECK_EQ(err, (status_t)OK);
@@ -4144,6 +4255,7 @@
 status_t OMXCodec::start(MetaData *meta) {
     Mutex::Autolock autoLock(mLock);
 
+#ifdef QCOM_HARDWARE
     if (mPaused) {
         if (!strncmp(mComponentName, "OMX.qcom.", 9)) {
             while (isIntermediateState(mState)) {
@@ -4164,6 +4276,7 @@
             return OK;
         }
     }
+#endif
 
     if (mState != LOADED) {
         CODEC_LOGE("called start in the unexpected state: %d", mState);
@@ -4275,7 +4388,9 @@
             isError = true;
         }
 
+#ifdef QCOM_HARDWARE
         case PAUSED:
+#endif
         case EXECUTING:
         {
             setState(EXECUTING_TO_IDLE);
@@ -4284,6 +4399,7 @@
                 CODEC_LOGV("This component requires a flush before transitioning "
                      "from EXECUTING to IDLE...");
 
+#ifdef QCOM_HARDWARE
                 //DSP supports flushing of ports simultaneously.
                 //Flushing individual port is not supported.
                 if(mQuirks & kRequiresGlobalFlush) {
@@ -4292,6 +4408,7 @@
                         onCmdComplete(OMX_CommandFlush, kPortIndexBoth);
                     }
                 } else {
+#endif
                 bool emulateInputFlushCompletion =
                     !flushPortAsync(kPortIndexInput);
 
@@ -4304,8 +4421,10 @@
 
                 if (emulateOutputFlushCompletion) {
                     onCmdComplete(OMX_CommandFlush, kPortIndexOutput);
-                    }
                 }
+#ifdef QCOM_HARDWARE
+                }
+#endif
             } else {
                 mPortStatus[kPortIndexInput] = SHUTTING_DOWN;
                 mPortStatus[kPortIndexOutput] = SHUTTING_DOWN;
@@ -4412,6 +4531,7 @@
         mFilledBuffers.clear();
 
         CHECK_EQ((int)mState, (int)EXECUTING);
+#ifdef QCOM_HARDWARE
         setState(FLUSHING);
 
         if(mQuirks & kRequiresGlobalFlush) {
@@ -4428,6 +4548,7 @@
                 onCmdComplete(OMX_CommandFlush, kPortIndexBoth);
             }
         } else {
+#endif
         bool emulateInputFlushCompletion = !flushPortAsync(kPortIndexInput);
         bool emulateOutputFlushCompletion = !flushPortAsync(kPortIndexOutput);
 
@@ -4438,8 +4559,10 @@
         if (emulateOutputFlushCompletion) {
             onCmdComplete(OMX_CommandFlush, kPortIndexOutput);
         }
-            }
+#ifdef QCOM_HARDWARE
         }
+        }
+#endif
 
         while (mSeekTimeUs >= 0) {
             if ((err = waitForBufferFilled_l()) != OK) {
@@ -4450,6 +4573,7 @@
 
     while (mState != ERROR && !mNoMoreOutputData && mFilledBuffers.empty()) {
         if ((err = waitForBufferFilled_l()) != OK) {
+#ifdef QCOM_HARDWARE
             if ((err == -ETIMEDOUT) && (mPaused == true) && !mIsVideo) {
                 // When the audio playback is paused, the fill buffer maybe timed out
                 // if input data is not available to decode. Hence, considering the
@@ -4457,6 +4581,7 @@
                 ALOGV("returned OK instead of timedout from read() as mPaused is true");
                 err = OK;
             }
+#endif
             return err;
         }
     }
@@ -4465,10 +4590,12 @@
         return UNKNOWN_ERROR;
     }
 
+#ifdef QCOM_HARDWARE
     if (seeking) {
         CHECK_EQ((int)mState, (int)FLUSHING);
         setState(EXECUTING);
     }
+#endif
 
     if (mFilledBuffers.empty()) {
         return mSignalledEOS ? mFinalStatus : ERROR_END_OF_STREAM;
@@ -5033,6 +5160,7 @@
                 mOutputFormat->setInt32(kKeySampleRate, sampleRate);
                 mOutputFormat->setInt32(kKeyBitRate, bitRate);
             } else {
+#ifdef QCOM_HARDWARE
                 AString mimeType;
                 if (OK == ExtendedCodec::handleSupportedAudioFormats(
                         audio_def->eEncoding, &mimeType)) {
@@ -5046,8 +5174,11 @@
                     mOutputFormat->setInt32(kKeySampleRate, sampleRate);
                     mOutputFormat->setInt32(kKeyBitRate, bitRate);
                 } else {
+#endif
                 CHECK(!"Should not be here. Unknown audio encoding.");
+#ifdef QCOM_HARDWARE
                 }
+#endif
             }
             break;
         }
@@ -5116,15 +5247,19 @@
                 }
 
                 if (mNativeWindow != NULL) {
+#ifdef QCOM_HARDWARE
                     if (mInSmoothStreamingMode) {
                         ExtendedUtils::updateNativeWindowBufferGeometry(
                                 mNativeWindow.get(), video_def->nFrameWidth,
                                 video_def->nFrameHeight, video_def->eColorFormat);
                     }
+#endif
                     initNativeWindowCrop();
                 }
+#ifdef QCOM_HARDWARE
             } else {
                 ExtendedUtils::HFR::copyHFRParams(inputFormat, mOutputFormat);
+#endif
             }
             break;
         }
@@ -5149,6 +5284,7 @@
     CODEC_LOGV("pause mState=%d", mState);
 
     Mutex::Autolock autoLock(mLock);
+#ifdef QCOM_HARDWARE
     if (mState != EXECUTING) {
         return UNKNOWN_ERROR;
     }
@@ -5166,9 +5302,12 @@
         }
         return mState == ERROR ? UNKNOWN_ERROR : OK;
     } else {
+#endif
         mPaused = true;
         return OK;
+#ifdef QCOM_HARDWARE
     }
+#endif
 }
 
 ////////////////////////////////////////////////////////////////////////////////
diff --git a/media/libstagefright/Utils.cpp b/media/libstagefright/Utils.cpp
index c6b94bd..124205c 100755
--- a/media/libstagefright/Utils.cpp
+++ b/media/libstagefright/Utils.cpp
@@ -32,7 +32,9 @@
 #include <hardware/audio.h>
 #include <media/stagefright/Utils.h>
 #include <media/AudioParameter.h>
+#ifdef QCOM_HARDWARE
 #include <media/stagefright/ExtendedCodec.h>
+#endif
 
 #ifdef ENABLE_AV_ENHANCEMENTS
 #include "QCMetaData.h"
@@ -282,7 +284,9 @@
         msg->setBuffer("csd-1", buffer);
     }
 
+#ifdef QCOM_HARDWARE
     ExtendedCodec::convertMetaDataToMessage(meta, &msg);
+#endif
     *format = msg;
 
     return OK;
diff --git a/media/libstagefright/avc_utils.cpp b/media/libstagefright/avc_utils.cpp
index c0f7322..1d843f3 100644
--- a/media/libstagefright/avc_utils.cpp
+++ b/media/libstagefright/avc_utils.cpp
@@ -44,7 +44,11 @@
 void FindAVCDimensions(
         const sp<ABuffer> &seqParamSet,
         int32_t *width, int32_t *height,
+#ifdef QCOM_HARDWARE
         int32_t *sarWidth, int32_t *sarHeight, int32_t *isInterlaced) {
+#else
+        int32_t *sarWidth, int32_t *sarHeight) {
+#endif
     ABitReader br(seqParamSet->data() + 1, seqParamSet->size() - 1);
 
     unsigned profile_idc = br.getBits(8);
@@ -63,11 +67,13 @@
         parseUE(&br);  // bit_depth_luma_minus8
         parseUE(&br);  // bit_depth_chroma_minus8
         br.skipBits(1);  // qpprime_y_zero_transform_bypass_flag
+#ifdef QCOM_HARDWARE
         bool seq_scaling_matrix_present = (br.getBits(1) != 0u);
         if (isInterlaced != NULL && seq_scaling_matrix_present) {
             return;
         }
         CHECK_EQ(seq_scaling_matrix_present, false);  // seq_scaling_matrix_present_flag
+#endif
     }
 
     parseUE(&br);  // log2_max_frame_num_minus4
@@ -137,9 +143,11 @@
             (frame_crop_top_offset + frame_crop_bottom_offset) * cropUnitY;
     }
 
+#ifdef QCOM_HARDWARE
     if (isInterlaced != NULL) {
         *isInterlaced = !frame_mbs_only_flag;
     }
+#endif
 
     if (sarWidth != NULL) {
         *sarWidth = 0;
diff --git a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
index bdba267..78d0b23 100644
--- a/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
+++ b/media/libstagefright/codecs/amrnb/dec/SoftAMR.cpp
@@ -438,10 +438,14 @@
 void SoftAMR::onPortFlushCompleted(OMX_U32 portIndex) {
         ALOGE("onPortFlushCompleted portindex %d, resetting frame ",portIndex);
         if(portIndex == 0) {
+#ifdef QCOM_HARDWARE
            if(mMode == MODE_NARROW)
               Speech_Decode_Frame_reset(mState);
            else
               pvDecoder_AmrWb_Reset(mState, 0);
+#else
+           Speech_Decode_Frame_reset(mState);
+#endif
         }
 }
 
diff --git a/media/libstagefright/codecs/mp3dec/Android.mk b/media/libstagefright/codecs/mp3dec/Android.mk
index 9e10527..c27a63d 100644
--- a/media/libstagefright/codecs/mp3dec/Android.mk
+++ b/media/libstagefright/codecs/mp3dec/Android.mk
@@ -2,7 +2,6 @@
 include $(CLEAR_VARS)
 
 LOCAL_SRC_FILES := \
-        MP3Decoder.cpp \
 	src/pvmp3_normalize.cpp \
  	src/pvmp3_alias_reduction.cpp \
  	src/pvmp3_crc.cpp \
@@ -43,6 +42,11 @@
  	src/pvmp3_dct_16.cpp
 endif
 
+ifeq ($(BOARD_USES_QCOM_HARDWARE),true)
+LOCAL_SRC_FILES += \
+	MP3Decoder.cpp
+endif
+
 LOCAL_C_INCLUDES := \
         frameworks/av/media/libstagefright/include \
         $(LOCAL_PATH)/src \
diff --git a/media/libstagefright/include/AwesomePlayer.h b/media/libstagefright/include/AwesomePlayer.h
index dd6c409..2973986 100644
--- a/media/libstagefright/include/AwesomePlayer.h
+++ b/media/libstagefright/include/AwesomePlayer.h
@@ -104,7 +104,9 @@
     void postAudioEOS(int64_t delayUs = 0ll);
     void postAudioSeekComplete();
     void postAudioTearDown();
+#ifdef QCOM_HARDWARE
     void printFileName(int fd);
+#endif
     status_t dump(int fd, const Vector<String16> &args) const;
 
 private:
@@ -207,7 +209,9 @@
 
     bool mWatchForAudioSeekComplete;
     bool mWatchForAudioEOS;
+#ifdef QCOM_HARDWARE
     static int mTunnelAliveAP;
+#endif
 
     sp<TimedEventQueue::Event> mVideoEvent;
     bool mVideoEventPending;
@@ -318,6 +322,7 @@
         ASSIGN
     };
     void modifyFlags(unsigned value, FlagMode mode);
+#ifdef QCOM_HARDWARE
     void checkTunnelExceptions();
     void logFirstFrame();
     void logCatchUp(int64_t ts, int64_t clock, int64_t delta);
@@ -327,6 +332,7 @@
     int64_t getTimeOfDayUs();
     bool mStatistics;
     int64_t mLateAVSyncMargin;
+#endif
 
     struct TrackStat {
         String8 mMIME;
@@ -353,6 +359,7 @@
         uint32_t mFlags;
         Vector<TrackStat> mTracks;
 
+#ifdef QCOM_HARDWARE
         int64_t mConsecutiveFramesDropped;
         uint32_t mCatchupTimeStart;
         uint32_t mNumTimesSyncLoss;
@@ -369,6 +376,7 @@
         int64_t mLastSeekToTimeMs;
         int64_t mResumeDelayStartUs;
         int64_t mSeekDelayStartUs;
+#endif
     } mStats;
 
     bool    mOffloadAudio;
@@ -388,9 +396,11 @@
 
     size_t countTracks() const;
 
+#ifdef QCOM_HARDWARE
     bool inSupportedTunnelFormats(const char * mime);
     //Flag to check if tunnel mode audio is enabled
     bool mIsTunnelAudio;
+#endif
     AwesomePlayer(const AwesomePlayer &);
     AwesomePlayer &operator=(const AwesomePlayer &);
 };
diff --git a/media/libstagefright/include/avc_utils.h b/media/libstagefright/include/avc_utils.h
index 8e67308..205e8ae 100644
--- a/media/libstagefright/include/avc_utils.h
+++ b/media/libstagefright/include/avc_utils.h
@@ -40,8 +40,11 @@
 void FindAVCDimensions(
         const sp<ABuffer> &seqParamSet,
         int32_t *width, int32_t *height,
+#ifdef QCOM_HARDWARE
         int32_t *sarWidth = NULL, int32_t *sarHeight = NULL, int32_t *isInterlaced = NULL);
-
+#else
+        int32_t *sarWidth = NULL, int32_t *sarHeight = NULL);
+#endif
 unsigned parseUE(ABitReader *br);
 
 status_t getNextNALUnit(
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp
index cef551c..092f512 100644
--- a/services/audioflinger/AudioFlinger.cpp
+++ b/services/audioflinger/AudioFlinger.cpp
@@ -154,8 +154,12 @@
       mBtNrecIsOff(false),
       mIsLowRamDevice(true),
       mIsDeviceTypeKnown(false),
+#ifdef QCOM_HARDWARE
       mGlobalEffectEnableTime(0),
       mAllChainsLocked(false)
+#else
+      mGlobalEffectEnableTime(0)
+#endif
 {
     getpid_cached = getpid();
     char value[PROPERTY_VALUE_MAX];
@@ -570,6 +574,7 @@
     return trackHandle;
 }
 
+#ifdef QCOM_HARDWARE
 sp<IDirectTrack> AudioFlinger::createDirectTrack(
         pid_t pid,
         uint32_t sampleRate,
@@ -676,16 +681,19 @@
         mLPAEffectChain = NULL;
     }
 }
+#endif
 
 uint32_t AudioFlinger::sampleRate(audio_io_handle_t output) const
 {
     Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
     if (!mDirectAudioTracks.isEmpty()) {
         AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
         if(desc != NULL) {
             return desc->stream->common.get_sample_rate(&desc->stream->common);
         }
     }
+#endif
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
         ALOGW("sampleRate() unknown thread %d", output);
@@ -697,10 +705,12 @@
 int AudioFlinger::channelCount(audio_io_handle_t output) const
 {
     Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
     AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
     if(desc != NULL) {
         return desc->stream->common.get_channels(&desc->stream->common);
     }
+#endif
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
         ALOGW("channelCount() unknown thread %d", output);
@@ -723,10 +733,12 @@
 size_t AudioFlinger::frameCount(audio_io_handle_t output) const
 {
     Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
     AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
     if(desc != NULL) {
         return desc->stream->common.get_buffer_size(&desc->stream->common);
     }
+#endif
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
         ALOGW("frameCount() unknown thread %d", output);
@@ -740,12 +752,14 @@
 uint32_t AudioFlinger::latency(audio_io_handle_t output) const
 {
     Mutex::Autolock _l(mLock);
+#ifdef QCOM_HARDWARE
     if (!mDirectAudioTracks.isEmpty()) {
         AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
         if (desc != NULL) {
             return desc->stream->get_latency(desc->stream);
         }
     }
+#endif
 
     PlaybackThread *thread = checkPlaybackThread_l(output);
     if (thread == NULL) {
@@ -937,6 +951,7 @@
     }
 
     AutoMutex lock(mLock);
+#ifdef QCOM_HARDWARE
     ALOGV("setStreamVolume stream %d, output %d, value %f",stream, output, value);
     AudioSessionDescriptor *desc = NULL;
     if (!mDirectAudioTracks.isEmpty()) {
@@ -953,13 +968,16 @@
             }
         }
     }
+#endif
     PlaybackThread *thread = NULL;
     if (output) {
         thread = checkPlaybackThread_l(output);
         if (thread == NULL) {
+#ifdef QCOM_HARDWARE
             if (desc != NULL) {
                 return NO_ERROR;
             }
+#endif
             return BAD_VALUE;
         }
     }
@@ -1094,6 +1112,7 @@
         return final_result;
     }
 
+#ifdef QCOM_HARDWARE
     AudioSessionDescriptor *desc = NULL;
     if (!mDirectAudioTracks.isEmpty()) {
         desc = mDirectAudioTracks.valueFor(ioHandle);
@@ -1116,6 +1135,7 @@
             }
         }
     }
+#endif
 
     // hold a strong ref on thread in case closeOutput() or closeInput() is called
     // and the thread is exited once the lock is released
@@ -1284,6 +1304,7 @@
     }
 }
 
+#ifdef QCOM_HARDWARE
 status_t AudioFlinger::deregisterClient(const sp<IAudioFlingerClient>& client)
 {
     ALOGV("deregisterClient() %p, tid %d, calling tid %d", client.get(), gettid(), IPCThreadState::self()->getCallingPid());
@@ -1298,6 +1319,7 @@
 
     return false;
 }
+#endif
 
 void AudioFlinger::removeNotificationClient(pid_t pid)
 {
@@ -1329,16 +1351,19 @@
 // audioConfigChanged_l() must be called with AudioFlinger::mLock held
 void AudioFlinger::audioConfigChanged_l(int event, audio_io_handle_t ioHandle, const void *param2)
 {
+#ifdef QCOM_HARDWARE
     ALOGV("AudioFlinger::audioConfigChanged_l: event %d", event);
     if (event == AudioSystem::EFFECT_CONFIG_CHANGED) {
         mIsEffectConfigChanged = true;
     }
     if (!mNotificationClients.isEmpty()){
+#endif
         size_t size = mNotificationClients.size();
         for (size_t i = 0; i < size; i++) {
             mNotificationClients.valueAt(i)->audioFlingerClient()->ioConfigChanged(event, ioHandle,
                                                                                    param2);
         }
+#ifdef QCOM_HARDWARE
     }
     if ((!mDirectAudioTracks.isEmpty())&& (event == AudioSystem::EFFECT_CONFIG_CHANGED)){
         size_t dsize = mDirectAudioTracks.size();
@@ -1352,6 +1377,7 @@
             }
         }
     }
+#endif
 }
 
 // removeClient_l() must be called with AudioFlinger::mLock held
@@ -1472,8 +1498,10 @@
     RecordThread *thread;
     size_t inFrameCount;
     int lSessionId;
+#ifdef QCOM_HARDWARE
     size_t inputBufferSize = 0;
     uint32_t channelCount = popcount(channelMask);
+#endif
 
     // check calling permissions
     if (!recordingAllowed()) {
@@ -1482,6 +1510,7 @@
         goto Exit;
     }
 
+#ifdef QCOM_HARDWARE
     // Check that audio input stream accepts requested audio parameters
     inputBufferSize = getInputBufferSize(sampleRate, format, channelCount);
     if (inputBufferSize == 0) {
@@ -1489,6 +1518,13 @@
         ALOGE("Bad audio input parameters: sampling rate %u, format %d, channels %d",  sampleRate, format, channelCount);
         goto Exit;
     }
+#else
+    if (format != AUDIO_FORMAT_PCM_16_BIT) {
+        ALOGE("openRecord() invalid format %d", format);
+        lStatus = BAD_VALUE;
+        goto Exit;
+    }
+#endif
 
     // add client to list
     { // scope for mLock
@@ -1520,6 +1556,7 @@
             }
         }
 
+#ifdef QCOM_HARDWARE
         // frameCount must be a multiple of input buffer size
         // Change for Codec type
         uint8_t channelCount = popcount(channelMask);
@@ -1542,6 +1579,7 @@
             }
         }
         frameCount = ((frameCount - 1)/inFrameCount + 1) * inFrameCount;
+#endif
 
         // create new record track.
         // The record track uses one track in mHardwareMixerThread by convention.
@@ -1779,6 +1817,7 @@
         if (flags & AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD) {
             thread = new OffloadThread(this, output, id, *pDevices);
             ALOGV("openOutput() created offload output: ID %d thread %p", id, thread);
+#ifdef QCOM_HARDWARE
         }
         if (flags & AUDIO_OUTPUT_FLAG_LPA || flags & AUDIO_OUTPUT_FLAG_TUNNEL ) {
             AudioSessionDescriptor *desc = new AudioSessionDescriptor(hwDevHal, outStream, flags);
@@ -1791,6 +1830,7 @@
             desc->trackRefPtr = NULL;
             mDirectAudioTracks.add(id, desc);
             mDirectDevice = desc->device;
+#endif
         } else if ((flags & AUDIO_OUTPUT_FLAG_DIRECT) ||
             (config.format != AUDIO_FORMAT_PCM_16_BIT) ||
             (config.channel_mask != AUDIO_CHANNEL_OUT_STEREO)) {
@@ -1818,6 +1858,7 @@
             // notify client processes of the new output creation
             thread->audioConfigChanged_l(AudioSystem::OUTPUT_OPENED);
         }
+#ifdef QCOM_HARDWARE
         else {
             *pLatencyMs = 0;
             if ((flags & AUDIO_OUTPUT_FLAG_LPA) || (flags & AUDIO_OUTPUT_FLAG_TUNNEL)) {
@@ -1825,6 +1866,7 @@
                 *pLatencyMs = desc->stream->get_latency(desc->stream);
             }
         }
+#endif
 
 
         // the first primary output opened designates the primary hw device
@@ -1877,6 +1919,7 @@
 {
     // keep strong reference on the playback thread so that
     // it is not destroyed while exit() is executed
+#ifdef QCOM_HARDWARE
     AudioSessionDescriptor *desc = mDirectAudioTracks.valueFor(output);
     if (desc) {
         ALOGV("Closing DirectTrack output %d", output);
@@ -1890,6 +1933,7 @@
         delete desc;
         return NO_ERROR;
     }
+#endif
 
     sp<PlaybackThread> thread;
     {
diff --git a/services/audioflinger/AudioFlinger.h b/services/audioflinger/AudioFlinger.h
index 6392bed..9844659 100644
--- a/services/audioflinger/AudioFlinger.h
+++ b/services/audioflinger/AudioFlinger.h
@@ -29,8 +29,10 @@
 
 #include <media/IAudioFlinger.h>
 #include <media/IAudioFlingerClient.h>
+#ifdef QCOM_HARDWARE
 #include <media/IDirectTrack.h>
 #include <media/IDirectTrackClient.h>
+#endif
 #include <media/IAudioTrack.h>
 #include <media/IAudioRecord.h>
 #include <media/AudioSystem.h>
@@ -91,7 +93,11 @@
 
 static uint32_t getInputChannelCount(uint32_t channels) {
     // only mono, stereo, and 5.1 are supported for input sources
+#ifdef QCOM_HARDWARE
     return popcount((channels)&(AUDIO_CHANNEL_IN_STEREO|AUDIO_CHANNEL_IN_MONO|AUDIO_CHANNEL_IN_5POINT1));
+#else
+    return popcount(channels);
+#endif
 }
 class AudioFlinger :
     public BinderService<AudioFlinger>,
@@ -117,6 +123,7 @@
                                 int *sessionId,
                                 String8& name,
                                 status_t *status);
+#ifdef QCOM_HARDWARE
     virtual sp<IDirectTrack> createDirectTrack(
                                 pid_t pid,
                                 uint32_t sampleRate,
@@ -127,6 +134,7 @@
                                 audio_stream_type_t streamType,
                                 status_t *status);
     virtual void deleteEffectSession();
+#endif
     virtual sp<IAudioRecord> openRecord(
                                 audio_io_handle_t input,
                                 uint32_t sampleRate,
@@ -167,7 +175,9 @@
     virtual     String8     getParameters(audio_io_handle_t ioHandle, const String8& keys) const;
 
     virtual     void        registerClient(const sp<IAudioFlingerClient>& client);
-    virtual    status_t     deregisterClient(const sp<IAudioFlingerClient>& client);
+#ifdef QCOM_HARDWARE
+    virtual     status_t    deregisterClient(const sp<IAudioFlingerClient>& client);
+#endif
     virtual     size_t      getInputBufferSize(uint32_t sampleRate, audio_format_t format,
                                                audio_channel_mask_t channelMask) const;
 
@@ -245,11 +255,13 @@
                                 Parcel* reply,
                                 uint32_t flags);
 
+#ifdef QCOM_HARDWARE
     bool applyEffectsOn(void *token,
                         int16_t *buffer1,
                         int16_t *buffer2,
                         int size,
                         bool force);
+#endif
 
     // end of IAudioFlinger interface
 
@@ -396,7 +408,9 @@
     class EffectModule;
     class EffectHandle;
     class EffectChain;
+#ifdef QCOM_HARDWARE
     struct AudioSessionDescriptor;
+#endif
     struct AudioStreamOut;
     struct AudioStreamIn;
 
@@ -486,6 +500,7 @@
 
               sp<PlaybackThread> getEffectThread_l(int sessionId, int EffectId);
 
+#ifdef QCOM_HARDWARE
     // server side of the client's IAudioTrack
     class DirectAudioTrack : public android::BnDirectTrack,
                              public AudioEventObserver
@@ -596,6 +611,7 @@
         sp<IBinder>             mWakeLockToken;
         sp<PMDeathRecipient>    mDeathRecipient;
     };
+#endif
                 void        removeClient_l(pid_t pid);
                 void        removeNotificationClient(pid_t pid);
 
@@ -657,6 +673,7 @@
         AudioStreamIn(AudioHwDevice *dev, audio_stream_in_t *in) :
             audioHwDev(dev), stream(in) {}
     };
+#ifdef QCOM_HARDWARE
     struct AudioSessionDescriptor {
         bool    mActive;
         int     mStreamType;
@@ -671,6 +688,7 @@
         AudioSessionDescriptor(audio_hw_device_t *dev, audio_stream_out_t *out, audio_output_flags_t outflag) :
             hwDev(dev), stream(out), flag(outflag)  {}
     };
+#endif
 
     // for mAudioSessionRefs only
     struct AudioSessionRef {
@@ -735,16 +753,20 @@
                 volatile int32_t                    mNextUniqueId;  // updated by android_atomic_inc
                 audio_mode_t                        mMode;
                 bool                                mBtNrecIsOff;
+#ifdef QCOM_HARDWARE
                 DefaultKeyedVector<audio_io_handle_t, AudioSessionDescriptor *> mDirectAudioTracks;
                 // protected by mLock
                 volatile bool                       mIsEffectConfigChanged;
+#endif
                 Vector<AudioSessionRef*> mAudioSessionRefs;
+#ifdef QCOM_HARDWARE
                 sp<EffectChain> mLPAEffectChain;
                 int         mLPASessionId;
                 audio_devices_t mDirectDevice;//device for directTrack,used for effects
                 int                                 mLPASampleRate;
                 int                                 mLPANumChannels;
                 volatile bool                       mAllChainsLocked;
+#endif
                 float       masterVolume_l() const;
                 bool        masterMute_l() const;
                 audio_module_handle_t loadHwModule_l(const char *name);
diff --git a/services/audioflinger/AudioMixer.cpp b/services/audioflinger/AudioMixer.cpp
index f45476c..95f7381 100644
--- a/services/audioflinger/AudioMixer.cpp
+++ b/services/audioflinger/AudioMixer.cpp
@@ -561,7 +561,11 @@
                       (value == 48000 && devSampleRate == 44100))) {
                     quality = AudioResampler::LOW_QUALITY;
                 } else {
+#ifdef QCOM_HARDWARE
                     quality = AudioResampler::VERY_HIGH_QUALITY;
+#else
+                    quality = AudioResampler::DEFAULT_QUALITY;
+#endif
                 }
                 resampler = AudioResampler::create(
                         format,
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index f916dfc..a8f0511 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -72,7 +72,11 @@
       mStatus(NO_INIT), mState(IDLE),
       // mMaxDisableWaitCnt is set by configure() and not used before then
       // mDisableWaitCnt is set by process() and updateState() and not used before then
+#ifdef QCOM_HARDWARE
       mSuspended(false), mIsForLPA(false)
+#else
+      mSuspended(false)
+#endif
 {
     ALOGV("Constructor %p", this);
     int lStatus;
@@ -307,14 +311,20 @@
     (*mEffectInterface)->command(mEffectInterface, EFFECT_CMD_RESET, 0, NULL, 0, NULL);
 }
 
+#ifdef QCOM_HARDWARE
 status_t AudioFlinger::EffectModule::configure(bool isForLPA, int sampleRate, int channelCount, int frameCount)
+#else
+status_t AudioFlinger::EffectModule::configure()
+#endif
 {
     status_t status;
     status_t cmdStatus = 0;
     sp<ThreadBase> thread;
     uint32_t size;
     audio_channel_mask_t channelMask;
+#ifdef QCOM_HARDWARE
     uint32_t channels;
+#endif
 
     if (mEffectInterface == NULL) {
         status = NO_INIT;
@@ -329,6 +339,7 @@
 
     // TODO: handle configuration of effects replacing track process
     channelMask = thread->channelMask();
+#ifdef QCOM_HARDWARE
     if(popcount(channelMask) > 2) {
         ALOGE("Error: Trying to apply effect on  %d channel content",popcount(channelMask));
         return INVALID_OPERATION;
@@ -347,6 +358,7 @@
             channels = AUDIO_CHANNEL_OUT_STEREO;
         }
     }
+#endif
 
     if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_AUXILIARY) {
         mConfig.inputCfg.channels = AUDIO_CHANNEL_OUT_MONO;
@@ -356,11 +368,15 @@
     mConfig.outputCfg.channels = channelMask;
     mConfig.inputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
     mConfig.outputCfg.format = AUDIO_FORMAT_PCM_16_BIT;
+#ifdef QCOM_HARDWARE
     if(isForLPA){
         mConfig.inputCfg.samplingRate = sampleRate;
     } else {
+#endif
         mConfig.inputCfg.samplingRate = thread->sampleRate();
+#ifdef QCOM_HARDWARE
     }
+#endif
     mConfig.outputCfg.samplingRate = mConfig.inputCfg.samplingRate;
     mConfig.inputCfg.bufferProvider.cookie = NULL;
     mConfig.inputCfg.bufferProvider.getBuffer = NULL;
@@ -385,11 +401,15 @@
     }
     mConfig.inputCfg.mask = EFFECT_CONFIG_ALL;
     mConfig.outputCfg.mask = EFFECT_CONFIG_ALL;
+#ifdef QCOM_HARDWARE
     if(isForLPA) {
         mConfig.inputCfg.buffer.frameCount = frameCount;
     } else {
+#endif
         mConfig.inputCfg.buffer.frameCount = thread->frameCount();
+#ifdef QCOM_HARDWARE
     }
+#endif
     mConfig.outputCfg.buffer.frameCount = mConfig.inputCfg.buffer.frameCount;
 
     ALOGV("configure() %p thread %p buffer %p framecount %d",
@@ -586,11 +606,15 @@
 // must be called with EffectModule::mLock held
 status_t AudioFlinger::EffectModule::setEnabled_l(bool enabled)
 {
+#ifdef QCOM_HARDWARE
     bool effectStateChanged = false;
+#endif
     ALOGV("setEnabled %p enabled %d", this, enabled);
 
     if (enabled != isEnabled()) {
+#ifdef QCOM_HARDWARE
         effectStateChanged = true;
+#endif
         status_t status = AudioSystem::setEffectEnabled(mId, enabled);
         if (enabled && status != NO_ERROR) {
             return status;
@@ -628,6 +652,7 @@
             }
         }
     }
+#ifdef QCOM_HARDWARE
     /*
        Send notification event to LPA Player when an effect for
        LPA output is enabled or disabled.
@@ -639,6 +664,7 @@
         thread->effectConfigChanged();
         lock();
     }
+#endif
     return NO_ERROR;
 }
 
@@ -1182,6 +1208,7 @@
         return disable();
     }
 
+#ifdef QCOM_HARDWARE
     if(mEffect->isOnLPA() &&
        ((cmdCode == EFFECT_CMD_SET_PARAM) || (cmdCode == EFFECT_CMD_SET_PARAM_DEFERRED) ||
         (cmdCode == EFFECT_CMD_SET_PARAM_COMMIT) || (cmdCode == EFFECT_CMD_SET_DEVICE) ||
@@ -1191,6 +1218,7 @@
         ALOGV("Notifying Direct Track for the change in effect config %d", cmdCode);
         mClient->audioFlinger()->audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
     }
+#endif
     return mEffect->command(cmdCode, cmdSize, pCmdData, replySize, pReplyData);
 }
 
@@ -1258,7 +1286,11 @@
                                         int sessionId)
     : mThread(thread), mSessionId(sessionId), mActiveTrackCnt(0), mTrackCnt(0), mTailBufferCount(0),
       mOwnInBuffer(false), mVolumeCtrlIdx(-1), mLeftVolume(UINT_MAX), mRightVolume(UINT_MAX),
+#ifdef QCOM_HARDWARE
       mNewLeftVolume(UINT_MAX), mNewRightVolume(UINT_MAX), mIsForLPATrack(false)
+#else
+      mNewLeftVolume(UINT_MAX), mNewRightVolume(UINT_MAX)
+#endif
 {
     mStrategy = AudioSystem::getStrategyForStream(AUDIO_STREAM_MUSIC);
     if (thread == NULL) {
@@ -1304,6 +1336,7 @@
     return 0;
 }
 
+#ifdef QCOM_HARDWARE
 sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromIndex_l(int idx)
 {
     sp<EffectModule> effect = NULL;
@@ -1315,6 +1348,7 @@
     }
     return effect;
 }
+#endif
 
 // getEffectFromType_l() must be called with ThreadBase::mLock held
 sp<AudioFlinger::EffectModule> AudioFlinger::EffectChain::getEffectFromType_l(
@@ -1381,7 +1415,11 @@
     }
 
     size_t size = mEffects.size();
+#ifdef QCOM_HARDWARE
     if (doProcess || isForLPATrack()) {
+#else
+    if (doProcess) {
+#endif
         for (size_t i = 0; i < size; i++) {
             mEffects[i]->process();
         }
@@ -1859,6 +1897,7 @@
     return false;
 }
 
+#ifdef QCOM_HARDWARE
 #define DEAFULT_FRAME_COUNT 1200
 bool AudioFlinger::applyEffectsOn(void *token, int16_t *inBuffer,
                             int16_t *outBuffer, int size, bool force)
@@ -2033,5 +2072,6 @@
     ALOGV("Creating Effects Thread");
     pthread_create(&mEffectsThread, &attr, EffectsThreadWrapper, this);
 }
+#endif
 
 }; // namespace android
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index 10c2227..5ad312b 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -69,10 +69,14 @@
                      void *pReplyData);
 
     void reset_l();
+#ifdef QCOM_HARDWARE
     status_t configure(bool isForLPA = false,
                        int sampleRate = 0,
                        int channelCount = 0,
                        int frameCount = 0);
+#else
+    status_t configure();
+#endif
     status_t init();
     effect_state state() const {
         return mState;
@@ -123,8 +127,10 @@
                         { return (mDescriptor.flags & EFFECT_FLAG_OFFLOAD_SUPPORTED) != 0; }
     status_t         setOffloaded(bool offloaded, audio_io_handle_t io);
     bool             isOffloaded() const;
+#ifdef QCOM_HARDWARE
     bool             isOnLPA() { return mIsForLPA;}
     void             setLPAFlag(bool isForLPA) {mIsForLPA = isForLPA; }
+#endif
 
     void             dump(int fd, const Vector<String16>& args);
 
@@ -159,7 +165,9 @@
     uint32_t mDisableWaitCnt;       // current process() calls count during disable period.
     bool     mSuspended;            // effect is suspended: temporarily disabled by framework
     bool     mOffloaded;            // effect is currently offloaded to the audio DSP
+#ifdef QCOM_HARDWARE
     bool     mIsForLPA;
+#endif
 };
 
 // The EffectHandle class implements the IEffect interface. It provides resources
@@ -269,14 +277,18 @@
 
     status_t addEffect_l(const sp<EffectModule>& handle);
     size_t removeEffect_l(const sp<EffectModule>& handle);
+#ifdef QCOM_HARDWARE
     size_t getNumEffects() { return mEffects.size(); }
+#endif
 
     int sessionId() const { return mSessionId; }
     void setSessionId(int sessionId) { mSessionId = sessionId; }
 
     sp<EffectModule> getEffectFromDesc_l(effect_descriptor_t *descriptor);
     sp<EffectModule> getEffectFromId_l(int id);
+#ifdef QCOM_HARDWARE
     sp<EffectModule> getEffectFromIndex_l(int idx);
+#endif
     sp<EffectModule> getEffectFromType_l(const effect_uuid_t *type);
     bool setVolume_l(uint32_t *left, uint32_t *right);
     void setDevice_l(audio_devices_t device);
@@ -326,8 +338,10 @@
 
 
     void dump(int fd, const Vector<String16>& args);
+#ifdef QCOM_HARDWARE
     bool isForLPATrack() {return mIsForLPATrack; }
     void setLPAFlag(bool flag) {mIsForLPATrack = flag;}
+#endif
 
 protected:
     friend class AudioFlinger;  // for mThread, mEffects
@@ -376,7 +390,9 @@
     uint32_t mNewLeftVolume;       // new volume on left channel
     uint32_t mNewRightVolume;      // new volume on right channel
     uint32_t mStrategy; // strategy for this effect chain
+#ifdef QCOM_HARDWARE
     bool     mIsForLPATrack;
+#endif
     // mSuspendedEffects lists all effects currently suspended in the chain.
     // Use effect type UUID timelow field as key. There is no real risk of identical
     // timeLow fields among effect type UUIDs.
diff --git a/services/audioflinger/RecordTracks.h b/services/audioflinger/RecordTracks.h
index cb54348..4b0c4d8 100644
--- a/services/audioflinger/RecordTracks.h
+++ b/services/audioflinger/RecordTracks.h
@@ -28,7 +28,9 @@
                                 audio_format_t format,
                                 audio_channel_mask_t channelMask,
                                 size_t frameCount,
+#ifdef QCOM_HARDWARE
                                 uint32_t flags,
+#endif
                                 int sessionId);
     virtual             ~RecordTrack();
 
@@ -58,7 +60,9 @@
                                    int64_t pts = kInvalidPTS);
     // releaseBuffer() not overridden
 
+#ifdef QCOM_HARDWARE
     track_flags_t       mFlags;
+#endif
     bool                mOverflow;  // overflow on most recent attempt to fill client buffer
     AudioRecordServerProxy* mAudioRecordServerProxy;
 };
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 568329f..aa9097b 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -85,9 +85,11 @@
 #define ALOGVV(a...) do { } while(0)
 #endif
 
+#ifdef QCOM_HARDWARE
 #define DIRECT_TRACK_EOS 1
 #define DIRECT_TRACK_HW_FAIL 6
 static const char lockName[] = "DirectTrack";
+#endif
 namespace android {
 
 // retry counts for buffer fill timeout
@@ -349,10 +351,12 @@
     return status;
 }
 
+#ifdef QCOM_HARDWARE
 void AudioFlinger::ThreadBase::effectConfigChanged() {
     ALOGV("New effect is being added to LPA chain, Notifying LPA Direct Track");
     mAudioFlinger->audioConfigChanged_l(AudioSystem::EFFECT_CONFIG_CHANGED, 0, NULL);
 }
+#endif
 
 void AudioFlinger::ThreadBase::sendIoConfigEvent(int event, int param)
 {
@@ -782,6 +786,7 @@
             addEffectChain_l(chain);
             chain->setStrategy(getStrategyForSession_l(sessionId));
             chainCreated = true;
+#ifdef QCOM_HARDWARE
             if(sessionId == mAudioFlinger->mLPASessionId) {
                 // Clear reference to previous effect chain if any
                 if(mAudioFlinger->mLPAEffectChain.get()) {
@@ -795,6 +800,7 @@
                 uint32_t volume = 0x1000000; // Equals to 1.0 in 8.24 format
                 chain->setVolume_l(&volume,&volume);
             }
+#endif
         } else {
             effect = chain->getEffectFromDesc_l(desc);
         }
@@ -823,7 +829,11 @@
             }
             effectCreated = true;
 
+#ifdef QCOM_HARDWARE
             effect->setDevice(mAudioFlinger->mLPASessionId == sessionId ? mAudioFlinger->mDirectDevice:mOutDevice);
+#else
+            effect->setDevice(mOutDevice);
+#endif
             effect->setDevice(mInDevice);
             effect->setMode(mAudioFlinger->getMode());
             effect->setAudioSource(mAudioSource);
@@ -938,13 +948,20 @@
         Vector< sp<AudioFlinger::EffectChain> >& effectChains)
 {
     effectChains = mEffectChains;
+#ifdef QCOM_HARDWARE
     mAudioFlinger->mAllChainsLocked = true;
+#endif
     for (size_t i = 0; i < mEffectChains.size(); i++) {
+#ifdef QCOM_HARDWARE
         if (mEffectChains[i] != mAudioFlinger->mLPAEffectChain) {
+#else
             mEffectChains[i]->lock();
+#endif
+#ifdef QCOM_HARDWARE
         } else {
             mAudioFlinger-> mAllChainsLocked = false;
         }
+#endif
     }
 }
 
@@ -952,7 +969,9 @@
         const Vector< sp<AudioFlinger::EffectChain> >& effectChains)
 {
     for (size_t i = 0; i < effectChains.size(); i++) {
+#ifdef QCOM_HARDWARE
         if (mAudioFlinger->mAllChainsLocked || effectChains[i] != mAudioFlinger->mLPAEffectChain)
+#endif
             effectChains[i]->unlock();
     }
 }
@@ -1268,6 +1287,7 @@
     }
 
     if (mType == DIRECT) {
+#ifdef QCOM_HARDWARE
         if (((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM)
                ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AMR_NB)
                ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_AMR_WB)
@@ -1275,6 +1295,9 @@
                ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCB)
                ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCWB)
                ||((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_EVRCNW)) {
+#else
+        if ((format & AUDIO_FORMAT_MAIN_MASK) == AUDIO_FORMAT_PCM) {
+#endif
             if (sampleRate != mSampleRate || format != mFormat || channelMask != mChannelMask) {
                 ALOGE("createTrack_l() Bad parameter: sampleRate %u format %d, channelMask 0x%08x "
                         "for output %p with format %d",
@@ -2317,9 +2340,13 @@
             // only process effects if we're going to write
             if (sleepTime == 0 && mType != OFFLOAD) {
                 for (size_t i = 0; i < effectChains.size(); i ++) {
+#ifdef QCOM_HARDWARE
                     if (effectChains[i] != mAudioFlinger->mLPAEffectChain) {
+#endif
                         effectChains[i]->process_l();
+#ifdef QCOM_HARDWARE
                   }
+#endif
                }
             }
         }
@@ -4530,6 +4557,7 @@
                         }
                         if (framesOut && (mFrameCount == mRsmpInIndex)) {
                             void *readInto;
+#ifdef QCOM_HARDWARE
                             int InputBytes;
                             /*Fix me: How does framesOut become 0 in this condition */
                             if (( framesOut != mFrameCount) &&
@@ -4549,8 +4577,21 @@
                                      mRsmpInIndex = 0;
                                      InputBytes = mBufferSize;
                              }
+#else
+                            if (framesOut == mFrameCount && mChannelCount == mReqChannelCount) {
+                                readInto = buffer.raw;
+                                framesOut = 0;
+                            } else {
+                                readInto = mRsmpInBuffer;
+                                mRsmpInIndex = 0;
+                            }
+#endif
                             mBytesRead = mInput->stream->read(mInput->stream, readInto,
+#ifdef QCOM_HARDWARE
                                     InputBytes);
+#else
+                                    mBufferSize);
+#endif
                             if (mBytesRead <= 0) {
                                 if ((mBytesRead < 0) && (mActiveTrack->mState == TrackBase::ACTIVE))
                                 {
@@ -4750,7 +4791,11 @@
         Mutex::Autolock _l(mLock);
 
         track = new RecordTrack(this, client, sampleRate,
+#ifdef QCOM_HARDWARE
                       format, channelMask, frameCount, *flags, sessionId);
+#else
+                      format, channelMask, frameCount, sessionId);
+#endif
 
         if (track->getCblk() == 0) {
             ALOGE("createRecordTrack_l() no control block");
@@ -5226,6 +5271,11 @@
     mChannelMask = mInput->stream->common.get_channels(&mInput->stream->common);
     mChannelCount = (uint16_t)getInputChannelCount(mChannelMask);
     mFormat = mInput->stream->common.get_format(&mInput->stream->common);
+#ifndef QCOM_HARDWARE
+    if (mFormat != AUDIO_FORMAT_PCM_16_BIT) {
+        ALOGE("HAL format %d not supported; must be AUDIO_FORMAT_PCM_16_BIT", mFormat);
+    }
+#endif
     mFrameSize = audio_stream_frame_size(&mInput->stream->common);
     mBufferSize = mInput->stream->common.get_buffer_size(&mInput->stream->common);
     mFrameCount = mBufferSize / mFrameSize;
@@ -5345,6 +5395,7 @@
     return 0;
 }
 
+#ifdef QCOM_HARDWARE
 // ----------------------------------------------------------------------------
 
 AudioFlinger::DirectAudioTrack::DirectAudioTrack(const sp<AudioFlinger>& audioFlinger,
@@ -5659,5 +5710,6 @@
 }
 
 // ----------------------------------------------------------------------------
+#endif
 
 }; // namespace android
diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h
index eff4bb7..0d01d05 100644
--- a/services/audioflinger/Threads.h
+++ b/services/audioflinger/Threads.h
@@ -138,7 +138,9 @@
     virtual     status_t    setParameters(const String8& keyValuePairs);
     virtual     String8     getParameters(const String8& keys) = 0;
     virtual     void        audioConfigChanged_l(int event, int param = 0) = 0;
+#ifdef QCOM_HARDWARE
                 void        effectConfigChanged();
+#endif
                 void        sendIoConfigEvent(int event, int param = 0);
                 void        sendIoConfigEvent_l(int event, int param = 0);
                 void        sendPrioConfigEvent_l(pid_t pid, pid_t tid, int32_t prio);
diff --git a/services/audioflinger/TrackBase.h b/services/audioflinger/TrackBase.h
index 065e020..358d74a 100644
--- a/services/audioflinger/TrackBase.h
+++ b/services/audioflinger/TrackBase.h
@@ -43,7 +43,9 @@
                                 audio_format_t format,
                                 audio_channel_mask_t channelMask,
                                 size_t frameCount,
+#ifdef QCOM_HARDWARE
                                 uint32_t flags,
+#endif
                                 const sp<IMemory>& sharedBuffer,
                                 int sessionId,
                                 bool isOut);
@@ -131,7 +133,9 @@
                                     // 8-bit PCM samples are stored as 16-bit
     const size_t        mFrameCount;// size of track buffer given at createTrack() or
                                     // openRecord(), and then adjusted as needed
+#ifdef QCOM_HARDWARE
     uint32_t            mFlags;
+#endif
     const int           mSessionId;
     Vector < sp<SyncEvent> >mSyncEvents;
     const bool          mIsOut;
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 436d4de..dfae5d9 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -66,7 +66,9 @@
             audio_format_t format,
             audio_channel_mask_t channelMask,
             size_t frameCount,
+#ifdef QCOM_HARDWARE
             uint32_t flags,
+#endif
             const sp<IMemory>& sharedBuffer,
             int sessionId,
             bool isOut)
@@ -80,10 +82,17 @@
         mFormat(format),
         mChannelMask(channelMask),
         mChannelCount(popcount(channelMask)),
+#ifdef QCOM_HARDWARE
         mFrameSize((audio_is_linear_pcm(format) || audio_is_supported_compressed(format)) ?
         ((flags & IAudioFlinger::TRACK_VOICE_COMMUNICATION)? mChannelCount * sizeof(int16_t) : mChannelCount * audio_bytes_per_sample(format)) : sizeof(int8_t)),
+#else
+        mFrameSize(audio_is_linear_pcm(format) ?
+                mChannelCount * audio_bytes_per_sample(format) : sizeof(int8_t)),
+#endif
         mFrameCount(frameCount),
+#ifdef QCOM_HARDWARE
         mFlags(0),
+#endif
         mSessionId(sessionId),
         mIsOut(isOut),
         mServerProxy(NULL),
@@ -98,6 +107,7 @@
 
     // ALOGD("Creating track with %d buffers @ %d bytes", bufferCount, bufferSize);
     size_t size = sizeof(audio_track_cblk_t);
+#ifdef QCOM_HARDWARE
     uint8_t channelCount = popcount(channelMask);
     size_t bufferSize = 0;
     if (flags & IAudioFlinger::TRACK_VOICE_COMMUNICATION) {
@@ -118,6 +128,9 @@
           bufferSize = frameCount * channelCount * AMR_WB_FRAMESIZE; // full rate frame size
        }
     }
+#else
+    size_t bufferSize = (sharedBuffer == 0 ? roundup(frameCount) : frameCount) * mFrameSize;
+#endif
 
     if (sharedBuffer == 0) {
         size += bufferSize;
@@ -146,6 +159,7 @@
         mCblk->frameCount_ = frameCount;
         if (sharedBuffer == 0) {
             mBuffer = (char*)mCblk + sizeof(audio_track_cblk_t);
+#ifdef QCOM_HARDWARE
             if (flags & IAudioFlinger::TRACK_VOICE_COMMUNICATION) {
                 memset(mBuffer, 0, bufferSize);
             } else {
@@ -169,6 +183,9 @@
                     memset(mBuffer, 0, frameCount * channelCount * AMR_WB_FRAMESIZE);
                 }
             }
+#else
+            memset(mBuffer, 0, bufferSize);
+#endif
         } else {
             mBuffer = sharedBuffer->pointer();
 #if 0
@@ -358,9 +375,14 @@
             const sp<IMemory>& sharedBuffer,
             int sessionId,
             IAudioFlinger::track_flags_t flags)
+#ifdef QCOM_HARDWARE
     :   TrackBase(thread, client, sampleRate, format, channelMask, frameCount,
      ((audio_stream_type_t)streamType == AUDIO_STREAM_VOICE_CALL)? IAudioFlinger::TRACK_VOICE_COMMUNICATION:0x0,
      sharedBuffer, sessionId, true /*isOut*/),
+#else
+    :   TrackBase(thread, client, sampleRate, format, channelMask, frameCount, sharedBuffer,
+            sessionId, true /*isOut*/),
+#endif
     mFillingUpStatus(FS_INVALID),
     // mRetryCount initialized later when needed
     mSharedBuffer(sharedBuffer),
@@ -1783,14 +1805,23 @@
             audio_format_t format,
             audio_channel_mask_t channelMask,
             size_t frameCount,
+#ifdef QCOM_HARDWARE
             uint32_t flags,
+#endif
             int sessionId)
+#ifdef QCOM_HARDWARE
     :   TrackBase(thread, client, sampleRate, format, channelMask, frameCount,
         flags, 0 /*sharedBuffer*/, sessionId, false /*isOut*/),
+#else
+    :   TrackBase(thread, client, sampleRate, format,
+                  channelMask, frameCount, 0 /*sharedBuffer*/, sessionId, false /*isOut*/),
+#endif
         mOverflow(false)
 {
     ALOGV("RecordTrack constructor");
+#ifdef QCOM_HARDWARE
     mFlags = flags;
+#endif
     if (mCblk != NULL) {
         mAudioRecordServerProxy = new AudioRecordServerProxy(mCblk, mBuffer, frameCount,
                 mFrameSize);