package m1; import android.app.Activity; import android.content.Context; import android.media.SoundPool; import android.util.Log; import busidol.mobile.tower.MainActivity; import i1.k; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; /* loaded from: classes.dex */ public class b { /* renamed from: h, reason: collision with root package name */ public static String f11770h = "SoundController"; /* renamed from: a, reason: collision with root package name */ public Context f11771a; /* renamed from: b, reason: collision with root package name */ public Activity f11772b; /* renamed from: c, reason: collision with root package name */ public k f11773c; /* renamed from: d, reason: collision with root package name */ public HashMap f11774d; /* renamed from: e, reason: collision with root package name */ public SoundPool f11775e; /* renamed from: f, reason: collision with root package name */ public SoundPool.OnLoadCompleteListener f11776f; /* renamed from: g, reason: collision with root package name */ public HashMap f11777g; class a implements SoundPool.OnLoadCompleteListener { a() { } @Override // android.media.SoundPool.OnLoadCompleteListener public void onLoadComplete(SoundPool soundPool, int i10, int i11) { Log.i(b.f11770h, "onLoadComplete"); } } public b(k kVar) { this.f11773c = kVar; MainActivity mainActivity = kVar.f10741c; this.f11772b = mainActivity; this.f11771a = mainActivity.getApplicationContext(); } public void a() { this.f11775e = new SoundPool.Builder().setMaxStreams(10).build(); a aVar = new a(); this.f11776f = aVar; this.f11775e.setOnLoadCompleteListener(aVar); this.f11774d = new HashMap(); this.f11777g = new HashMap(); } public void b() { f(); } public void c() { f(); a(); } public void d(String str) { if (str == null || str.isEmpty()) { return; } try { this.f11774d.put(str, Integer.valueOf(this.f11775e.load(this.f11772b.getAssets().openFd(this.f11773c.f10740b.f10662p + str), 1))); } catch (IOException e10) { e10.printStackTrace(); } } public c e(String str, boolean z10) { if (!this.f11774d.containsKey(str)) { d(str); e(str, z10); return null; } int play = this.f11775e.play(((Integer) this.f11774d.get(str)).intValue(), 0.3f, 0.3f, 0, z10 ? -1 : 0, 1.0f); if (!z10) { return null; } c cVar = new c(str, play); this.f11777g.put(Integer.valueOf(play), cVar); return cVar; } public void f() { HashMap hashMap; if (this.f11775e != null && (hashMap = this.f11774d) != null) { Iterator it = hashMap.keySet().iterator(); while (it.hasNext()) { this.f11775e.unload(((Integer) this.f11774d.get((String) it.next())).intValue()); } } SoundPool soundPool = this.f11775e; if (soundPool != null) { soundPool.release(); } HashMap hashMap2 = this.f11774d; if (hashMap2 != null) { hashMap2.clear(); } HashMap hashMap3 = this.f11777g; if (hashMap3 != null) { hashMap3.clear(); } } }