PEBL 2.2
Psychology Experiment Building Language - Cross-platform psychological experiment development system
PlatformAudioOut.cpp File Reference
#include "PlatformAudioOut.h"
#include "../../devices/PAudioOut.h"
#include "../../utility/PEBLPath.h"
#include "../../utility/PError.h"
#include "../../libs/PEBLEnvironment.h"
#include "../../base/Evaluator.h"
#include "SDL.h"
#include "SDL_audio.h"
#include <cmath>
#include <fstream>
#include <memory.h>
#include <cerrno>
#include <cstring>

Go to the source code of this file.

Functions

void PlayCallBack (void *dummy, Uint8 *stream, int len)
 

Variables

AudioInfogWaveStream =NULL
 

Function Documentation

◆ PlayCallBack()

void PlayCallBack ( void *  dummy,
Uint8 *  stream,
int  len 
)

Definition at line 1057 of file sdl/PlatformAudioOut.cpp.

1058{
1059
1060 SDL_memset(stream, 0, len);
1061
1062 Uint8 * waveptr;
1063 int waveleft;
1064
1065 //Cast udata to a proper form--this is dangerous and nasty.
1066 AudioInfo * wave = gWaveStream;//(AudioInfo*)(udata);
1067
1068
1069 //Put pointer at the proper place in the buffer.
1070 waveptr = wave->audio + wave->audiopos;
1071 waveleft = wave->audiolen - wave->audiopos;
1072
1073 // cerr << "waveleft: " << waveleft << " len:" << len << endl;
1074 if(waveleft >= len)
1075 {
1076
1077 SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME);
1078 //This may appear in future formats.
1079 //SDL_MixAudioFormat(stream,waveptr,wave->spec,len,SDL_MIX_MAXVOLUME);
1080 wave->audiopos += len;
1081
1082 }
1083 else
1084 {
1085 //This plays the of the file and stops playing.
1086 SDL_MixAudio(stream, waveptr, waveleft, SDL_MIX_MAXVOLUME);
1087 //SDL_MixAudioFormat(stream,waveptr,wave->spec,waveleft,SDL_MIX_MAXVOLUME);
1088
1089 wave->audiopos += waveleft;
1090 SDL_PauseAudio(1);
1091 wave->audiopos=0; //Reset it back to the beginning.
1092
1093 }
1094
1095}
AudioInfo * gWaveStream
Uint8 * audio
Uint32 audiolen

References AudioInfo::audio, AudioInfo::audiolen, AudioInfo::audiopos, and gWaveStream.

Variable Documentation

◆ gWaveStream