Added stub android sound system
authorPaul Hunkin <paul@bieh.net>
Tue, 27 Jul 2010 11:34:43 +0200
changeset 471879aa6c61f33b
parent 4717 191f4693d0c1
child 4719 d59792d2c3ae
Added stub android sound system
Makefile.android
src/audio/SDL_audio.c
src/audio/android/SDL_androidaudio.c
src/audio/android/SDL_androidaudio.h
src/audio/android/SDL_androidaudio.o
     1.1 --- a/Makefile.android	Tue Jul 27 11:02:07 2010 +0200
     1.2 +++ b/Makefile.android	Tue Jul 27 11:34:43 2010 +0200
     1.3 @@ -28,7 +28,7 @@
     1.4  	src/timer/*.c \
     1.5  	src/video/*.c \
     1.6  	src/power/*.c \
     1.7 -	src/audio/dummy/*.c \
     1.8 +	src/audio/android/*.c \
     1.9  	src/video/android/*.c \
    1.10  	src/joystick/dummy/*.c \
    1.11  	src/haptic/dummy/*.c \
     2.1 --- a/src/audio/SDL_audio.c	Tue Jul 27 11:02:07 2010 +0200
     2.2 +++ b/src/audio/SDL_audio.c	Tue Jul 27 11:34:43 2010 +0200
     2.3 @@ -69,6 +69,7 @@
     2.4  extern AudioBootStrap DART_bootstrap;
     2.5  extern AudioBootStrap NDSAUD_bootstrap;
     2.6  extern AudioBootStrap FUSIONSOUND_bootstrap;
     2.7 +extern AudioBootStrap ANDROIDAUD_bootstrap;
     2.8  
     2.9  
    2.10  /* Available audio drivers */
    2.11 @@ -137,6 +138,9 @@
    2.12  #if SDL_AUDIO_DRIVER_FUSIONSOUND
    2.13      &FUSIONSOUND_bootstrap,
    2.14  #endif
    2.15 +#if SDL_AUDIO_DRIVER_ANDROID
    2.16 +    &ANDROIDAUD_bootstrap,
    2.17 +#endif
    2.18      NULL
    2.19  };
    2.20  
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/audio/android/SDL_androidaudio.c	Tue Jul 27 11:34:43 2010 +0200
     3.3 @@ -0,0 +1,106 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2010 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +
    3.25 +    This file written by Ryan C. Gordon (icculus@icculus.org)
    3.26 +*/
    3.27 +#include "SDL_config.h"
    3.28 +
    3.29 +/* Output audio to Android */
    3.30 +
    3.31 +#include "SDL_audio.h"
    3.32 +#include "../SDL_audio_c.h"
    3.33 +#include "SDL_androidaudio.h"
    3.34 +
    3.35 +#include <android/log.h>
    3.36 +
    3.37 +static int
    3.38 +AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
    3.39 +{
    3.40 +    //TODO: Sample rates etc
    3.41 +    __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Open\n");
    3.42 +    
    3.43 +    return 1;
    3.44 +}
    3.45 +
    3.46 +static void
    3.47 +AndroidAUD_PlayDevice(_THIS)
    3.48 +{
    3.49 +    __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Play\n");
    3.50 +    
    3.51 +    
    3.52 +
    3.53 +    //playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
    3.54 +    
    3.55 +#if 0
    3.56 +//    sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
    3.57 +//    sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
    3.58 +//    sound->rate = 22050; /* sample rate = 22050Hz */
    3.59 +//    sound->vol = 127;    /* volume [0..127] for [min..max] */
    3.60 +//    sound->pan = 64;     /* balance [0..127] for [left..right] */
    3.61 +//    sound->format = 0;   /* 0 for 16-bit, 1 for 8-bit */
    3.62 +//    playSound(sound);
    3.63 +#endif
    3.64 +}
    3.65 +
    3.66 +
    3.67 +static Uint8 *
    3.68 +AndroidAUD_GetDeviceBuf(_THIS)
    3.69 +{
    3.70 +    return this->hidden->mixbuf;        /* is this right? */
    3.71 +}
    3.72 +
    3.73 +static void
    3.74 +AndroidAUD_WaitDevice(_THIS)
    3.75 +{
    3.76 +    /* stub */
    3.77 +}
    3.78 +
    3.79 +static void
    3.80 +AndroidAUD_CloseDevice(_THIS)
    3.81 +{
    3.82 +    /* stub */
    3.83 +}
    3.84 +
    3.85 +static int
    3.86 +AndroidAUD_Init(SDL_AudioDriverImpl * impl)
    3.87 +{
    3.88 +    /* Set the function pointers */
    3.89 +    impl->OpenDevice = AndroidAUD_OpenDevice;
    3.90 +    impl->PlayDevice = AndroidAUD_PlayDevice;
    3.91 +    impl->WaitDevice = AndroidAUD_WaitDevice;
    3.92 +    impl->GetDeviceBuf = AndroidAUD_GetDeviceBuf;
    3.93 +    impl->CloseDevice = AndroidAUD_CloseDevice;
    3.94 +
    3.95 +    /* and the capabilities */
    3.96 +    impl->HasCaptureSupport = 0; //TODO
    3.97 +    impl->OnlyHasDefaultOutputDevice = 1;
    3.98 +    impl->OnlyHasDefaultInputDevice = 1;
    3.99 +
   3.100 +    __android_log_print(ANDROID_LOG_INFO, "SDL","Audio init\n");
   3.101 +
   3.102 +    return 1;   /* this audio target is available. */
   3.103 +}
   3.104 +
   3.105 +AudioBootStrap ANDROIDAUD_bootstrap = {
   3.106 +    "android", "SDL Android audio driver", AndroidAUD_Init, 0       /*1? */
   3.107 +};
   3.108 +
   3.109 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/audio/android/SDL_androidaudio.h	Tue Jul 27 11:34:43 2010 +0200
     4.3 @@ -0,0 +1,42 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2010 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +#include "SDL_config.h"
    4.26 +
    4.27 +#ifndef _SDL_androidaudio_h
    4.28 +#define _SDL_androidaudio_h
    4.29 +
    4.30 +#include "../SDL_sysaudio.h"
    4.31 +
    4.32 +/* Hidden "this" pointer for the audio functions */
    4.33 +#define _THIS	SDL_AudioDevice *this
    4.34 +
    4.35 +struct SDL_PrivateAudioData
    4.36 +{
    4.37 +    /* The file descriptor for the audio device */
    4.38 +    Uint8 *mixbuf;
    4.39 +    Uint32 mixlen;
    4.40 +    Uint32 write_delay;
    4.41 +    Uint32 initial_calls;
    4.42 +};
    4.43 +
    4.44 +#endif /* _SDL_androidaudio_h */
    4.45 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 Binary file src/audio/android/SDL_androidaudio.o has changed