forked from mia/Aegisub
More complete error checking in new DSound player, shouldn't crash/die on errors now.
Originally committed to SVN as r2496.
This commit is contained in:
parent
a6c169a4b2
commit
735ce2385e
|
@ -623,20 +623,38 @@ DirectSoundPlayer2::~DirectSoundPlayer2()
|
||||||
void DirectSoundPlayer2::OpenStream()
|
void DirectSoundPlayer2::OpenStream()
|
||||||
{
|
{
|
||||||
if (thread) return;
|
if (thread) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
thread = new DirectSoundPlayer2Thread(GetProvider());
|
thread = new DirectSoundPlayer2Thread(GetProvider());
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
thread = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSoundPlayer2::CloseStream()
|
void DirectSoundPlayer2::CloseStream()
|
||||||
{
|
{
|
||||||
if (!thread) return;
|
if (!thread) return;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
delete thread;
|
delete thread;
|
||||||
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
}
|
||||||
thread = 0;
|
thread = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSoundPlayer2::SetProvider(AudioProvider *provider)
|
void DirectSoundPlayer2::SetProvider(AudioProvider *provider)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (thread && provider != GetProvider())
|
if (thread && provider != GetProvider())
|
||||||
{
|
{
|
||||||
|
@ -646,18 +664,32 @@ void DirectSoundPlayer2::SetProvider(AudioProvider *provider)
|
||||||
|
|
||||||
AudioPlayer::SetProvider(provider);
|
AudioPlayer::SetProvider(provider);
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSoundPlayer2::Play(int64_t start,int64_t count)
|
void DirectSoundPlayer2::Play(int64_t start,int64_t count)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
OpenStream();
|
OpenStream();
|
||||||
thread->Play(start, count);
|
thread->Play(start, count);
|
||||||
|
|
||||||
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
if (displayTimer && !displayTimer->IsRunning()) displayTimer->Start(15);
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSoundPlayer2::Stop(bool timerToo)
|
void DirectSoundPlayer2::Stop(bool timerToo)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (thread) thread->Stop();
|
if (thread) thread->Stop();
|
||||||
|
|
||||||
|
@ -665,59 +697,125 @@ void DirectSoundPlayer2::Stop(bool timerToo)
|
||||||
displayTimer->Stop();
|
displayTimer->Stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool DirectSoundPlayer2::IsPlaying()
|
bool DirectSoundPlayer2::IsPlaying()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!thread) return false;
|
if (!thread) return false;
|
||||||
return thread->IsPlaying();
|
return thread->IsPlaying();
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t DirectSoundPlayer2::GetStartPosition()
|
int64_t DirectSoundPlayer2::GetStartPosition()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!thread) return 0;
|
if (!thread) return 0;
|
||||||
return thread->GetStartFrame();
|
return thread->GetStartFrame();
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t DirectSoundPlayer2::GetEndPosition()
|
int64_t DirectSoundPlayer2::GetEndPosition()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!thread) return 0;
|
if (!thread) return 0;
|
||||||
return thread->GetEndFrame();
|
return thread->GetEndFrame();
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int64_t DirectSoundPlayer2::GetCurrentPosition()
|
int64_t DirectSoundPlayer2::GetCurrentPosition()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!thread) return 0;
|
if (!thread) return 0;
|
||||||
return thread->GetCurrentFrame();
|
return thread->GetCurrentFrame();
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSoundPlayer2::SetEndPosition(int64_t pos)
|
void DirectSoundPlayer2::SetEndPosition(int64_t pos)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (thread) thread->SetEndFrame(pos);
|
if (thread) thread->SetEndFrame(pos);
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSoundPlayer2::SetCurrentPosition(int64_t pos)
|
void DirectSoundPlayer2::SetCurrentPosition(int64_t pos)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (thread) thread->Play(pos, thread->GetEndFrame()-pos);
|
if (thread) thread->Play(pos, thread->GetEndFrame()-pos);
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DirectSoundPlayer2::SetVolume(double vol)
|
void DirectSoundPlayer2::SetVolume(double vol)
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (thread) thread->SetVolume(vol);
|
if (thread) thread->SetVolume(vol);
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
double DirectSoundPlayer2::GetVolume()
|
double DirectSoundPlayer2::GetVolume()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
if (!thread) return 0;
|
if (!thread) return 0;
|
||||||
return thread->GetVolume();
|
return thread->GetVolume();
|
||||||
}
|
}
|
||||||
|
catch (const wxChar *msg)
|
||||||
|
{
|
||||||
|
wxLogError(msg);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // WITH_DIRECTSOUND
|
#endif // WITH_DIRECTSOUND
|
||||||
|
|
Loading…
Reference in a new issue