Don't bother refcounting portaudio initializations as portaudio does that internally

Originally committed to SVN as r6206.
This commit is contained in:
Thomas Goyne 2012-01-08 01:04:44 +00:00
parent 0fd475031a
commit 4990d8255c
2 changed files with 4 additions and 15 deletions

View File

@ -50,26 +50,18 @@
// Uncomment to enable extremely spammy debug logging
//#define PORTAUDIO_DEBUG
// Init reference counter
int PortAudioPlayer::pa_refcount = 0;
PortAudioPlayer::PortAudioPlayer() {
// Initialize portaudio
if (!pa_refcount) {
PaError err = Pa_Initialize();
PaError err = Pa_Initialize();
if (err != paNoError)
throw PortAudioError(std::string("Failed opening PortAudio:") + Pa_GetErrorText(err));
}
pa_refcount++;
if (err != paNoError)
throw PortAudioError(std::string("Failed opening PortAudio:") + Pa_GetErrorText(err));
volume = 1.0f;
pa_start = 0.0;
}
PortAudioPlayer::~PortAudioPlayer() {
// Deinit portaudio
if (!--pa_refcount) Pa_Terminate();
Pa_Terminate();
}
void PortAudioPlayer::OpenStream() {

View File

@ -51,9 +51,6 @@ DEFINE_SIMPLE_EXCEPTION_NOINNER(PortAudioError, agi::Exception, "audio/player/po
/// @brief PortAudio Player
///
class PortAudioPlayer : public AudioPlayer {
/// PortAudio initilisation reference counter
static int pa_refcount;
float volume; ///< Current volume level
int64_t current; ///< Current position
int64_t start; ///< Start position