1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.soundtrigger_middleware;
18 
19 import android.annotation.NonNull;
20 
21 /**
22  * Allow registering listeners for tracking changes in audio capture state (when recording starts /
23  * stops). The client will be notified in a synchronized manner.
24  */
25 interface ICaptureStateNotifier {
26     interface Listener {
onCaptureStateChange(boolean state)27         void onCaptureStateChange(boolean state);
28     }
29 
30     /**
31      * Register a listener for state change notifications. Returns the current capture state and
32      * any subsequent changes will be sent to the listener.
33      * @param listener The listener.
34      * @return The state at the time of registration.
35      */
registerListener(@onNull Listener listener)36     boolean registerListener(@NonNull Listener listener);
37 
38     /**
39      * Unregister a listener, previously registered with {@link #registerListener(Listener)}.
40      * Once this call returns, no more invocations of the listener will be made.
41      */
unregisterListener(@onNull Listener listener)42     void unregisterListener(@NonNull Listener listener);
43 }
44