Loading services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +16 −21 Original line number Original line Diff line number Diff line Loading @@ -1276,7 +1276,8 @@ public class SoundTriggerService extends SystemService { * @return The initialized AudioRecord * @return The initialized AudioRecord */ */ private @NonNull AudioRecord createAudioRecordForEvent( private @NonNull AudioRecord createAudioRecordForEvent( @NonNull SoundTrigger.GenericRecognitionEvent event) { @NonNull SoundTrigger.GenericRecognitionEvent event) throws IllegalArgumentException, UnsupportedOperationException { AudioAttributes.Builder attributesBuilder = new AudioAttributes.Builder(); AudioAttributes.Builder attributesBuilder = new AudioAttributes.Builder(); attributesBuilder.setInternalCapturePreset(MediaRecorder.AudioSource.HOTWORD); attributesBuilder.setInternalCapturePreset(MediaRecorder.AudioSource.HOTWORD); AudioAttributes attributes = attributesBuilder.build(); AudioAttributes attributes = attributesBuilder.build(); Loading @@ -1285,7 +1286,6 @@ public class SoundTriggerService extends SystemService { sEventLogger.log(new SoundTriggerLogger.StringEvent("createAudioRecordForEvent")); sEventLogger.log(new SoundTriggerLogger.StringEvent("createAudioRecordForEvent")); try { return (new AudioRecord.Builder()) return (new AudioRecord.Builder()) .setAudioAttributes(attributes) .setAudioAttributes(attributes) .setAudioFormat((new AudioFormat.Builder()) .setAudioFormat((new AudioFormat.Builder()) Loading @@ -1295,11 +1295,6 @@ public class SoundTriggerService extends SystemService { .build()) .build()) .setSessionId(event.getCaptureSession()) .setSessionId(event.getCaptureSession()) .build(); .build(); } catch (IllegalArgumentException | UnsupportedOperationException e) { Slog.w(TAG, mPuuid + ": createAudioRecordForEvent(" + event + "), failed to create AudioRecord"); return null; } } } @Override @Override Loading @@ -1325,13 +1320,13 @@ public class SoundTriggerService extends SystemService { // execute if throttled: // execute if throttled: () -> { () -> { if (event.isCaptureAvailable()) { if (event.isCaptureAvailable()) { try { AudioRecord capturedData = createAudioRecordForEvent(event); AudioRecord capturedData = createAudioRecordForEvent(event); // Currently we need to start and release the audio record to reset // the DSP even if we don't want to process the event if (capturedData != null) { capturedData.startRecording(); capturedData.startRecording(); capturedData.release(); capturedData.release(); } catch (IllegalArgumentException | UnsupportedOperationException e) { Slog.w(TAG, mPuuid + ": createAudioRecordForEvent(" + event + "), failed to create AudioRecord"); } } } } })); })); Loading Loading
services/voiceinteraction/java/com/android/server/soundtrigger/SoundTriggerService.java +16 −21 Original line number Original line Diff line number Diff line Loading @@ -1276,7 +1276,8 @@ public class SoundTriggerService extends SystemService { * @return The initialized AudioRecord * @return The initialized AudioRecord */ */ private @NonNull AudioRecord createAudioRecordForEvent( private @NonNull AudioRecord createAudioRecordForEvent( @NonNull SoundTrigger.GenericRecognitionEvent event) { @NonNull SoundTrigger.GenericRecognitionEvent event) throws IllegalArgumentException, UnsupportedOperationException { AudioAttributes.Builder attributesBuilder = new AudioAttributes.Builder(); AudioAttributes.Builder attributesBuilder = new AudioAttributes.Builder(); attributesBuilder.setInternalCapturePreset(MediaRecorder.AudioSource.HOTWORD); attributesBuilder.setInternalCapturePreset(MediaRecorder.AudioSource.HOTWORD); AudioAttributes attributes = attributesBuilder.build(); AudioAttributes attributes = attributesBuilder.build(); Loading @@ -1285,7 +1286,6 @@ public class SoundTriggerService extends SystemService { sEventLogger.log(new SoundTriggerLogger.StringEvent("createAudioRecordForEvent")); sEventLogger.log(new SoundTriggerLogger.StringEvent("createAudioRecordForEvent")); try { return (new AudioRecord.Builder()) return (new AudioRecord.Builder()) .setAudioAttributes(attributes) .setAudioAttributes(attributes) .setAudioFormat((new AudioFormat.Builder()) .setAudioFormat((new AudioFormat.Builder()) Loading @@ -1295,11 +1295,6 @@ public class SoundTriggerService extends SystemService { .build()) .build()) .setSessionId(event.getCaptureSession()) .setSessionId(event.getCaptureSession()) .build(); .build(); } catch (IllegalArgumentException | UnsupportedOperationException e) { Slog.w(TAG, mPuuid + ": createAudioRecordForEvent(" + event + "), failed to create AudioRecord"); return null; } } } @Override @Override Loading @@ -1325,13 +1320,13 @@ public class SoundTriggerService extends SystemService { // execute if throttled: // execute if throttled: () -> { () -> { if (event.isCaptureAvailable()) { if (event.isCaptureAvailable()) { try { AudioRecord capturedData = createAudioRecordForEvent(event); AudioRecord capturedData = createAudioRecordForEvent(event); // Currently we need to start and release the audio record to reset // the DSP even if we don't want to process the event if (capturedData != null) { capturedData.startRecording(); capturedData.startRecording(); capturedData.release(); capturedData.release(); } catch (IllegalArgumentException | UnsupportedOperationException e) { Slog.w(TAG, mPuuid + ": createAudioRecordForEvent(" + event + "), failed to create AudioRecord"); } } } } })); })); Loading