src/audio/disk/SDL_diskaudio.c
changeset 10247 886ab9de5f43
parent 10246 db0b712b79dd
child 10263 2a002e96888f
equal deleted inserted replaced
10246:db0b712b79dd 10247:886ab9de5f43
    39 #define DISKENVR_OUTFILE         "SDL_DISKAUDIOFILE"
    39 #define DISKENVR_OUTFILE         "SDL_DISKAUDIOFILE"
    40 #define DISKDEFAULT_OUTFILE      "sdlaudio.raw"
    40 #define DISKDEFAULT_OUTFILE      "sdlaudio.raw"
    41 #define DISKENVR_INFILE         "SDL_DISKAUDIOFILEIN"
    41 #define DISKENVR_INFILE         "SDL_DISKAUDIOFILEIN"
    42 #define DISKDEFAULT_INFILE      "sdlaudio-in.raw"
    42 #define DISKDEFAULT_INFILE      "sdlaudio-in.raw"
    43 #define DISKENVR_IODELAY      "SDL_DISKAUDIODELAY"
    43 #define DISKENVR_IODELAY      "SDL_DISKAUDIODELAY"
    44 #define DISKDEFAULT_IODELAY   150
       
    45 
    44 
    46 /* This function waits until it is possible to write a full sound buffer */
    45 /* This function waits until it is possible to write a full sound buffer */
    47 static void
    46 static void
    48 DISKAUD_WaitDevice(_THIS)
    47 DISKAUD_WaitDevice(_THIS)
    49 {
    48 {
   138     if (this->hidden == NULL) {
   137     if (this->hidden == NULL) {
   139         return SDL_OutOfMemory();
   138         return SDL_OutOfMemory();
   140     }
   139     }
   141     SDL_zerop(this->hidden);
   140     SDL_zerop(this->hidden);
   142 
   141 
   143     this->hidden->io_delay = (envr) ? SDL_atoi(envr) : DISKDEFAULT_IODELAY;
   142     if (envr != NULL) {
       
   143         this->hidden->io_delay = SDL_atoi(envr);
       
   144     } else {
       
   145         this->hidden->io_delay = ((this->spec.samples * 1000) / this->spec.freq);
       
   146     }
   144 
   147 
   145     /* Open the audio device */
   148     /* Open the audio device */
   146     this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb");
   149     this->hidden->io = SDL_RWFromFile(fname, iscapture ? "rb" : "wb");
   147     if (this->hidden->io == NULL) {
   150     if (this->hidden->io == NULL) {
   148         return -1;
   151         return -1;