~didrocks/+junk/sensorydemo

« back to all changes in this revision

Viewing changes to shared/checkflagstext.c

  • Committer: Didier Roche
  • Date: 2016-04-21 08:17:28 UTC
  • Revision ID: didier.roche@canonical.com-20160421081728-qwph04mwkbbwnfg1
Add files for sensory test

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Sensory Confidential
 
3
 *
 
4
 * Copyright (C)2013-2015 Sensory Inc.
 
5
 *
 
6
 * Returns a text string with a short description of all the flags set by
 
7
 * thfCheckRecording(), thfSpeakerCheckEnrollments()
 
8
 *  and thfUdtCheckEnrollments().
 
9
 */
 
10
 
 
11
#include <trulyhandsfree.h>
 
12
 
 
13
#include <string.h>
 
14
 
 
15
char *checkFlagsText(int flags)
 
16
{
 
17
  struct {
 
18
    int bitfield;
 
19
    char *text;
 
20
  } problems[] = {
 
21
    {CHECKRECORDING_BITFIELD_ENERGY_MIN, "energy_min"},
 
22
    {CHECKRECORDING_BITFIELD_ENERGY_STD_DEV, "energy_std_dev"},
 
23
    {CHECKRECORDING_BITFIELD_SIL_BEG_MSEC, "sil_beg_msec"},
 
24
    {CHECKRECORDING_BITFIELD_SIL_END_MSEC, "sil_end_msec"},
 
25
    {CHECKRECORDING_BITFIELD_SNR, "snr"},
 
26
    {CHECKRECORDING_BITFIELD_RECORDING_VARIANCE, "recording_variance"},
 
27
    {CHECKRECORDING_BITFIELD_CLIPPING_PERCENT, "clipping_percent"},
 
28
    {CHECKRECORDING_BITFIELD_CLIPPING_MSEC, "clipping_msec"},
 
29
    {CHECKRECORDING_BITFIELD_POOR_RECORDINGS, "poor_recordings"},
 
30
    {CHECKRECORDING_BITFIELD_SPOT, "spot"},
 
31
    {CHECKRECORDING_BITFIELD_VOWEL_DUR, "vowel_dur"},
 
32
    {0, NULL}
 
33
  };
 
34
  static char r[1024];
 
35
  int i, n=0;
 
36
 
 
37
  r[0]='\0';
 
38
  for (i=0; flags && problems[i].bitfield; i++) {
 
39
    if (!(flags & problems[i].bitfield)) continue;
 
40
    flags &= ~problems[i].bitfield;
 
41
    if (n > 0) {
 
42
      if (flags) strcat(r, ", ");
 
43
      else strcat(r, " and ");
 
44
    }
 
45
    n++;
 
46
    strcat(r,problems[i].text);
 
47
  }
 
48
  return r;
 
49
}