src/audio/dummy/SDL_dummyaudio.c
branchSDL-ryan-multiple-audio-device
changeset 3798 c8b3d3d13ed1
parent 3796 b19680c84cdf
child 3809 7852b5b78af5
     1.1 --- a/src/audio/dummy/SDL_dummyaudio.c	Wed Oct 04 20:42:39 2006 +0000
     1.2 +++ b/src/audio/dummy/SDL_dummyaudio.c	Wed Oct 04 21:27:53 2006 +0000
     1.3 @@ -47,13 +47,7 @@
     1.4  static int
     1.5  DUMMYAUD_Available(void)
     1.6  {
     1.7 -    /* !!! FIXME: check this at a higher level... */
     1.8 -    /* only ever use this driver if explicitly requested. */
     1.9 -    const char *envr = SDL_getenv("SDL_AUDIODRIVER");
    1.10 -    if (envr && (SDL_strcmp(envr, DUMMYAUD_DRIVER_NAME) == 0)) {
    1.11 -        return (1);
    1.12 -    }
    1.13 -    return (0);
    1.14 +    return 1;  /* always available. */
    1.15  }
    1.16  
    1.17  static int
    1.18 @@ -61,10 +55,6 @@
    1.19  {
    1.20      /* Set the function pointers */
    1.21      impl->OpenDevice = DUMMYAUD_OpenDevice;
    1.22 -    impl->WaitDevice = DUMMYAUD_WaitDevice;
    1.23 -    impl->PlayDevice = DUMMYAUD_PlayDevice;
    1.24 -    impl->GetDeviceBuf = DUMMYAUD_GetDeviceBuf;
    1.25 -    impl->CloseDevice = DUMMYAUD_CloseDevice;
    1.26      impl->OnlyHasDefaultOutputDevice = 1;
    1.27  
    1.28      return 1;
    1.29 @@ -72,82 +62,13 @@
    1.30  
    1.31  AudioBootStrap DUMMYAUD_bootstrap = {
    1.32      DUMMYAUD_DRIVER_NAME, "SDL dummy audio driver",
    1.33 -    DUMMYAUD_Available, DUMMYAUD_Init
    1.34 +    DUMMYAUD_Available, DUMMYAUD_Init, 1
    1.35  };
    1.36  
    1.37 -/* This function waits until it is possible to write a full sound buffer */
    1.38 -static void
    1.39 -DUMMYAUD_WaitDevice(_THIS)
    1.40 -{
    1.41 -    /* Don't block on first calls to simulate initial fragment filling. */
    1.42 -    if (this->hidden->initial_calls)
    1.43 -        this->hidden->initial_calls--;
    1.44 -    else
    1.45 -        SDL_Delay(this->hidden->write_delay);
    1.46 -}
    1.47 -
    1.48 -static void
    1.49 -DUMMYAUD_PlayDevice(_THIS)
    1.50 -{
    1.51 -    /* no-op...this is a null driver. */
    1.52 -}
    1.53 -
    1.54 -static Uint8 *
    1.55 -DUMMYAUD_GetDeviceBuf(_THIS)
    1.56 -{
    1.57 -    return (this->hidden->mixbuf);
    1.58 -}
    1.59 -
    1.60 -static void
    1.61 -DUMMYAUD_CloseDevice(_THIS)
    1.62 -{
    1.63 -    if (this->hidden->mixbuf != NULL) {
    1.64 -        SDL_FreeAudioMem(this->hidden->mixbuf);
    1.65 -        this->hidden->mixbuf = NULL;
    1.66 -    }
    1.67 -    SDL_free(this->hidden);
    1.68 -    this->hidden = NULL;
    1.69 -}
    1.70 -
    1.71  static int
    1.72  DUMMYAUD_OpenDevice(_THIS, const char *devname, int iscapture)
    1.73  {
    1.74 -    float bytes_per_sec = 0.0f;
    1.75 -
    1.76 -    /* Initialize all variables that we clean on shutdown */
    1.77 -    this->hidden = (struct SDL_PrivateAudioData *)
    1.78 -                    SDL_malloc((sizeof *this->hidden));
    1.79 -    if (this->hidden == NULL) {
    1.80 -        SDL_OutOfMemory();
    1.81 -        return 0;
    1.82 -    }
    1.83 -    SDL_memset(this->hidden, 0, (sizeof *this->hidden));
    1.84 -
    1.85 -    /* Allocate mixing buffer */
    1.86 -    this->hidden->mixlen = this->spec.size;
    1.87 -    this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->hidden->mixlen);
    1.88 -    if (this->hidden->mixbuf == NULL) {
    1.89 -        DUMMYAUD_CloseDevice(this);
    1.90 -        return 0;
    1.91 -    }
    1.92 -    SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size);
    1.93 -
    1.94 -    bytes_per_sec = (float) (SDL_AUDIO_BITSIZE(this->spec.format) / 8) *
    1.95 -                             this->spec.channels * this->spec.freq;
    1.96 -
    1.97 -    /*
    1.98 -     * We try to make this request more audio at the correct rate for
    1.99 -     *  a given audio spec, so timing stays fairly faithful.
   1.100 -     * Also, we have it not block at all for the first two calls, so
   1.101 -     *  it seems like we're filling two audio fragments right out of the
   1.102 -     *  gate, like other SDL drivers tend to do.
   1.103 -     */
   1.104 -    this->hidden->initial_calls = 2;
   1.105 -    this->hidden->write_delay =
   1.106 -        (Uint32) ((((float) this->spec.size) / bytes_per_sec) * 1000.0f);
   1.107 -
   1.108 -    /* We're ready to rock and roll. :-) */
   1.109 -    return 1;
   1.110 +    return 1;   /* always succeeds. */
   1.111  }
   1.112  
   1.113  /* vi: set ts=4 sw=4 expandtab: */