bug: Fix version incompatibility
Even between minor versions, Lua simply removes or renames functions.
This commit is contained in:
parent
d10b61eaf9
commit
862a265a70
4 changed files with 16 additions and 8 deletions
|
@ -1,6 +1,7 @@
|
|||
#include "context.h"
|
||||
|
||||
#include "pulseaudio.h"
|
||||
#include "lua_util.h"
|
||||
|
||||
#include <pulse/context.h>
|
||||
#include <pulse/error.h>
|
||||
|
@ -196,7 +197,7 @@ int context_subscribe(lua_State* L) {
|
|||
lua_pa_context* ctx = luaL_checkudata(L, 1, LUA_PA_CONTEXT);
|
||||
luaL_checktype(L, 2, LUA_TFUNCTION);
|
||||
|
||||
size_t pos = lua_objlen(ctx->event_callback_data->L, 1) + 1;
|
||||
size_t pos = lua_rawlen(ctx->event_callback_data->L, 1) + 1;
|
||||
// Duplicate the callback function, so we can move it over to the other thread
|
||||
lua_pushvalue(L, 2);
|
||||
lua_xmove(L, ctx->event_callback_data->L, 1);
|
||||
|
@ -211,7 +212,7 @@ int context_unsubscribe(lua_State* L) {
|
|||
lua_pa_context* ctx = luaL_checkudata(L, 1, LUA_PA_CONTEXT);
|
||||
lua_State* thread_L = ctx->event_callback_data->L;
|
||||
size_t pos = 0;
|
||||
size_t len = lua_objlen(thread_L, 1);
|
||||
size_t len = lua_rawlen(thread_L, 1);
|
||||
|
||||
if (len == 0) {
|
||||
return 0;
|
||||
|
|
|
@ -55,7 +55,7 @@ void sink_info_callback(pa_context* c, const pa_sink_info* info, int eol, void*
|
|||
|
||||
if (data->is_list) {
|
||||
if (!eol) {
|
||||
int i = lua_objlen(L, 2);
|
||||
int i = lua_rawlen(L, 2);
|
||||
lua_pushinteger(L, i + 1);
|
||||
sink_info_to_lua(L, info);
|
||||
lua_settable(L, 2);
|
||||
|
@ -446,7 +446,7 @@ void source_info_callback(pa_context* c, const pa_source_info* info, int eol, vo
|
|||
|
||||
if (data->is_list) {
|
||||
if (!eol) {
|
||||
int i = lua_objlen(L, 2);
|
||||
int i = lua_rawlen(L, 2);
|
||||
lua_pushinteger(L, i + 1);
|
||||
source_info_to_lua(L, info);
|
||||
lua_settable(L, 2);
|
||||
|
@ -827,7 +827,7 @@ void sink_input_info_callback(pa_context* c, const pa_sink_input_info* info, int
|
|||
|
||||
if (data->is_list) {
|
||||
if (!eol) {
|
||||
int i = lua_objlen(L, 2);
|
||||
int i = lua_rawlen(L, 2);
|
||||
lua_pushinteger(L, i + 1);
|
||||
sink_input_info_to_lua(L, info);
|
||||
lua_settable(L, 2);
|
||||
|
@ -1100,7 +1100,7 @@ void source_output_info_callback(pa_context* c, const pa_source_output_info* inf
|
|||
|
||||
if (data->is_list) {
|
||||
if (!eol) {
|
||||
int i = lua_objlen(L, 2);
|
||||
int i = lua_rawlen(L, 2);
|
||||
lua_pushinteger(L, i + 1);
|
||||
source_output_info_to_lua(L, info);
|
||||
lua_settable(L, 2);
|
||||
|
|
|
@ -6,6 +6,13 @@
|
|||
|
||||
#define LUA_MOD_EXPORT extern
|
||||
|
||||
#if LUA_VERSION_NUM <= 501
|
||||
#define lua_rawlen lua_objlen
|
||||
#endif
|
||||
|
||||
#if LUA_VERSION_NUM > 501
|
||||
#define lua_equal(L, i1, i2) lua_compare(L, i1, i2, LUA_OPEQ)
|
||||
#endif
|
||||
|
||||
typedef struct luaU_enumfield {
|
||||
const char* name;
|
||||
|
|
|
@ -35,7 +35,7 @@ int volume_to_lua(lua_State* L, const pa_cvolume* pa_volume) {
|
|||
pa_cvolume* volume_from_lua(lua_State* L, int index) {
|
||||
switch (lua_type(L, index)) {
|
||||
case LUA_TTABLE: {
|
||||
uint8_t channels = (uint8_t) lua_objlen(L, index);
|
||||
uint8_t channels = (uint8_t) lua_rawlen(L, index);
|
||||
if (channels > PA_CHANNELS_MAX) {
|
||||
channels = PA_CHANNELS_MAX;
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ int volume__eq(lua_State* L) {
|
|||
|
||||
int volume__index(lua_State* L) {
|
||||
volume_t* volume = luaL_checkudata(L, 1, LUA_PA_VOLUME);
|
||||
int index = luaL_checkint(L, 2);
|
||||
int index = (int) luaL_checkinteger(L, 2);
|
||||
luaL_argcheck(L, index >= 1 && index <= (PA_CHANNELS_MAX + 1), 2, "channel index out of bounds");
|
||||
lua_pushinteger(L, volume->inner.values[index - 1]);
|
||||
return 1;
|
||||
|
|
Loading…
Add table
Reference in a new issue