mirror of
https://github.com/love2d/love.git
synced 2026-08-17 02:58:31 +02:00
made :getData produce SoundData directly
moved SoundData::load back to private --HG-- branch : minor-mic-input
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "RecordingDevice.h"
|
||||
#include "Audio.h"
|
||||
#include "sound/Sound.h"
|
||||
|
||||
namespace love
|
||||
{
|
||||
@@ -28,6 +29,8 @@ namespace audio
|
||||
namespace openal
|
||||
{
|
||||
|
||||
#define soundInstance() (Module::getInstance<love::sound::Sound>(Module::M_SOUND))
|
||||
|
||||
class InvalidFormatException : public love::Exception
|
||||
{
|
||||
public:
|
||||
@@ -99,23 +102,20 @@ void RecordingDevice::stopRecording()
|
||||
device = nullptr;
|
||||
}
|
||||
|
||||
int RecordingDevice::getData(love::sound::SoundData *soundData)
|
||||
love::sound::SoundData *RecordingDevice::getData()
|
||||
{
|
||||
if (!isRecording())
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
int samples = getSampleCount();
|
||||
if (samples == 0)
|
||||
return 0;
|
||||
return nullptr;
|
||||
|
||||
//reinitialize soundData if necessary
|
||||
if (samples != soundData->getSampleCount() || sampleRate != soundData->getSampleRate() ||
|
||||
bitDepth != soundData->getBitDepth() || channels != soundData->getChannels())
|
||||
soundData->load(samples, sampleRate, bitDepth, channels);
|
||||
love::sound::SoundData *soundData = soundInstance()->newSoundData(samples, sampleRate, bitDepth, channels);
|
||||
|
||||
alcCaptureSamples(device, soundData->getData(), samples);
|
||||
|
||||
return samples;
|
||||
return soundData;
|
||||
}
|
||||
|
||||
int RecordingDevice::getSampleCount() const
|
||||
|
||||
@@ -52,7 +52,7 @@ public:
|
||||
virtual bool startRecording();
|
||||
virtual bool startRecording(int samples, int sampleRate, int bitDepth, int channels);
|
||||
virtual void stopRecording();
|
||||
virtual int getData(love::sound::SoundData *soundData);
|
||||
virtual love::sound::SoundData *getData();
|
||||
virtual const char *getName() const;
|
||||
virtual int getID() const;
|
||||
virtual int getSampleCount() const;
|
||||
|
||||
Reference in New Issue
Block a user