Throw agi::Exception derived exceptions from the OSS player rather than bare strings

Originally committed to SVN as r5916.
This commit is contained in:
Thomas Goyne 2011-11-25 19:30:42 +00:00
parent 4b51c34497
commit e5e159d6b1
2 changed files with 9 additions and 5 deletions

View file

@ -81,7 +81,7 @@ void OSSPlayer::OpenStream()
wxString device = lagi_wxString(OPT_GET("Audio/OSS/Device")->GetString()); wxString device = lagi_wxString(OPT_GET("Audio/OSS/Device")->GetString());
dspdev = ::open(device.mb_str(wxConvUTF8), O_WRONLY, 0); dspdev = ::open(device.mb_str(wxConvUTF8), O_WRONLY, 0);
if (dspdev < 0) { if (dspdev < 0) {
throw "OSS player: opening device failed"; throw OSSError("OSS player: opening device failed");
} }
// Use a reasonable buffer policy for low latency (OSS4) // Use a reasonable buffer policy for low latency (OSS4)
@ -93,7 +93,7 @@ void OSSPlayer::OpenStream()
// Set number of channels // Set number of channels
int channels = provider->GetChannels(); int channels = provider->GetChannels();
if (ioctl(dspdev, SNDCTL_DSP_CHANNELS, &channels) < 0) { if (ioctl(dspdev, SNDCTL_DSP_CHANNELS, &channels) < 0) {
throw "OSS player: setting channels failed"; throw OSSError("OSS player: setting channels failed");
} }
// Set sample format // Set sample format
@ -106,17 +106,17 @@ void OSSPlayer::OpenStream()
sample_format = AFMT_S16_LE; sample_format = AFMT_S16_LE;
break; break;
default: default:
throw "OSS player: can only handle 8 and 16 bit sound"; throw OSSError("OSS player: can only handle 8 and 16 bit sound");
} }
if (ioctl(dspdev, SNDCTL_DSP_SETFMT, &sample_format) < 0) { if (ioctl(dspdev, SNDCTL_DSP_SETFMT, &sample_format) < 0) {
throw "OSS player: setting sample format failed"; throw OSSError("OSS player: setting sample format failed");
} }
// Set sample rate // Set sample rate
rate = provider->GetSampleRate(); rate = provider->GetSampleRate();
if (ioctl(dspdev, SNDCTL_DSP_SPEED, &rate) < 0) { if (ioctl(dspdev, SNDCTL_DSP_SPEED, &rate) < 0) {
throw("OSS player: setting samplerate failed"); throw OSSError("OSS player: setting samplerate failed");
} }
// Now ready // Now ready

View file

@ -51,6 +51,10 @@
#include "include/aegisub/audio_player.h" #include "include/aegisub/audio_player.h"
#include "include/aegisub/audio_provider.h" #include "include/aegisub/audio_provider.h"
#include <libaegisub/exception.h>
DEFINE_SIMPLE_EXCEPTION_NOINNER(OSSError, agi::Exception, "audio/player/oss")
class OSSPlayer; class OSSPlayer;
/// DOCME /// DOCME