~audio-recorder/audio-recorder/trunk

« back to all changes in this revision

Viewing changes to src/timer-parser.c

  • Committer: Osmo Antero
  • Date: 2015-02-06 14:13:34 UTC
  • Revision ID: osmoma@gmail.com-20150206141334-ifaeqyan4ygxo49g
Updated README and INSTALL files.

Show diffs side-by-side

added added

removed removed

Lines of Context:
8
8
 *
9
9
 * This library is distributed in the hope that it will be useful,
10
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 
 
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12
12
 * See the GNU Library General Public License 3 for more details.
13
13
 *
14
14
 * You should have received a copy of the GNU Library General Public
673
673
            state = 3;
674
674
        } else if (match_word(g_curtoken.tok, "s", NULL) || starts_with(g_curtoken.tok, "se")) { // s, sec, second, seconds
675
675
 
676
 
            if (str_length0(tr->threshold_unit) < 1) /* == '\0'*/ {
 
676
            if (str_length0(tr->threshold_unit) < 1) { /* == '\0'*/
677
677
                // Save threshold value (eg. 0.4)
678
678
                // "stop if silence 0.4 5s" => "stop if silence 5s 0.4"
679
679
                tr->threshold = tr->val[2];
680
 
            }     
 
680
            }
681
681
 
682
682
            // 'd' = time duration
683
683
            tr->data_type = 'd';
750
750
                if (tok_type == TOK_NUMERIC) {
751
751
                    tr->threshold = val;
752
752
                    if (tr->threshold > 1.0) {
753
 
                      // Value between [1%, 100%], assume it's a %-value
754
 
                      g_utf8_strncpy(tr->threshold_unit, "%", -1);
 
753
                        // Value between [1%, 100%], assume it's a %-value
 
754
                        g_utf8_strncpy(tr->threshold_unit, "%", -1);
755
755
                    } else {
756
 
                      // Value between [0, 1.0] is a plain number
757
 
                      *(tr->threshold_unit) = '\0';
 
756
                        // Value between [0, 1.0] is a plain number
 
757
                        *(tr->threshold_unit) = '\0';
758
758
                    }
759
 
                    
 
759
 
760
760
                }
761
761
                state = 0;
762
762
 
786
786
    } // while...
787
787
 
788
788
    if (!g_strcmp0(tr->label, "silence") ||
789
 
        !g_strcmp0(tr->label, "voice") ||
790
 
        !g_strcmp0(tr->label, "sound") ||
791
 
        !g_strcmp0(tr->label, "audio")) {
792
 
    
793
 
        tr->data_type = 'x'; 
794
 
    }      
 
789
            !g_strcmp0(tr->label, "voice") ||
 
790
            !g_strcmp0(tr->label, "sound") ||
 
791
            !g_strcmp0(tr->label, "audio")) {
 
792
 
 
793
        tr->data_type = 'x';
 
794
    }
795
795
 
796
796
    // We got time value?
797
797
    if (tr->data_type == 't' || tr->data_type == 'd') {
952
952
 
953
953
static void parser_fix_list() {
954
954
    // Fix OR'ed commands.
955
 
    // Eg. "stop if 100 MB | 1 h 20 min | silence" becomes three separate nodes. 
 
955
    // Eg. "stop if 100 MB | 1 h 20 min | silence" becomes three separate nodes.
956
956
    // It becomes:
957
957
    //     "stop if 100 MB"
958
958
    //     "stop if 1 h 20 min"
1033
1033
            !g_strcmp0(tr->label, "sound") ||
1034
1034
            !g_strcmp0(tr->label, "audio")) {
1035
1035
 
1036
 
        LOG_MSG("\tlabel: %s, delay:%3.1f %3.1f %3.1f threshold:%3.3f %s\n", tr->label, tr->val[0], tr->val[1], tr->val[2], 
 
1036
        LOG_MSG("\tlabel: %s, delay:%3.1f %3.1f %3.1f threshold:%3.3f %s\n", tr->label, tr->val[0], tr->val[1], tr->val[2],
1037
1037
                tr->threshold, tr->threshold_unit);
1038
1038
    }
1039
1039