Remove pointless duplicated member variable in OSSPlayer and document a few of the members

Originally committed to SVN as r6225.
This commit is contained in:
Thomas Goyne 2012-01-08 01:33:55 +00:00
parent 02fa5bee3e
commit 81a99ae27b
2 changed files with 29 additions and 98 deletions

View file

@ -52,9 +52,6 @@
DEFINE_SIMPLE_EXCEPTION(OSSError, agi::AudioPlayerOpenError, "audio/player/open/oss") DEFINE_SIMPLE_EXCEPTION(OSSError, agi::AudioPlayerOpenError, "audio/player/open/oss")
/// @brief Constructor
///
OSSPlayer::OSSPlayer() OSSPlayer::OSSPlayer()
{ {
volume = 1.0f; volume = 1.0f;
@ -65,21 +62,15 @@ OSSPlayer::OSSPlayer()
thread = 0; thread = 0;
} }
/// @brief Destructor
///
OSSPlayer::~OSSPlayer() OSSPlayer::~OSSPlayer()
{ {
CloseStream(); CloseStream();
} }
/// @brief Open stream
///
void OSSPlayer::OpenStream() void OSSPlayer::OpenStream()
{ {
CloseStream(); CloseStream();
// Get provider
provider = GetProvider();
bpf = provider->GetChannels() * provider->GetBytesPerSample(); bpf = provider->GetChannels() * provider->GetBytesPerSample();
// Open device // Open device
@ -128,9 +119,6 @@ void OSSPlayer::OpenStream()
open = true; open = true;
} }
/// @brief Close stream
/// @return
///
void OSSPlayer::CloseStream() void OSSPlayer::CloseStream()
{ {
if (!open) return; if (!open) return;
@ -142,10 +130,6 @@ void OSSPlayer::CloseStream()
open = false; open = false;
} }
/// @brief Play
/// @param start
/// @param count
///
void OSSPlayer::Play(int64_t start, int64_t count) void OSSPlayer::Play(int64_t start, int64_t count)
{ {
Stop(); Stop();
@ -162,10 +146,6 @@ void OSSPlayer::Play(int64_t start, int64_t count)
playing = true; playing = true;
} }
/// @brief Stop
/// @param timerToo
/// @return
///
void OSSPlayer::Stop(bool timerToo) void OSSPlayer::Stop(bool timerToo)
{ {
if (!open) return; if (!open) return;
@ -195,17 +175,6 @@ void OSSPlayer::Stop(bool timerToo)
} }
} }
/// @brief DOCME
/// @return
///
bool OSSPlayer::IsPlaying()
{
return playing;
}
/// @brief Set end
/// @param pos
///
void OSSPlayer::SetEndPosition(int64_t pos) void OSSPlayer::SetEndPosition(int64_t pos)
{ {
end_frame = pos; end_frame = pos;
@ -215,36 +184,13 @@ void OSSPlayer::SetEndPosition(int64_t pos)
if (thread && thread->IsAlive()) if (thread && thread->IsAlive())
thread->Delete(); thread->Delete();
} }
} }
/// @brief Set current position
/// @param pos
///
void OSSPlayer::SetCurrentPosition(int64_t pos) void OSSPlayer::SetCurrentPosition(int64_t pos)
{ {
cur_frame = start_frame = pos; cur_frame = start_frame = pos;
} }
/// @brief DOCME
/// @return
///
int64_t OSSPlayer::GetStartPosition()
{
return start_frame;
}
/// @brief DOCME
/// @return
///
int64_t OSSPlayer::GetEndPosition()
{
return end_frame;
}
/// @brief Get current position
/// @return
///
int64_t OSSPlayer::GetCurrentPosition() int64_t OSSPlayer::GetCurrentPosition()
{ {
if (!playing) if (!playing)
@ -290,17 +236,12 @@ int64_t OSSPlayer::GetCurrentPosition()
return cur_frame; return cur_frame;
} }
/// @brief Thread constructor OSSPlayerThread::OSSPlayerThread(OSSPlayer *par)
/// @param par : wxThread(wxTHREAD_JOINABLE)
/// , parent(par)
OSSPlayerThread::OSSPlayerThread(OSSPlayer *par) : wxThread(wxTHREAD_JOINABLE)
{ {
parent = par;
} }
/// @brief Thread entry point
/// @return
///
wxThread::ExitCode OSSPlayerThread::Entry() { wxThread::ExitCode OSSPlayerThread::Entry() {
// Use small enough writes for good timing accuracy with all // Use small enough writes for good timing accuracy with all
// timing methods. // timing methods.
@ -317,7 +258,7 @@ wxThread::ExitCode OSSPlayerThread::Entry() {
free(buf); free(buf);
parent->cur_frame = parent->end_frame; parent->cur_frame = parent->end_frame;
LOG_D("player/audio/oss") << "Thread dead"; LOG_D("player/audio/oss") << "Thread dead";
return 0; return 0;
} }

View file

@ -55,18 +55,17 @@ class OSSPlayer;
/// DOCME /// DOCME
/// @class OSSPlayerThread /// @class OSSPlayerThread
/// @brief DOCME /// @brief Worker thread to asynchronously write audio data to the output device
///
/// DOCME
class OSSPlayerThread : public wxThread { class OSSPlayerThread : public wxThread {
private: /// Parent player
/// DOCME
OSSPlayer *parent; OSSPlayer *parent;
public: public:
/// Constructor
/// @param parent Player to get audio data and playback state from
OSSPlayerThread(OSSPlayer *parent); OSSPlayerThread(OSSPlayer *parent);
/// Main thread entry point
wxThread::ExitCode Entry(); wxThread::ExitCode Entry();
}; };
@ -76,37 +75,34 @@ public:
/// ///
/// DOCME /// DOCME
class OSSPlayer : public AudioPlayer { class OSSPlayer : public AudioPlayer {
private:
friend class OSSPlayerThread; friend class OSSPlayerThread;
/// DOCME /// Is the output file handle initialized and ready to be written to?
bool open; bool open;
/// DOCME /// sample rate of audio
unsigned int rate; // sample rate of audio unsigned int rate;
/// Worker thread that does the actual writing
OSSPlayerThread *thread; OSSPlayerThread *thread;
/// DOCME /// Is the player currently playing?
AudioProvider *provider;
/// DOCME
volatile bool playing; volatile bool playing;
/// DOCME /// Current volume level
volatile float volume; volatile float volume;
/// DOCME /// first frame of playback
volatile unsigned long start_frame; // first frame of playback volatile unsigned long start_frame;
/// DOCME /// last written frame + 1
volatile unsigned long cur_frame; // last written frame + 1 volatile unsigned long cur_frame;
/// DOCME /// last frame to play
volatile unsigned long end_frame; // last frame to play volatile unsigned long end_frame;
/// DOCME /// bytes per frame
unsigned long bpf; // bytes per frame unsigned long bpf;
// OSS audio device handle // OSS audio device handle
volatile int dspdev; volatile int dspdev;
@ -120,23 +116,17 @@ 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);
bool IsPlaying(); bool IsPlaying() { return playing; }
int64_t GetStartPosition(); int64_t GetStartPosition() { return start_frame; }
int64_t GetEndPosition();
int64_t GetCurrentPosition(); int64_t GetEndPosition() { return end_frame; }
void SetEndPosition(int64_t pos); void SetEndPosition(int64_t pos);
int64_t GetCurrentPosition();
void SetCurrentPosition(int64_t pos); void SetCurrentPosition(int64_t pos);
/// @brief DOCME
/// @param vol
/// @return
///
void SetVolume(double vol) { volume = vol; } void SetVolume(double vol) { volume = vol; }
/// @brief DOCME
/// @return
///
double GetVolume() { return volume; } double GetVolume() { return volume; }
}; };
#endif #endif