1 /* Copyright (c) 2013 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_SERVER_METRICS_H_ 7 #define CRAS_SERVER_METRICS_H_ 8 9 #include <stdbool.h> 10 11 #include "cras_iodev.h" 12 #include "cras_rstream.h" 13 14 extern const char kNoCodecsFoundMetric[]; 15 16 enum CRAS_METRICS_BT_SCO_ERROR_TYPE { 17 CRAS_METRICS_SCO_SKT_SUCCESS = 0, 18 CRAS_METRICS_SCO_SKT_CONNECT_ERROR = 1, 19 CRAS_METRICS_SCO_SKT_OPEN_ERROR = 2, 20 CRAS_METRICS_SCO_SKT_POLL_TIMEOUT = 3, 21 CRAS_METRICS_SCO_SKT_POLL_ERR_HUP = 4, 22 }; 23 24 /* Logs the error type happens when setting up SCO connection. This is mainly 25 * used to track whether the setup of SCO connection succeeds and the frequency 26 * of different errors. This will also be used to track if our fixes for these 27 * errors address the issues we find. 28 */ 29 int cras_server_metrics_hfp_sco_connection_error( 30 enum CRAS_METRICS_BT_SCO_ERROR_TYPE type); 31 32 /* Logs an enum representing which spec does HFP headset supports battery 33 * indicator. Apple, HFP, none or both. */ 34 int cras_server_metrics_hfp_battery_indicator(int battery_indicator_support); 35 36 /* Logs an enum representing the spec through which the battery level change 37 * event reported. Apple or HFP.*/ 38 int cras_server_metrics_hfp_battery_report(int battery_report); 39 40 /* Logs if connected HFP headset supports wideband speech. */ 41 int cras_server_metrics_hfp_wideband_support(bool supported); 42 43 /* Logs the selected codec in HFP wideband connection. */ 44 int cras_server_metrics_hfp_wideband_selected_codec(int codec); 45 46 /* Logs the number of packet loss per 1000 packets under HFP capture. */ 47 int cras_server_metrics_hfp_packet_loss(float packet_loss_ratio); 48 49 /* Logs runtime of a device. */ 50 int cras_server_metrics_device_runtime(struct cras_iodev *iodev); 51 52 /* Logs the gain of a device. */ 53 int cras_server_metrics_device_gain(struct cras_iodev *iodev); 54 55 /* Logs the volume of a device. */ 56 int cras_server_metrics_device_volume(struct cras_iodev *iodev); 57 58 /* Logs the highest delay time of a device. */ 59 int cras_server_metrics_highest_device_delay( 60 unsigned int hw_level, unsigned int largest_cb_level, 61 enum CRAS_STREAM_DIRECTION direction); 62 63 /* Logs the highest hardware level of a device. */ 64 int cras_server_metrics_highest_hw_level(unsigned hw_level, 65 enum CRAS_STREAM_DIRECTION direction); 66 67 /* Logs the number of underruns of a device. */ 68 int cras_server_metrics_num_underruns(unsigned num_underruns); 69 70 /* Logs the missed callback event. */ 71 int cras_server_metrics_missed_cb_event(struct cras_rstream *stream); 72 73 /* Logs information when a stream creates. */ 74 int cras_server_metrics_stream_create(const struct cras_rstream_config *config); 75 76 /* Logs information when a stream destroys. */ 77 int cras_server_metrics_stream_destroy(const struct cras_rstream *stream); 78 79 /* Logs the number of busyloops for different time periods. */ 80 int cras_server_metrics_busyloop(struct timespec *ts, unsigned count); 81 82 /* Logs the length of busyloops. */ 83 int cras_server_metrics_busyloop_length(unsigned length); 84 85 /* Initialize metrics logging stuff. */ 86 int cras_server_metrics_init(); 87 88 #endif /* CRAS_SERVER_METRICS_H_ */ 89