Mercurial > sdl-ios-xcode
comparison src/audio/nds/SDL_ndsaudio.c @ 2735:204be4fc2726
Final merge of Google Summer of Code 2008 work...
Port SDL 1.3 to the Nintendo DS
by Darren Alton, mentored by Sam Lantinga
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 27 Aug 2008 15:10:03 +0000 |
parents | |
children | 99210400e8b9 |
comparison
equal
deleted
inserted
replaced
2734:dd25eabe441c | 2735:204be4fc2726 |
---|---|
1 /* | |
2 SDL - Simple DirectMedia Layer | |
3 Copyright (C) 1997-2006 Sam Lantinga | |
4 | |
5 This library is free software; you can redistribute it and/or | |
6 modify it under the terms of the GNU Lesser General Public | |
7 License as published by the Free Software Foundation; either | |
8 version 2.1 of the License, or (at your option) any later version. | |
9 | |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 Lesser General Public License for more details. | |
14 | |
15 You should have received a copy of the GNU Lesser General Public | |
16 License along with this library; if not, write to the Free Software | |
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
18 | |
19 Sam Lantinga | |
20 slouken@libsdl.org | |
21 | |
22 This file written by Ryan C. Gordon (icculus@icculus.org) | |
23 */ | |
24 #include "SDL_config.h" | |
25 | |
26 /* Output audio to NDS */ | |
27 | |
28 #include <nds.h> | |
29 | |
30 #include "SDL_audio.h" | |
31 #include "../SDL_audio_c.h" | |
32 #include "SDL_ndsaudio.h" | |
33 | |
34 static int | |
35 NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture) | |
36 { | |
37 SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); | |
38 int valid_datatype = 0; | |
39 | |
40 this->hidden = SDL_malloc(sizeof(*(this->hidden))); | |
41 if (!this->hidden) { | |
42 SDL_OutOfMemory(); | |
43 return 0; | |
44 } | |
45 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); | |
46 | |
47 while ((!valid_datatype) && (test_format)) { | |
48 this->spec.format = test_format; | |
49 switch (test_format) { | |
50 case AUDIO_S8: | |
51 /*case AUDIO_S16LSB: */ | |
52 valid_datatype = 1; | |
53 break; | |
54 default: | |
55 test_format = SDL_NextAudioFormat(); | |
56 break; | |
57 } | |
58 } | |
59 | |
60 /* set the generic sound parameters */ | |
61 setGenericSound(22050, /* sample rate */ | |
62 127, /* volume */ | |
63 64, /* panning/balance */ | |
64 0); /* sound format */ | |
65 | |
66 return 1; | |
67 } | |
68 | |
69 static void | |
70 NDSAUD_PlayDevice(_THIS) | |
71 { | |
72 TransferSoundData *sound = SDL_malloc(sizeof(TransferSoundData)); | |
73 if (!sound) { | |
74 SDL_OutOfMemory(); | |
75 } | |
76 | |
77 playGenericSound(this->hidden->mixbuf, this->hidden->mixlen); | |
78 #if 0 | |
79 // sound->data = this->hidden->mixbuf;/* pointer to raw audio data */ | |
80 // sound->len = this->hidden->mixlen; /* size of raw data pointed to above */ | |
81 // sound->rate = 22050; /* sample rate = 22050Hz */ | |
82 // sound->vol = 127; /* volume [0..127] for [min..max] */ | |
83 // sound->pan = 64; /* balance [0..127] for [left..right] */ | |
84 // sound->format = 0; /* 0 for 16-bit, 1 for 8-bit */ | |
85 // playSound(sound); | |
86 #endif | |
87 } | |
88 | |
89 | |
90 static Uint8 * | |
91 NDSAUD_GetDeviceBuf(_THIS) | |
92 { | |
93 return this->hidden->mixbuf; /* is this right? */ | |
94 } | |
95 | |
96 static void | |
97 NDSAUD_WaitDevice(_THIS) | |
98 { | |
99 /* stub */ | |
100 } | |
101 | |
102 static void | |
103 NDSAUD_CloseDevice(_THIS) | |
104 { | |
105 /* stub */ | |
106 } | |
107 | |
108 static int | |
109 NDSAUD_Init(SDL_AudioDriverImpl * impl) | |
110 { | |
111 /* Set the function pointers */ | |
112 impl->OpenDevice = NDSAUD_OpenDevice; | |
113 impl->PlayDevice = NDSAUD_PlayDevice; | |
114 impl->WaitDevice = NDSAUD_WaitDevice; | |
115 impl->GetDeviceBuf = NDSAUD_GetDeviceBuf; | |
116 impl->CloseDevice = NDSAUD_CloseDevice; | |
117 | |
118 /* and the capabilities */ | |
119 impl->HasCaptureSupport = 1; | |
120 impl->OnlyHasDefaultOutputDevice = 1; | |
121 impl->OnlyHasDefaultInputDevice = 1; | |
122 | |
123 return 1; | |
124 } | |
125 | |
126 AudioBootStrap NDSAUD_bootstrap = { | |
127 "nds", "SDL NDS audio driver", NDSAUD_Init, 0 /*1? */ | |
128 }; | |
129 | |
130 /* vi: set ts=4 sw=4 expandtab: */ |