summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-28 13:29:58 +0200
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2011-05-28 14:22:40 +0200
commit06a8e0630cae8b106a9df2f96a00d4ba4a8a76f2 (patch)
tree77e76b1d9032149bf9932e30b8a91f6ebc639706
parentf715439457f7b25445eca4297309b3e878f16b41 (diff)
downloadcmumble-06a8e0630cae8b106a9df2f96a00d4ba4a8a76f2.tar.gz
cmumble-06a8e0630cae8b106a9df2f96a00d4ba4a8a76f2.tar.bz2
cmumble-06a8e0630cae8b106a9df2f96a00d4ba4a8a76f2.zip
cleanup
-rw-r--r--src/cmumble.c34
-rw-r--r--src/varint.c2
2 files changed, 12 insertions, 24 deletions
diff --git a/src/cmumble.c b/src/cmumble.c
index 657cb2a..a629fd5 100644
--- a/src/cmumble.c
+++ b/src/cmumble.c
@@ -8,16 +8,14 @@
static struct user *
find_user(struct context *ctx, uint32_t session)
{
- struct user *user = NULL, *tmp;
+ struct user *user = NULL;
GList *l;
- for (l = ctx->users; l; l = l->next) {
- tmp = l->data;
- if (tmp->session == session) {
- user = tmp;
+ for (l = ctx->users; l; l = l->next)
+ if (((struct user *) l->data)->session == session) {
+ user = l->data;
break;
}
- }
return user;
}
@@ -27,28 +25,24 @@ appsrc_push(GstAppSrc *src, const void *mem, size_t size)
{
GstBuffer *gstbuf;
- gstbuf = gst_app_buffer_new(g_memdup(mem, size), size,
- g_free, NULL);
+ gstbuf = gst_app_buffer_new(g_memdup(mem, size), size, g_free, NULL);
gst_app_src_push_buffer(src, gstbuf);
}
-
static GstFlowReturn
pull_buffer(GstAppSink *sink, gpointer user_data)
{
struct context *ctx = user_data;
GstBuffer *buf;
uint8_t data[1024];
- uint32_t write = 0;
- uint32_t pos = 0;
+ uint32_t write = 0, pos = 0;
GOutputStream *output = g_io_stream_get_output_stream(ctx->iostream);
MumbleProto__UDPTunnel tunnel;
static int seq = 0;
buf = gst_app_sink_pull_buffer(ctx->sink);
- ++seq;
- if (seq <= 2) {
+ if (++seq <= 2) {
gst_buffer_unref(buf);
return GST_FLOW_OK;
}
@@ -79,10 +73,8 @@ pull_buffer(GstAppSink *sink, gpointer user_data)
static void
recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct context *ctx)
{
- int64_t session;
- int64_t sequence;
- uint32_t pos = 1;
- uint32_t read = 0;
+ int64_t session, sequence;
+ uint32_t pos = 1, read = 0;
uint8_t frame_len, terminator;
struct user *user = NULL;
uint8_t *data = tunnel->packet.data;
@@ -134,7 +126,6 @@ recv_server_sync(MumbleProto__ServerSync *sync, struct context *ctx)
ctx->session = sync->session;
printf("got session: %d\n", ctx->session);
-
}
static void
@@ -147,21 +138,18 @@ recv_crypt_setup(MumbleProto__CryptSetup *crypt, struct context *ctx)
for (i = 0; i < crypt->key.len; ++i)
printf("%x", crypt->key.data[i]);
printf("\n");
-
}
if (crypt->has_client_nonce) {
printf("client nonce: 0x");
for (i = 0; i < crypt->client_nonce.len; ++i)
printf("%x", crypt->client_nonce.data[i]);
printf("\n");
-
}
if (crypt->has_server_nonce) {
printf("server nonce: 0x");
for (i = 0; i < crypt->server_nonce.len; ++i)
printf("%x", crypt->server_nonce.data[i]);
printf("\n");
-
}
}
@@ -252,10 +240,8 @@ do_ping(struct context *ctx)
g_get_current_time(&tv);
mumble_proto__ping__init(&ping);
-
ping.timestamp = tv.tv_sec;
ping.resync = 1;
-
send_msg(ctx, &ping.base);
return TRUE;
@@ -271,11 +257,11 @@ read_cb(GSocket *socket, GIOCondition condition, gpointer data)
recv_msg(ctx, callbacks, G_N_ELEMENTS(callbacks));
} while (g_input_stream_has_pending(input));
-
/* FIXME */
static int i = 0;
if (i++ < 2)
do_ping(ctx);
+
return TRUE;
}
diff --git a/src/varint.c b/src/varint.c
index da7e480..cd766b4 100644
--- a/src/varint.c
+++ b/src/varint.c
@@ -1,4 +1,5 @@
#include <stdint.h>
+#include "varint.h"
void
encode_varint(uint8_t *data, uint32_t *write, int64_t value, uint32_t left)
@@ -6,6 +7,7 @@ encode_varint(uint8_t *data, uint32_t *write, int64_t value, uint32_t left)
uint32_t pos = 0;
if (value < 0) {
+ /* FIXME */
*write = 0;
return;
}