|
PebbleOS
|
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <pbl/drivers/mic.h>#include <kernel/pebble_tasks.h>Typedefs | |
| typedef void(* | MicManagerPreemptedCb) (void *context) |
| Called (without the manager lock held) when the client's mic is taken away. | |
Enumerations | |
| enum | MicClient { MicClientNone = 0 , MicClientVoiceDictation , MicClientAppStream , MicClientAppCapture } |
| Arbitrates the single microphone between kernel clients. More... | |
| enum | MicManagerAppCheck { MicManagerAppOk = 0 , MicManagerAppNotForeground , MicManagerAppWatchface } |
Functions | |
| MicManagerAppCheck | mic_manager_check_app (PebbleTask task) |
Whether task is a foreground app in focus, the only kind that may use the mic. | |
| void | mic_manager_init (void) |
| bool | mic_manager_acquire (MicClient client, MicDataHandlerCB handler, void *context, int16_t *buffer, size_t buffer_len, MicManagerPreemptedCb on_preempted, void *preempt_context) |
| Starts the microphone for a client. | |
| bool | mic_manager_reserve (MicClient client) |
| Holds the idle mic for an app client whose start is pending, so other apps see it as busy. | |
| void | mic_manager_release (MicClient client) |
| Stops the microphone if the client owns it and drops its reservation. No-op otherwise. | |
| void | mic_manager_set_dictation_active (bool active) |
| Set for a whole dictation session, from before it takes the audio endpoint until it ends. | |
| MicClient | mic_manager_get_owner (void) |
| bool | mic_manager_is_busy (void) |
| typedef void(* MicManagerPreemptedCb) (void *context) |
Called (without the manager lock held) when the client's mic is taken away.
The client must not call mic_manager_release() for the lost session; it is already released.
| enum MicClient |
Arbitrates the single microphone between kernel clients.
Dictation (the system voice UI) has priority over app capture: acquiring for dictation while an app owns the mic preempts the app, which is told through its preempted callback before the mic is restarted. An app cannot acquire the mic while dictation owns it. The OS mic banner is shown while an app client owns the running mic.
| Enumerator | |
|---|---|
| MicClientNone | |
| MicClientVoiceDictation | |
| MicClientAppStream | |
| MicClientAppCapture | |
| enum MicManagerAppCheck |
| bool mic_manager_acquire | ( | MicClient | client, |
| MicDataHandlerCB | handler, | ||
| void * | context, | ||
| int16_t * | buffer, | ||
| size_t | buffer_len, | ||
| MicManagerPreemptedCb | on_preempted, | ||
| void * | preempt_context | ||
| ) |
Starts the microphone for a client.
See mic_start for the buffer semantics.
| MicManagerAppCheck mic_manager_check_app | ( | PebbleTask | task | ) |
Whether task is a foreground app in focus, the only kind that may use the mic.
| MicClient mic_manager_get_owner | ( | void | ) |
| void mic_manager_init | ( | void | ) |
| bool mic_manager_is_busy | ( | void | ) |
| void mic_manager_release | ( | MicClient | client | ) |
Stops the microphone if the client owns it and drops its reservation. No-op otherwise.
| bool mic_manager_reserve | ( | MicClient | client | ) |
Holds the idle mic for an app client whose start is pending, so other apps see it as busy.
Only that client or dictation may then acquire it. Cleared by acquire or release.
| void mic_manager_set_dictation_active | ( | bool | active | ) |
Set for a whole dictation session, from before it takes the audio endpoint until it ends.
Apps can neither reserve nor acquire the mic meanwhile.