mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
RecordingDevice:start has default arguments (resolves issue #1296).
--HG-- branch : minor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user