]> git.tdb.fi Git - libs/al.git/commitdiff
Use standard exception classes
authorMikko Rasa <tdb@tdb.fi>
Sat, 17 Nov 2012 21:29:56 +0000 (23:29 +0200)
committerMikko Rasa <tdb@tdb.fi>
Sat, 17 Nov 2012 21:29:56 +0000 (23:29 +0200)
source/context.cpp
source/device.cpp
source/jukebox.cpp
source/sound.cpp

index 14f607cdd9778a6cdcb87bef5aaadc43c9ed5057..4c9b77cd23300bbbaefbf805057b012095ac227e 100644 (file)
@@ -1,4 +1,4 @@
-#include <msp/core/except.h>
+#include <stdexcept>
 #include "context.h"
 #include "device.h"
 
@@ -9,7 +9,7 @@ Context::Context(Device &dev)
 {
        context = alcCreateContext(dev.get_device(), 0);
        if(!context)
-               throw Exception("Couldn't create OpenAL context");
+               throw std::runtime_error("Couldn't create OpenAL context");
 
        alcMakeContextCurrent(context);
 }
index 63e87a98dbe509febd59ba665f60be05ae7c9e56..c866b32f704e620c5c331dc6b34182e84e6b8f48 100644 (file)
@@ -1,4 +1,4 @@
-#include <msp/core/except.h>
+#include <stdexcept>
 #include "device.h"
 
 using namespace std;
@@ -10,14 +10,14 @@ Device::Device()
 {
        dev = alcOpenDevice(0);
        if(!dev)
-               throw Exception("Couldn't get OpenAL device");
+               throw runtime_error("Couldn't get OpenAL device");
 }
 
 Device::Device(const string &spec)
 {
        dev = alcOpenDevice(spec.c_str());
        if(!dev)
-               throw Exception("Couldn't get OpenAL device");
+               throw runtime_error("Couldn't get OpenAL device");
 }
 
 Device::~Device()
index da2bcbbd4663907dfde24430b98c5bdf87319dad..d2a997d4cfffcf35f61f7e020183665b837f1492 100644 (file)
@@ -1,6 +1,6 @@
 #include <algorithm>
 #include <cstdlib>
-#include <msp/core/except.h>
+#include <stdexcept>
 #include "jukebox.h"
 #include "sound.h"
 
@@ -56,7 +56,7 @@ void Jukebox::clear_tracks()
 const string &Jukebox::get_current_track() const
 {
        if(tracks.empty())
-               throw InvalidState("No current track");
+               throw logic_error("No current track");
        return *current_track;
 }
 
index 947f6d17c1684fcab1f0422e26bf8978d90dcd84..f43948e65030b9d5041881ec8966171ca9eb08d9 100644 (file)
@@ -1,5 +1,5 @@
 #include <cstring>
-#include <msp/core/except.h>
+#include <stdexcept>
 #include "sound.h"
 
 using namespace std;
@@ -81,9 +81,9 @@ Sound::~Sound()
 void Sound::open_file(const string &fn)
 {
        if(ovfile.datasource)
-               throw InvalidState("Sound has already been opened");
+               throw logic_error("Sound has already been opened");
        if(ov_fopen(const_cast<char *>(fn.c_str()), &ovfile)<0)
-               throw Exception("Could not open ogg vorbis file "+fn);
+               throw runtime_error("Could not open ogg vorbis file "+fn);
 
        open_common();
 }
@@ -91,13 +91,13 @@ void Sound::open_file(const string &fn)
 void Sound::open_memory(const void *d, unsigned len)
 {
        if(ovfile.datasource)
-               throw InvalidState("Sound has already been opened");
+               throw logic_error("Sound has already been opened");
 
        MemorySource *src = new MemorySource(d, len);
        if(ov_open_callbacks(src, &ovfile, 0, 0, memory_callbacks)<0)
        {
                delete src;
-               throw Exception("Could not open ogg vorbis memory block");
+               throw runtime_error("Could not open ogg vorbis memory block");
        }
 
        open_common();
@@ -106,7 +106,7 @@ void Sound::open_memory(const void *d, unsigned len)
 void Sound::load_data()
 {
        if(data)
-               throw InvalidState("Data has already been loaded");
+               throw logic_error("Data has already been loaded");
 
        size = ov_pcm_total(&ovfile, 0)*4;
        char *dptr = new char[size];
@@ -160,19 +160,19 @@ unsigned Sound::read(char *buf, unsigned len)
                int section = 0;
                int res = ov_read(&ovfile, buf, len, 0, 2, 1, &section);
                if(res<0)
-                       throw Exception("Error reading ogg vorbis file");
+                       throw runtime_error("Error reading ogg vorbis file");
                else if(res==0)
                        eof_flag = true;
                return res;
        }
        else
-               throw InvalidState("No data available");
+               throw logic_error("No data available");
 }
 
 const char *Sound::get_data() const
 {
        if(!data)
-               throw InvalidState("Data has not been loaded");
+               throw logic_error("Data has not been loaded");
        return data;
 }
 
@@ -187,7 +187,7 @@ void Sound::open_common()
        {
        case 1: format = MONO16; break;
        case 2: format = STEREO16; break;
-       default: throw Exception("Unsupported number of channels");
+       default: throw runtime_error("Unsupported number of channels");
        }
 }