mirror of
https://github.com/love2d/love.git
synced 2026-08-17 11:00:31 +02:00
made RecordingDevice create new SoundData every time captured samples are aquired
--HG-- branch : minor-mic-input
This commit is contained in:
@@ -102,8 +102,9 @@ int RecordingDevice::getData(love::sound::SoundData *soundData)
|
|||||||
if (samples == 0)
|
if (samples == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
//resize internal buffer to proper size
|
//reinitialize soundData if necessary
|
||||||
if (samples != soundData->getSampleCount())
|
if (samples != soundData->getSampleCount() || sampleRate != soundData->getSampleRate() ||
|
||||||
|
bitDepth != soundData->getBitDepth() || channels != soundData->getChannels())
|
||||||
soundData->load(samples, sampleRate, bitDepth, channels);
|
soundData->load(samples, sampleRate, bitDepth, channels);
|
||||||
|
|
||||||
alcCaptureSamples(device, soundData->getData(), samples);
|
alcCaptureSamples(device, soundData->getData(), samples);
|
||||||
|
|||||||
@@ -67,23 +67,8 @@ int w_RecordingDevice_stopRecording(lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
love::sound::SoundData *s = nullptr;
|
love::sound::SoundData *s = nullptr;
|
||||||
if (lua_gettop(L) > 1)
|
|
||||||
{
|
|
||||||
if (luax_istype(L, 2, SOUND_SOUND_DATA_ID))
|
|
||||||
s = luax_totype<love::sound::SoundData>(L, 2, SOUND_SOUND_DATA_ID);
|
|
||||||
else
|
|
||||||
return luaL_typerror(L, 2, "SoundData");
|
|
||||||
|
|
||||||
s->retain();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
luax_catchexcept(L, [&](){
|
|
||||||
s = soundInstance()->newSoundData(samples, d->getSampleRate(), d->getBitDepth(), d->getChannels());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
luax_catchexcept(L, [&](){
|
luax_catchexcept(L, [&](){
|
||||||
|
s = soundInstance()->newSoundData(samples, d->getSampleRate(), d->getBitDepth(), d->getChannels());
|
||||||
d->getData(s);
|
d->getData(s);
|
||||||
d->stopRecording();
|
d->stopRecording();
|
||||||
});
|
});
|
||||||
@@ -104,23 +89,10 @@ int w_RecordingDevice_getData(lua_State *L)
|
|||||||
}
|
}
|
||||||
|
|
||||||
love::sound::SoundData *s = nullptr;
|
love::sound::SoundData *s = nullptr;
|
||||||
if (lua_gettop(L) > 1)
|
luax_catchexcept(L, [&](){
|
||||||
{
|
s = soundInstance()->newSoundData(samples, d->getSampleRate(), d->getBitDepth(), d->getChannels());
|
||||||
if (luax_istype(L, 2, SOUND_SOUND_DATA_ID))
|
d->getData(s);
|
||||||
s = luax_totype<love::sound::SoundData>(L, 2, SOUND_SOUND_DATA_ID);
|
});
|
||||||
else
|
|
||||||
return luaL_typerror(L, 2, "SoundData");
|
|
||||||
|
|
||||||
s->retain();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
luax_catchexcept(L, [&](){
|
|
||||||
s = soundInstance()->newSoundData(samples, d->getSampleRate(), d->getBitDepth(), d->getChannels());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
luax_catchexcept(L, [&](){ d->getData(s); });
|
|
||||||
|
|
||||||
luax_pushtype(L, SOUND_SOUND_DATA_ID, s);
|
luax_pushtype(L, SOUND_SOUND_DATA_ID, s);
|
||||||
s->release();
|
s->release();
|
||||||
|
|||||||
Reference in New Issue
Block a user