Home | History | Annotate | Download | only in server
      1 /* Copyright 2016 The Chromium OS Authors. All rights reserved.
      2  * Use of this source code is governed by a BSD-style license that can be
      3  * found in the LICENSE file.
      4  */
      5 
      6 #ifndef CRAS_OBSERVER_H
      7 #define CRAS_OBSERVER_H
      8 
      9 #include "cras_observer_ops.h"
     10 
     11 struct cras_observer_client;
     12 
     13 /* Add an observer.
     14  * Args:
     15  *    ops - Set callback function pointers in the operations that should be
     16  *          called for state changes, or NULL otherwise.
     17  *    context - Context pointer passed to the callbacks.
     18  * Returns:
     19  *    Valid pointer to the client reference, or NULL on memory allocation
     20  *    error.
     21  */
     22 struct cras_observer_client *cras_observer_add(
     23 			const struct cras_observer_ops *ops,
     24 			void *context);
     25 
     26 /* Retrieve the observed state changes.
     27  * Args:
     28  *    client - The client to query.
     29  *    ops - Filled with the current values in the callback table.
     30  */
     31 void cras_observer_get_ops(const struct cras_observer_client *client,
     32 			   struct cras_observer_ops *ops);
     33 
     34 /* Update the observed state changes.
     35  * Args:
     36  *    client - The client to modify.
     37  *    ops - Set callback function pointers in the operations that should be
     38  *          called for state changes, or NULL otherwise.
     39  */
     40 void cras_observer_set_ops(struct cras_observer_client *client,
     41 			   const struct cras_observer_ops *ops);
     42 
     43 /* Returns non-zero if the given ops are empty. */
     44 int cras_observer_ops_are_empty(const struct cras_observer_ops *ops);
     45 
     46 /* Remove this observer client.
     47  * Args:
     48  *    client - The client to remove.
     49  */
     50 void cras_observer_remove(struct cras_observer_client *client);
     51 
     52 /* Initialize the observer server. */
     53 int cras_observer_server_init();
     54 
     55 /* Destroy the observer server. */
     56 void cras_observer_server_free();
     57 
     58 /* Notify observers of output volume change. */
     59 void cras_observer_notify_output_volume(int32_t volume);
     60 
     61 /* Notify observers of output mute change. */
     62 void cras_observer_notify_output_mute(int muted, int user_muted,
     63 				      int mute_locked);
     64 
     65 /* Notify observers of capture gain change. */
     66 void cras_observer_notify_capture_gain(int32_t gain);
     67 
     68 /* Notify observers of capture mute change. */
     69 void cras_observer_notify_capture_mute(int muted, int mute_locked);
     70 
     71 /* Notify observers of a nodes list change. */
     72 void cras_observer_notify_nodes(void);
     73 
     74 /* Notify observers of active output node change. */
     75 void cras_observer_notify_active_node(enum CRAS_STREAM_DIRECTION dir,
     76 				      cras_node_id_t node_id);
     77 
     78 /* Notify observers of output node volume change. */
     79 void cras_observer_notify_output_node_volume(cras_node_id_t node_id,
     80 					     int32_t volume);
     81 
     82 /* Notify observers of node left-right swap change. */
     83 void cras_observer_notify_node_left_right_swapped(cras_node_id_t node_id,
     84 						  int swapped);
     85 
     86 /* Notify observers of input node gain change. */
     87 void cras_observer_notify_input_node_gain(cras_node_id_t node_id,
     88 					  int32_t gain);
     89 
     90 /* Notify observers of suspend state changed. */
     91 void cras_observer_notify_suspend_changed(int suspended);
     92 
     93 /* Notify observers of the number of active streams. */
     94 void cras_observer_notify_num_active_streams(enum CRAS_STREAM_DIRECTION dir,
     95 					     uint32_t num_active_streams);
     96 
     97 #endif /* CRAS_OBSERVER_H */
     98