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

View file

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