audio: Fixed mBytesRemaining when partial buffers are sent

- When AudioFlinger writes partial buffers to HAL,
  write() on HAl returns period_size if bytes written
  are less than period_size. This is causing
  mBytesRemaining to be negative

- Fix is to check the return value of write() and
  set mBytesRemaining and mBytesWritten correctly

Change-Id: Ibd3cb138c0d4669e9e17c22f6b2c80804c6499a5
CRs-fixed: 611119
Merge branch 'cm-11.0' of git://github.com/CyanogenMod/android_frameworks_av into cd-4.4