use of android.media.AudioDeviceCallback in project vlc-android by videolan.
the class MediaPlayer method createAudioDeviceCallback.
@TargetApi(Build.VERSION_CODES.M)
private AudioDeviceCallback createAudioDeviceCallback() {
return new AudioDeviceCallback() {
private SparseArray<Long> mEncodedDevices = new SparseArray<>();
private void onAudioDevicesChanged() {
long encodingFlags = 0;
for (int i = 0; i < mEncodedDevices.size(); ++i) encodingFlags |= mEncodedDevices.valueAt(i);
updateAudioOutputDevice(encodingFlags, "pcm");
}
@RequiresApi(Build.VERSION_CODES.M)
@Override
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
for (AudioDeviceInfo info : addedDevices) {
if (!info.isSink())
continue;
long encodingFlags = getEncodingFlags(info.getEncodings());
if (encodingFlags != 0)
mEncodedDevices.put(info.getId(), encodingFlags);
}
onAudioDevicesChanged();
}
@RequiresApi(Build.VERSION_CODES.M)
@Override
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
for (AudioDeviceInfo info : removedDevices) {
if (!info.isSink())
continue;
mEncodedDevices.remove(info.getId());
}
onAudioDevicesChanged();
}
};
}
use of android.media.AudioDeviceCallback in project vlc-android by GeoffreyMetais.
the class MediaPlayer method createAudioDeviceCallback.
@TargetApi(Build.VERSION_CODES.M)
private AudioDeviceCallback createAudioDeviceCallback() {
return new AudioDeviceCallback() {
private SparseArray<Long> mEncodedDevices = new SparseArray<>();
private void onAudioDevicesChanged() {
long encodingFlags = 0;
for (int i = 0; i < mEncodedDevices.size(); ++i) encodingFlags |= mEncodedDevices.valueAt(i);
updateAudioOutputDevice(encodingFlags, "pcm");
}
@RequiresApi(Build.VERSION_CODES.M)
@Override
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
for (AudioDeviceInfo info : addedDevices) {
if (!info.isSink())
continue;
long encodingFlags = getEncodingFlags(info.getEncodings());
if (encodingFlags != 0)
mEncodedDevices.put(info.getId(), encodingFlags);
}
onAudioDevicesChanged();
}
@RequiresApi(Build.VERSION_CODES.M)
@Override
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
for (AudioDeviceInfo info : removedDevices) {
if (!info.isSink())
continue;
mEncodedDevices.remove(info.getId());
}
onAudioDevicesChanged();
}
};
}
Aggregations