Skip to content

Commit 97e1f79

Browse files
authored
Merge pull request #782 from Rust-SDL2/unstable-build-rs-work
Move ffi into sys, update bindgen, build.rs and update to sdl2.0.8
2 parents 0772363 + 9a0afae commit 97e1f79

File tree

130 files changed

+32692
-14847
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

130 files changed

+32692
-14847
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ os:
88
- linux
99
- osx
1010
install:
11-
- wget https://www.libsdl.org/release/SDL2-2.0.5.tar.gz -O sdl2.tar.gz
11+
- wget https://www.libsdl.org/release/SDL2-2.0.8.tar.gz -O sdl2.tar.gz
1212
- tar xzf sdl2.tar.gz
1313
- pushd SDL2-* && ./configure && make && sudo make install && popd
1414
- wget -q https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.14.tar.gz

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ optional = true
3737

3838
unsafe_textures = []
3939
default = []
40-
ttf = []
41-
image = []
42-
gfx = ["c_vec"]
43-
mixer = []
40+
gfx = ["c_vec", "sdl2-sys/gfx"]
41+
mixer = ["sdl2-sys/mixer"]
42+
image = ["sdl2-sys/image"]
43+
ttf = ["sdl2-sys/ttf"]
4444

4545
use-bindgen = ["sdl2-sys/use-bindgen"]
4646
use-pkgconfig = ["sdl2-sys/use-pkgconfig"]

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ We currently target the latest stable release of Rust.
3232

3333
## *SDL2.0 development libraries*
3434

35-
SDL2 >= 2.0.5 is recommended to use these bindings, but note that SDL2 >= 2.0.4 is also supported. Below 2.0.4, you may experience link-time errors as some functions are used here but are not defined in SDL2. If you experience this issue because you are on a LTS machine (for instance, Ubuntu 12.04 or Ubuntu 14.04), we definitely recommend you to use the feature "bundled" which will compile the lastest stable version of SDL2 for your project.
35+
SDL2 >= 2.0.8 is recommended to use these bindings, but note that SDL2 >= 2.0.4 is also supported. Below 2.0.4, you may experience link-time errors as some functions are used here but are not defined in SDL2. If you experience this issue because you are on a LTS machine (for instance, Ubuntu 12.04 or Ubuntu 14.04), we definitely recommend you to use the feature "bundled" which will compile the lastest stable version of SDL2 for your project.
3636

3737
### "Bundled" Feature
3838

@@ -129,10 +129,10 @@ SDL2-devel-2.0.x-mingw.tar.gz\SDL2-2.0.x\i686-w64-mingw32\bin -> gnu-mingw\dl
129129
SDL2-devel-2.0.x-mingw.tar.gz\SDL2-2.0.x\x86_64-w64-mingw32\bin -> gnu-mingw\dll\64
130130
SDL2-devel-2.0.x-mingw.tar.gz\SDL2-2.0.x\i686-w64-mingw32\lib -> gnu-mingw\lib\32
131131
SDL2-devel-2.0.x-mingw.tar.gz\SDL2-2.0.x\x86_64-w64-mingw32\lib -> gnu-mingw\lib\64
132-
SDL2-devel-2.0.5-VC.zip\SDL2-2.0.x\lib\x86\*.dll -> msvc\dll\32
133-
SDL2-devel-2.0.5-VC.zip\SDL2-2.0.x\lib\x64\*.dll -> msvc\dll\64
134-
SDL2-devel-2.0.5-VC.zip\SDL2-2.0.x\lib\x86\*.lib -> msvc\lib\32
135-
SDL2-devel-2.0.5-VC.zip\SDL2-2.0.x\lib\x64\*.lib -> msvc\lib\64
132+
SDL2-devel-2.0.8-VC.zip\SDL2-2.0.x\lib\x86\*.dll -> msvc\dll\32
133+
SDL2-devel-2.0.8-VC.zip\SDL2-2.0.x\lib\x64\*.dll -> msvc\dll\64
134+
SDL2-devel-2.0.8-VC.zip\SDL2-2.0.x\lib\x86\*.lib -> msvc\lib\32
135+
SDL2-devel-2.0.8-VC.zip\SDL2-2.0.x\lib\x64\*.lib -> msvc\lib\64
136136
```
137137

138138
5. Create a build script, if you don't already have one put this in your Cargo.toml under `[package]`:
@@ -334,7 +334,7 @@ you may sometimes face trouble when using platform-specific features of SDL2, fo
334334

335335
The feature "use-bindgen" allows you to avoid this limitation by generating the proper bindings depending on your target. It will take
336336
the headers based on what `pkg-config` outputs (if you enabled the feature "use-pkg-config") and generate bindings based on them.
337-
If you don't have pkg-config or disabled the feature, it will try to get the headers in `SDL-2.0.6/include` of this crate instead.
337+
If you don't have pkg-config or disabled the feature, it will try to get the headers in `SDL-2.0.8/include` of this crate instead.
338338

339339
If somehow you have your own headers that you want to use (use a beta version, an older version, ...),
340340
you can set the environment variable "SDL2_INCLUDE_PATH" and those headers will be used by bindgen instead.

examples/mixer-demo.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ extern crate sdl2;
44

55
use std::env;
66
use std::path::Path;
7-
use sdl2::mixer::{DEFAULT_CHANNELS, INIT_MP3, INIT_FLAC, INIT_MOD, INIT_FLUIDSYNTH, INIT_MODPLUG,
7+
use sdl2::mixer::{DEFAULT_CHANNELS, INIT_MP3, INIT_FLAC, INIT_MOD,
88
INIT_OGG, AUDIO_S16LSB};
99

1010
fn main() {
@@ -33,7 +33,7 @@ fn demo(music_file: &Path, sound_file: Option<&Path>) {
3333
let chunk_size = 1_024;
3434
sdl2::mixer::open_audio(frequency, format, channels, chunk_size).unwrap();
3535
let _mixer_context = sdl2::mixer::init(
36-
INIT_MP3 | INIT_FLAC | INIT_MOD | INIT_FLUIDSYNTH | INIT_MODPLUG | INIT_OGG
36+
INIT_MP3 | INIT_FLAC | INIT_MOD | INIT_OGG
3737
).unwrap();
3838

3939
// Number of mixing channels available for sound effect `Chunk`s to play

sdl2-sys/Cargo.toml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ name = "sdl2_sys"
1616
path = "src/lib.rs"
1717

1818
[build-dependencies.bindgen]
19-
version = "0.31"
19+
version = "0.35"
2020
optional = true
2121

2222
[build-dependencies.pkg-config]
@@ -50,3 +50,7 @@ use-bindgen = ["bindgen"]
5050
static-link = []
5151
use_mac_framework = []
5252
bundled = ["cmake", "reqwest", "tar", "flate2"]
53+
mixer = []
54+
image = []
55+
ttf = []
56+
gfx = []

sdl2-sys/SDL2-2.0.6/include/SDL_revision.h

Lines changed: 0 additions & 2 deletions
This file was deleted.

sdl2-sys/SDL2-2.0.6/include/SDL.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages

sdl2-sys/SDL2-2.0.6/include/SDL_assert.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL_assert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages

sdl2-sys/SDL2-2.0.6/include/SDL_atomic.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL_atomic.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages
@@ -158,6 +158,9 @@ extern DECLSPEC void SDLCALL SDL_MemoryBarrierAcquireFunction(void);
158158
#if defined(__GNUC__) && (defined(__powerpc__) || defined(__ppc__))
159159
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("lwsync" : : : "memory")
160160
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("lwsync" : : : "memory")
161+
#elif defined(__GNUC__) && defined(__aarch64__)
162+
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")
163+
#define SDL_MemoryBarrierAcquire() __asm__ __volatile__ ("dmb ish" : : : "memory")
161164
#elif defined(__GNUC__) && defined(__arm__)
162165
#if defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) || defined(__ARM_ARCH_7EM__) || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7S__)
163166
#define SDL_MemoryBarrierRelease() __asm__ __volatile__ ("dmb ish" : : : "memory")

sdl2-sys/SDL2-2.0.6/include/SDL_audio.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL_audio.h

Lines changed: 137 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages
@@ -164,6 +164,15 @@ typedef void (SDLCALL * SDL_AudioCallback) (void *userdata, Uint8 * stream,
164164

165165
/**
166166
* The calculated values in this structure are calculated by SDL_OpenAudio().
167+
*
168+
* For multi-channel audio, the default SDL channel mapping is:
169+
* 2: FL FR (stereo)
170+
* 3: FL FR LFE (2.1 surround)
171+
* 4: FL FR BL BR (quad)
172+
* 5: FL FR FC BL BR (quad + center)
173+
* 6: FL FR FC LFE SL SR (5.1 surround - last two can also be BL BR)
174+
* 7: FL FR FC LFE BC SL SR (6.1 surround)
175+
* 8: FL FR FC LFE BL BR SL SR (7.1 surround)
167176
*/
168177
typedef struct SDL_AudioSpec
169178
{
@@ -477,6 +486,132 @@ extern DECLSPEC int SDLCALL SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
477486
*/
478487
extern DECLSPEC int SDLCALL SDL_ConvertAudio(SDL_AudioCVT * cvt);
479488

489+
/* SDL_AudioStream is a new audio conversion interface.
490+
The benefits vs SDL_AudioCVT:
491+
- it can handle resampling data in chunks without generating
492+
artifacts, when it doesn't have the complete buffer available.
493+
- it can handle incoming data in any variable size.
494+
- You push data as you have it, and pull it when you need it
495+
*/
496+
/* this is opaque to the outside world. */
497+
struct _SDL_AudioStream;
498+
typedef struct _SDL_AudioStream SDL_AudioStream;
499+
500+
/**
501+
* Create a new audio stream
502+
*
503+
* \param src_format The format of the source audio
504+
* \param src_channels The number of channels of the source audio
505+
* \param src_rate The sampling rate of the source audio
506+
* \param dst_format The format of the desired audio output
507+
* \param dst_channels The number of channels of the desired audio output
508+
* \param dst_rate The sampling rate of the desired audio output
509+
* \return 0 on success, or -1 on error.
510+
*
511+
* \sa SDL_AudioStreamPut
512+
* \sa SDL_AudioStreamGet
513+
* \sa SDL_AudioStreamAvailable
514+
* \sa SDL_AudioStreamFlush
515+
* \sa SDL_AudioStreamClear
516+
* \sa SDL_FreeAudioStream
517+
*/
518+
extern DECLSPEC SDL_AudioStream * SDLCALL SDL_NewAudioStream(const SDL_AudioFormat src_format,
519+
const Uint8 src_channels,
520+
const int src_rate,
521+
const SDL_AudioFormat dst_format,
522+
const Uint8 dst_channels,
523+
const int dst_rate);
524+
525+
/**
526+
* Add data to be converted/resampled to the stream
527+
*
528+
* \param stream The stream the audio data is being added to
529+
* \param buf A pointer to the audio data to add
530+
* \param len The number of bytes to write to the stream
531+
* \return 0 on success, or -1 on error.
532+
*
533+
* \sa SDL_NewAudioStream
534+
* \sa SDL_AudioStreamGet
535+
* \sa SDL_AudioStreamAvailable
536+
* \sa SDL_AudioStreamFlush
537+
* \sa SDL_AudioStreamClear
538+
* \sa SDL_FreeAudioStream
539+
*/
540+
extern DECLSPEC int SDLCALL SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len);
541+
542+
/**
543+
* Get converted/resampled data from the stream
544+
*
545+
* \param stream The stream the audio is being requested from
546+
* \param buf A buffer to fill with audio data
547+
* \param len The maximum number of bytes to fill
548+
* \return The number of bytes read from the stream, or -1 on error
549+
*
550+
* \sa SDL_NewAudioStream
551+
* \sa SDL_AudioStreamPut
552+
* \sa SDL_AudioStreamAvailable
553+
* \sa SDL_AudioStreamFlush
554+
* \sa SDL_AudioStreamClear
555+
* \sa SDL_FreeAudioStream
556+
*/
557+
extern DECLSPEC int SDLCALL SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len);
558+
559+
/**
560+
* Get the number of converted/resampled bytes available. The stream may be
561+
* buffering data behind the scenes until it has enough to resample
562+
* correctly, so this number might be lower than what you expect, or even
563+
* be zero. Add more data or flush the stream if you need the data now.
564+
*
565+
* \sa SDL_NewAudioStream
566+
* \sa SDL_AudioStreamPut
567+
* \sa SDL_AudioStreamGet
568+
* \sa SDL_AudioStreamFlush
569+
* \sa SDL_AudioStreamClear
570+
* \sa SDL_FreeAudioStream
571+
*/
572+
extern DECLSPEC int SDLCALL SDL_AudioStreamAvailable(SDL_AudioStream *stream);
573+
574+
/**
575+
* Tell the stream that you're done sending data, and anything being buffered
576+
* should be converted/resampled and made available immediately.
577+
*
578+
* It is legal to add more data to a stream after flushing, but there will
579+
* be audio gaps in the output. Generally this is intended to signal the
580+
* end of input, so the complete output becomes available.
581+
*
582+
* \sa SDL_NewAudioStream
583+
* \sa SDL_AudioStreamPut
584+
* \sa SDL_AudioStreamGet
585+
* \sa SDL_AudioStreamAvailable
586+
* \sa SDL_AudioStreamClear
587+
* \sa SDL_FreeAudioStream
588+
*/
589+
extern DECLSPEC int SDLCALL SDL_AudioStreamFlush(SDL_AudioStream *stream);
590+
591+
/**
592+
* Clear any pending data in the stream without converting it
593+
*
594+
* \sa SDL_NewAudioStream
595+
* \sa SDL_AudioStreamPut
596+
* \sa SDL_AudioStreamGet
597+
* \sa SDL_AudioStreamAvailable
598+
* \sa SDL_AudioStreamFlush
599+
* \sa SDL_FreeAudioStream
600+
*/
601+
extern DECLSPEC void SDLCALL SDL_AudioStreamClear(SDL_AudioStream *stream);
602+
603+
/**
604+
* Free an audio stream
605+
*
606+
* \sa SDL_NewAudioStream
607+
* \sa SDL_AudioStreamPut
608+
* \sa SDL_AudioStreamGet
609+
* \sa SDL_AudioStreamAvailable
610+
* \sa SDL_AudioStreamFlush
611+
* \sa SDL_AudioStreamClear
612+
*/
613+
extern DECLSPEC void SDLCALL SDL_FreeAudioStream(SDL_AudioStream *stream);
614+
480615
#define SDL_MIX_MAXVOLUME 128
481616
/**
482617
* This takes two audio buffers of the playing audio format and mixes
@@ -532,7 +667,7 @@ extern DECLSPEC void SDLCALL SDL_MixAudioFormat(Uint8 * dst,
532667
* \param dev The device ID to which we will queue audio.
533668
* \param data The data to queue to the device for later playback.
534669
* \param len The number of bytes (not samples!) to which (data) points.
535-
* \return zero on success, -1 on error.
670+
* \return 0 on success, or -1 on error.
536671
*
537672
* \sa SDL_GetQueuedAudioSize
538673
* \sa SDL_ClearQueuedAudio

sdl2-sys/SDL2-2.0.6/include/SDL_bits.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL_bits.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages

sdl2-sys/SDL2-2.0.6/include/SDL_blendmode.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL_blendmode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages

sdl2-sys/SDL2-2.0.6/include/SDL_clipboard.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL_clipboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages

sdl2-sys/SDL2-2.0.6/include/SDL_config.h renamed to sdl2-sys/SDL2-2.0.8/include/SDL_config.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*
22
Simple DirectMedia Layer
3-
Copyright (C) 1997-2017 Sam Lantinga <[email protected]>
3+
Copyright (C) 1997-2018 Sam Lantinga <[email protected]>
44
55
This software is provided 'as-is', without any express or implied
66
warranty. In no event will the authors be held liable for any damages

0 commit comments

Comments
 (0)