Mercurial > almixer_isolated
annotate Isolated/LGPL/SDL_sound_minimal.c @ 70:7d63f5149d40
Enhanced endian detection code in SoundDecoder.h after reviewing ANDROID_NDK changes.
author | Eric Wing <ewing . public |-at-| gmail . com> |
---|---|
date | Wed, 20 Jun 2012 10:41:06 -0700 |
parents | 96c61ac12446 |
children |
rev | line source |
---|---|
38 | 1 /* |
2 * SDL_sound -- An abstract sound format decoding API. | |
3 * Copyright (C) 2001 Ryan C. Gordon. | |
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
18 */ | |
19 | |
20 /* | |
67
96c61ac12446
Fixed a copy/paste comment error about the origins of SDL_sound_minimal.c
Eric Wing <ewing@anscamobile.com>
parents:
38
diff
changeset
|
21 Attention: This was extracted from SDL_sound to go with the wav.c plugin (also from SDL_sound). |
38 | 22 This code is licensed under the LGPL. |
23 This means we must not compile this code into anything that we are not willing to | |
24 publicly release source code. | |
25 You should compile this into a separate dynamic library that is isolated from proprietary code. | |
26 */ | |
27 | |
28 | |
29 #include <stdint.h> | |
30 #include "SoundDecoder.h" | |
31 | |
32 uint32_t __Sound_convertMsToBytePos(Sound_AudioInfo *info, uint32_t ms) | |
33 { | |
34 /* "frames" == "sample frames" */ | |
35 float frames_per_ms = ((float) info->rate) / 1000.0f; | |
36 uint32_t frame_offset = (uint32_t) (frames_per_ms * ((float) ms)); | |
37 uint32_t frame_size = (uint32_t) ((info->format & 0xFF) / 8) * info->channels; | |
38 return(frame_offset * frame_size); | |
39 } /* __Sound_convertMsToBytePos */ | |
40 | |
41 |