forked from mia/Aegisub
* Clean up doxygen comments.
* Fix spacing between blocks. * Add some debugging info. Originally committed to SVN as r3440.
This commit is contained in:
parent
e0f84274b0
commit
3eff6459cb
|
@ -40,7 +40,6 @@
|
||||||
#ifdef WITH_PORTAUDIO
|
#ifdef WITH_PORTAUDIO
|
||||||
|
|
||||||
|
|
||||||
///////////
|
|
||||||
// Headers
|
// Headers
|
||||||
#include "audio_player_portaudio.h"
|
#include "audio_player_portaudio.h"
|
||||||
#include "audio_provider_manager.h"
|
#include "audio_provider_manager.h"
|
||||||
|
@ -51,11 +50,6 @@
|
||||||
//#define PORTAUDIO_DEBUG
|
//#define PORTAUDIO_DEBUG
|
||||||
|
|
||||||
|
|
||||||
/// Reference counter
|
|
||||||
int PortAudioPlayer::pa_refcount = 0;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Constructor
|
/// @brief Constructor
|
||||||
PortAudioPlayer::PortAudioPlayer() {
|
PortAudioPlayer::PortAudioPlayer() {
|
||||||
// Initialize portaudio
|
// Initialize portaudio
|
||||||
|
@ -67,17 +61,14 @@ PortAudioPlayer::PortAudioPlayer() {
|
||||||
swprintf(errormsg, 2048, L"Failed opening PortAudio: %s", Pa_GetErrorText(err));
|
swprintf(errormsg, 2048, L"Failed opening PortAudio: %s", Pa_GetErrorText(err));
|
||||||
throw (const wchar_t *)errormsg;
|
throw (const wchar_t *)errormsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
pa_refcount++;
|
pa_refcount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variables
|
|
||||||
volume = 1.0f;
|
volume = 1.0f;
|
||||||
pos.pa_start = 0.0;
|
pos.pa_start = 0.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Destructor
|
/// @brief Destructor
|
||||||
PortAudioPlayer::~PortAudioPlayer() {
|
PortAudioPlayer::~PortAudioPlayer() {
|
||||||
// Deinit portaudio
|
// Deinit portaudio
|
||||||
|
@ -85,7 +76,6 @@ PortAudioPlayer::~PortAudioPlayer() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Open stream
|
/// @brief Open stream
|
||||||
void PortAudioPlayer::OpenStream() {
|
void PortAudioPlayer::OpenStream() {
|
||||||
// Open stream
|
// Open stream
|
||||||
|
@ -124,7 +114,6 @@ void PortAudioPlayer::OpenStream() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Close stream
|
/// @brief Close stream
|
||||||
void PortAudioPlayer::CloseStream() {
|
void PortAudioPlayer::CloseStream() {
|
||||||
Stop(false);
|
Stop(false);
|
||||||
|
@ -145,7 +134,6 @@ void PortAudioPlayer::paStreamFinishedCallback(void *userData) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Play audio.
|
/// @brief Play audio.
|
||||||
/// @param start Start position.
|
/// @param start Start position.
|
||||||
/// @param count Frame count
|
/// @param count Frame count
|
||||||
|
@ -163,13 +151,14 @@ void PortAudioPlayer::Play(int64_t start,int64_t count) {
|
||||||
err = Pa_SetStreamFinishedCallback(stream, paStreamFinishedCallback);
|
err = Pa_SetStreamFinishedCallback(stream, paStreamFinishedCallback);
|
||||||
|
|
||||||
if (err != paNoError) {
|
if (err != paNoError) {
|
||||||
wxLogDebug(_T("PortAudioPlayer::Play Could not set FinishedCallback\n"));
|
wxLogDebug(_T("PortAudioPlayer::Play Could not set FinishedCallback.\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = Pa_StartStream(stream);
|
err = Pa_StartStream(stream);
|
||||||
|
|
||||||
if (err != paNoError) {
|
if (err != paNoError) {
|
||||||
|
wxLogDebug(_T("PortAudioPlayer::Play Error playing stream.\n"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -180,7 +169,6 @@ void PortAudioPlayer::Play(int64_t start,int64_t count) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Stop Playback
|
/// @brief Stop Playback
|
||||||
/// @param timerToo Stop display timer?
|
/// @param timerToo Stop display timer?
|
||||||
///
|
///
|
||||||
|
@ -195,8 +183,7 @@ void PortAudioPlayer::Stop(bool timerToo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// @brief PortAudio callback, used to fill buffer for playback, and prime the playback buffer.
|
||||||
/// @brief PortAudio callback
|
|
||||||
/// @param inputBuffer Input buffer.
|
/// @param inputBuffer Input buffer.
|
||||||
/// @param outputBuffer Output buffer.
|
/// @param outputBuffer Output buffer.
|
||||||
/// @param framesPerBuffer Frames per buffer.
|
/// @param framesPerBuffer Frames per buffer.
|
||||||
|
@ -226,7 +213,6 @@ int PortAudioPlayer::paCallback(
|
||||||
// Calculate how much left
|
// Calculate how much left
|
||||||
int64_t lenAvailable = (player->pos.end - player->pos.current) > 0 ? framesPerBuffer : 0;
|
int64_t lenAvailable = (player->pos.end - player->pos.current) > 0 ? framesPerBuffer : 0;
|
||||||
|
|
||||||
|
|
||||||
// Play something
|
// Play something
|
||||||
if (lenAvailable > 0) {
|
if (lenAvailable > 0) {
|
||||||
provider->GetAudioWithVolume(outputBuffer, player->pos.current, lenAvailable, player->GetVolume());
|
provider->GetAudioWithVolume(outputBuffer, player->pos.current, lenAvailable, player->GetVolume());
|
||||||
|
@ -267,7 +253,6 @@ int64_t PortAudioPlayer::GetCurrentPosition()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// @brief Get list of available output devices
|
/// @brief Get list of available output devices
|
||||||
/// @param favorite Favorite output device
|
/// @param favorite Favorite output device
|
||||||
/// @return List of available output devices with the 'favorite' being first in the list.
|
/// @return List of available output devices with the 'favorite' being first in the list.
|
||||||
|
|
|
@ -68,6 +68,7 @@ private:
|
||||||
};
|
};
|
||||||
PositionInfo pos;
|
PositionInfo pos;
|
||||||
|
|
||||||
|
/// PortAudio stream.
|
||||||
void *stream;
|
void *stream;
|
||||||
|
|
||||||
static int paCallback(
|
static int paCallback(
|
||||||
|
@ -82,6 +83,9 @@ private:
|
||||||
|
|
||||||
static void paStreamFinishedCallback(void *userData);
|
static void paStreamFinishedCallback(void *userData);
|
||||||
|
|
||||||
|
/// Reference counter
|
||||||
|
int PortAudioPlayer::pa_refcount = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PortAudioPlayer();
|
PortAudioPlayer();
|
||||||
~PortAudioPlayer();
|
~PortAudioPlayer();
|
||||||
|
|
Loading…
Reference in a new issue