mirror of https://github.com/bjornbytes/lovr.git
audio capture stubs
This commit is contained in:
parent
5c2e270c3f
commit
033817bd74
|
@ -76,6 +76,58 @@ static int l_lovrAudioSetListenerPose(lua_State *L) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrAudioGetCaptureDuration(lua_State *L) {
|
||||
TimeUnit units = luax_checkenum(L, 1, TimeUnit, "seconds");
|
||||
size_t sampleCount = lovrAudioGetCaptureSampleCount();
|
||||
|
||||
if (units == UNIT_SECONDS) {
|
||||
lua_pushnumber(L, (double) sampleCount / LOVR_AUDIO_SAMPLE_RATE);
|
||||
} else {
|
||||
lua_pushinteger(L, sampleCount);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrAudioCapture(lua_State* L) {
|
||||
int index = 1;
|
||||
|
||||
size_t samples = lua_type(L, index) == LUA_TNUMBER ? lua_tointeger(L, index++) : lovrAudioGetCaptureSampleCount();
|
||||
|
||||
if (samples == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SoundData* soundData = luax_totype(L, index++, SoundData);
|
||||
size_t offset = soundData ? luaL_optinteger(L, index, 0) : 0;
|
||||
|
||||
if (soundData) {
|
||||
lovrRetain(soundData);
|
||||
}
|
||||
|
||||
soundData = lovrAudioCapture(samples, soundData, offset);
|
||||
luax_pushtype(L, SoundData, soundData);
|
||||
lovrRelease(SoundData, soundData);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int l_lovrAudioSetCaptureDevice(lua_State *L) {
|
||||
//
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrAudioGetCaptureDevice(lua_State *L) {
|
||||
//
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int l_lovrAudioListCaptureDevices(lua_State *L) {
|
||||
//
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const luaL_Reg lovrAudio[] = {
|
||||
{ "reset", l_lovrAudioReset },
|
||||
{ "start", l_lovrAudioStart },
|
||||
|
@ -84,6 +136,11 @@ static const luaL_Reg lovrAudio[] = {
|
|||
{ "setVolume", l_lovrAudioSetVolume },
|
||||
{ "newSource", l_lovrAudioNewSource },
|
||||
{ "setListenerPose", l_lovrAudioSetListenerPose },
|
||||
{ "capture", l_lovrAudioCapture },
|
||||
{ "getCaptureDuration", l_lovrAudioGetCaptureDuration },
|
||||
{ "setCaptureDevice", l_lovrAudioSetCaptureDevice },
|
||||
{ "getCaptureDevice", l_lovrAudioGetCaptureDevice },
|
||||
{ "listCaptureDevices", l_lovrAudioListCaptureDevices },
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
|
|
@ -113,8 +113,7 @@ static void onPlayback(ma_device* device, void* output, const void* _, uint32_t
|
|||
}
|
||||
|
||||
static void onCapture(ma_device* device, void* output, const void* input, uint32_t frames) {
|
||||
ma_mutex_lock(&state.locks[1]);
|
||||
ma_mutex_unlock(&state.locks[1]);
|
||||
|
||||
}
|
||||
|
||||
static const ma_device_callback_proc callbacks[] = { onPlayback, onCapture };
|
||||
|
@ -340,3 +339,15 @@ void lovrSourceSetTime(Source* source, uint32_t time) {
|
|||
SoundData* lovrSourceGetSoundData(Source* source) {
|
||||
return source->sound;
|
||||
}
|
||||
|
||||
// Capture
|
||||
|
||||
uint32_t lovrAudioGetCaptureSampleCount()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
struct SoundData* lovrAudioCapture(uint32_t sampleCount, SoundData *soundData, uint32_t offset)
|
||||
{
|
||||
|
||||
}
|
|
@ -57,3 +57,6 @@ void lovrSourceSetPose(Source *source, float position[4], float orientation[4]);
|
|||
uint32_t lovrSourceGetTime(Source* source);
|
||||
void lovrSourceSetTime(Source* source, uint32_t sample);
|
||||
struct SoundData* lovrSourceGetSoundData(Source* source);
|
||||
|
||||
uint32_t lovrAudioGetCaptureSampleCount();
|
||||
struct SoundData* lovrAudioCapture(uint32_t sampleCount, struct SoundData *soundData, uint32_t offset);
|
Loading…
Reference in New Issue