src/audio/android/SDL_androidaudio.c
author Paul Hunkin
Tue, 27 Jul 2010 11:34:43 +0200
changeset 4718 79aa6c61f33b
child 4724 d86332c0fb9b
permissions -rw-r--r--
Added stub android sound system
paul@4718
     1
/*
paul@4718
     2
    SDL - Simple DirectMedia Layer
paul@4718
     3
    Copyright (C) 1997-2010 Sam Lantinga
paul@4718
     4
paul@4718
     5
    This library is free software; you can redistribute it and/or
paul@4718
     6
    modify it under the terms of the GNU Lesser General Public
paul@4718
     7
    License as published by the Free Software Foundation; either
paul@4718
     8
    version 2.1 of the License, or (at your option) any later version.
paul@4718
     9
paul@4718
    10
    This library is distributed in the hope that it will be useful,
paul@4718
    11
    but WITHOUT ANY WARRANTY; without even the implied warranty of
paul@4718
    12
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
paul@4718
    13
    Lesser General Public License for more details.
paul@4718
    14
paul@4718
    15
    You should have received a copy of the GNU Lesser General Public
paul@4718
    16
    License along with this library; if not, write to the Free Software
paul@4718
    17
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
paul@4718
    18
paul@4718
    19
    Sam Lantinga
paul@4718
    20
    slouken@libsdl.org
paul@4718
    21
paul@4718
    22
    This file written by Ryan C. Gordon (icculus@icculus.org)
paul@4718
    23
*/
paul@4718
    24
#include "SDL_config.h"
paul@4718
    25
paul@4718
    26
/* Output audio to Android */
paul@4718
    27
paul@4718
    28
#include "SDL_audio.h"
paul@4718
    29
#include "../SDL_audio_c.h"
paul@4718
    30
#include "SDL_androidaudio.h"
paul@4718
    31
paul@4718
    32
#include <android/log.h>
paul@4718
    33
paul@4718
    34
static int
paul@4718
    35
AndroidAUD_OpenDevice(_THIS, const char *devname, int iscapture)
paul@4718
    36
{
paul@4718
    37
    //TODO: Sample rates etc
paul@4718
    38
    __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Open\n");
paul@4718
    39
    
paul@4718
    40
    return 1;
paul@4718
    41
}
paul@4718
    42
paul@4718
    43
static void
paul@4718
    44
AndroidAUD_PlayDevice(_THIS)
paul@4718
    45
{
paul@4718
    46
    __android_log_print(ANDROID_LOG_INFO, "SDL", "AndroidAudio Play\n");
paul@4718
    47
    
paul@4718
    48
    
paul@4718
    49
paul@4718
    50
    //playGenericSound(this->hidden->mixbuf, this->hidden->mixlen);
paul@4718
    51
    
paul@4718
    52
#if 0
paul@4718
    53
//    sound->data = this->hidden->mixbuf;/* pointer to raw audio data */
paul@4718
    54
//    sound->len = this->hidden->mixlen; /* size of raw data pointed to above */
paul@4718
    55
//    sound->rate = 22050; /* sample rate = 22050Hz */
paul@4718
    56
//    sound->vol = 127;    /* volume [0..127] for [min..max] */
paul@4718
    57
//    sound->pan = 64;     /* balance [0..127] for [left..right] */
paul@4718
    58
//    sound->format = 0;   /* 0 for 16-bit, 1 for 8-bit */
paul@4718
    59
//    playSound(sound);
paul@4718
    60
#endif
paul@4718
    61
}
paul@4718
    62
paul@4718
    63
paul@4718
    64
static Uint8 *
paul@4718
    65
AndroidAUD_GetDeviceBuf(_THIS)
paul@4718
    66
{
paul@4718
    67
    return this->hidden->mixbuf;        /* is this right? */
paul@4718
    68
}
paul@4718
    69
paul@4718
    70
static void
paul@4718
    71
AndroidAUD_WaitDevice(_THIS)
paul@4718
    72
{
paul@4718
    73
    /* stub */
paul@4718
    74
}
paul@4718
    75
paul@4718
    76
static void
paul@4718
    77
AndroidAUD_CloseDevice(_THIS)
paul@4718
    78
{
paul@4718
    79
    /* stub */
paul@4718
    80
}
paul@4718
    81
paul@4718
    82
static int
paul@4718
    83
AndroidAUD_Init(SDL_AudioDriverImpl * impl)
paul@4718
    84
{
paul@4718
    85
    /* Set the function pointers */
paul@4718
    86
    impl->OpenDevice = AndroidAUD_OpenDevice;
paul@4718
    87
    impl->PlayDevice = AndroidAUD_PlayDevice;
paul@4718
    88
    impl->WaitDevice = AndroidAUD_WaitDevice;
paul@4718
    89
    impl->GetDeviceBuf = AndroidAUD_GetDeviceBuf;
paul@4718
    90
    impl->CloseDevice = AndroidAUD_CloseDevice;
paul@4718
    91
paul@4718
    92
    /* and the capabilities */
paul@4718
    93
    impl->HasCaptureSupport = 0; //TODO
paul@4718
    94
    impl->OnlyHasDefaultOutputDevice = 1;
paul@4718
    95
    impl->OnlyHasDefaultInputDevice = 1;
paul@4718
    96
paul@4718
    97
    __android_log_print(ANDROID_LOG_INFO, "SDL","Audio init\n");
paul@4718
    98
paul@4718
    99
    return 1;   /* this audio target is available. */
paul@4718
   100
}
paul@4718
   101
paul@4718
   102
AudioBootStrap ANDROIDAUD_bootstrap = {
paul@4718
   103
    "android", "SDL Android audio driver", AndroidAUD_Init, 0       /*1? */
paul@4718
   104
};
paul@4718
   105
paul@4718
   106
/* vi: set ts=4 sw=4 expandtab: */