mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
Android: Remove unnecessary SDK version checks
This commit is contained in:
parent
80b190b75d
commit
51be8b9332
15 changed files with 210 additions and 405 deletions
|
|
@ -207,8 +207,7 @@ public:
|
|||
STREAM_MUSIC, sampleRate, CHANNEL_OUT_STEREO, ENCODING_PCM_16BIT,
|
||||
(jint) (minBufferSizeOut * numDeviceOutputChannels * static_cast<int> (sizeof (int16))), MODE_STREAM)));
|
||||
|
||||
const bool supportsUnderrunCount = (getAndroidSDKVersion() >= 24);
|
||||
getUnderrunCount = supportsUnderrunCount ? env->GetMethodID (AudioTrack, "getUnderrunCount", "()I") : nullptr;
|
||||
getUnderrunCount = env->GetMethodID (AudioTrack, "getUnderrunCount", "()I");
|
||||
|
||||
int outputDeviceState = env->CallIntMethod (outputDevice, AudioTrack.getState);
|
||||
if (outputDeviceState > 0)
|
||||
|
|
|
|||
|
|
@ -798,7 +798,7 @@ constexpr unsigned char javaMidiByteCode[]
|
|||
METHOD (openMidiInputPortWithID, "openMidiInputPortWithID", "(IJ)Lcom/rmsl/juce/JuceMidiSupport$JuceMidiPort;") \
|
||||
METHOD (openMidiOutputPortWithID, "openMidiOutputPortWithID", "(I)Lcom/rmsl/juce/JuceMidiSupport$JuceMidiPort;")
|
||||
|
||||
DECLARE_JNI_CLASS_WITH_MIN_SDK (MidiDeviceManager, "com/rmsl/juce/JuceMidiSupport$MidiDeviceManager", 23)
|
||||
DECLARE_JNI_CLASS (MidiDeviceManager, "com/rmsl/juce/JuceMidiSupport$MidiDeviceManager")
|
||||
#undef JNI_CLASS_MEMBERS
|
||||
|
||||
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
|
||||
|
|
@ -808,7 +808,7 @@ DECLARE_JNI_CLASS_WITH_MIN_SDK (MidiDeviceManager, "com/rmsl/juce/JuceMidiSuppor
|
|||
METHOD (sendMidi, "sendMidi", "([BII)V") \
|
||||
METHOD (getName, "getName", "()Ljava/lang/String;")
|
||||
|
||||
DECLARE_JNI_CLASS_WITH_MIN_SDK (JuceMidiPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiPort", 23)
|
||||
DECLARE_JNI_CLASS (JuceMidiPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiPort")
|
||||
#undef JNI_CLASS_MEMBERS
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -928,7 +928,7 @@ private:
|
|||
#define JNI_CLASS_MEMBERS(METHOD, STATICMETHOD, FIELD, STATICFIELD, CALLBACK) \
|
||||
CALLBACK (generatedCallback<&MidiInput::Pimpl::handleReceive>, "handleReceive", "(J[BIIJ)V" )
|
||||
|
||||
DECLARE_JNI_CLASS_WITH_MIN_SDK (JuceMidiInputPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiInputPort", 23)
|
||||
DECLARE_JNI_CLASS (JuceMidiInputPort, "com/rmsl/juce/JuceMidiSupport$JuceMidiInputPort")
|
||||
#undef JNI_CLASS_MEMBERS
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -1014,24 +1014,18 @@ private:
|
|||
//==============================================================================
|
||||
Array<MidiDeviceInfo> MidiInput::getAvailableDevices()
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23)
|
||||
return {};
|
||||
|
||||
AndroidMidiDeviceManager manager;
|
||||
return manager.getDevices (true);
|
||||
}
|
||||
|
||||
MidiDeviceInfo MidiInput::getDefaultDevice()
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23)
|
||||
return {};
|
||||
|
||||
return getAvailableDevices().getFirst();
|
||||
}
|
||||
|
||||
std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier, MidiInputCallback* callback)
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23 || deviceIdentifier.isEmpty())
|
||||
if (deviceIdentifier.isEmpty())
|
||||
return {};
|
||||
|
||||
AndroidMidiDeviceManager manager;
|
||||
|
|
@ -1051,9 +1045,6 @@ std::unique_ptr<MidiInput> MidiInput::openDevice (const String& deviceIdentifier
|
|||
|
||||
StringArray MidiInput::getDevices()
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23)
|
||||
return {};
|
||||
|
||||
StringArray deviceNames;
|
||||
|
||||
for (auto& d : getAvailableDevices())
|
||||
|
|
@ -1064,7 +1055,7 @@ StringArray MidiInput::getDevices()
|
|||
|
||||
int MidiInput::getDefaultDeviceIndex()
|
||||
{
|
||||
return (getAndroidSDKVersion() < 23 ? -1 : 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<MidiInput> MidiInput::openDevice (int index, MidiInputCallback* callback)
|
||||
|
|
@ -1094,24 +1085,18 @@ void MidiInput::stop()
|
|||
//==============================================================================
|
||||
Array<MidiDeviceInfo> MidiOutput::getAvailableDevices()
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23)
|
||||
return {};
|
||||
|
||||
AndroidMidiDeviceManager manager;
|
||||
return manager.getDevices (false);
|
||||
}
|
||||
|
||||
MidiDeviceInfo MidiOutput::getDefaultDevice()
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23)
|
||||
return {};
|
||||
|
||||
return getAvailableDevices().getFirst();
|
||||
}
|
||||
|
||||
std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String& deviceIdentifier)
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23 || deviceIdentifier.isEmpty())
|
||||
if (deviceIdentifier.isEmpty())
|
||||
return {};
|
||||
|
||||
AndroidMidiDeviceManager manager;
|
||||
|
|
@ -1130,9 +1115,6 @@ std::unique_ptr<MidiOutput> MidiOutput::openDevice (const String& deviceIdentifi
|
|||
|
||||
StringArray MidiOutput::getDevices()
|
||||
{
|
||||
if (getAndroidSDKVersion() < 23)
|
||||
return {};
|
||||
|
||||
StringArray deviceNames;
|
||||
|
||||
for (auto& d : getAvailableDevices())
|
||||
|
|
@ -1143,7 +1125,7 @@ StringArray MidiOutput::getDevices()
|
|||
|
||||
int MidiOutput::getDefaultDeviceIndex()
|
||||
{
|
||||
return (getAndroidSDKVersion() < 23 ? -1 : 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::unique_ptr<MidiOutput> MidiOutput::openDevice (int index)
|
||||
|
|
|
|||
|
|
@ -1196,8 +1196,7 @@ public:
|
|||
|
||||
bool supportsDevicesInfo() const
|
||||
{
|
||||
static auto result = getAndroidSDKVersion() >= 23;
|
||||
return result;
|
||||
return true;
|
||||
}
|
||||
|
||||
void addDevice (const LocalRef<jobject>& device, JNIEnv* env)
|
||||
|
|
|
|||
|
|
@ -360,22 +360,17 @@ public:
|
|||
if (runner == nullptr)
|
||||
return false;
|
||||
|
||||
const bool supportsJavaProxy = (getAndroidSDKVersion() >= 24);
|
||||
// may return nullptr on some platforms - that's ok
|
||||
config = SlRef<SLAndroidConfigurationItf_>::cast (runner);
|
||||
|
||||
if (supportsJavaProxy)
|
||||
if (config != nullptr)
|
||||
{
|
||||
// may return nullptr on some platforms - that's ok
|
||||
config = SlRef<SLAndroidConfigurationItf_>::cast (runner);
|
||||
jobject audioRoutingJni;
|
||||
auto status = (*config)->AcquireJavaProxy (config, /*SL_ANDROID_JAVA_PROXY_ROUTING*/1,
|
||||
&audioRoutingJni);
|
||||
|
||||
if (config != nullptr)
|
||||
{
|
||||
jobject audioRoutingJni;
|
||||
auto status = (*config)->AcquireJavaProxy (config, /*SL_ANDROID_JAVA_PROXY_ROUTING*/1,
|
||||
&audioRoutingJni);
|
||||
|
||||
if (status == SL_RESULT_SUCCESS && audioRoutingJni != nullptr)
|
||||
javaProxy = GlobalRef (LocalRef<jobject> (getEnv()->NewLocalRef (audioRoutingJni)));
|
||||
}
|
||||
if (status == SL_RESULT_SUCCESS && audioRoutingJni != nullptr)
|
||||
javaProxy = GlobalRef (LocalRef<jobject> (getEnv()->NewLocalRef (audioRoutingJni)));
|
||||
}
|
||||
|
||||
queue = SlRef<SLAndroidSimpleBufferQueueItf_>::cast (runner);
|
||||
|
|
@ -677,8 +672,7 @@ public:
|
|||
return;
|
||||
}
|
||||
|
||||
const bool supportsUnderrunCount = (getAndroidSDKVersion() >= 24);
|
||||
getUnderrunCount = supportsUnderrunCount ? getEnv()->GetMethodID (AudioTrack, "getUnderrunCount", "()I") : nullptr;
|
||||
getUnderrunCount = getEnv()->GetMethodID (AudioTrack, "getUnderrunCount", "()I");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1054,18 +1048,14 @@ OpenSLAudioIODevice::OpenSLSession* OpenSLAudioIODevice::OpenSLSession::create (
|
|||
int numBuffersToUse)
|
||||
{
|
||||
std::unique_ptr<OpenSLSession> retval;
|
||||
auto sdkVersion = getAndroidSDKVersion();
|
||||
|
||||
// SDK versions 21 and higher should natively support floating point...
|
||||
if (sdkVersion >= 21)
|
||||
{
|
||||
retval.reset (new OpenSLSessionT<float> (numInputChannels, numOutputChannels, samleRateToUse,
|
||||
bufferSizeToUse, numBuffersToUse));
|
||||
retval.reset (new OpenSLSessionT<float> (numInputChannels, numOutputChannels, samleRateToUse,
|
||||
bufferSizeToUse, numBuffersToUse));
|
||||
|
||||
// ...however, some devices lie so re-try without floating point
|
||||
if (retval != nullptr && (! retval->openedOK()))
|
||||
retval = nullptr;
|
||||
}
|
||||
// ...however, some devices lie so re-try without floating point
|
||||
if (retval != nullptr && (! retval->openedOK()))
|
||||
retval = nullptr;
|
||||
|
||||
if (retval == nullptr)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue