diff options
author | Dario Lombardo <lomato@gmail.com> | 2015-09-04 17:12:25 +0200 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2015-09-09 17:53:08 +0000 |
commit | ecc62d8706ad4ed7768cde31dcd4476b4d2389a9 (patch) | |
tree | b1fc6ad1945a8749383118623d88ac1dcef3feed | |
parent | 8a8a82d1b672ebefdc65ea1f316b725fabe47954 (diff) |
codecs/gtk: fix int to size_t
Change-Id: I8f467f09375c8227c4b70aef47ff3a590a0c00d7
Reviewed-on: https://code.wireshark.org/review/10413
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
-rw-r--r-- | codecs/G711a/G711adecode.c | 12 | ||||
-rw-r--r-- | codecs/G711a/G711adecode.h | 8 | ||||
-rw-r--r-- | codecs/G711u/G711udecode.c | 12 | ||||
-rw-r--r-- | codecs/G711u/G711udecode.h | 8 | ||||
-rw-r--r-- | codecs/codecs.c | 7 | ||||
-rw-r--r-- | codecs/codecs.h | 16 | ||||
-rw-r--r-- | codecs/sbc/sbc.c | 14 | ||||
-rw-r--r-- | codecs/sbc/sbc_private.h | 8 | ||||
-rw-r--r-- | ui/gtk/rtp_player.c | 32 |
9 files changed, 61 insertions, 56 deletions
diff --git a/codecs/G711a/G711adecode.c b/codecs/G711a/G711adecode.c index 6d31657973..2ed2436058 100644 --- a/codecs/G711a/G711adecode.c +++ b/codecs/G711a/G711adecode.c @@ -39,25 +39,25 @@ codec_g711a_release(void *ctx _U_) } -int +unsigned codec_g711a_get_channels(void *ctx _U_) { return 1; } -int +unsigned codec_g711a_get_frequency(void *ctx _U_) { return 8000; } -int -codec_g711a_decode(void *ctx _U_, const void *input, int inputSizeBytes, void *output, - int *outputSizeBytes) +size_t +codec_g711a_decode(void *ctx _U_, const void *input, size_t inputSizeBytes, void *output, + size_t *outputSizeBytes) { const guint8 *dataIn = (const guint8 *) input; gint16 *dataOut = (gint16 *) output; - int i; + size_t i; if (!output || !outputSizeBytes) { return inputSizeBytes * 2; diff --git a/codecs/G711a/G711adecode.h b/codecs/G711a/G711adecode.h index d89d166217..a1a57c2580 100644 --- a/codecs/G711a/G711adecode.h +++ b/codecs/G711a/G711adecode.h @@ -25,10 +25,10 @@ void *codec_g711a_init(void); void codec_g711a_release(void *ctx); -int codec_g711a_get_channels(void *ctx); -int codec_g711a_get_frequency(void *ctx); -int codec_g711a_decode(void *ctx, const void *input, int inputSizeBytes, void *output, - int *outputSizeBytes); +unsigned codec_g711a_get_channels(void *ctx); +unsigned codec_g711a_get_frequency(void *ctx); +size_t codec_g711a_decode(void *ctx, const void *input, size_t inputSizeBytes, void *output, + size_t *outputSizeBytes); #endif /* G711adecode.h */ diff --git a/codecs/G711u/G711udecode.c b/codecs/G711u/G711udecode.c index 8399195d6e..8db44bed12 100644 --- a/codecs/G711u/G711udecode.c +++ b/codecs/G711u/G711udecode.c @@ -39,25 +39,25 @@ codec_g711u_release(void *ctx _U_) } -int +unsigned codec_g711u_get_channels(void *ctx _U_) { return 1; } -int +unsigned codec_g711u_get_frequency(void *ctx _U_) { return 8000; } -int -codec_g711u_decode(void *ctx _U_, const void *input, int inputSizeBytes, void *output, - int *outputSizeBytes) +size_t +codec_g711u_decode(void *ctx _U_, const void *input, size_t inputSizeBytes, void *output, + size_t *outputSizeBytes) { const guint8 *dataIn = (const guint8 *) input; gint16 *dataOut = (gint16 *) output; - int i; + size_t i; if (!output || !outputSizeBytes) { return inputSizeBytes * 2; diff --git a/codecs/G711u/G711udecode.h b/codecs/G711u/G711udecode.h index a0a7ad0a4e..08e086de59 100644 --- a/codecs/G711u/G711udecode.h +++ b/codecs/G711u/G711udecode.h @@ -25,10 +25,10 @@ void *codec_g711u_init(void); void codec_g711u_release(void *ctx); -int codec_g711u_get_channels(void *ctx); -int codec_g711u_get_frequency(void *ctx); -int codec_g711u_decode(void *ctx, const void *input, int inputSizeBytes, void *output, - int *outputSizeBytes); +unsigned codec_g711u_get_channels(void *ctx); +unsigned codec_g711u_get_frequency(void *ctx); +size_t codec_g711u_decode(void *ctx, const void *input, size_t inputSizeBytes, void *output, + size_t *outputSizeBytes); #endif /* G711udecode.h */ diff --git a/codecs/codecs.c b/codecs/codecs.c index 07a183ff7a..f7921eade2 100644 --- a/codecs/codecs.c +++ b/codecs/codecs.c @@ -93,6 +93,7 @@ register_codec_plugin(gpointer data, gpointer user_data _U_) (plugin->register_codec_module)(); } + /* * For all codec plugins, call their register routines. */ @@ -180,19 +181,19 @@ void codec_release(codec_handle_t codec, void *context) (codec->release_fn)(context); } -int codec_get_channels(codec_handle_t codec, void *context) +unsigned codec_get_channels(codec_handle_t codec, void *context) { if (!codec) return 0; return (codec->channels_fn)(context); } -int codec_get_frequency(codec_handle_t codec, void *context) +unsigned codec_get_frequency(codec_handle_t codec, void *context) { if (!codec) return 0; return (codec->frequency_fn)(context); } -int codec_decode(codec_handle_t codec, void *context, const void *input, int inputSizeBytes, void *output, int *outputSizeBytes) +size_t codec_decode(codec_handle_t codec, void *context, const void *input, size_t inputSizeBytes, void *output, size_t *outputSizeBytes) { if (!codec) return 0; return (codec->decode_fn)(context, input, inputSizeBytes, output, outputSizeBytes); diff --git a/codecs/codecs.h b/codecs/codecs.h index 80d0d71e2f..7ba918ac30 100644 --- a/codecs/codecs.h +++ b/codecs/codecs.h @@ -42,10 +42,10 @@ typedef struct codec_handle *codec_handle_t; typedef void *(*codec_init_fn)(void); typedef void (*codec_release_fn)(void *context); -typedef int (*codec_get_channels_fn)(void *context); -typedef int (*codec_get_frequency_fn)(void *context); -typedef int (*codec_decode_fn)(void *context, const void *input, int inputSizeBytes, - void *output, int *outputSizeBytes); +typedef unsigned (*codec_get_channels_fn)(void *context); +typedef unsigned (*codec_get_frequency_fn)(void *context); +typedef size_t (*codec_decode_fn)(void *context, const void *input, size_t inputSizeBytes, + void *output, size_t *outputSizeBytes); extern gboolean register_codec(const char *name, codec_init_fn init_fn, codec_release_fn release_fn, codec_get_channels_fn channels_fn, @@ -53,10 +53,10 @@ extern gboolean register_codec(const char *name, codec_init_fn init_fn, extern codec_handle_t find_codec(const char *name); extern void *codec_init(codec_handle_t codec); extern void codec_release(codec_handle_t codec, void *context); -extern int codec_get_channels(codec_handle_t codec, void *context); -extern int codec_get_frequency(codec_handle_t codec, void *context); -extern int codec_decode(codec_handle_t codec, void *context, const void *input, - int inputSizeBytes, void *output, int *outputSizeBytes); +extern unsigned codec_get_channels(codec_handle_t codec, void *context); +extern unsigned codec_get_frequency(codec_handle_t codec, void *context); +extern size_t codec_decode(codec_handle_t codec, void *context, const void *input, + size_t inputSizeBytes, void *output, size_t *outputSizeBytes); #ifdef __cplusplus } diff --git a/codecs/sbc/sbc.c b/codecs/sbc/sbc.c index dea07dc1a9..1fa1b69508 100644 --- a/codecs/sbc/sbc.c +++ b/codecs/sbc/sbc.c @@ -53,7 +53,7 @@ codec_sbc_release(void *ctx) g_free(sbc); } -int +unsigned codec_sbc_get_channels(void *ctx) { sbc_t *sbc = (sbc_t *) ctx; @@ -63,7 +63,7 @@ codec_sbc_get_channels(void *ctx) return 2; } -int +unsigned codec_sbc_get_frequency(void *ctx) { sbc_t *sbc = (sbc_t *) ctx; @@ -92,15 +92,15 @@ codec_sbc_get_frequency(void *ctx) return frequency; } -int -codec_sbc_decode(void *ctx, const void *input, int inputSizeBytes, void *output, - int *outputSizeBytes) +size_t +codec_sbc_decode(void *ctx, const void *input, size_t inputSizeBytes, void *output, + size_t *outputSizeBytes) { size_t size_in = (size_t) inputSizeBytes; size_t size_out = SBC_BUFFER; size_t len; - int framelen; - int xframe_pos = 0; + size_t framelen; + size_t xframe_pos = 0; const guint8 *data_in = (const guint8 *) input; guint8 *data_out = (guint8 *) output; sbc_t *sbc = (sbc_t *) ctx; diff --git a/codecs/sbc/sbc_private.h b/codecs/sbc/sbc_private.h index 10e63ca360..d2e4ab85a3 100644 --- a/codecs/sbc/sbc_private.h +++ b/codecs/sbc/sbc_private.h @@ -27,10 +27,10 @@ void *codec_sbc_init(void); void codec_sbc_release(void *ctx); -int codec_sbc_get_channels(void *ctx); -int codec_sbc_get_frequency(void *ctx); -int codec_sbc_decode(void *ctx, const void *input, int inputSizeBytes, void *output, - int *outputSizeBytes); +unsigned codec_sbc_get_channels(void *ctx); +unsigned codec_sbc_get_frequency(void *ctx); +size_t codec_sbc_decode(void *ctx, const void *input, size_t inputSizeBytes, void *output, + size_t *outputSizeBytes); #endif /* sbc.h */ diff --git a/ui/gtk/rtp_player.c b/ui/gtk/rtp_player.c index 9dc9767846..50bbf70fbe 100644 --- a/ui/gtk/rtp_player.c +++ b/ui/gtk/rtp_player.c @@ -55,6 +55,7 @@ #include <math.h> #include <string.h> #include <portaudio.h> +#include <assert.h> #include <gtk/gtk.h> @@ -119,11 +120,11 @@ static int new_jitter_buff; /* a hash table with the RTP streams to play per audio channel */ static GHashTable *rtp_channels_hash = NULL; -static int sample_rate = 8000; -static int channels = 1; +static unsigned sample_rate = 8000; +static unsigned channels = 1; /* Port Audio stuff */ -static int output_channels = 2; +static unsigned output_channels = 2; #define PA_SAMPLE_TYPE paInt16 typedef gint16 SAMPLE; @@ -456,15 +457,15 @@ mark_all_rtp_stream_to_decode(gchar *key _U_ , rtp_stream_info_t *rsi, gpointer /* Decode a RTP packet * Return the number of decoded bytes */ -static int +static size_t decode_rtp_packet(rtp_packet_t *rp, SAMPLE **out_buff, GHashTable *decoders_hash) { unsigned int payload_type; const gchar *p; rtp_decoder_t *decoder; SAMPLE *tmp_buff = NULL; - int tmp_buff_len; - int decoded_bytes = 0; + size_t tmp_buff_len; + size_t decoded_bytes = 0; if ((rp->payload_data == NULL) || (rp->info->info_payload_len == 0) ) { return 0; @@ -533,7 +534,8 @@ decode_rtp_stream(rtp_stream_info_t *rsi, gpointer ptr) GList* rtp_packet_list; rtp_packet_t *rp; - int i; + size_t i; + gint32 j; double rtp_time; double rtp_time_prev; double arrive_time; @@ -551,8 +553,8 @@ decode_rtp_stream(rtp_stream_info_t *rsi, gpointer ptr) #endif char *src_addr, *dst_addr; - int decoded_bytes; - int decoded_bytes_prev; + size_t decoded_bytes; + size_t decoded_bytes_prev; int jitter_buff; SAMPLE *out_buff = NULL; sample_t silence; @@ -611,7 +613,7 @@ decode_rtp_stream(rtp_stream_info_t *rsi, gpointer ptr) } else { /* Add silence between the two streams if needed */ silence_frames = (gint32)((nstime_to_msec(&rsi->start_fd->abs_ts) - nstime_to_msec(&rci->stop_time_abs)) * sample_rate); - for (i = 0; i< silence_frames; i++) { + for (j = 0; j < silence_frames; j++) { g_array_append_val(rci->samples, silence); } rci->num_packets += rsi->packet_count; @@ -720,7 +722,7 @@ decode_rtp_stream(rtp_stream_info_t *rsi, gpointer ptr) if (silence_frames > MAX_SILENCE_FRAMES) silence_frames = MAX_SILENCE_FRAMES; - for (i = 0; i< silence_frames; i++) { + for (j = 0; j < silence_frames; j++) { silence.status = status; g_array_append_val(rci->samples, silence); @@ -756,7 +758,7 @@ decode_rtp_stream(rtp_stream_info_t *rsi, gpointer ptr) if (silence_frames > MAX_SILENCE_FRAMES) silence_frames = MAX_SILENCE_FRAMES; - for (i = 0; i< silence_frames; i++) { + for (j = 0; j < silence_frames; j++) { silence.status = status; g_array_append_val(rci->samples, silence); @@ -1888,6 +1890,7 @@ play_channels(void) /* if not PAUSE, then start to PLAY */ } else { #if PORTAUDIO_API_1 + assert(output_channels <= INT_MAX); err = Pa_OpenStream( &pa_stream, paNoDevice, /* default input device */ @@ -1895,7 +1898,7 @@ play_channels(void) PA_SAMPLE_TYPE, NULL, Pa_GetDefaultOutputDeviceID(), - output_channels, + (int)output_channels, PA_SAMPLE_TYPE, NULL, sample_rate, @@ -1935,10 +1938,11 @@ play_channels(void) } #else /* PORTAUDIO_API_1 */ if (Pa_GetDefaultOutputDevice() != paNoDevice) { + assert(output_channels <= INT_MAX); err = Pa_OpenDefaultStream( &pa_stream, 0, - output_channels, + (int)output_channels, PA_SAMPLE_TYPE, sample_rate, FRAMES_PER_BUFFER, |