From 498f3e8abb59742720e8ff01b3018802651be430 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Fri, 23 Sep 2011 15:15:47 +0200 Subject: Add prefix cmumble_ to struct context and struct user --- src/audio.c | 17 +++++++++-------- src/audio.h | 14 +++++++------- src/cmumble.c | 38 +++++++++++++++++++------------------- src/cmumble.h | 6 +++--- src/commands.c | 12 ++++++------ src/commands.h | 6 +++--- src/connection.c | 10 +++++----- src/connection.h | 6 +++--- src/io.c | 8 ++++---- src/io.h | 6 +++--- src/message.c | 4 ++-- src/message.h | 6 +++--- 12 files changed, 67 insertions(+), 66 deletions(-) (limited to 'src') diff --git a/src/audio.c b/src/audio.c index c364b4f..4d6c5dd 100644 --- a/src/audio.c +++ b/src/audio.c @@ -7,7 +7,7 @@ #define CHANNELS 1 void -cmumble_audio_push(struct context *ctx, struct user *user, +cmumble_audio_push(struct cmumble_context *ctx, struct cmumble_user *user, const uint8_t *data, gsize size) { GstBuffer *gstbuf; @@ -19,7 +19,7 @@ cmumble_audio_push(struct context *ctx, struct user *user, static GstFlowReturn pull_buffer(GstAppSink *sink, gpointer user_data) { - struct context *ctx = user_data; + struct cmumble_context *ctx = user_data; GstBuffer *buf; uint8_t data[1024]; uint32_t write = 0, pos = 0; @@ -57,7 +57,7 @@ pull_buffer(GstAppSink *sink, gpointer user_data) } static int -setup_recording_gst_pipeline(struct context *ctx) +setup_recording_gst_pipeline(struct cmumble_context *ctx) { GstElement *pipeline, *cutter, *sink; GError *error = NULL; @@ -103,7 +103,7 @@ static void set_pulse_states(gpointer data, gpointer user_data) { GstElement *elm = data; - struct user *user = user_data; + struct cmumble_user *user = user_data; GstStructure *props; gchar *name; @@ -134,7 +134,8 @@ out: } int -cmumble_audio_create_playback_pipeline(struct context *ctx, struct user *user) +cmumble_audio_create_playback_pipeline(struct cmumble_context *ctx, + struct cmumble_user *user) { GstElement *pipeline, *sink_bin; GError *error = NULL; @@ -173,7 +174,7 @@ cmumble_audio_create_playback_pipeline(struct context *ctx, struct user *user) } static int -setup_playback_gst_pipeline(struct context *ctx) +setup_playback_gst_pipeline(struct cmumble_context *ctx) { ctx->audio.celt_mode = celt_mode_create(SAMPLERATE, SAMPLERATE / 100, NULL); @@ -185,7 +186,7 @@ setup_playback_gst_pipeline(struct context *ctx) } int -cmumble_audio_init(struct context *ctx) +cmumble_audio_init(struct cmumble_context *ctx) { if (setup_playback_gst_pipeline(ctx) < 0) return -1; @@ -197,7 +198,7 @@ cmumble_audio_init(struct context *ctx) } int -cmumble_audio_fini(struct context *ctx) +cmumble_audio_fini(struct cmumble_context *ctx) { return 0; diff --git a/src/audio.h b/src/audio.h index b31c77f..7092d46 100644 --- a/src/audio.h +++ b/src/audio.h @@ -20,21 +20,21 @@ struct cmumble_audio { CELTMode *celt_mode; }; -struct context; -struct user; +struct cmumble_context; +struct cmumble_user; int -cmumble_audio_init(struct context *ctx); +cmumble_audio_init(struct cmumble_context *ctx); int -cmumble_audio_fini(struct context *ctx); +cmumble_audio_fini(struct cmumble_context *ctx); int -cmumble_audio_create_playback_pipeline(struct context *ctx, - struct user *user); +cmumble_audio_create_playback_pipeline(struct cmumble_context *ctx, + struct cmumble_user *user); void -cmumble_audio_push(struct context *ctx, struct user *user, +cmumble_audio_push(struct cmumble_context *ctx, struct cmumble_user *user, const uint8_t *data, gsize size); #endif /* _AUDIO_H_ */ diff --git a/src/cmumble.c b/src/cmumble.c index d56256b..7069029 100644 --- a/src/cmumble.c +++ b/src/cmumble.c @@ -7,14 +7,14 @@ #include "io.h" #include "connection.h" -static struct user * -find_user(struct context *ctx, uint32_t session) +static struct cmumble_user * +find_user(struct cmumble_context *ctx, uint32_t session) { - struct user *user = NULL; + struct cmumble_user *user = NULL; GList *l; for (l = ctx->users; l; l = l->next) - if (((struct user *) l->data)->session == session) { + if (((struct cmumble_user *) l->data)->session == session) { user = l->data; break; } @@ -23,12 +23,12 @@ find_user(struct context *ctx, uint32_t session) } static void -recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct context *ctx) +recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct cmumble_context *ctx) { int64_t session, sequence; uint32_t pos = 1, read = 0; uint8_t frame_len, terminator; - struct user *user = NULL; + struct cmumble_user *user = NULL; uint8_t *data = tunnel->packet.data; size_t len = tunnel->packet.len; @@ -59,21 +59,21 @@ recv_udp_tunnel(MumbleProto__UDPTunnel *tunnel, struct context *ctx) } static void -recv_version(MumbleProto__Version *version, struct context *ctx) +recv_version(MumbleProto__Version *version, struct cmumble_context *ctx) { g_print("version: 0x%x\n", version->version); g_print("release: %s\n", version->release); } static void -recv_channel_state(MumbleProto__ChannelState *state, struct context *ctx) +recv_channel_state(MumbleProto__ChannelState *state, struct cmumble_context *ctx) { g_print("channel: id: %u, parent: %u, name: %s, description: %s, temporary: %d, position: %d\n", state->channel_id, state->parent, state->name, state->description, state->temporary, state->position); } static void -recv_server_sync(MumbleProto__ServerSync *sync, struct context *ctx) +recv_server_sync(MumbleProto__ServerSync *sync, struct cmumble_context *ctx) { ctx->session = sync->session; @@ -81,7 +81,7 @@ recv_server_sync(MumbleProto__ServerSync *sync, struct context *ctx) } static void -recv_crypt_setup(MumbleProto__CryptSetup *crypt, struct context *ctx) +recv_crypt_setup(MumbleProto__CryptSetup *crypt, struct cmumble_context *ctx) { #if 0 int i; @@ -108,7 +108,7 @@ recv_crypt_setup(MumbleProto__CryptSetup *crypt, struct context *ctx) } static void -recv_codec_version(MumbleProto__CodecVersion *codec, struct context *ctx) +recv_codec_version(MumbleProto__CodecVersion *codec, struct cmumble_context *ctx) { g_print("Codec Version: alpha: %d, beta: %d, pefer_alpha: %d\n", codec->alpha, codec->beta, codec->prefer_alpha); @@ -116,29 +116,29 @@ recv_codec_version(MumbleProto__CodecVersion *codec, struct context *ctx) static void -recv_user_remove(MumbleProto__UserRemove *remove, struct context *ctx) +recv_user_remove(MumbleProto__UserRemove *remove, struct cmumble_context *ctx) { - struct user *user = NULL; + struct cmumble_user *user = NULL; if ((user = find_user(ctx, remove->session))) { ctx->users = g_list_remove(ctx->users, user); g_free(user->name); /* FIXME: destroy playback pipeline */ - g_slice_free(struct user, user); + g_slice_free(struct cmumble_user, user); } } static void -recv_user_state(MumbleProto__UserState *state, struct context *ctx) +recv_user_state(MumbleProto__UserState *state, struct cmumble_context *ctx) { - struct user *user = NULL; + struct cmumble_user *user = NULL; if ((user = find_user(ctx, state->session))) { /* update */ return; } - user = g_slice_new0(struct user); + user = g_slice_new0(struct cmumble_user); if (user == NULL) { g_printerr("Out of memory.\n"); exit(1); @@ -156,7 +156,7 @@ recv_user_state(MumbleProto__UserState *state, struct context *ctx) static const struct { -#define MUMBLE_MSG(a,b) void (* a)(MumbleProto__##a *, struct context *); +#define MUMBLE_MSG(a,b) void (* a)(MumbleProto__##a *, struct cmumble_context *); MUMBLE_MSGS #undef MUMBLE_MSG } callbacks = { @@ -192,7 +192,7 @@ int main(int argc, char **argv) { char *host = "localhost"; unsigned int port = 64738; - struct context ctx; + struct cmumble_context ctx; if (argc >= 3) host = argv[2]; diff --git a/src/cmumble.h b/src/cmumble.h index 63b332a..afca177 100644 --- a/src/cmumble.h +++ b/src/cmumble.h @@ -12,9 +12,9 @@ #include "audio.h" #include "commands.h" -typedef void (*callback_t)(ProtobufCMessage *msg, struct context *); +typedef void (*callback_t)(ProtobufCMessage *msg, struct cmumble_context *); -struct context { +struct cmumble_context { struct cmumble_connection con; struct cmumble_io io; struct cmumble_audio audio; @@ -31,7 +31,7 @@ struct context { GList *users; }; -struct user { +struct cmumble_user { uint32_t session; char *name; uint32_t user_id; diff --git a/src/commands.c b/src/commands.c index be78a69..656869c 100644 --- a/src/commands.c +++ b/src/commands.c @@ -8,9 +8,9 @@ #include static void -list_users(struct context *ctx) +list_users(struct cmumble_context *ctx) { - struct user *user = NULL; + struct cmumble_user *user = NULL; GList *l; for (l = ctx->users; l; l = l->next) { @@ -21,14 +21,14 @@ list_users(struct context *ctx) } static void -quit(struct context *ctx) +quit(struct cmumble_context *ctx) { rl_already_prompted = 1; g_main_loop_quit(ctx->loop); } static void -clear(struct context *ctx) +clear(struct cmumble_context *ctx) { rl_clear_screen(0,0); rl_reset_line_state(); @@ -36,7 +36,7 @@ clear(struct context *ctx) } static void -help(struct context *ctx) +help(struct cmumble_context *ctx) { int i; @@ -54,7 +54,7 @@ static const struct cmumble_command commands[] = { }; void -cmumble_commands_init(struct context *ctx) +cmumble_commands_init(struct cmumble_context *ctx) { ctx->commands = commands; } diff --git a/src/commands.h b/src/commands.h index 2b1ad66..c95f238 100644 --- a/src/commands.h +++ b/src/commands.h @@ -1,15 +1,15 @@ #ifndef _COMMANDS_H_ #define _COMMANDS_H_ -struct context; +struct cmumble_context; struct cmumble_command { const char *name; - void (*callback)(struct context *); + void (*callback)(struct cmumble_context *); const char *description; }; void -cmumble_commands_init(struct context *ctx); +cmumble_commands_init(struct cmumble_context *ctx); #endif /* _COMMANDS_H_ */ diff --git a/src/connection.c b/src/connection.c index c9b7d5c..58a5e67 100644 --- a/src/connection.c +++ b/src/connection.c @@ -8,7 +8,7 @@ static gboolean read_cb(GObject *pollable_stream, gpointer data) { GPollableInputStream *input = G_POLLABLE_INPUT_STREAM(pollable_stream); - struct context *ctx = data; + struct cmumble_context *ctx = data; gint count; do { @@ -19,7 +19,7 @@ read_cb(GObject *pollable_stream, gpointer data) } static gboolean -do_ping(struct context *ctx) +do_ping(struct cmumble_context *ctx) { MumbleProto__Ping ping; GTimeVal tv; @@ -34,7 +34,7 @@ do_ping(struct context *ctx) } static void -setup_ping_timer(struct context *ctx) +setup_ping_timer(struct cmumble_context *ctx) { GSource *source; @@ -45,7 +45,7 @@ setup_ping_timer(struct context *ctx) } int -cmumble_connection_init(struct context *ctx, +cmumble_connection_init(struct cmumble_context *ctx, const char *host, int port) { struct cmumble_connection *con = &ctx->con; @@ -90,7 +90,7 @@ cmumble_connection_init(struct context *ctx, } int -cmumble_connection_fini(struct context *ctx) +cmumble_connection_fini(struct cmumble_context *ctx) { g_source_remove(g_source_get_id(ctx->con.source)); g_source_unref(ctx->con.source); diff --git a/src/connection.h b/src/connection.h index cf3dbc0..f37c0c7 100644 --- a/src/connection.h +++ b/src/connection.h @@ -14,13 +14,13 @@ struct cmumble_connection { GSource *source; }; -struct context; +struct cmumble_context; int -cmumble_connection_init(struct context *ctx, +cmumble_connection_init(struct cmumble_context *ctx, const char *host, int port); int -cmumble_connection_fini(struct context *ctx); +cmumble_connection_fini(struct cmumble_context *ctx); #endif /* _CONNECTION_H_ */ diff --git a/src/io.c b/src/io.c index 33d1232..7c69447 100644 --- a/src/io.c +++ b/src/io.c @@ -22,7 +22,7 @@ static gpointer global_rl_user_data = NULL; static gboolean read_cb(GIOChannel *source, GIOCondition condition, gpointer data) { - struct context *ctx = data; + struct cmumble_context *ctx = data; if (condition & G_IO_IN) { global_rl_user_data = ctx; @@ -65,7 +65,7 @@ print_preserve_prompt(const gchar *string) static void process_line(char *line) { - struct context *ctx = global_rl_user_data; + struct cmumble_context *ctx = global_rl_user_data; int i; g_assert(global_rl_user_data); @@ -95,7 +95,7 @@ process_line(char *line) } int -cmumble_io_init(struct context *ctx) +cmumble_io_init(struct cmumble_context *ctx) { struct termios term; @@ -126,7 +126,7 @@ cmumble_io_init(struct context *ctx) } int -cmumble_io_fini(struct context *ctx) +cmumble_io_fini(struct cmumble_context *ctx) { rl_callback_handler_remove(); g_io_channel_unref(ctx->io.input_channel); diff --git a/src/io.h b/src/io.h index 2f48df7..c774b6a 100644 --- a/src/io.h +++ b/src/io.h @@ -10,12 +10,12 @@ struct cmumble_io { struct termios term; }; -struct context; +struct cmumble_context; int -cmumble_io_init(struct context *ctx); +cmumble_io_init(struct cmumble_context *ctx); int -cmumble_io_fini(struct context *ctx); +cmumble_io_fini(struct cmumble_context *ctx); #endif /* _IO_H_ */ diff --git a/src/message.c b/src/message.c index 5ed6f14..8acf83b 100644 --- a/src/message.c +++ b/src/message.c @@ -39,7 +39,7 @@ get_preamble(uint8_t *buffer, int *type, int *len) } void -cmumble_send_msg(struct context *ctx, ProtobufCMessage *msg) +cmumble_send_msg(struct cmumble_context *ctx, ProtobufCMessage *msg) { uint8_t pad[128]; uint8_t preamble[PREAMBLE_SIZE]; @@ -72,7 +72,7 @@ cmumble_send_msg(struct context *ctx, ProtobufCMessage *msg) } int -cmumble_recv_msg(struct context *ctx) +cmumble_recv_msg(struct cmumble_context *ctx) { uint8_t preamble[PREAMBLE_SIZE]; ProtobufCMessage *msg; diff --git a/src/message.h b/src/message.h index 4309801..d70743b 100644 --- a/src/message.h +++ b/src/message.h @@ -10,12 +10,12 @@ enum cmumble_message { #undef MUMBLE_MSG }; -struct context; +struct cmumble_context; void -cmumble_send_msg(struct context *ctx, ProtobufCMessage *msg); +cmumble_send_msg(struct cmumble_context *ctx, ProtobufCMessage *msg); int -cmumble_recv_msg(struct context *ctx); +cmumble_recv_msg(struct cmumble_context *ctx); #endif /* _MESSAGE_H_ */ -- cgit