Skip to content

Commit

Permalink
Remove unnecessary arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
bkacjios committed Jan 3, 2025
1 parent 54bee63 commit 1111af6
Show file tree
Hide file tree
Showing 8 changed files with 245 additions and 196 deletions.
20 changes: 10 additions & 10 deletions mumble/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ static void handle_audio_stream_end(lua_State *l, MumbleClient *client, AudioStr
sound->loop_count--;
} else {
mumble_registry_pushref(l, client->audio_streams, sound->refrence);
mumble_hook_call(l, client, "OnAudioStreamEnd", 1);
mumble_hook_call(client, "OnAudioStreamEnd", 1);
audio_transmission_unreference(l, sound);
}
}
Expand Down Expand Up @@ -313,7 +313,7 @@ static void audio_transmission_bitrate_warning(MumbleClient *client, size_t leng
mumble_log(LOG_WARN, "Audio packet length %u greater than maximum of %u, stopping all audio streams. Try reducing the bitrate.", length, UDP_BUFFER_MAX);
}

static void send_legacy_audio(lua_State *l, MumbleClient *client, uint8_t *encoded, opus_int32 encoded_len, bool end_frame) {
static void send_legacy_audio(MumbleClient *client, uint8_t *encoded, opus_int32 encoded_len, bool end_frame) {
uint32_t frame_header = encoded_len;
if (end_frame) {
frame_header |= (1 << 13);
Expand Down Expand Up @@ -342,10 +342,10 @@ static void send_legacy_audio(lua_State *l, MumbleClient *client, uint8_t *encod
packet_sendudp(client, packet_buffer, len);
}

mumble_handle_speaking_hooks_legacy(l, client, packet_buffer + 1, LEGACY_UDP_OPUS, client->audio_target, client->session);
mumble_handle_speaking_hooks_legacy(client, packet_buffer + 1, LEGACY_UDP_OPUS, client->audio_target, client->session);
}

static void send_protobuf_audio(lua_State *l, MumbleClient *client, uint8_t *encoded, opus_int32 encoded_len, bool end_frame) {
static void send_protobuf_audio(MumbleClient *client, uint8_t *encoded, opus_int32 encoded_len, bool end_frame) {
MumbleUDP__Audio audio = MUMBLE_UDP__AUDIO__INIT;
ProtobufCBinaryData audio_data = { .data = encoded, .len = (size_t)encoded_len };

Expand Down Expand Up @@ -375,19 +375,19 @@ static void send_protobuf_audio(lua_State *l, MumbleClient *client, uint8_t *enc
packet_sendudp(client, packet_buffer, len);
}

mumble_handle_speaking_hooks_protobuf(l, client, &audio, client->session);
mumble_handle_speaking_hooks_protobuf(client, &audio, client->session);
}

static void encode_and_send_audio(lua_State *l, MumbleClient *client, sf_count_t frame_size, bool end_frame) {
static void encode_and_send_audio(MumbleClient *client, sf_count_t frame_size, bool end_frame) {
uint8_t encoded[PAYLOAD_SIZE_MAX];
opus_int32 encoded_len = opus_encode_float(client->encoder, (float *)client->audio_output, frame_size, encoded, PAYLOAD_SIZE_MAX);

if (encoded_len <= 0) return;

if (client->legacy) {
send_legacy_audio(l, client, encoded, encoded_len, end_frame);
send_legacy_audio(client, encoded, encoded_len, end_frame);
} else {
send_protobuf_audio(l, client, encoded, encoded_len, end_frame);
send_protobuf_audio(client, encoded, encoded_len, end_frame);
}

client->audio_sequence++;
Expand Down Expand Up @@ -416,7 +416,7 @@ void audio_transmission_event(lua_State *l, MumbleClient *client) {
lua_pushinteger(l, AUDIO_SAMPLE_RATE);
lua_pushinteger(l, AUDIO_PLAYBACK_CHANNELS);
lua_pushinteger(l, frame_size);
mumble_hook_call(l, client, "OnAudioStream", 3);
mumble_hook_call(client, "OnAudioStream", 3);

// Keep track of when an audio buffer is outputting data
static bool stream_active = false;
Expand Down Expand Up @@ -467,7 +467,7 @@ void audio_transmission_event(lua_State *l, MumbleClient *client) {

if (biggest_read > 0 || end_frame) {
// Encode and transmit until the end
encode_and_send_audio(l, client, frame_size, end_frame);
encode_and_send_audio(client, frame_size, end_frame);
}

stream_active = streamed_audio;
Expand Down
14 changes: 7 additions & 7 deletions mumble/channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static int channel_remove(lua_State *l) {

static int channel_getClient(lua_State *l) {
MumbleChannel *channel = luaL_checkudata(l, 1, METATABLE_CHAN);
mumble_client_raw_get(l, channel->client);
mumble_client_raw_get(channel->client);
return 1;
}

Expand All @@ -79,7 +79,7 @@ static int channel_getParent(lua_State *l) {
return 1;
}

mumble_channel_raw_get(l, channel->client, channel->parent);
mumble_channel_raw_get(channel->client, channel->parent);
return 1;
}

Expand All @@ -94,7 +94,7 @@ static int channel_getChildren(lua_State *l) {
MumbleChannel *chan = current->data;
if (chan->channel_id != chan->parent && chan->parent == channel->channel_id) {
lua_pushinteger(l, i++);
mumble_channel_raw_get(l, channel->client, current->index);
mumble_channel_raw_get(channel->client, current->index);
lua_settable(l, -3);
}
current = current->next;
Expand All @@ -112,7 +112,7 @@ static int channel_getUsers(lua_State *l) {
while (current != NULL) {
if (current->index == channel->channel_id) {
lua_pushinteger(l, i++);
mumble_user_raw_get(l, channel->client, current->index);
mumble_user_raw_get(channel->client, current->index);
lua_settable(l, -3);
}
current = current->next;
Expand Down Expand Up @@ -289,7 +289,7 @@ static int channel_getLinks(lua_State *l) {
// Add all linked channels to the table
while (current != NULL) {
lua_pushinteger(l, current->index);
mumble_channel_raw_get(l, channel->client, current->index);
mumble_channel_raw_get(channel->client, current->index);
lua_settable(l, -3);

current = current->next;
Expand Down Expand Up @@ -377,7 +377,7 @@ int channel_call(lua_State *l) {
if (strcmp(pch, ".") == 0) {
current = channel;
} else if (strcmp(pch, "..") == 0) {
mumble_channel_raw_get(l, channel->client, channel->parent);
mumble_channel_raw_get(channel->client, channel->parent);
current = lua_touserdata(l, -1);
lua_remove(l, -2);
} else {
Expand All @@ -400,7 +400,7 @@ int channel_call(lua_State *l) {
pch = strtok(NULL, "/\\");
}

mumble_channel_raw_get(l, channel->client, channel->channel_id);
mumble_channel_raw_get(channel->client, channel->channel_id);
return 1;
}

Expand Down
18 changes: 9 additions & 9 deletions mumble/client.c
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ static int client_setTokens(lua_State *l) {

static int client_disconnect(lua_State *l) {
MumbleClient *client = mumble_client_connecting(l, 1);
mumble_disconnect(l, client, "connection closed by client", false);
mumble_disconnect(client, "connection closed by client", false);
return 0;
}

Expand Down Expand Up @@ -273,7 +273,7 @@ static int client_transmit(lua_State *l) {
voicepacket_setheader(&packet, codec, client->audio_target, client->audio_sequence);
voicepacket_setframe(&packet, codec, frame_header, output, outputlen);

mumble_handle_speaking_hooks_legacy(l, client, packet.buffer + 1, codec, client->audio_target, client->session);
mumble_handle_speaking_hooks_legacy(client, packet.buffer + 1, codec, client->audio_target, client->session);

if (client->tcp_udp_tunnel) {
packet_sendex(client, PACKET_UDPTUNNEL, packet_buffer, NULL, voicepacket_getlength(&packet));
Expand Down Expand Up @@ -301,7 +301,7 @@ static int client_transmit(lua_State *l) {

int len = 1 + mumble_udp__audio__pack(&audio, packet_buffer + 1);

mumble_handle_speaking_hooks_protobuf(l, client, &audio, client->session);
mumble_handle_speaking_hooks_protobuf(client, &audio, client->session);

if (client->tcp_udp_tunnel) {
packet_sendex(client, PACKET_UDPTUNNEL, packet_buffer, NULL, len);
Expand Down Expand Up @@ -495,7 +495,7 @@ static int client_call(lua_State *l) {
MumbleClient *client = luaL_checkudata(l, 1, METATABLE_CLIENT);
const char* hook = luaL_checkstring(l, 2);
int nargs = lua_gettop(l) - 2;
return mumble_hook_call_ret(l, client, hook, nargs, LUA_MULTRET);
return mumble_hook_call_ret(client, hook, nargs, LUA_MULTRET);
}

static int client_getHooks(lua_State *l) {
Expand All @@ -513,7 +513,7 @@ static int client_getUsers(lua_State *l) {

while (current != NULL) {
lua_pushinteger(l, i++);
mumble_user_raw_get(l, client, current->index);
mumble_user_raw_get(client, current->index);
lua_settable(l, -3);
current = current->next;
}
Expand All @@ -529,7 +529,7 @@ static int client_getChannels(lua_State *l) {

while (current != NULL) {
lua_pushinteger(l, i++);
mumble_channel_raw_get(l, client, current->index);
mumble_channel_raw_get(client, current->index);
lua_settable(l, -3);
current = current->next;
}
Expand Down Expand Up @@ -919,7 +919,7 @@ static int client_createAudioBuffer(lua_State *l) {

static int client_getMe(lua_State *l) {
MumbleClient *client = luaL_checkudata(l, 1, METATABLE_CLIENT);
mumble_user_raw_get(l, client, client->session);
mumble_user_raw_get(client, client->session);
return 1;
}

Expand All @@ -931,7 +931,7 @@ static int client_isTunnelingUDP(lua_State *l) {

static int client_gc(lua_State *l) {
MumbleClient *client = luaL_checkudata(l, 1, METATABLE_CLIENT);
mumble_disconnect(l, client, "garbage collected", true);
mumble_disconnect(client, "garbage collected", true);

mumble_unref(l, client->hooks);
mumble_unref(l, client->users);
Expand All @@ -957,7 +957,7 @@ static int client_index(lua_State *l) {
MumbleClient *client = luaL_checkudata(l, 1, METATABLE_CLIENT);

if (strcmp(lua_tostring(l, 2), "me") == 0 && client->session) {
mumble_user_raw_get(l, client, client->session);
mumble_user_raw_get(client, client->session);
return 1;
} else if (strcmp(lua_tostring(l, 2), "host") == 0 && client->host) {
lua_pushstring(l, client->host);
Expand Down
Loading

0 comments on commit 1111af6

Please sign in to comment.