annotate src/audio/android/SDL_androidaudio.c @ 4718:79aa6c61f33b

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