Mercurial > sdl-ios-xcode
annotate docs/man3/SDL_ConvertAudio.3 @ 4134:31c7c57af8a4 SDL-1.2
Updates for building on Windows CE using mingw32ce cross compiler:
http://sourceforge.net/mailarchive/forum.php?thread_name 0703291652.38437.jwalt%40garni.ch&forum_name=cegcc-devel
Hi!
I just managed to compile SDL for Windows CE using the "mingw32ce"
configuration of http://cegcc.sourceforge.net. Test programs work as expected
(except for those using signals -- no POSIX on mingw32ce), and I didn't yet
encounter any problem.
While it was a pain to get everything compiled and running, the changes to
SDL are actually quite small (see attached SDL-ce.diff).
Unfortunately, the win32 headers shipped with cegcc are not 100% correct, and
it feels quite messy to work around them in SDL code, so those headers will
also need to be patched. (Attachment: win32api-ce.diff)
Since I had to apply the libtool patch from the cegcc patch, I have also ad ded
my copy of aclocal.m4 for SDL. I had to modify the cegcc libtool patch to
use "lt_cv_deplibs_check_method=pass_all" for mingw32ce, otherwise libtool
would not recognize the import libraries as valid for dynamic linking.
All these changes should not affect non-WinCE builds, so they could be
included in mainline SDL.
If you need some docs, you can use this description for a cross-compilation
README:
1) get cegcc from http://cegcc.sourceforge.net
2) build and install the "mingw32ce" variant (see cegcc installation docs)
3) patch w32api-headers (if not yet included in cegcc)
4) setup environment (customize the first three lines as you like):
PREFIX=/opt/mingw32ce
TARGET=arm-wince-mingw32ce
BUILD=`uname -m`-pc-linux-gnu
export PATH="$PREFIX/bin:$PREFIX/$TARGET/bin:$PREFIX/local/bin:$PATH"
export CFLAGS="${CFLAGS:- -O2 -g} -I$PREFIX/local/include"
export CPPFLAGS="${CPPFLAGS:- -O2 -g} -I$PREFIX/local/include"
export CXXFLAGS="${CXXFLAGS:- -O2 -g} -I$PREFIX/local/include"
export LDFLAGS="${LDFLAGS:- -O2 -g} -L$PREFIX/local/lib"
export HOST_CC="gcc"
export CC="$PREFIX/bin/$TARGET-gcc"
export CXX="$PREFIX/bin/$TARGET-g++"
export LD="$PREFIX/bin/$TARGET-ld"
export AS="$PREFIX/bin/$TARGET-as"
export AR="$PREFIX/bin/$TARGET-ar"
export RANLIB="$PREFIX/bin/$TARGET-ranlib"
export CONFIG_SHELL="/bin/sh"
5) build and install
./configure --target=$TARGET --host=$TARGET --build=$BUILD
make
make install
6) use (4) and (5) for any SDL-using software you want to cross-compile
7) copy $PREFIX/local/bin/SDL-1-2-0.dll into your executable directory on the WinCE machine
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 03 Jan 2008 06:19:07 +0000 |
parents | 4e3b250c950e |
children | 1238da4a7112 |
rev | line source |
---|---|
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
1 .TH "SDL_ConvertAudio" "3" "Tue 11 Sep 2001, 22:58" "SDL" "SDL API Reference" |
0 | 2 .SH "NAME" |
4107
4e3b250c950e
Erik Heckers fixed bug #493
Sam Lantinga <slouken@libsdl.org>
parents:
181
diff
changeset
|
3 SDL_ConvertAudio \- Convert audio data to a desired audio format\&. |
0 | 4 .SH "SYNOPSIS" |
5 .PP | |
6 \fB#include "SDL\&.h" | |
7 .sp | |
8 \fBint \fBSDL_ConvertAudio\fP\fR(\fBSDL_AudioCVT *cvt\fR); | |
9 .SH "DESCRIPTION" | |
10 .PP | |
11 \fBSDL_ConvertAudio\fP takes one parameter, \fBcvt\fR, which was previously initilized\&. Initilizing a \fI\fBSDL_AudioCVT\fR\fR is a two step process\&. First of all, the structure must be passed to \fI\fBSDL_BuildAudioCVT\fP\fR along with source and destination format parameters\&. Secondly, the \fBcvt\fR->\fBbuf\fR and \fBcvt\fR->\fBlen\fR fields must be setup\&. \fBcvt\fR->\fBbuf\fR should point to the audio data and \fBcvt\fR->\fBlen\fR should be set to the length of the audio data in bytes\&. Remember, the length of the buffer pointed to by \fBbuf\fR show be \fBlen\fR*\fBlen_mult\fR bytes in length\&. | |
12 .PP | |
13 Once the \fBSDL_AudioCVT\fRstructure is initilized then we can pass it to \fBSDL_ConvertAudio\fP, which will convert the audio data pointer to by \fBcvt\fR->\fBbuf\fR\&. If \fBSDL_ConvertAudio\fP returned \fB0\fR then the conversion was completed successfully, otherwise \fB-1\fR is returned\&. | |
14 .PP | |
15 If the conversion completed successfully then the converted audio data can be read from \fBcvt\fR->\fBbuf\fR\&. The amount of valid, converted, audio data in the buffer is equal to \fBcvt\fR->\fBlen\fR*\fBcvt\fR->\fBlen_ratio\fR\&. | |
16 .SH "EXAMPLES" | |
17 .PP | |
18 .nf | |
19 \f(CW/* Converting some WAV data to hardware format */ | |
20 void my_audio_callback(void *userdata, Uint8 *stream, int len); | |
21 | |
22 SDL_AudioSpec *desired, *obtained; | |
23 SDL_AudioSpec wav_spec; | |
24 SDL_AudioCVT wav_cvt; | |
25 Uint32 wav_len; | |
26 Uint8 *wav_buf; | |
27 int ret; | |
28 | |
29 /* Allocated audio specs */ | |
30 desired=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec)); | |
31 obtained=(SDL_AudioSpec *)malloc(sizeof(SDL_AudioSpec)); | |
32 | |
33 /* Set desired format */ | |
34 desired->freq=22050; | |
35 desired->format=AUDIO_S16LSB; | |
36 desired->samples=8192; | |
37 desired->callback=my_audio_callback; | |
38 desired->userdata=NULL; | |
39 | |
40 /* Open the audio device */ | |
41 if ( SDL_OpenAudio(desired, obtained) < 0 ){ | |
42 fprintf(stderr, "Couldn\&'t open audio: %s | |
43 ", SDL_GetError()); | |
44 exit(-1); | |
45 } | |
46 | |
47 free(desired); | |
48 | |
49 /* Load the test\&.wav */ | |
50 if( SDL_LoadWAV("test\&.wav", &wav_spec, &wav_buf, &wav_len) == NULL ){ | |
51 fprintf(stderr, "Could not open test\&.wav: %s | |
52 ", SDL_GetError()); | |
53 SDL_CloseAudio(); | |
54 free(obtained); | |
55 exit(-1); | |
56 } | |
57 | |
58 /* Build AudioCVT */ | |
59 ret = SDL_BuildAudioCVT(&wav_cvt, | |
60 wav_spec\&.format, wav_spec\&.channels, wav_spec\&.freq, | |
61 obtained->format, obtained->channels, obtained->freq); | |
62 | |
63 /* Check that the convert was built */ | |
64 if(ret==-1){ | |
65 fprintf(stderr, "Couldn\&'t build converter! | |
66 "); | |
67 SDL_CloseAudio(); | |
68 free(obtained); | |
69 SDL_FreeWAV(wav_buf); | |
70 } | |
71 | |
72 /* Setup for conversion */ | |
73 wav_cvt\&.buf=(Uint8 *)malloc(wav_len*wav_cvt\&.len_mult); | |
74 wav_cvt\&.len=wav_len; | |
75 memcpy(wav_cvt\&.buf, wav_buf, wav_len); | |
76 | |
77 /* We can delete to original WAV data now */ | |
78 SDL_FreeWAV(wav_buf); | |
79 | |
80 /* And now we\&'re ready to convert */ | |
81 SDL_ConvertAudio(&wav_cvt); | |
82 | |
83 /* do whatever */ | |
84 \&. | |
85 \&. | |
86 \&. | |
87 \&. | |
88 | |
89 \fR | |
90 .fi | |
91 .PP | |
92 .SH "SEE ALSO" | |
93 .PP | |
94 \fI\fBSDL_BuildAudioCVT\fP\fR, \fI\fBSDL_AudioCVT\fP\fR | |
181
e5bc29de3f0a
Updated from the SDL Documentation Project
Sam Lantinga <slouken@libsdl.org>
parents:
55
diff
changeset
|
95 ...\" created by instant / docbook-to-man, Tue 11 Sep 2001, 22:58 |