mphtogen.c revision 8b8875067dd02b79361abb00c5d65b02a8ae72b0
1/*
2 * Copyright (C) 2010 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17// Generate the MPH_to_*.h tables for C compilers that don't support designated initializers
18
19#include <assert.h>
20#include <stdio.h>
21#include <stdlib.h>
22#include "MPH.h"
23#include "MPH_to.h"
24
25static void convert(const signed char MPH_to[MPH_MAX], const char *filename)
26{
27    FILE *fp = fopen(filename, "w");
28    assert(NULL != fp);
29    fputs("// This file is automagically generated by mphtogen, do not edit\n", fp);
30    unsigned i;
31    unsigned len = 0;
32    for (i = 0; i < MPH_MAX; ++i) {
33        if (len > 0) {
34            fputc(',', fp);
35            ++len;
36        }
37        if (len > 78) {
38            fputc('\n', fp);
39            len = 0;
40        }
41        fprintf(fp, "%3d", MPH_to[i]);
42        len += 3;
43    }
44    if (len > 0) {
45        fputc('\n', fp);
46    }
47    fclose(fp);
48}
49
50#define _(x) convert(MPH_to_##x, "../../libopensles/MPH_to_" #x ".h");
51
52int main(int argc, char **argv)
53{
54    _(3DGroup)
55    _(AudioPlayer)
56    _(AudioRecorder)
57    _(Engine)
58    _(LEDDevice)
59    _(Listener)
60    _(MetadataExtractor)
61    _(MidiPlayer)
62    _(OutputMix)
63    _(Vibra)
64    _(MediaPlayer)
65    return EXIT_SUCCESS;
66}
67