home *** CD-ROM | disk | FTP | other *** search
/ rtsi.com / 2014.01.www.rtsi.com.tar / www.rtsi.com / OS9 / MM1 / SOUNDUTILS / mm1_tracker.lzh / TRACKER4.6 / setup_audio.c < prev    next >
Text File  |  1994-11-24  |  2KB  |  100 lines

  1. /* setup_audio.c 
  2.     vi:ts=3 sw=3:
  3.  */
  4. /* higher level interface to the raw metal */
  5.  
  6. /* $Id: setup_audio.c,v 4.3 1994/11/15 16:11:01 espie Exp espie $
  7.  * $Log: setup_audio.c,v $
  8.  * Revision 4.3  1994/11/15  16:11:01  espie
  9.  * *** empty log message ***
  10.  *
  11.  *
  12.  * Revision 4.0  1994/01/11  17:55:28  espie
  13.  * Use autoinit.
  14.  * Suppressed multiple at_end.
  15.  * Use new pref scheme.
  16.  * Modified in a more consistent way.
  17.  * Added check before closing for the sgi.
  18.  * Added finetune.
  19.  */
  20.  
  21.  
  22. #include <stdio.h>
  23. #include <stdlib.h>
  24. #include <string.h>
  25.  
  26. #include "defs.h"
  27. #include "extern.h"
  28. #include "tags.h"
  29. #include "prefs.h"
  30.  
  31. ID("$Id: setup_audio.c,v 4.3 1994/11/15 16:11:01 espie Exp espie $")
  32.  
  33. LOCAL void init_audio P((void));
  34.  
  35. LOCAL void (*INIT)P((void)) = init_audio;
  36.  
  37. LOCAL int opened = FALSE;
  38. LOCAL int ask_freq, real_freq, oversample;
  39. LOCAL int stereo;
  40.  
  41.  
  42. LOCAL void init_audio()
  43.    {
  44.    at_end(do_close_audio);
  45.    }
  46.  
  47. /* setup_audio(frequency, stereo, oversample):
  48.  * try to avoid calling open_audio and other things
  49.  * all the time
  50.  */
  51. void setup_audio(f, s, o)
  52. int f;
  53. int s;
  54. int o;
  55.    {
  56.    INIT_ONCE;
  57.  
  58.    if (!opened)
  59.       {
  60.       ask_freq = f;
  61.       stereo = s;
  62.       oversample = o;
  63.       real_freq = open_audio(f, s);
  64.       init_player(o, real_freq);
  65.       opened = TRUE;
  66.       }
  67.    else
  68.       {
  69.       int new_freq;
  70.  
  71.       if (s != stereo || f != ask_freq)
  72.          {
  73.          ask_freq = f;
  74.          stereo = s;
  75.          close_audio();
  76.          new_freq = open_audio(f, s);
  77.          }
  78.       else
  79.          new_freq = real_freq;
  80.  
  81.       if (new_freq != real_freq || oversample != o)
  82.          {
  83.          real_freq = new_freq;
  84.          oversample = o;
  85.          init_player(o, real_freq);
  86.          }
  87.       }
  88.    set_synchro(get_pref_scalar(PREF_SYNC));
  89.    }
  90.  
  91. void do_close_audio()
  92.    {
  93.    if (opened)
  94.       {
  95.       close_audio();
  96.       }
  97.    opened = FALSE;
  98.    }
  99.  
  100.