MCPcopy Create free account
hub / github.com/android/ndk-samples / SfxMan

Method SfxMan

endless-tunnel/app/src/main/cpp/sfxman.cpp:45–165  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43}
44
45SfxMan::SfxMan() {
46 // Note: this initialization code was mostly copied from the NDK audio sample.
47 SLresult result;
48 SLObjectItf engineObject = NULL;
49 SLEngineItf engineEngine;
50 SLObjectItf outputMixObject = NULL;
51 SLEnvironmentalReverbItf outputMixEnvironmentalReverb = NULL;
52 SLObjectItf bqPlayerObject = NULL;
53 SLPlayItf bqPlayerPlay;
54 SLEffectSendItf bqPlayerEffectSend;
55 SLVolumeItf bqPlayerVolume;
56 const SLEnvironmentalReverbSettings reverbSettings =
57 SL_I3DL2_ENVIRONMENT_PRESET_STONECORRIDOR;
58
59 LOGD("SfxMan: initializing.");
60 mPlayerBufferQueue = NULL;
61
62 // create engine
63 result = slCreateEngine(&engineObject, 0, NULL, 0, NULL, NULL);
64 if (_checkError(result, "creating engine")) return;
65
66 // realize the engine
67 result = (*engineObject)->Realize(engineObject, SL_BOOLEAN_FALSE);
68 if (_checkError(result, "realizing engine")) return;
69
70 // get the engine interface, which is needed in order to create other objects
71 result =
72 (*engineObject)->GetInterface(engineObject, SL_IID_ENGINE, &engineEngine);
73 if (_checkError(result, "getting engine interface")) return;
74
75 // create output mix, with einitializingnvironmental reverb specified as a
76 // non-required interface
77 const SLInterfaceID ids[1] = {SL_IID_ENVIRONMENTALREVERB};
78 const SLboolean req[1] = {SL_BOOLEAN_FALSE};
79 result = (*engineEngine)
80 ->CreateOutputMix(engineEngine, &outputMixObject, 1, ids, req);
81 if (_checkError(result, "creating output mix")) return;
82
83 // realize the output mix
84 result = (*outputMixObject)->Realize(outputMixObject, SL_BOOLEAN_FALSE);
85 if (_checkError(result, "realizin goutput mix")) return;
86
87 // get the environmental reverb interface
88 // this could fail if the environmental reverb effect is not available,
89 // either because the feature is not present, excessive CPU load, or
90 // the required MODIFY_AUDIO_SETTINGS permission was not requested and granted
91 result = (*outputMixObject)
92 ->GetInterface(outputMixObject, SL_IID_ENVIRONMENTALREVERB,
93 &outputMixEnvironmentalReverb);
94 if (SL_RESULT_SUCCESS == result) {
95 result = (*outputMixEnvironmentalReverb)
96 ->SetEnvironmentalReverbProperties(
97 outputMixEnvironmentalReverb, &reverbSettings);
98 }
99 // ignore unsuccessful result codes for environmental reverb, as it is
100 // optional for this example
101
102 // configure audio source

Callers

nothing calls this directly

Calls 2

_checkErrorFunction · 0.85
RegisterCallbackMethod · 0.80

Tested by

no test coverage detected