mphtogen.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. // Generate the MPH_to_*.h tables for C compilers that don't support designated initializers
  17. #include <assert.h>
  18. #include <stdio.h>
  19. #include <stdlib.h>
  20. #include "MPH.h"
  21. #include "MPH_to.h"
  22. static void convert(const signed char MPH_to[MPH_MAX], const char *filename)
  23. {
  24. FILE *fp = fopen(filename, "w");
  25. assert(NULL != fp);
  26. fputs("// This file is automagically generated by mphtogen, do not edit\n", fp);
  27. unsigned i;
  28. unsigned len = 0;
  29. for (i = 0; i < MPH_MAX; ++i) {
  30. if (len > 0) {
  31. fputc(',', fp);
  32. ++len;
  33. }
  34. if (len > 78) {
  35. fputc('\n', fp);
  36. len = 0;
  37. }
  38. fprintf(fp, "%3d", MPH_to[i]);
  39. len += 3;
  40. }
  41. if (len > 0) {
  42. fputc('\n', fp);
  43. }
  44. fclose(fp);
  45. }
  46. #define _(x) convert(MPH_to_##x, "../../src/autogen/MPH_to_" #x ".h");
  47. int main(int argc, char **argv)
  48. {
  49. _(3DGroup)
  50. _(AudioPlayer)
  51. _(AudioRecorder)
  52. _(Engine)
  53. _(LEDDevice)
  54. _(Listener)
  55. _(MetadataExtractor)
  56. _(MidiPlayer)
  57. _(OutputMix)
  58. _(Vibra)
  59. _(MediaPlayer)
  60. return EXIT_SUCCESS;
  61. }