the error meassage:E/AudioEffect: set(): AudioFlinger could not create effect, status: -1 04-17 21:49:09.967 24849-24849/? E/visualizers-JNI: Visualizer initCheck failed E/Visualizer-JAVA: Error code -3 when initializing Visualizer.
baoqianyue opened this issue · 5 comments
public class MonitorSoundFragment extends Fragment {
private static final String TAG = "MonitorSoundFragment.class";
private BarVisualizer envirnment_bar;
public static MonitorSoundFragment newIntance() {
return new MonitorSoundFragment();
}
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_monitor_sound, null);
findViews(view);
return view;
}
private void findViews(View view) {
envirnment_bar = view.findViewById(R.id.environment_shower);
envirnment_bar.setDensity(70);
envirnment_bar.setColor(R.color.colorAccent);
//获取AudioManager
AudioManager audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);
envirnment_bar.setPlayer(audioManager.generateAudioSessionId());
int volume = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC);
Log.i(TAG, "current volume" + volume);
}
}
this is my code, I find the parameter is int audioSessionId,So I used this method of audiomanager, but it doesn't seem feasible
I believe you want the session id of a specific MediaPlayer or AudioTrack, not audioManager.generateAudioSessionId() which gives an unused Id.
If you want the visualiser to apply to the output mix you can pass in 0
I also found same issue I have added permissions:
<uses-permission android:name="android.permission.RECORD_AUDIO"/> <uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS"/> <uses-permission android:name="android.permission.INTERNET"/>
And verified it has permission still getting this issue
E/AudioEffect: set(): AudioFlinger could not create effect e46b26a0-dddd-11db-8afd-0002a5d5c51b / , status: -2 E/visualizers-JNI: Visualizer initCheck failed -3 E/Visualizer-JAVA: Error code -3 when initializing Visualizer.
I have tried to set audio player's session ID "1009" (mAudioPlayer.getAudioSessionId();) and "0" also but none is working
It's unfortunate i got the same error, has anyone solved this anyway... i got
2021-06-18 19:11:54.504 24961-24961/com.bigger.bb E/AudioEffect: set(): AudioFlinger could not create effect e46b26a0-dddd-11db-8afd-0002a5d5c51b / �$���5�, status: -1 2021-06-18 19:11:54.504 24961-24961/com.bigger.bb E/visualizers-JNI: Visualizer initCheck failed -3 2021-06-18 19:11:54.505 24961-24961/com.bigger.bb E/Visualizer-JAVA: Error code -3 when initializing Visualizer. 2021-06-18 19:11:54.506 24961-24961/com.bigger.bb D/AndroidRuntime: Shutting down VM 2021-06-18 19:11:54.515 24961-24961/com.bigger.bb E/AndroidRuntime: FATAL EXCEPTION: main Process: com.bigger.bb, PID: 24961 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bigger.bb/com.bigger.bb.MainActivity}: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3 at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2819) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2897) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1623) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6548) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888) Caused by: java.lang.RuntimeException: Cannot initialize Visualizer engine, error: -3 at android.media.audiofx.Visualizer.<init>(Visualizer.java:218) at com.bigger.bb.MainActivity.setupVisualizerFxAndUI(MainActivity.java:330) at com.bigger.bb.MainActivity.initView(MainActivity.java:145) at com.bigger.bb.MainActivity.onCreate(MainActivity.java:115) at android.app.Activity.performCreate(Activity.java:7044) at android.app.Activity.performCreate(Activity.java:7035) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1214) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2772) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2897) at android.app.ActivityThread.-wrap11(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1623) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6548) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:451) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:888)
also i found same error :
E/AudioEffect( 5739): set(): AudioFlinger could not create effect 0bed4300-ddd6-11db-8f34-0002a5d5c51b / ec7178ec-e5e1-4432-a3f4-4657e6795210, status: -1
E/AudioEffects-JNI( 5739): AudioEffect initCheck failed -3
E/AudioEffect-JAVA( 5739): Error code -3 when initializing AudioEffect.
also i found same error :
E/AudioEffect( 5739): set(): AudioFlinger could not create effect 0bed4300-ddd6-11db-8f34-0002a5d5c51b / ec7178ec-e5e1-4432-a3f4-4657e6795210, status: -1 E/AudioEffects-JNI( 5739): AudioEffect initCheck failed -3 E/AudioEffect-JAVA( 5739): Error code -3 when initializing AudioEffect.
This is permission issue.
Make sure your app have android.permission.RECORD_AUDIO permission.