MCPcopy Create free account
hub / github.com/defold/defold / GetSampleRate

Function GetSampleRate

engine/sound/src/devices/device_opensl.cpp:192–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

190 }
191
192 static int GetSampleRate()
193 {
194 dmAndroid::ThreadAttacher thread;
195 JNIEnv* env = thread.GetEnv();
196 if (env == 0)
197 {
198 return 44100;
199 }
200
201 jclass sound_class = dmAndroid::LoadClass(env, "com.defold.sound.Sound");
202
203 jmethodID get_sample_rate = env->GetStaticMethodID(sound_class, "getSampleRate", "(Landroid/content/Context;I)I");
204 assert(get_sample_rate);
205 jint sample_rate = env->CallStaticIntMethod(sound_class, get_sample_rate, thread.GetActivity()->clazz, 44100);
206
207 env->DeleteLocalRef(sound_class);
208
209 return (int)sample_rate;
210 }
211
212 dmSound::Result DeviceOpenSLOpen(const dmSound::OpenDeviceParams* params, dmSound::HDevice* device)
213 {

Callers 1

DeviceOpenSLOpenFunction · 0.85

Calls 4

LoadClassFunction · 0.85
GetEnvMethod · 0.80
GetActivityMethod · 0.80
assertFunction · 0.50

Tested by

no test coverage detected