Add float to pcm16 writing capability to tinysndfile
Also added pcm16 to float writing capability.
Change-Id: Ic9aef8a3f699ec06d175f0040ee2e5096330a429
diff --git a/audio_utils/tinysndfile.c b/audio_utils/tinysndfile.c
index 4843986..15b3a81 100644
--- a/audio_utils/tinysndfile.c
+++ b/audio_utils/tinysndfile.c
@@ -506,7 +506,11 @@
actualBytes = fwrite(handle->temp, sizeof(char), desiredBytes, handle->stream);
}
break;
- case SF_FORMAT_FLOAT: // transcoding from short to float not yet implemented
+ case SF_FORMAT_FLOAT:
+ handle->temp = realloc(handle->temp, desiredBytes);
+ memcpy_to_float_from_i16((float *) handle->temp, ptr, desiredFrames);
+ actualBytes = fwrite(handle->temp, sizeof(char), desiredBytes, handle->stream);
+ break;
default:
break;
}
@@ -525,8 +529,12 @@
case SF_FORMAT_FLOAT:
actualBytes = fwrite(ptr, sizeof(char), desiredBytes, handle->stream);
break;
- case SF_FORMAT_PCM_U8: // transcoding from float to byte/short not yet implemented
case SF_FORMAT_PCM_16:
+ handle->temp = realloc(handle->temp, desiredBytes);
+ memcpy_to_i16_from_float((short *) handle->temp, ptr, desiredFrames);
+ actualBytes = fwrite(handle->temp, sizeof(char), desiredBytes, handle->stream);
+ break;
+ case SF_FORMAT_PCM_U8: // transcoding from float to byte not yet implemented
default:
break;
}