RecordingDevice:start has default arguments (resolves issue #1296).

--HG--
branch : minor
This commit is contained in:
Alex Szpakowski
2017-07-28 18:53:54 -03:00
parent 7fa8fe7572
commit b19a8ab67e
6 changed files with 28 additions and 40 deletions
+5 -11
View File
@@ -56,19 +56,8 @@ RecordingDevice::~RecordingDevice()
alcCaptureCloseDevice(device);
}
bool RecordingDevice::start()
{
return start(samples, sampleRate, bitDepth, channels);
}
bool RecordingDevice::start(int samples, int sampleRate, int bitDepth, int channels)
{
if (isRecording())
{
alcCaptureStop(device);
alcCaptureCloseDevice(device);
}
ALenum format = Audio::getFormat(bitDepth, channels);
if (format == AL_NONE)
throw InvalidFormatException(channels, bitDepth);
@@ -79,15 +68,20 @@ bool RecordingDevice::start(int samples, int sampleRate, int bitDepth, int chann
if (sampleRate <= 0)
throw love::Exception("Invalid sample rate.");
if (isRecording())
stop();
device = alcCaptureOpenDevice(name.c_str(), sampleRate, format, samples);
if (device == nullptr)
return false;
alcCaptureStart(device);
this->samples = samples;
this->sampleRate = sampleRate;
this->bitDepth = bitDepth;
this->channels = channels;
return true;
}
+8 -5
View File
@@ -49,9 +49,9 @@ namespace openal
class RecordingDevice : public love::audio::RecordingDevice
{
public:
RecordingDevice(const char *name);
virtual ~RecordingDevice();
virtual bool start();
virtual bool start(int samples, int sampleRate, int bitDepth, int channels);
virtual void stop();
virtual love::sound::SoundData *getData();
@@ -63,12 +63,15 @@ public:
virtual bool isRecording() const;
private:
int samples = 8192;
int sampleRate = 8000;
int bitDepth = 16;
int channels = 1;
int samples = 0;
int sampleRate = 0;
int bitDepth = 0;
int channels = 0;
std::string name;
ALCdevice *device = nullptr;
}; //RecordingDevice
} //openal