annotate src/audio/nds/SDL_ndsaudio.c @ 2686:e9f27fe4f2a1 gsoc2008_nds

Existing testsprite programs made into NDS projects
author Darren Alton <dalton@stevens.edu>
date Wed, 13 Aug 2008 00:49:03 +0000
parents 2190b873ff00
children e065c9f6a393
rev   line source
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
1 /*
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
3 Copyright (C) 1997-2006 Sam Lantinga
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
4
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
5 This library is free software; you can redistribute it and/or
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
6 modify it under the terms of the GNU Lesser General Public
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
7 License as published by the Free Software Foundation; either
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
8 version 2.1 of the License, or (at your option) any later version.
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
9
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
13 Lesser General Public License for more details.
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
14
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
15 You should have received a copy of the GNU Lesser General Public
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
16 License along with this library; if not, write to the Free Software
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
18
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
19 Sam Lantinga
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
20 slouken@libsdl.org
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
21
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
22 This file written by Ryan C. Gordon (icculus@icculus.org)
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
23 */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
24 #include "SDL_config.h"
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
25
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
26 /* Output audio to NDS */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
27
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
28 #include <nds.h>
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
29
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
30 #include "SDL_audio.h"
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
31 #include "../SDL_audio_c.h"
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
32 #include "SDL_ndsaudio.h"
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
33
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
34 static int
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
35 NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture)
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
36 {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
37 return 1; /* always succeeds. */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
38 }
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
39
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
40 static void
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
41 NDSAUD_PlayDevice(_THIS)
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
42 {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
43 TransferSoundData* sound = SDL_malloc(sizeof(TransferSoundData));
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
44 if(!sound) {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
45 SDL_OutOfMemory();
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
46 }
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
47 sound->data = NULL; /* pointer to raw audio data */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
48 sound->len = 0; /* size of raw data pointed to above */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
49 sound->rate = 22050; /* sample rate = 22050Hz */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
50 sound->vol = 127; /* volume [0..127] for [min..max] */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
51 sound->pan = 64; /* balance [0..127] for [left..right] */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
52 sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */
2685
2190b873ff00 Making room for test prog's
Darren Alton <dalton@stevens.edu>
parents: 2680
diff changeset
53 /*playSound(sound);*/
2680
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
54 /* stub */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
55 }
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
56
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
57
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
58 static Uint8 *
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
59 NDSAUD_GetDeviceBuf(_THIS)
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
60 {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
61 /* stub */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
62 }
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
63
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
64 static void
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
65 NDSAUD_WaitDevice(_THIS)
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
66 {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
67 /* stub */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
68 }
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
69
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
70 static void
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
71 NDSAUD_CloseDevice(_THIS)
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
72 {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
73 /* stub */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
74 }
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
75
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
76 static int
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
77 NDSAUD_Init(SDL_AudioDriverImpl * impl)
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
78 {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
79 /* Set the function pointers */
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
80 impl->OpenDevice = NDSAUD_OpenDevice;
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
81 impl->PlayDevice = NDSAUD_PlayDevice;
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
82 impl->WaitDevice = NDSAUD_WaitDevice;
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
83 impl->GetDeviceBuf = NDSAUD_GetDeviceBuf;
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
84 impl->CloseDevice = NDSAUD_CloseDevice;
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
85 impl->OnlyHasDefaultOutputDevice = 1;
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
86 return 1;
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
87 }
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
88
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
89 AudioBootStrap NDSAUD_bootstrap = {
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
90 "nds", "SDL NDS audio driver", NDSAUD_Init, 1
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
91 };
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
92
4135aa9c5645 More work on the accelerated 2D video driver, beginnings of sprite-based rendering support. Also some initial work on an audio driver.
Darren Alton <dalton@stevens.edu>
parents:
diff changeset
93 /* vi: set ts=4 sw=4 expandtab: */