package android.media;
import android.annotation.NonNull;
import android.annotation.SuppressLint;
import android.os.Build;
import android.util.Log;
/**
* The CarVirtualPlayer class manages and plays car virtual audio resources for applications.
* mega porting
*
*/
@SuppressLint("NotCloseable")
public class CarVirtualPlayer extends PlayerBase {
private final static String TAG = "CarVirtualPlayer";
private static final boolean DEBUG = !"user".equals(Build.TYPE);
private final Object mPlayStateLock;
public CarVirtualPlayer(int streamType) {
this(new AudioAttributes.Builder().setInternalLegacyStreamType(streamType).build());
PlayerBase.deprecateStreamTypeForPlayback(streamType, "CarVirtualPlayer", "CarVirtualPlayer()");
}
public CarVirtualPlayer(@NonNull AudioAttributes attributes) {
super(attributes, AudioPlaybackConfiguration.PLAYER_TYPE_UNKNOWN);
mPlayStateLock = new Object();
baseRegisterPlayer();
Log.i(TAG, "create");
}
/**
* Release the SoundPool resources.
*
* Release all memory and native resources used by the SoundPool
* object. The SoundPool can no longer be used and the reference
* should be set to null.
*/
public final void release() {
if (DEBUG) Log.d(TAG, "release called");
synchronized(mPlayStateLock) {
baseRelease();
}
}
protected void finalize() {
release();
}
public final void play() {
if (DEBUG) Log.d(TAG, "play called");
synchronized(mPlayStateLock) {
baseStart();
}
}
public void pause() {
if (DEBUG) Log.d(TAG, "pause called");
synchronized(mPlayStateLock) {
basePause();
}
}
public void stop() {
if (DEBUG) Log.d(TAG, "stop called");
synchronized(mPlayStateLock) {
baseStop();
}
}
//--------------------------------------------------------------------------
// Initialization / configuration
//--------------------
@Override
void playerSetVolume(boolean muting, float leftVolume, float rightVolume) {
// not used here to control the player volume directly, but used to mute/unmute
if (DEBUG) Log.d(TAG, "playerSetVolume muting: " + muting
+ ", leftVolume: " + leftVolume + ", rightVolume: " + rightVolume);
}
@Override
int playerApplyVolumeShaper(VolumeShaper.Configuration configuration, VolumeShaper.Operation operation) {
if (DEBUG) Log.d(TAG, "playerApplyVolumeShaper configuration: " + configuration
+ ", operation: " + operation);
return -1;
}
@Override
VolumeShaper.State playerGetVolumeShaperState(int id) {
if (DEBUG) Log.d(TAG, "playerGetVolumeShaperState id: " + id);
return null;
}
//--------------------------------------------------------------------------
// Audio effects management
//--------------------
@Override
int playerSetAuxEffectSendLevel(boolean muting, float level) {
if (DEBUG) Log.d(TAG, "playerSetAuxEffectSendLevel muting: " + muting + ", level");
// no aux send functionality so no-op
return AudioSystem.SUCCESS;
}
//---------------------------------------------------------
// Methods for IPlayer interface
//--------------------
@Override
void playerStart() {
if (DEBUG) Log.d(TAG, "playerStart called");
// FIXME implement resuming any paused sound
}
@Override
void playerPause() {
if (DEBUG) Log.d(TAG, "playerPause called");
// FIXME implement pausing any playing sound
}
@Override
void playerStop() {
if (DEBUG) Log.d(TAG, "playerStop called");
// FIXME implement pausing any playing sound
}
}