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 "../../base/Evaluator.h"
#include "portaudio.h"

Go to the source code of this file.

Functions

int PEBLAudioCallback (const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo *timeInfo, const PaStreamCallbackFlags statusFlags, void *userData)
 
void PlayCallBack (void *udata, Uint8 *stream, int len)
 

Function Documentation

◆ PEBLAudioCallback()

int PEBLAudioCallback ( const void *  inputBuffer,
void *  outputBuffer,
unsigned long  framesPerBuffer,
const PaStreamCallbackTimeInfo *  timeInfo,
const PaStreamCallbackFlags  statusFlags,
void *  userData 
)

◆ PlayCallBack()

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

Definition at line 160 of file portaudio/PlatformAudioOut.cpp.

161{
162
163 // cout << "Callback Called\n" <<endl;
164 Uint8 * waveptr;
165 int waveleft;
166
167 //Cast udata to a proper form--this is dangerous and nasty.
168 AudioInfo * wave = (AudioInfo*)(udata);
169
170 //Put pointer at the proper place in the buffer.
171 waveptr = wave->audio + wave->audiopos;
172 waveleft = wave->audiolen - wave->audiopos;
173
174 // cout << "waveleft: " << waveleft << " len:" << len << endl;
175 if(waveleft >= len)
176 {
177 SDL_MixAudio(stream, waveptr, len, SDL_MIX_MAXVOLUME);
178 wave->audiopos += len;
179
180 }
181 else
182 {
183 //This plays the rest of the file and stops playing.
184 SDL_MixAudio(stream, waveptr, waveleft, SDL_MIX_MAXVOLUME);
185 wave->audiopos += waveleft;
186 SDL_PauseAudio(1);
187 wave->audiopos=0; //Reset it back to the beginning.
188
189 }
190
191}
Uint8 * audio
Uint32 audiolen