List of usage examples for android.content.pm PackageManager FEATURE_AUDIO_LOW_LATENCY
String FEATURE_AUDIO_LOW_LATENCY
To view the source code for android.content.pm PackageManager FEATURE_AUDIO_LOW_LATENCY.
Click Source Link
From source file:Main.java
private static boolean checkLowLatencySupport(Context context) { if (context == null) { return false; }//w w w .ja v a2 s . c o m PackageManager pm = context.getPackageManager(); return pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY); }
From source file:Main.java
/** * A single feature that can be requested by an application. * This corresponds to information collected from the AndroidManifest.xml's tag. * @param feature "FeatureInfo"//from www. ja va2 s. c o m */ @SuppressWarnings("deprecation") public static String getFeature(String feature) { if (TextUtils.isEmpty(feature)) { return UNKNOWN; } switch (feature) { case PackageManager.FEATURE_APP_WIDGETS://android.software.app_widgets return "FEATURE_APP_WIDGETS"; case PackageManager.FEATURE_AUDIO_LOW_LATENCY://android.hardware.audio.low_latency return "FEATURE_AUDIO_LOW_LATENCY"; case PackageManager.FEATURE_AUDIO_OUTPUT://android.hardware.audio.output return "FEATURE_AUDIO_OUTPUT"; case PackageManager.FEATURE_AUDIO_PRO://android.hardware.audio.pro return "FEATURE_AUDIO_PRO";//API 23 case PackageManager.FEATURE_AUTOMOTIVE://android.hardware.type.automotive return "FEATURE_AUTOMOTIVE";//API 23 case PackageManager.FEATURE_BACKUP://android.software.backup return "FEATURE_BACKUP"; case PackageManager.FEATURE_BLUETOOTH://android.hardware.bluetooth return "FEATURE_BLUETOOTH"; case PackageManager.FEATURE_BLUETOOTH_LE://android.hardware.bluetooth_le return "FEATURE_BLUETOOTH_LE"; case PackageManager.FEATURE_CAMERA://android.hardware.camera return "FEATURE_CAMERA"; case PackageManager.FEATURE_CAMERA_ANY://android.hardware.camera.any return "FEATURE_CAMERA_ANY"; case PackageManager.FEATURE_CAMERA_AUTOFOCUS://android.hardware.camera.autofocus return "FEATURE_CAMERA_AUTOFOCUS"; case PackageManager.FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING://android.hardware.camera.capability.manual_post_processing return "FEATURE_CAMERA_CAPABILITY_MANUAL_POST_PROCESSING"; case PackageManager.FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR://android.hardware.camera.capability.manual_sensor return "FEATURE_CAMERA_CAPABILITY_MANUAL_SENSOR"; case PackageManager.FEATURE_CAMERA_CAPABILITY_RAW://android.hardware.camera.capability.raw return "FEATURE_CAMERA_CAPABILITY_RAW"; case PackageManager.FEATURE_CAMERA_EXTERNAL://android.hardware.camera.external return "FEATURE_CAMERA_EXTERNAL"; case PackageManager.FEATURE_CAMERA_FLASH://android.hardware.camera.flash return "FEATURE_CAMERA_FLASH"; case PackageManager.FEATURE_CAMERA_FRONT://android.hardware.camera.front return "FEATURE_CAMERA_FRONT"; case PackageManager.FEATURE_CAMERA_LEVEL_FULL://android.hardware.camera.level.full return "FEATURE_CAMERA_LEVEL_FULL"; case PackageManager.FEATURE_CONNECTION_SERVICE://android.software.connectionservice return "FEATURE_CONNECTION_SERVICE"; case PackageManager.FEATURE_CONSUMER_IR://android.hardware.consumerir return "FEATURE_CONSUMER_IR"; case PackageManager.FEATURE_DEVICE_ADMIN://android.software.device_admin return "FEATURE_DEVICE_ADMIN"; case PackageManager.FEATURE_FAKETOUCH://android.hardware.faketouch return "FEATURE_FAKETOUCH"; case PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT://android.hardware.faketouch.multitouch.distinct return "FEATURE_FAKETOUCH_MULTITOUCH_DISTINCT"; case PackageManager.FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND://android.hardware.faketouch.multitouch.jazzhand return "FEATURE_FAKETOUCH_MULTITOUCH_JAZZHAND"; case PackageManager.FEATURE_FINGERPRINT://android.hardware.fingerprint return "FEATURE_FINGERPRINT";//API 23 case PackageManager.FEATURE_GAMEPAD://android.hardware.gamepad return "FEATURE_GAMEPAD"; case PackageManager.FEATURE_HIFI_SENSORS://android.hardware.sensor.hifi_sensors return "FEATURE_HIFI_SENSORS";//API 23 case PackageManager.FEATURE_HOME_SCREEN://android.software.home_screen return "FEATURE_HOME_SCREEN"; case PackageManager.FEATURE_INPUT_METHODS://android.software.input_methods return "FEATURE_INPUT_METHODS"; case PackageManager.FEATURE_LEANBACK://android.software.leanback return "FEATURE_LEANBACK"; case PackageManager.FEATURE_LIVE_TV://android.software.live_tv return "FEATURE_LIVE_TV"; case PackageManager.FEATURE_LIVE_WALLPAPER://android.software.live_wallpaper return "FEATURE_LIVE_WALLPAPER"; case PackageManager.FEATURE_LOCATION://android.hardware.location return "FEATURE_LOCATION"; case PackageManager.FEATURE_LOCATION_GPS://android.hardware.location.gps return "FEATURE_LOCATION_GPS"; case PackageManager.FEATURE_LOCATION_NETWORK://android.hardware.location.network return "FEATURE_LOCATION_NETWORK"; case PackageManager.FEATURE_MANAGED_USERS://android.software.managed_users return "FEATURE_MANAGED_USERS"; case PackageManager.FEATURE_MICROPHONE://android.hardware.microphone return "FEATURE_MICROPHONE"; case PackageManager.FEATURE_MIDI://android.software.midi return "FEATURE_MIDI";//API 23 case PackageManager.FEATURE_NFC://android.hardware.nfc return "FEATURE_NFC"; case PackageManager.FEATURE_NFC_HOST_CARD_EMULATION://android.hardware.nfc.hce return "FEATURE_NFC_HOST_CARD_EMULATION"; case PackageManager.FEATURE_OPENGLES_EXTENSION_PACK://android.hardware.opengles.aep return "FEATURE_OPENGLES_EXTENSION_PACK"; case PackageManager.FEATURE_PRINTING://android.software.print return "FEATURE_PRINTING"; case PackageManager.FEATURE_SCREEN_LANDSCAPE://android.hardware.screen.landscape return "FEATURE_SCREEN_LANDSCAPE"; case PackageManager.FEATURE_SCREEN_PORTRAIT://android.hardware.screen.portrait return "FEATURE_SCREEN_PORTRAIT"; case PackageManager.FEATURE_SECURELY_REMOVES_USERS://android.software.securely_removes_users return "FEATURE_SECURELY_REMOVES_USERS"; case PackageManager.FEATURE_SENSOR_ACCELEROMETER://android.hardware.sensor.accelerometer return "FEATURE_SENSOR_ACCELEROMETER"; case PackageManager.FEATURE_SENSOR_AMBIENT_TEMPERATURE://android.hardware.sensor.ambient_temperature return "FEATURE_SENSOR_AMBIENT_TEMPERATURE"; case PackageManager.FEATURE_SENSOR_BAROMETER://android.hardware.sensor.barometer return "FEATURE_SENSOR_BAROMETER"; case PackageManager.FEATURE_SENSOR_COMPASS://android.hardware.sensor.compass return "FEATURE_SENSOR_COMPASS"; case PackageManager.FEATURE_SENSOR_GYROSCOPE://android.hardware.sensor.gyroscope return "FEATURE_SENSOR_GYROSCOPE"; case PackageManager.FEATURE_SENSOR_HEART_RATE://android.hardware.sensor.heartrate return "FEATURE_SENSOR_HEART_RATE"; case PackageManager.FEATURE_SENSOR_HEART_RATE_ECG://android.hardware.sensor.heartrate.ecg return "FEATURE_SENSOR_HEART_RATE_ECG"; case PackageManager.FEATURE_SENSOR_LIGHT://android.hardware.sensor.light return "FEATURE_SENSOR_LIGHT"; case PackageManager.FEATURE_SENSOR_PROXIMITY://android.hardware.sensor.proximity return "FEATURE_SENSOR_PROXIMITY"; case PackageManager.FEATURE_SENSOR_RELATIVE_HUMIDITY://android.hardware.sensor.relative_humidity return "FEATURE_SENSOR_RELATIVE_HUMIDITY"; case PackageManager.FEATURE_SENSOR_STEP_COUNTER://android.hardware.sensor.stepcounter return "FEATURE_SENSOR_STEP_COUNTER"; case PackageManager.FEATURE_SENSOR_STEP_DETECTOR://android.hardware.sensor.stepdetector return "FEATURE_SENSOR_STEP_DETECTOR"; case PackageManager.FEATURE_SIP://android.software.sip return "FEATURE_SIP"; case PackageManager.FEATURE_SIP_VOIP://android.software.sip.voip return "FEATURE_SIP_VOIP"; case PackageManager.FEATURE_TELEPHONY://android.hardware.telephony return "FEATURE_TELEPHONY"; case PackageManager.FEATURE_TELEPHONY_CDMA://android.hardware.telephony.cdma return "FEATURE_TELEPHONY_CDMA"; case PackageManager.FEATURE_TELEPHONY_GSM://android.hardware.telephony.gsm return "FEATURE_TELEPHONY_GSM"; case PackageManager.FEATURE_TELEVISION://android.hardware.type.television return "FEATURE_TELEVISION"; case PackageManager.FEATURE_TOUCHSCREEN://android.hardware.touchscreen return "FEATURE_TOUCHSCREEN"; case PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH://android.hardware.touchscreen.multitouch return "FEATURE_TOUCHSCREEN_MULTITOUCH"; case PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT://android.hardware.touchscreen.multitouch.distinct return "FEATURE_TOUCHSCREEN_MULTITOUCH_DISTINCT"; case PackageManager.FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND://android.hardware.touchscreen.multitouch.jazzhand return "FEATURE_TOUCHSCREEN_MULTITOUCH_JAZZHAND"; case PackageManager.FEATURE_USB_ACCESSORY://android.hardware.usb.accessory return "FEATURE_USB_ACCESSORY"; case PackageManager.FEATURE_USB_HOST://android.hardware.usb.host return "FEATURE_USB_HOST"; case PackageManager.FEATURE_VERIFIED_BOOT://android.software.verified_boot return "FEATURE_VERIFIED_BOOT"; case PackageManager.FEATURE_WATCH://android.hardware.type.watch return "FEATURE_WATCH"; case PackageManager.FEATURE_WEBVIEW://android.software.webview return "FEATURE_WEBVIEW"; case PackageManager.FEATURE_WIFI://android.hardware.wifi return "FEATURE_WIFI"; case PackageManager.FEATURE_WIFI_DIRECT://android.hardware.wifi.direct return "FEATURE_WIFI_DIRECT"; default: return UNKNOWN; } }
From source file:com.example.nativeaudio.NativeAudio.java
/** Called when the activity is first created. */ @Override/* w w w .jav a 2s . c om*/ @TargetApi(17) protected void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.main); Log.d(TAG, "onCreate ----------- "); assetManager = getAssets(); /* Ctrl+O ? Ctrl+I ? Ctrl+N /? Ctrl+Shift+N Ctrl+Shift+ALt+N ? Ctrl+Space ??? Ctrl+Shift+Space ? Ctrl+Shift+Enter (? ?; ) Ctrl+P ?? Alt+Enter ?/?/ Ctrl+J ?? ( for foreach Toast system.out.println) logm logr loge */ // initialize native audio system createEngine(); int sampleRate = 0; int bufSize = 0; /* * retrieve fast audio path sample rate and buf size; if we have it, we pass to native * side to create a player with fast audio enabled [ fast audio == low latency audio ]; * IF we do not have a fast audio path, we pass 0 for sampleRate, which will force native * side to pick up the 8Khz sample rate. */ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) { AudioManager myAudioMgr = (AudioManager) getSystemService(Context.AUDIO_SERVICE); String nativeParam = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE); sampleRate = Integer.parseInt(nativeParam); nativeParam = myAudioMgr.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER); bufSize = Integer.parseInt(nativeParam); // buffer? PackageManager pm = getPackageManager(); boolean claimsFeature = pm.hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY); // ?5 OUTPUT_SAMPLE_RATE = 48000 OUTPUT_FRAMES_PER_BUFFER = 192 FEATURE_AUDIO_LOW_LATENCY = false // MTK MT6735 OUTPUT_SAMPLE_RATE = 44100 OUTPUT_FRAMES_PER_BUFFER = 1024 FEATURE_AUDIO_LOW_LATENCY = false Log.d(TAG, "OUTPUT_SAMPLE_RATE = " + sampleRate + " OUTPUT_FRAMES_PER_BUFFER = " + bufSize + " FEATURE_AUDIO_LOW_LATENCY = " + claimsFeature); } // buffer queue AudioPlayer Demo createBufferQueueAudioPlayer(sampleRate, bufSize); // initialize URI spinner Spinner uriSpinner = (Spinner) findViewById(R.id.uri_spinner); ArrayAdapter<CharSequence> uriAdapter = ArrayAdapter.createFromResource(this, R.array.local_uri_spinner_array, /* R.array.uri_spinner_array, */ android.R.layout.simple_spinner_item); uriAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); uriSpinner.setAdapter(uriAdapter); uriSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { URI = parent.getItemAtPosition(pos).toString(); /* ? ? <string-array name="uri_spinner_array"> <item>http://upload.wikimedia.org/wikipedia/commons/6/6d/Banana.ogg</item> <item>http://www.freesound.org/data/previews/18/18765_18799-lq.mp3</item> </string-array> */ } public void onNothingSelected(AdapterView parent) { URI = null; } }); // initialize button click handlers ((Button) findViewById(R.id.hello)).setOnClickListener(new OnClickListener() { public void onClick(View view) { // ignore the return value selectClip(CLIP_HELLO, 2); } }); ((Button) findViewById(R.id.android)).setOnClickListener(new OnClickListener() { public void onClick(View view) { // ignore the return value selectClip(CLIP_ANDROID, 7); } }); ((Button) findViewById(R.id.sawtooth)).setOnClickListener(new OnClickListener() { public void onClick(View view) { // ignore the return value selectClip(CLIP_SAWTOOTH, 1); } }); ((Button) findViewById(R.id.reverb)).setOnClickListener(new OnClickListener() { boolean enabled = false; public void onClick(View view) { enabled = !enabled; if (!enableReverb(enabled)) { enabled = !enabled; } } }); // AssertManager APK?mp3 // ((Button) findViewById(R.id.embedded_soundtrack)).setOnClickListener(new OnClickListener() { boolean created = false; public void onClick(View view) { if (!created) { created = createAssetAudioPlayer(assetManager, "withus.mp3"); } if (created) { // URI AudioPlayer Demo ? // URI AudioPlayer Demo ? ?play pause // Assert/fd AudioPlayer Demo ? isPlayingAsset = !isPlayingAsset; setPlayingAssetAudioPlayer(isPlayingAsset); } } }); ((Button) findViewById(R.id.uri_soundtrack)).setOnClickListener(new OnClickListener() { boolean created = false; public void onClick(View view) { if (!created && URI != null) { Log.d(TAG, " uri_soundtrack create URI Audio Player URI " + URI); //URI = "file:///mnt/sdcard/xxx.3gp" ; //URI = "file:///mnt/sdcard/Banana.ogg" ; created = createUriAudioPlayer(URI); } } }); ((Button) findViewById(R.id.pause_uri)).setOnClickListener(new OnClickListener() { public void onClick(View view) { Log.d(TAG, " setPlayingUriAudioPlayer pause URI "); setPlayingUriAudioPlayer(false); } }); ((Button) findViewById(R.id.play_uri)).setOnClickListener(new OnClickListener() { public void onClick(View view) { Log.d(TAG, " setPlayingUriAudioPlayer play URI "); setPlayingUriAudioPlayer(true); } }); ((Button) findViewById(R.id.loop_uri)).setOnClickListener(new OnClickListener() { boolean isLooping = false; public void onClick(View view) { isLooping = !isLooping; setLoopingUriAudioPlayer(isLooping); } }); ((Button) findViewById(R.id.mute_left_uri)).setOnClickListener(new OnClickListener() { boolean muted = false; public void onClick(View view) { muted = !muted; setChannelMuteUriAudioPlayer(0, muted); } }); ((Button) findViewById(R.id.mute_right_uri)).setOnClickListener(new OnClickListener() { boolean muted = false; public void onClick(View view) { muted = !muted; setChannelMuteUriAudioPlayer(1, muted); } }); ((Button) findViewById(R.id.solo_left_uri)).setOnClickListener(new OnClickListener() { boolean soloed = false; public void onClick(View view) { soloed = !soloed; setChannelSoloUriAudioPlayer(0, soloed); } }); ((Button) findViewById(R.id.solo_right_uri)).setOnClickListener(new OnClickListener() { boolean soloed = false; public void onClick(View view) { soloed = !soloed; setChannelSoloUriAudioPlayer(1, soloed); } }); ((Button) findViewById(R.id.mute_uri)).setOnClickListener(new OnClickListener() { boolean muted = false; public void onClick(View view) { muted = !muted; setMuteUriAudioPlayer(muted); } }); /* * ???? ? Stereo Panning * https://developer.android.com/ndk/guides/audio/opensl-prog-notes.html#panning * * */ ((Button) findViewById(R.id.enable_stereo_position_uri)).setOnClickListener(new OnClickListener() { boolean enabled = false; public void onClick(View view) { enabled = !enabled; enableStereoPositionUriAudioPlayer(enabled); } }); // ?? ?AudioPlayer ??? ?SetPlayState??? ((Button) findViewById(R.id.channels_uri)).setOnClickListener(new OnClickListener() { public void onClick(View view) { if (numChannelsUri == 0) { numChannelsUri = getNumChannelsUriAudioPlayer(); } Toast.makeText(NativeAudio.this, "Channels: " + numChannelsUri, Toast.LENGTH_SHORT).show(); } }); // ?? ((SeekBar) findViewById(R.id.volume_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() { int lastProgress = 100; public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) { throw new AssertionError(); } lastProgress = progress; } public void onStartTrackingTouch(SeekBar seekBar) { } public void onStopTrackingTouch(SeekBar seekBar) { int attenuation = 100 - lastProgress; int millibel = attenuation * -50; // 100 * -50 ~ 0 setVolumeUriAudioPlayer(millibel); } }); ((SeekBar) findViewById(R.id.pan_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() { int lastProgress = 100; public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) { throw new AssertionError(); } lastProgress = progress; } public void onStartTrackingTouch(SeekBar seekBar) { } public void onStopTrackingTouch(SeekBar seekBar) { // ?? ? // ? ? ?<50 >50 ? int permille = (lastProgress - 50) * 20; setStereoPositionUriAudioPlayer(permille); } }); ((SeekBar) findViewById(R.id.playback_rate_uri)).setOnSeekBarChangeListener(new OnSeekBarChangeListener() { int lastProgress = 100; public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { if (BuildConfig.DEBUG && !(progress >= 0 && progress <= 100)) { throw new AssertionError(); } lastProgress = progress; } public void onStartTrackingTouch(SeekBar seekBar) { } public void onStopTrackingTouch(SeekBar seekBar) { /* 0 ----- 50 ---- 100 -1000 --- 0 ---- 1000 */ int permille = lastProgress * (1000 - -1000) / 100 + (-1000); setPlaybackRateUriAudioPlayer(permille); } }); ((Button) findViewById(R.id.record)).setOnClickListener(new OnClickListener() { public void onClick(View view) { // int status = ActivityCompat.checkSelfPermission(NativeAudio.this, // Manifest.permission.RECORD_AUDIO); // if (status != PackageManager.PERMISSION_GRANTED) { // ActivityCompat.requestPermissions( // NativeAudio.this, // new String[]{Manifest.permission.RECORD_AUDIO}, // AUDIO_ECHO_REQUEST); // return; // } recordAudio(); } }); ((Button) findViewById(R.id.playback)).setOnClickListener(new OnClickListener() { public void onClick(View view) { // ignore the return value selectClip(CLIP_PLAYBACK, 3); } }); }
From source file:com.imagine.BaseActivity.java
boolean hasLowLatencyAudio() { return getPackageManager().hasSystemFeature(PackageManager.FEATURE_AUDIO_LOW_LATENCY); }