changeset 2760:35ac6cb80680

Use glib types.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 02 Jul 2008 08:03:42 +0300
parents fd550b4fc79f
children 41a80a649b9d
files src/alsa/alsa.h src/alsa/audio.c src/alsa/configure.c
diffstat 3 files changed, 82 insertions(+), 82 deletions(-) [+]
line wrap: on
line diff
--- a/src/alsa/alsa.h	Wed Jul 02 07:56:49 2008 +0300
+++ b/src/alsa/alsa.h	Wed Jul 02 08:03:42 2008 +0300
@@ -41,15 +41,15 @@
 
 struct alsa_config
 {
-	char *pcm_device;
-	int mixer_card;
-	char *mixer_device;
-	int buffer_time;
-	int period_time;
+	gchar *pcm_device;
+	gint mixer_card;
+	gchar *mixer_device;
+	gint buffer_time;
+	gint period_time;
 	gboolean debug;
 	struct
 	{
-		int left, right;
+		gint left, right;
 	} vol;
 };
 
@@ -57,21 +57,21 @@
 
 void alsa_about(void);
 void alsa_configure(void);
-int alsa_get_mixer(snd_mixer_t **mixer, int card);
+gint alsa_get_mixer(snd_mixer_t **mixer, gint card);
 void alsa_save_config(void);
 
-void alsa_get_volume(int *l, int *r);
-void alsa_set_volume(int l, int r);
+void alsa_get_volume(gint *l, gint *r);
+void alsa_set_volume(gint l, gint r);
 
-int alsa_playing(void);
-int alsa_free(void);
-void alsa_write(void *ptr, int length);
+gint alsa_playing(void);
+gint alsa_free(void);
+void alsa_write(void *ptr, gint length);
 void alsa_close(void);
-void alsa_flush(int time);
-void alsa_pause(short p);
-int alsa_open(AFormat fmt, int rate, int nch);
-int alsa_get_output_time(void);
-int alsa_get_written_time(void);
+void alsa_flush(gint time);
+void alsa_pause(gshort p);
+gint alsa_open(AFormat fmt, gint rate, gint nch);
+gint alsa_get_output_time(void);
+gint alsa_get_written_time(void);
 void alsa_tell(AFormat * fmt, gint * rate, gint * nch);
 
 extern GStaticMutex alsa_mutex;
--- a/src/alsa/audio.c	Wed Jul 02 07:56:49 2008 +0300
+++ b/src/alsa/audio.c	Wed Jul 02 08:03:42 2008 +0300
@@ -46,8 +46,8 @@
 static guint64 output_time_offset;
 
 /* device buffer/period sizes in bytes */
-static int hw_buffer_size, hw_period_size;		/* in output bytes */
-static int hw_buffer_size_in, hw_period_size_in;	/* in input bytes */
+static gint hw_buffer_size, hw_period_size;		/* in output bytes */
+static gint hw_buffer_size_in, hw_period_size_in;	/* in input bytes */
 
 /* Set/Get volume */
 static snd_mixer_elem_t *pcm_element;
@@ -60,32 +60,32 @@
 
 /* for audio thread */
 static GThread *audio_thread;	 /* audio loop thread */
-static int thread_buffer_size;	 /* size of intermediate buffer in bytes */
-static char *thread_buffer;	 /* audio intermediate buffer */
-static int rd_index, wr_index;	 /* current read/write position in int-buffer */
+static gint thread_buffer_size;	 /* size of intermediate buffer in bytes */
+static gchar *thread_buffer;	 /* audio intermediate buffer */
+static gint rd_index, wr_index;	 /* current read/write position in int-buffer */
 static gboolean pause_request;	 /* pause status currently requested */
-static int flush_request;	 /* flush status (time) currently requested */
-static int prebuffer_size;
+static gint flush_request;	 /* flush status (time) currently requested */
+static gint prebuffer_size;
 GStaticMutex alsa_mutex = G_STATIC_MUTEX_INIT;
 
 struct snd_format {
-	unsigned int rate;
-	unsigned int channels;
+	guint rate;
+	guint channels;
 	snd_pcm_format_t format;
 	AFormat xmms_format;
-	int sample_bits;
-	int bps;
+	gint sample_bits;
+	gint bps;
 };
 
 static struct snd_format *inputf = NULL;
 static struct snd_format *outputf = NULL;
 
-static int alsa_setup(struct snd_format *f);
-static void alsa_write_audio(char *data, int length);
+static gint alsa_setup(struct snd_format *f);
+static void alsa_write_audio(gchar *data, gint length);
 static void alsa_cleanup_mixer(void);
-static int get_thread_buffer_filled(void);
+static gint get_thread_buffer_filled(void);
 
-static struct snd_format * snd_format_from_xmms(AFormat fmt, int rate, int channels);
+static struct snd_format * snd_format_from_xmms(AFormat fmt, gint rate, gint channels);
 
 static const struct {
 	AFormat xmms;
@@ -115,9 +115,9 @@
 };
 
 
-static void debug(char *str, ...) G_GNUC_PRINTF(1, 2);
+static void debug(gchar *str, ...) G_GNUC_PRINTF(1, 2);
 
-static void debug(char *str, ...)
+static void debug(gchar *str, ...)
 {
 	va_list args;
 
@@ -140,10 +140,10 @@
                get_thread_buffer_filled() > hw_period_size_in;
 }
 
-static int
-alsa_recovery(int err)
+static gint
+alsa_recovery(gint err)
 {
-	int err2;
+	gint err2;
 
 	/* if debug mode is enabled, dump ALSA state to console */
 	if (alsa_cfg.debug)
@@ -298,7 +298,7 @@
 
 /* reopen ALSA PCM */
 #if 0
-static int alsa_reopen(struct snd_format *f)
+static gint alsa_reopen(struct snd_format *f)
 {
 	/* remember the current position */
 	output_time_offset += (alsa_hw_written * 1000) / outputf->bps;
@@ -311,7 +311,7 @@
 #endif
 
 /* do flush (drop) operation */
-static void alsa_do_flush(int time)
+static void alsa_do_flush(gint time)
 {
 	if (alsa_pcm)
 	{
@@ -324,16 +324,16 @@
 	rd_index = wr_index = alsa_hw_written = 0;
 }
 
-void alsa_flush(int time)
+void alsa_flush(gint time)
 {
 	flush_request = time;
 	while ((flush_request != -1) && (going))
 		g_usleep(10000);
 }
 
-static void parse_mixer_name(char *str, char **name, int *index)
+static void parse_mixer_name(gchar *str, gchar **name, gint *index)
 {
-	char *end;
+	gchar *end;
 
 	while (isspace(*str))
 		str++;
@@ -351,10 +351,10 @@
 	}
 }
 
-int alsa_get_mixer(snd_mixer_t **mixer, int card)
+gint alsa_get_mixer(snd_mixer_t **mixer, gint card)
 {
-	char *dev;
-	int err;
+	gchar *dev;
+	gint err;
 
 	debug("alsa_get_mixer");
 
@@ -393,7 +393,7 @@
 }
 
 
-static snd_mixer_elem_t* alsa_get_mixer_elem(snd_mixer_t *mixer, char *name, int index)
+static snd_mixer_elem_t* alsa_get_mixer_elem(snd_mixer_t *mixer, gchar *name, gint index)
 {
 	snd_mixer_selem_id_t *selem_id;
 	snd_mixer_elem_t* elem;
@@ -411,10 +411,10 @@
 
 static int alsa_setup_mixer(void)
 {
-	char *name;
-	long int a, b;
-	long alsa_min_vol, alsa_max_vol;
-	int err, index;
+	gchar *name;
+	glong a, b;
+	glong alsa_min_vol, alsa_max_vol;
+	gint err, index;
 
 	debug("alsa_setup_mixer");
 
@@ -471,9 +471,9 @@
 	}
 }
 
-void alsa_get_volume(int *l, int *r)
+void alsa_get_volume(gint *l, gint *r)
 {
-	long ll = *l, lr = *r;
+	glong ll = *l, lr = *r;
 
 	if (mixer_start)
 	{
@@ -497,7 +497,7 @@
 }
 
 
-void alsa_set_volume(int l, int r)
+void alsa_set_volume(gint l, gint r)
 {
 	if (!pcm_element)
 		return;
@@ -541,7 +541,7 @@
 	return thread_buffer_size - (rd_index - wr_index);
 }
 
-int alsa_get_output_time(void)
+gint alsa_get_output_time(void)
 {
 	snd_pcm_sframes_t delay;
 	guint64 bytes = alsa_hw_written;
@@ -560,7 +560,7 @@
 	return output_time_offset + (bytes * 1000) / outputf->bps;
 }
 
-int alsa_get_written_time(void)
+gint alsa_get_written_time(void)
 {
 	if (!going)
 		return 0;
@@ -581,10 +581,10 @@
 }
 
 /* write callback */
-void alsa_write(gpointer data, int length)
+void alsa_write(gpointer data, gint length)
 {
-	int cnt;
-	char *src = (char *)data;
+	gint cnt;
+	gchar *src = (gchar *)data;
 	
 	remove_prebuffer = FALSE;
 	
@@ -602,7 +602,7 @@
 }
 
 /* transfer data to audio h/w via normal write */
-static void alsa_write_audio(char *data, int length)
+static void alsa_write_audio(gchar *data, gint length)
 {
 	snd_pcm_sframes_t written_frames;
 
@@ -655,8 +655,8 @@
 /* FIXME: proper lock? */
 static void *alsa_loop(void *arg)
 {
-	int npfds = snd_pcm_poll_descriptors_count(alsa_pcm);
-	int wr = 0;
+	gint npfds = snd_pcm_poll_descriptors_count(alsa_pcm);
+	gint wr = 0;
 
 	g_static_mutex_lock(&alsa_mutex);
 
@@ -704,7 +704,7 @@
 }
 
 /* open callback */
-int alsa_open(AFormat fmt, int rate, int nch)
+gint alsa_open(AFormat fmt, gint rate, gint nch)
 {
 	debug("Opening device");
 	if((inputf = snd_format_from_xmms(fmt, rate, nch)) == NULL) return 0;
@@ -751,11 +751,11 @@
 	return 1;
 }
 
-static struct snd_format * snd_format_from_xmms(AFormat fmt, int rate, int channels)
+static struct snd_format * snd_format_from_xmms(AFormat fmt, gint rate, gint channels)
 {
 	struct snd_format *f = g_malloc(sizeof(struct snd_format));
 	size_t i;
-        int found = 0;
+    gint found = 0;
 
 	f->xmms_format = fmt;
 	f->format = SND_PCM_FORMAT_UNKNOWN;
@@ -790,12 +790,12 @@
 	return f;
 }
 
-static int alsa_setup(struct snd_format *f)
+static gint alsa_setup(struct snd_format *f)
 {
-	int err;
+	gint err;
 	snd_pcm_hw_params_t *hwparams = NULL;
 	snd_pcm_sw_params_t *swparams = NULL;
-	unsigned int alsa_buffer_time, alsa_period_time;
+	guint alsa_buffer_time, alsa_period_time;
 	snd_pcm_uframes_t alsa_buffer_size, alsa_period_size;
 
 	debug("alsa_setup");
--- a/src/alsa/configure.c	Wed Jul 02 07:56:49 2008 +0300
+++ b/src/alsa/configure.c	Wed Jul 02 08:03:42 2008 +0300
@@ -24,7 +24,7 @@
 
 static GtkWidget *devices_combo, *mixer_devices_combo;
 
-static int current_mixer_card;
+static gint current_mixer_card;
 
 #define GET_SPIN_INT(spin) \
 	gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(spin))
@@ -58,10 +58,10 @@
 	aud_cfg_db_close(cfgfile);
 }
 
-static int get_cards(GtkOptionMenu *omenu, GtkSignalFunc cb, int active)
+static gint get_cards(GtkOptionMenu *omenu, GtkSignalFunc cb, gint active)
 {
 	GtkWidget *menu, *item;
-	int card = -1, err, set = 0, curr = -1;
+	gint card = -1, err, set = 0, curr = -1;
 
 	menu = gtk_menu_new();
 	if ((err = snd_card_next(&card)) != 0)
@@ -69,7 +69,7 @@
 
 	while (card > -1)
 	{
-		char *label;
+		gchar *label;
 
 		curr++;
 		if (card == active)
@@ -98,10 +98,10 @@
 	return set;
 }
 
-static int get_mixer_devices(GtkCombo *combo, int card)
+static gint get_mixer_devices(GtkCombo *combo, gint card)
 {
 	GList *items = NULL;
-	int err;
+	gint err;
 	snd_mixer_t *mixer;
 	snd_mixer_elem_t *current;
 
@@ -115,8 +115,8 @@
 		if (snd_mixer_selem_is_active(current) &&
 		    snd_mixer_selem_has_playback_volume(current))
 		{
-			const char *sname = snd_mixer_selem_get_name(current);
-			int index = snd_mixer_selem_get_index(current);
+			const gchar *sname = snd_mixer_selem_get_name(current);
+			gint index = snd_mixer_selem_get_index(current);
 			if (index)
 				items = g_list_append(items, g_strdup_printf("%s,%d", sname, index));
 			else
@@ -130,13 +130,13 @@
 	return 0;
 }
 
-static void get_devices_for_card(GtkCombo *combo, int card)
+static void get_devices_for_card(GtkCombo *combo, gint card)
 {
 	GtkWidget *item;
-	int pcm_device = -1, err;
+	gint pcm_device = -1, err;
 	snd_pcm_info_t *pcm_info = NULL;
 	snd_ctl_t *ctl;
-	char dev[64], *card_name;
+	gchar dev[64], *card_name;
 
 	sprintf(dev, "hw:%i", card);
 
@@ -200,9 +200,9 @@
 static void get_devices(GtkCombo *combo)
 {
 	GtkWidget *item;
-	int card = -1;
-	int err = 0;
-	char *descr;
+	gint card = -1;
+	gint err = 0;
+	gchar *descr;
 
 	descr = g_strdup_printf(_("Default PCM device (%s)"), "default");
 	item = gtk_list_item_new_with_label(descr);
@@ -250,7 +250,7 @@
 	GtkObject *buffer_time_adj, *period_time_adj;
 	GtkWidget *bbox, *ok, *cancel;
 
-	int mset;
+	gint mset;
 
 	if (configure_win)
 	{