aboutsummaryrefslogtreecommitdiffstats
path: root/examples/allatency.c
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2013-06-05 20:12:13 -0700
committerChris Robinson <[email protected]>2013-06-05 20:12:13 -0700
commit9fd87314800f27d626f25688a69587166a809dd0 (patch)
tree9ea27e551ffd80acc9b2e44c67975518a101d4fa /examples/allatency.c
parent056fa2a47443eb40cf40eadae5721c847015813e (diff)
Use SDL_sound for the other examples
Diffstat (limited to 'examples/allatency.c')
-rw-r--r--examples/allatency.c31
1 files changed, 11 insertions, 20 deletions
diff --git a/examples/allatency.c b/examples/allatency.c
index 3468692c..deb13d3b 100644
--- a/examples/allatency.c
+++ b/examples/allatency.c
@@ -26,20 +26,13 @@
#include <stdio.h>
#include <assert.h>
-#ifdef _WIN32
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#else
-#include <unistd.h>
-#define Sleep(x) usleep((x)*1000)
-#endif
#include "AL/al.h"
#include "AL/alc.h"
#include "AL/alext.h"
#include "common/alhelpers.h"
-#include "common/alffmpeg.h"
+#include "common/sdl_sound.h"
static LPALBUFFERSAMPLESSOFT alBufferSamplesSOFT = wrap_BufferSamples;
@@ -66,24 +59,22 @@ static ALuint LoadSound(const char *filename)
ALuint rate, buffer;
size_t datalen;
void *data;
- FilePtr audiofile;
- StreamPtr sound;
+ FilePtr sound;
- /* Open the file and get the first stream from it */
- audiofile = openAVFile(filename);
- sound = getAVAudioStream(audiofile, 0);
+ /* Open the audio file */
+ sound = openAudioFile(filename, 1000);
if(!sound)
{
fprintf(stderr, "Could not open audio in %s\n", filename);
- closeAVFile(audiofile);
+ closeAudioFile(sound);
return 0;
}
/* Get the sound format, and figure out the OpenAL format */
- if(getAVAudioInfo(sound, &rate, &channels, &type) != 0)
+ if(getAudioInfo(sound, &rate, &channels, &type) != 0)
{
fprintf(stderr, "Error getting audio info for %s\n", filename);
- closeAVFile(audiofile);
+ closeAudioFile(sound);
return 0;
}
@@ -92,16 +83,16 @@ static ALuint LoadSound(const char *filename)
{
fprintf(stderr, "Unsupported format (%s, %s) for %s\n",
ChannelsName(channels), TypeName(type), filename);
- closeAVFile(audiofile);
+ closeAudioFile(sound);
return 0;
}
/* Decode the whole audio stream to a buffer. */
- data = decodeAVAudioStream(sound, &datalen);
+ data = decodeAudioStream(sound, &datalen);
if(!data)
{
fprintf(stderr, "Failed to read audio from %s\n", filename);
- closeAVFile(audiofile);
+ closeAudioFile(sound);
return 0;
}
@@ -112,7 +103,7 @@ static ALuint LoadSound(const char *filename)
alBufferSamplesSOFT(buffer, rate, format, BytesToFrames(datalen, channels, type),
channels, type, data);
free(data);
- closeAVFile(audiofile);
+ closeAudioFile(sound);
/* Check if an error occured, and clean up if so. */
err = alGetError();