mirror of https://github.com/odrling/Aegisub
Kill AudioPlayer::displayTimer
The rewritten audio display does not use displayTimer and that functionality shouldn't have been in the players in the first place. Originally committed to SVN as r6605.
This commit is contained in:
parent
2840fc0aea
commit
7218c04d52
|
@ -62,13 +62,6 @@
|
|||
|
||||
AudioPlayer::AudioPlayer() {
|
||||
provider = NULL;
|
||||
displayTimer = NULL;
|
||||
}
|
||||
|
||||
AudioPlayer::~AudioPlayer() {
|
||||
if (displayTimer) {
|
||||
displayTimer->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
AudioPlayer* AudioPlayerFactory::GetAudioPlayer() {
|
||||
|
|
|
@ -404,33 +404,23 @@ void AlsaPlayer::Play(int64_t start, int64_t count)
|
|||
{
|
||||
OpenStream();
|
||||
|
||||
{
|
||||
PthreadMutexLocker ml(ps->mutex);
|
||||
ps->signal_start = true;
|
||||
ps->signal_stop = true; // make sure to stop any ongoing playback first
|
||||
ps->start_position = start;
|
||||
ps->end_position = start + count;
|
||||
pthread_cond_signal(&ps->cond);
|
||||
}
|
||||
|
||||
if (displayTimer && !displayTimer->IsRunning())
|
||||
displayTimer->Start(15);
|
||||
PthreadMutexLocker ml(ps->mutex);
|
||||
ps->signal_start = true;
|
||||
ps->signal_stop = true; // make sure to stop any ongoing playback first
|
||||
ps->start_position = start;
|
||||
ps->end_position = start + count;
|
||||
pthread_cond_signal(&ps->cond);
|
||||
}
|
||||
|
||||
|
||||
void AlsaPlayer::Stop(bool timerToo)
|
||||
void AlsaPlayer::Stop()
|
||||
{
|
||||
if (!open) return;
|
||||
|
||||
{
|
||||
PthreadMutexLocker ml(ps->mutex);
|
||||
ps->signal_stop = true;
|
||||
LOG_D("audio/player/alsa") << "stop stream, stop signal";
|
||||
pthread_cond_signal(&ps->cond);
|
||||
}
|
||||
|
||||
if (timerToo && displayTimer)
|
||||
displayTimer->Stop();
|
||||
PthreadMutexLocker ml(ps->mutex);
|
||||
ps->signal_stop = true;
|
||||
LOG_D("audio/player/alsa") << "stop stream, stop signal";
|
||||
pthread_cond_signal(&ps->cond);
|
||||
}
|
||||
|
||||
bool AlsaPlayer::IsPlaying()
|
||||
|
|
|
@ -57,7 +57,7 @@ public:
|
|||
void CloseStream();
|
||||
|
||||
void Play(int64_t start, int64_t count);
|
||||
void Stop(bool timerToo=true);
|
||||
void Stop();
|
||||
bool IsPlaying();
|
||||
|
||||
int64_t GetStartPosition();
|
||||
|
|
|
@ -258,15 +258,12 @@ void DirectSoundPlayer::Play(int64_t start,int64_t count) {
|
|||
res = buffer->Play(0,0,play_flag);
|
||||
if (SUCCEEDED(res)) playing = true;
|
||||
startTime = GetTickCount();
|
||||
|
||||
// Update timer
|
||||
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
||||
}
|
||||
|
||||
/// @brief Stop
|
||||
/// @param timerToo
|
||||
///
|
||||
void DirectSoundPlayer::Stop(bool timerToo) {
|
||||
void DirectSoundPlayer::Stop() {
|
||||
// Stop the thread
|
||||
if (thread) {
|
||||
if (thread->IsAlive()) {
|
||||
|
@ -286,11 +283,6 @@ void DirectSoundPlayer::Stop(bool timerToo) {
|
|||
startPos = 0;
|
||||
endPos = 0;
|
||||
offset = 0;
|
||||
|
||||
// Stop timer
|
||||
if (timerToo && displayTimer) {
|
||||
displayTimer->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
/// @brief Set end
|
||||
|
|
|
@ -137,7 +137,7 @@ public:
|
|||
void CloseStream();
|
||||
|
||||
void Play(int64_t start,int64_t count);
|
||||
void Stop(bool timerToo=true);
|
||||
void Stop();
|
||||
|
||||
/// @brief DOCME
|
||||
/// @return
|
||||
|
|
|
@ -870,8 +870,6 @@ void DirectSoundPlayer2::Play(int64_t start,int64_t count)
|
|||
{
|
||||
OpenStream();
|
||||
thread->Play(start, count);
|
||||
|
||||
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
||||
}
|
||||
catch (const char *msg)
|
||||
{
|
||||
|
@ -879,15 +877,11 @@ void DirectSoundPlayer2::Play(int64_t start,int64_t count)
|
|||
}
|
||||
}
|
||||
|
||||
void DirectSoundPlayer2::Stop(bool timerToo)
|
||||
void DirectSoundPlayer2::Stop()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (IsThreadAlive()) thread->Stop();
|
||||
|
||||
if (timerToo && displayTimer) {
|
||||
displayTimer->Stop();
|
||||
}
|
||||
}
|
||||
catch (const char *msg)
|
||||
{
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
|
||||
/// @brief Stop audio playback
|
||||
/// @param timerToo Whether to also stop the playback update timer
|
||||
void Stop(bool timerToo=true);
|
||||
void Stop();
|
||||
|
||||
/// @brief Tell whether playback is active
|
||||
/// @return True if audio is playing back
|
||||
|
|
|
@ -161,12 +161,9 @@ void OpenALPlayer::Play(int64_t start, int64_t count)
|
|||
alSourcePlay(source);
|
||||
wxTimer::Start(100);
|
||||
playback_segment_timer.Start();
|
||||
|
||||
// Update timer
|
||||
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
||||
}
|
||||
|
||||
void OpenALPlayer::Stop(bool timerToo)
|
||||
void OpenALPlayer::Stop()
|
||||
{
|
||||
if (!open) return;
|
||||
if (!playing) return;
|
||||
|
@ -181,10 +178,6 @@ void OpenALPlayer::Stop(bool timerToo)
|
|||
// Then drop the playback
|
||||
alSourceStop(source);
|
||||
alSourcei(source, AL_BUFFER, 0);
|
||||
|
||||
if (timerToo && displayTimer) {
|
||||
displayTimer->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void OpenALPlayer::FillBuffers(ALsizei count)
|
||||
|
@ -237,7 +230,7 @@ void OpenALPlayer::Notify()
|
|||
LOG_D("player/audio/openal") << "frames played=" << (buffers_played - num_buffers) * decode_buffer.size() / bpf << " num frames=" << end_frame - start_frame;
|
||||
// Check that all of the selected audio plus one full set of buffers has been queued
|
||||
if ((buffers_played - num_buffers) * (int64_t)decode_buffer.size() > (end_frame - start_frame) * bpf) {
|
||||
Stop(true);
|
||||
Stop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
void CloseStream();
|
||||
|
||||
void Play(int64_t start,int64_t count);
|
||||
void Stop(bool timerToo=true);
|
||||
void Stop();
|
||||
bool IsPlaying() { return playing; }
|
||||
|
||||
int64_t GetStartPosition() { return start_frame; }
|
||||
|
|
|
@ -141,12 +141,10 @@ void OSSPlayer::Play(int64_t start, int64_t count)
|
|||
thread->Create();
|
||||
thread->Run();
|
||||
|
||||
// Update timer
|
||||
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
||||
playing = true;
|
||||
}
|
||||
|
||||
void OSSPlayer::Stop(bool timerToo)
|
||||
void OSSPlayer::Stop()
|
||||
{
|
||||
if (!open) return;
|
||||
if (!playing) return;
|
||||
|
@ -168,11 +166,6 @@ void OSSPlayer::Stop(bool timerToo)
|
|||
start_frame = 0;
|
||||
cur_frame = 0;
|
||||
end_frame = 0;
|
||||
|
||||
// Stop timer
|
||||
if (timerToo && displayTimer) {
|
||||
displayTimer->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
void OSSPlayer::SetEndPosition(int64_t pos)
|
||||
|
@ -208,10 +201,6 @@ int64_t OSSPlayer::GetCurrentPosition()
|
|||
played_frames = pos.samples + pos.fifo_samples;
|
||||
#endif
|
||||
LOG_D("player/audio/oss") << "played_frames: " << played_frames << " fifo " << pos.fifo_samples;
|
||||
if (start_frame + played_frames >= end_frame) {
|
||||
if (displayTimer)
|
||||
displayTimer->Stop();
|
||||
}
|
||||
return start_frame + played_frames;
|
||||
}
|
||||
#endif
|
||||
|
@ -224,8 +213,6 @@ int64_t OSSPlayer::GetCurrentPosition()
|
|||
LOG_D("player/audio/oss") << "cur_frame: " << cur_frame << " delay " << delay;
|
||||
// delay can jitter a bit at the end, detect that
|
||||
if (cur_frame == end_frame && delay < rate / 20) {
|
||||
if (displayTimer)
|
||||
displayTimer->Stop();
|
||||
return cur_frame;
|
||||
}
|
||||
return MAX(0, (long) cur_frame - delay);
|
||||
|
|
|
@ -115,7 +115,7 @@ public:
|
|||
void CloseStream();
|
||||
|
||||
void Play(int64_t start, int64_t count);
|
||||
void Stop(bool timerToo=true);
|
||||
void Stop();
|
||||
bool IsPlaying() { return playing; }
|
||||
|
||||
int64_t GetStartPosition() { return start_frame; }
|
||||
|
|
|
@ -173,15 +173,11 @@ void PortAudioPlayer::OpenStream() {
|
|||
}
|
||||
|
||||
void PortAudioPlayer::CloseStream() {
|
||||
Stop(false);
|
||||
Stop();
|
||||
Pa_CloseStream(stream);
|
||||
}
|
||||
|
||||
void PortAudioPlayer::paStreamFinishedCallback(void *userData) {
|
||||
PortAudioPlayer *player = (PortAudioPlayer *) userData;
|
||||
|
||||
if (player->displayTimer)
|
||||
player->displayTimer->Stop();
|
||||
void PortAudioPlayer::paStreamFinishedCallback(void *) {
|
||||
LOG_D("audio/player/portaudio") << "stopping stream";
|
||||
}
|
||||
|
||||
|
@ -205,17 +201,10 @@ void PortAudioPlayer::Play(int64_t start_sample, int64_t count) {
|
|||
}
|
||||
}
|
||||
pa_start = Pa_GetStreamTime(stream);
|
||||
|
||||
// Update timer
|
||||
if (displayTimer && !displayTimer->IsRunning())
|
||||
displayTimer->Start(15);
|
||||
}
|
||||
|
||||
void PortAudioPlayer::Stop(bool timerToo) {
|
||||
void PortAudioPlayer::Stop() {
|
||||
Pa_StopStream(stream);
|
||||
|
||||
if (timerToo && displayTimer)
|
||||
displayTimer->Stop();
|
||||
}
|
||||
|
||||
int PortAudioPlayer::paCallback(const void *inputBuffer, void *outputBuffer,
|
||||
|
|
|
@ -111,7 +111,7 @@ public:
|
|||
void Play(int64_t start,int64_t count);
|
||||
/// @brief Stop Playback
|
||||
/// @param timerToo Stop display timer?
|
||||
void Stop(bool timerToo=true);
|
||||
void Stop();
|
||||
|
||||
/// @brief Whether audio is currently being played.
|
||||
/// @return Status
|
||||
|
|
|
@ -217,12 +217,9 @@ void PulseAudioPlayer::Play(int64_t start,int64_t count)
|
|||
paerror = pa_context_errno(context);
|
||||
printf("PulseAudio player: Error triggering stream: %s (%d)\n", pa_strerror(paerror), paerror);
|
||||
}
|
||||
|
||||
// Update timer
|
||||
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
||||
}
|
||||
|
||||
void PulseAudioPlayer::Stop(bool timerToo)
|
||||
void PulseAudioPlayer::Stop()
|
||||
{
|
||||
if (!is_playing) return;
|
||||
//printf("Stopping PulseAudio\n");
|
||||
|
@ -247,10 +244,6 @@ void PulseAudioPlayer::Stop(bool timerToo)
|
|||
|
||||
// And unref it
|
||||
//printf("Stopped stream\n\n");
|
||||
|
||||
if (timerToo && displayTimer) {
|
||||
displayTimer->Stop();
|
||||
}
|
||||
}
|
||||
|
||||
bool PulseAudioPlayer::IsPlaying()
|
||||
|
|
|
@ -131,7 +131,7 @@ public:
|
|||
void CloseStream();
|
||||
|
||||
void Play(int64_t start,int64_t count);
|
||||
void Stop(bool timerToo=true);
|
||||
void Stop();
|
||||
bool IsPlaying();
|
||||
|
||||
int64_t GetStartPosition();
|
||||
|
|
|
@ -36,12 +36,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#ifndef AGI_PRE
|
||||
#include <wx/event.h>
|
||||
#include <wx/thread.h>
|
||||
#include <wx/timer.h>
|
||||
#endif
|
||||
|
||||
#include "factory_manager.h"
|
||||
|
||||
class AudioProvider;
|
||||
|
@ -55,18 +49,15 @@ protected:
|
|||
/// DOCME
|
||||
AudioProvider *provider;
|
||||
|
||||
/// DOCME
|
||||
wxTimer *displayTimer;
|
||||
|
||||
public:
|
||||
AudioPlayer();
|
||||
virtual ~AudioPlayer();
|
||||
virtual ~AudioPlayer() { }
|
||||
|
||||
virtual void OpenStream()=0;
|
||||
virtual void CloseStream()=0;
|
||||
|
||||
virtual void Play(int64_t start,int64_t count)=0; // Play sample range
|
||||
virtual void Stop(bool timerToo=true)=0; // Stop playing
|
||||
virtual void Stop()=0; // Stop playing
|
||||
virtual bool IsPlaying()=0;
|
||||
|
||||
virtual void SetVolume(double volume)=0;
|
||||
|
|
Loading…
Reference in New Issue