timidity/timidity.c
changeset 245 63b3650714de
parent 24 a25bb2d59ce8
child 263 5cd1ec721824
     1.1 --- a/timidity/timidity.c	Fri Aug 20 19:32:09 2004 +0000
     1.2 +++ b/timidity/timidity.c	Sat Aug 21 12:27:02 2004 +0000
     1.3 @@ -39,8 +39,9 @@
     1.4  static char def_instr_name[256]="";
     1.5  
     1.6  int AUDIO_BUFFER_SIZE;
     1.7 -sample_t *resample_buffer;
     1.8 +resample_t *resample_buffer;
     1.9  int32 *common_buffer;
    1.10 +int num_ochannels;
    1.11  
    1.12  #define MAXWORDS 10
    1.13  
    1.14 @@ -63,24 +64,28 @@
    1.15     return -1;
    1.16  
    1.17    while (fgets(tmp, sizeof(tmp), fp))
    1.18 -   {
    1.19 -      line++;
    1.20 +  {
    1.21 +    line++;
    1.22      w[words=0]=strtok(tmp, " \t\r\n\240");
    1.23      if (!w[0] || (*w[0]=='#')) continue;
    1.24 -      while (w[words] && (words < MAXWORDS))
    1.25 -  w[++words]=strtok(0," \t\r\n\240");
    1.26 -      if (!strcmp(w[0], "dir"))
    1.27 -  {
    1.28 -    if (words < 2)
    1.29 -     {
    1.30 +    while (w[words] && (words < MAXWORDS))
    1.31 +      {
    1.32 +        w[++words]=strtok(0," \t\r\n\240");
    1.33 +        if (w[words] && w[words][0]=='#') break;
    1.34 +      }
    1.35 +    if (!strcmp(w[0], "map")) continue;
    1.36 +    if (!strcmp(w[0], "dir"))
    1.37 +    {
    1.38 +      if (words < 2)
    1.39 +       {
    1.40          ctl->cmsg(CMSG_ERROR, VERB_NORMAL,
    1.41            "%s: line %d: No directory given\n", name, line);
    1.42          return -2;
    1.43 -     }
    1.44 -    for (i=1; i<words; i++)
    1.45 -      add_to_pathlist(w[i]);
    1.46 -  }
    1.47 -    else if (!strcmp(w[0], "source"))
    1.48 +       }
    1.49 +      for (i=1; i<words; i++)
    1.50 +        add_to_pathlist(w[i]);
    1.51 +    }
    1.52 +  else if (!strcmp(w[0], "source"))
    1.53    {
    1.54      if (words < 2)
    1.55        {
    1.56 @@ -293,6 +298,10 @@
    1.57      return(-1);
    1.58    }
    1.59  
    1.60 +  if (channels < 1 || channels == 3 || channels == 5 || channels > 6) return(-1);
    1.61 +
    1.62 +  num_ochannels = channels;
    1.63 +
    1.64    /* Set play mode parameters */
    1.65    play_mode->rate = rate;
    1.66    play_mode->encoding = 0;
    1.67 @@ -331,8 +340,8 @@
    1.68    AUDIO_BUFFER_SIZE = samples;
    1.69  
    1.70    /* Allocate memory for mixing (WARNING:  Memory leak!) */
    1.71 -  resample_buffer = safe_malloc(AUDIO_BUFFER_SIZE*sizeof(sample_t));
    1.72 -  common_buffer = safe_malloc(AUDIO_BUFFER_SIZE*2*sizeof(int32));
    1.73 +  resample_buffer = safe_malloc(AUDIO_BUFFER_SIZE*sizeof(resample_t)+100);
    1.74 +  common_buffer = safe_malloc(AUDIO_BUFFER_SIZE*num_ochannels*sizeof(int32));
    1.75  
    1.76    init_tables();
    1.77