Document PortAudio player, this is broken in doxygen at the moment not sure why..

Originally committed to SVN as r3323.
This commit is contained in:
Amar Takhar 2009-07-30 02:51:42 +00:00
parent 612e007be6
commit cd8bb7c241
2 changed files with 54 additions and 79 deletions

View file

@ -48,17 +48,16 @@
#include "utils.h" #include "utils.h"
#include "charset_conv.h" #include "charset_conv.h"
// Uncomment to enable debug features. /// @define PORTAUDIO_DEBUG Enable debugging?
//#define PORTAUDIO_DEBUG //#define PORTAUDIO_DEBUG
/// DOCME /// Reference counter
int PortAudioPlayer::pa_refcount = 0; int PortAudioPlayer::pa_refcount = 0;
/// @brief Constructor /// @brief Constructor
///
PortAudioPlayer::PortAudioPlayer() { PortAudioPlayer::PortAudioPlayer() {
// Initialize portaudio // Initialize portaudio
if (!pa_refcount) { if (!pa_refcount) {
@ -82,8 +81,7 @@ PortAudioPlayer::PortAudioPlayer() {
/// @brief Destructor /// @brief Destructor
///
PortAudioPlayer::~PortAudioPlayer() { PortAudioPlayer::~PortAudioPlayer() {
// Deinit portaudio // Deinit portaudio
if (!--pa_refcount) Pa_Terminate(); if (!--pa_refcount) Pa_Terminate();
@ -91,8 +89,7 @@ PortAudioPlayer::~PortAudioPlayer() {
/// @brief Open stream /// @brief Open stream
///
void PortAudioPlayer::OpenStream() { void PortAudioPlayer::OpenStream() {
// Open stream // Open stream
PaStreamParameters pa_output_p; PaStreamParameters pa_output_p;
@ -131,8 +128,7 @@ void PortAudioPlayer::OpenStream() {
/// @brief Close stream /// @brief Close stream
///
void PortAudioPlayer::CloseStream() { void PortAudioPlayer::CloseStream() {
try { try {
Stop(false); Stop(false);
@ -142,8 +138,7 @@ void PortAudioPlayer::CloseStream() {
/// @brief Called when the callback has finished. /// @brief Called when the callback has finished.
/// @param userData /// @param userData Local data to be handed to the callback.
///
void PortAudioPlayer::paStreamFinishedCallback(void *userData) { void PortAudioPlayer::paStreamFinishedCallback(void *userData) {
PortAudioPlayer *player = (PortAudioPlayer *) userData; PortAudioPlayer *player = (PortAudioPlayer *) userData;
@ -158,11 +153,9 @@ void PortAudioPlayer::paStreamFinishedCallback(void *userData) {
/// @brief Play /// @brief Play audio.
/// @param start /// @param start Start position.
/// @param count /// @param count Frame count
/// @return
///
void PortAudioPlayer::Play(int64_t start,int64_t count) { void PortAudioPlayer::Play(int64_t start,int64_t count) {
PaError err; PaError err;
@ -199,8 +192,8 @@ void PortAudioPlayer::Play(int64_t start,int64_t count) {
/// @brief Stop /// @brief Stop Playback
/// @param timerToo /// @param timerToo Stop display timer?
/// ///
void PortAudioPlayer::Stop(bool timerToo) { void PortAudioPlayer::Stop(bool timerToo) {
//wxMutexLocker locker(PAMutex); //wxMutexLocker locker(PAMutex);
@ -218,14 +211,14 @@ void PortAudioPlayer::Stop(bool timerToo) {
/// @brief PortAudio callback /// @brief PortAudio callback
/// @param inputBuffer /// @param inputBuffer Input buffer.
/// @param outputBuffer /// @param outputBuffer Output buffer.
/// @param framesPerBuffer /// @param framesPerBuffer Frames per buffer.
/// @param timeInfo /// @param timeInfo PortAudio time information.
/// @param statusFlags /// @param statusFlags Status flags
/// @param userData /// @param userData Local data to hand callback
/// @return /// @return Whether to stop playback.
/// ///
int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) { int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData) {
@ -260,9 +253,8 @@ int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer, uns
/// @brief Get current stream position. /// @brief Get current stream position.
/// @return /// @return Stream position
///
int64_t PortAudioPlayer::GetCurrentPosition() int64_t PortAudioPlayer::GetCurrentPosition()
{ {
@ -285,9 +277,9 @@ int64_t PortAudioPlayer::GetCurrentPosition()
/// @brief @param Setting from config file. Return a list of available output devices. /// @brief @param Setting from config file.
/// @param favorite /// @param favorite Favorite output device
/// /// @return List of available output devices.
wxArrayString PortAudioPlayer::GetOutputDevices(wxString favorite) { wxArrayString PortAudioPlayer::GetOutputDevices(wxString favorite) {
wxArrayString list; wxArrayString list;
int devices = Pa_GetDeviceCount(); int devices = Pa_GetDeviceCount();
@ -307,5 +299,3 @@ wxArrayString PortAudioPlayer::GetOutputDevices(wxString favorite) {
} }
#endif // WITH_PORTAUDIO #endif // WITH_PORTAUDIO

View file

@ -50,43 +50,41 @@ extern "C" {
/// DOCME
/// @class PortAudioPlayer /// @class PortAudioPlayer
/// @brief DOCME /// @brief PortAudio Player
/// ///
/// DOCME
class PortAudioPlayer : public AudioPlayer { class PortAudioPlayer : public AudioPlayer {
private: private:
/// DOCME /// DOCME
static int pa_refcount; static int pa_refcount;
/// DOCME /// PortAudio Mutex
wxMutex PAMutex; wxMutex PAMutex;
/// DOCME /// Is playback being stopped?
volatile bool stopping; volatile bool stopping;
/// DOCME /// Currently Playing?
bool playing; bool playing;
/// DOCME /// Current volume level.
float volume; float volume;
/// DOCME /// Playback position.
volatile int64_t playPos; volatile int64_t playPos;
/// DOCME /// Playback start position.
volatile int64_t startPos; volatile int64_t startPos;
/// DOCME /// Playback end position.
volatile int64_t endPos; volatile int64_t endPos;
/// DOCME /// Audio Stream
void *stream; void *stream;
/// DOCME /// PortAudio internal start position.
PaTime paStart; PaTime paStart;
static int paCallback( static int paCallback(
@ -111,68 +109,55 @@ public:
void Play(int64_t start,int64_t count); void Play(int64_t start,int64_t count);
void Stop(bool timerToo=true); void Stop(bool timerToo=true);
/// @brief DOCME /// @brief Whether audio is currently being played.
/// @return /// @return Status
///
bool IsPlaying() { return playing; } bool IsPlaying() { return playing; }
/// @brief DOCME /// @brief Position audio will be played from.
/// @return /// @return Start position.
///
int64_t GetStartPosition() { return startPos; } int64_t GetStartPosition() { return startPos; }
/// @brief DOCME /// @brief End position playback will stop at.
/// @return /// @return End position.
///
int64_t GetEndPosition() { return endPos; } int64_t GetEndPosition() { return endPos; }
int64_t GetCurrentPosition(); int64_t GetCurrentPosition();
/// @brief DOCME /// @brief Set end position of playback
/// @param pos /// @param pos End position
///
void SetEndPosition(int64_t pos) { endPos = pos; } void SetEndPosition(int64_t pos) { endPos = pos; }
/// @brief DOCME /// @brief Set current position of playback.
/// @param pos /// @param pos Current position
///
void SetCurrentPosition(int64_t pos) { playPos = pos; } void SetCurrentPosition(int64_t pos) { playPos = pos; }
/// @brief DOCME /// @brief Set volume level
/// @param vol /// @param vol Volume
/// @return
///
void SetVolume(double vol) { volume = vol; } void SetVolume(double vol) { volume = vol; }
/// @brief DOCME /// @brief Get current volume level
/// @return /// @return Volume level
///
double GetVolume() { return volume; } double GetVolume() { return volume; }
wxArrayString GetOutputDevices(wxString favorite); wxArrayString GetOutputDevices(wxString favorite);
/// @brief DOCME /// @brief Get Mutex
/// @return /// @return Current Mutex
/// ///
wxMutex *GetMutex() { return &PAMutex; } wxMutex *GetMutex() { return &PAMutex; }
}; };
/// DOCME
/// @class PortAudioPlayerFactory /// @class PortAudioPlayerFactory
/// @brief DOCME /// @brief PortAudio Player Factory
///
/// DOCME
class PortAudioPlayerFactory : public AudioPlayerFactory { class PortAudioPlayerFactory : public AudioPlayerFactory {
public: public:
/// @brief DOCME /// @brief Create player
/// /// @return New PortAudio Player
AudioPlayer *CreatePlayer() { return new PortAudioPlayer(); } AudioPlayer *CreatePlayer() { return new PortAudioPlayer(); }
}; };
#endif //ifdef WITH_PORTAUDIO #endif //ifdef WITH_PORTAUDIO