Skip to content

Commit

Permalink
FIX: [audiotrack] check api for write flavours
Browse files Browse the repository at this point in the history
  • Loading branch information
koying committed Sep 14, 2016
1 parent 905a3e2 commit 00b022f
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions AudioTrack.cpp
Expand Up @@ -134,14 +134,17 @@ int CJNIAudioTrack::write(char* audioData, int offsetInBytes, int sizeInBytes)
{
memcpy(pArray + offsetInBytes, audioData, sizeInBytes);
jenv->ReleasePrimitiveArrayCritical(m_buffer, pArray, 0);
if (m_audioFormat == CJNIAudioFormat::ENCODING_PCM_FLOAT)
if (CJNIBase::GetSDKVersion() >= 21 && m_audioFormat == CJNIAudioFormat::ENCODING_PCM_FLOAT)
{
written = call_method<int>(m_object, "write", "([FIII)I", m_buffer, (int)(offsetInBytes / sizeof(float)), (int)(sizeInBytes / sizeof(float)), CJNIAudioTrack::WRITE_BLOCKING);
written *= sizeof(float);
}
else if (m_audioFormat == CJNIAudioFormat::ENCODING_IEC61937)
{
written = call_method<int>(m_object, "write", "([SIII)I", m_buffer, (int)(offsetInBytes / sizeof(uint16_t)), (int)(sizeInBytes / sizeof(uint16_t)), CJNIAudioTrack::WRITE_BLOCKING);
if (CJNIBase::GetSDKVersion() >= 23)
written = call_method<int>(m_object, "write", "([SIII)I", m_buffer, (int)(offsetInBytes / sizeof(uint16_t)), (int)(sizeInBytes / sizeof(uint16_t)), CJNIAudioTrack::WRITE_BLOCKING);
else
written = call_method<int>(m_object, "write", "([SII)I", m_buffer, (int)(offsetInBytes / sizeof(uint16_t)), (int)(sizeInBytes / sizeof(uint16_t)));
written *= sizeof(uint16_t);
}
else
Expand Down

0 comments on commit 00b022f

Please sign in to comment.