use of android.media.SoundPool in project robolectric by robolectric.
the class ShadowSoundPoolTest method shouldCreateSoundPool_Lollipop.
@Test
@Config(minSdk = LOLLIPOP)
public void shouldCreateSoundPool_Lollipop() {
SoundPool soundPool = new SoundPool.Builder().build();
assertThat(soundPool).isNotNull();
SoundPool.OnLoadCompleteListener listener = mock(SoundPool.OnLoadCompleteListener.class);
soundPool.setOnLoadCompleteListener(listener);
}
use of android.media.SoundPool in project robolectric by robolectric.
the class ShadowSoundPoolTest method shouldCreateSoundPool_JellyBean.
@Test
@Config(maxSdk = JELLY_BEAN_MR2)
public void shouldCreateSoundPool_JellyBean() {
SoundPool soundPool = new SoundPool(1, AudioManager.STREAM_MUSIC, 0);
assertThat(soundPool).isNotNull();
}
use of android.media.SoundPool in project platform_frameworks_base by android.
the class KeyguardViewMediator method setupLocked.
private void setupLocked() {
mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mWM = WindowManagerGlobal.getWindowManagerService();
mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
mShowKeyguardWakeLock.setReferenceCounted(false);
mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_KEYGUARD_ACTION));
mContext.registerReceiver(mBroadcastReceiver, new IntentFilter(DELAYED_LOCK_PROFILE_ACTION));
mKeyguardDisplayManager = new KeyguardDisplayManager(mContext);
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
mLockPatternUtils = new LockPatternUtils(mContext);
KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure...
setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser()));
updateInputRestrictedLocked();
mTrustManager.reportKeyguardShowingChanged();
mStatusBarKeyguardViewManager = SystemUIFactory.getInstance().createStatusBarKeyguardViewManager(mContext, mViewMediatorCallback, mLockPatternUtils);
final ContentResolver cr = mContext.getContentResolver();
mDeviceInteractive = mPM.isInteractive();
mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND);
if (soundPath != null) {
mLockSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mLockSoundId == 0) {
Log.w(TAG, "failed to load lock sound from " + soundPath);
}
soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND);
if (soundPath != null) {
mUnlockSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mUnlockSoundId == 0) {
Log.w(TAG, "failed to load unlock sound from " + soundPath);
}
soundPath = Settings.Global.getString(cr, Settings.Global.TRUSTED_SOUND);
if (soundPath != null) {
mTrustedSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mTrustedSoundId == 0) {
Log.w(TAG, "failed to load trusted sound from " + soundPath);
}
int lockSoundDefaultAttenuation = mContext.getResources().getInteger(com.android.internal.R.integer.config_lockSoundVolumeDb);
mLockSoundVolume = (float) Math.pow(10, (float) lockSoundDefaultAttenuation / 20);
mHideAnimation = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.lock_screen_behind_enter);
}
use of android.media.SoundPool in project love-android by hagish.
the class LuanAudio method InitLib.
public LuaTable InitLib() {
mSoundPool = new SoundPool(kAudioChannels, AudioManager.STREAM_MUSIC, 0);
LuaTable t = LuaValue.tableOf();
LuaValue _G = vm.get_G();
_G.set(sMetaName_LuanSource, LuanObjSource.CreateMetaTable(this));
_G.set(sMetaName_LuanDecoder, LuanObjDecoder.CreateMetaTable(this));
_G.set(sMetaName_LuanSoundData, LuanObjSoundData.CreateMetaTable(this));
// numSources = love.audio.getNumSources( )
t.set("getNumSources", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
vm.NotImplemented("love.audio.getNumSources");
return LuaValue.ZERO;
}
});
// fx, fy, fz, ux, uy, uz = love.audio.getOrientation( )
t.set("getOrientation", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(orientationForward.x), LuaNumber.valueOf(orientationForward.y), LuaNumber.valueOf(orientationForward.z), LuaNumber.valueOf(orientationUp.x), LuaNumber.valueOf(orientationUp.y), LuaNumber.valueOf(orientationUp.z) });
}
});
// x, y, z = love.audio.getPosition( )
t.set("getPosition", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(position.x), LuaNumber.valueOf(position.y), LuaNumber.valueOf(position.z) });
}
});
// x, y, z = love.audio.getVelocity( )
t.set("getVelocity", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(velocity.x), LuaNumber.valueOf(velocity.y), LuaNumber.valueOf(velocity.z) });
}
});
// volume = love.audio.getVolume( )
t.set("getVolume", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
return varargsOf(new LuaValue[] { LuaNumber.valueOf(volume) });
}
});
// source = love.audio.newSource( file, type )
t.set("newSource", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
Log("love.audio.newSource params:" + ((args.narg() >= 1) ? getLuaTypeName(args.type(1)) : "notset") + "," + ((args.narg() >= 2) ? getLuaTypeName(args.type(2)) : "notset") + "," + ((args.narg() >= 3) ? getLuaTypeName(args.type(3)) : "notset") + "...");
if (args.isstring(1)) {
Log("love.audio.newSource(string,..)");
String sFileName = args.checkjstring(1);
String sType = IsArgSet(args, 2) ? args.checkjstring(2) : "static";
return LuaValue.userdataOf(new LuanObjSource(LuanAudio.this, sFileName, sType), vm.get_G().get(sMetaName_LuanSource));
}
if (IsArgSet(args, 2) && args.isstring(2)) {
Log("love.audio.newSource(???,string,..)");
LuanObjDecoder decoder = (LuanObjDecoder) args.checkuserdata(1, LuanObjDecoder.class);
String sType = args.checkjstring(2);
return LuaValue.userdataOf(new LuanObjSource(LuanAudio.this, decoder, sType), vm.get_G().get(sMetaName_LuanSource));
}
LuanObjSoundData soundata = (LuanObjSoundData) args.checkuserdata(1, LuanObjSoundData.class);
return LuaValue.userdataOf(new LuanObjSource(LuanAudio.this, soundata), vm.get_G().get(sMetaName_LuanSource));
}
});
// love.audio.pause( )
t.set("pause", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.pause");
return LuaValue.NONE;
}
});
/// love.audio.play( source )
///Plays the specified Source.
t.set("play", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
LuanObjSource src = (LuanObjSource) args.checkuserdata(1, LuanObjSource.class);
src.play();
return LuaValue.NONE;
}
});
// love.audio.resume( )
t.set("resume", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.resume");
return LuaValue.NONE;
}
});
// love.audio.rewind( )
t.set("rewind", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.rewind");
return LuaValue.NONE;
}
});
// love.audio.setOrientation( fx, fy, fz, ux, uy, uz )
t.set("setOrientation", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
orientationForward.x = args.arg(1).tofloat();
orientationForward.y = args.arg(2).tofloat();
orientationForward.z = args.arg(3).tofloat();
orientationUp.x = args.arg(4).tofloat();
orientationUp.y = args.arg(5).tofloat();
orientationUp.z = args.arg(6).tofloat();
notifySpatialChange();
return LuaValue.NONE;
}
});
// love.audio.setPosition( x, y, z )
t.set("setPosition", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
position.x = args.arg(1).tofloat();
position.y = args.arg(2).tofloat();
position.z = args.arg(3).tofloat();
notifySpatialChange();
return LuaValue.NONE;
}
});
// love.audio.setVelocity( x, y, z )
t.set("setVelocity", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
position.x = args.arg(1).tofloat();
position.y = args.arg(2).tofloat();
position.z = args.arg(3).tofloat();
notifySpatialChange();
return LuaValue.NONE;
}
});
// love.audio.setVolume( volume )
t.set("setVolume", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
volume = args.arg(1).tofloat();
// TODO
vm.NotImplemented("love.audio.setVolume");
return LuaValue.NONE;
}
});
// love.audio.stop( )
t.set("stop", new VarArgFunction() {
@Override
public Varargs invoke(Varargs args) {
// TODO
vm.NotImplemented("love.audio.stop");
return LuaValue.NONE;
}
});
return t;
}
use of android.media.SoundPool in project android_frameworks_base by ResurrectionRemix.
the class KeyguardViewMediator method setupLocked.
private void setupLocked() {
mPM = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
mWM = WindowManagerGlobal.getWindowManagerService();
mTrustManager = (TrustManager) mContext.getSystemService(Context.TRUST_SERVICE);
mShowKeyguardWakeLock = mPM.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "show keyguard");
mShowKeyguardWakeLock.setReferenceCounted(false);
mProfileManager = ProfileManager.getInstance(mContext);
IntentFilter filter = new IntentFilter();
filter.addAction(DELAYED_KEYGUARD_ACTION);
filter.addAction(DELAYED_LOCK_PROFILE_ACTION);
filter.addAction(Intent.ACTION_SHUTDOWN);
mContext.registerReceiver(mBroadcastReceiver, filter);
mKeyguardDisplayManager = new KeyguardDisplayManager(mContext);
mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
mUpdateMonitor = KeyguardUpdateMonitor.getInstance(mContext);
mLockPatternUtils = new LockPatternUtils(mContext);
KeyguardUpdateMonitor.setCurrentUser(ActivityManager.getCurrentUser());
// Assume keyguard is showing (unless it's disabled) until we know for sure...
setShowingLocked(!shouldWaitForProvisioning() && !mLockPatternUtils.isLockScreenDisabled(KeyguardUpdateMonitor.getCurrentUser()));
updateInputRestrictedLocked();
mTrustManager.reportKeyguardShowingChanged();
mStatusBarKeyguardViewManager = SystemUIFactory.getInstance().createStatusBarKeyguardViewManager(mContext, mViewMediatorCallback, mLockPatternUtils);
final ContentResolver cr = mContext.getContentResolver();
mDeviceInteractive = mPM.isInteractive();
mLockSounds = new SoundPool(1, AudioManager.STREAM_SYSTEM, 0);
String soundPath = Settings.Global.getString(cr, Settings.Global.LOCK_SOUND);
if (soundPath != null) {
mLockSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mLockSoundId == 0) {
Log.w(TAG, "failed to load lock sound from " + soundPath);
}
soundPath = Settings.Global.getString(cr, Settings.Global.UNLOCK_SOUND);
if (soundPath != null) {
mUnlockSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mUnlockSoundId == 0) {
Log.w(TAG, "failed to load unlock sound from " + soundPath);
}
soundPath = Settings.Global.getString(cr, Settings.Global.TRUSTED_SOUND);
if (soundPath != null) {
mTrustedSoundId = mLockSounds.load(soundPath, 1);
}
if (soundPath == null || mTrustedSoundId == 0) {
Log.w(TAG, "failed to load trusted sound from " + soundPath);
}
int lockSoundDefaultAttenuation = mContext.getResources().getInteger(com.android.internal.R.integer.config_lockSoundVolumeDb);
mLockSoundVolume = (float) Math.pow(10, (float) lockSoundDefaultAttenuation / 20);
mHideAnimation = AnimationUtils.loadAnimation(mContext, com.android.internal.R.anim.lock_screen_behind_enter);
}
Aggregations