From ee4bcb2f731616dbe89bc04f60ecbd6e790898d0 Mon Sep 17 00:00:00 2001 From: Eduardo Valentin Date: Tue, 7 Nov 2006 11:32:10 +0100 Subject: Alsa support for Maemo SDK (n770) - Remove compile warnings Here is a patch to remove compile warnings. It must be applied after last patch set I sent. This patch simply changes signedness of some point from the code to match the correct sign used by dsp-protocol structures. All must use unsigned variables. It also changes the way the pthread_mutex is initialized. The warning about pthreads is also removed. I tested the compilation with: gcc (GCC) 4.1.2 20061028 (prerelease) (Debian 4.1.1-19) and sbox-arm-linux-gcc (GCC) 3.4.4 (release) (CodeSourcery ARM 2005q3-2) Signed-off-by: Eduardo Valentin --- maemo/alsa-dsp.c | 1 - maemo/dsp-ctl.c | 4 ++-- maemo/dsp-protocol.c | 27 ++++++++++++++------------- maemo/dsp-protocol.h | 2 +- 4 files changed, 17 insertions(+), 17 deletions(-) diff --git a/maemo/alsa-dsp.c b/maemo/alsa-dsp.c index f23741c..50ffb00 100644 --- a/maemo/alsa-dsp.c +++ b/maemo/alsa-dsp.c @@ -164,7 +164,6 @@ static snd_pcm_sframes_t alsa_dsp_transfer(snd_pcm_ioplug_t * io, words); result *= 2; result /= alsa_dsp->bytes_per_frame; - out: alsa_dsp->hw_pointer += result; DLEAVE(result); return result; diff --git a/maemo/dsp-ctl.c b/maemo/dsp-ctl.c index a7a2be0..da00c1a 100644 --- a/maemo/dsp-ctl.c +++ b/maemo/dsp-ctl.c @@ -273,7 +273,7 @@ static int dsp_ctl_read_integer(snd_ctl_ext_t * ext, snd_ctl_ext_key_t key, long *value) { int ret = 0; - char left, right; + unsigned char left, right; snd_ctl_dsp_t *dsp_ctl = ext->private_data; control_list_t *tmp = dsp_ctl->controls[key]; @@ -317,7 +317,7 @@ static int dsp_ctl_write_integer(snd_ctl_ext_t * ext, snd_ctl_ext_key_t key, long *value) { int ret; - char left, right; + unsigned char left, right; snd_ctl_dsp_t *dsp_ctl = ext->private_data; control_list_t *tmp = dsp_ctl->controls[key]; diff --git a/maemo/dsp-protocol.c b/maemo/dsp-protocol.c index a0fa6a0..1e7ef66 100644 --- a/maemo/dsp-protocol.c +++ b/maemo/dsp-protocol.c @@ -69,10 +69,12 @@ union semun { static int dsp_protocol_flush(dsp_protocol_t * dsp_protocol); static int dsp_protocol_send_command(dsp_protocol_t * dsp_protocol, const short int command); -static void dsp_protocol_linear2Q15(const short int input, - short int *scale, short int *power2); -static void dsp_protocol_Q152linear(const short int scale, - const short int power2, short int *output); +static void dsp_protocol_linear2Q15(const unsigned short int input, + unsigned short int *scale, + unsigned short int *power2); +static void dsp_protocol_Q152linear(const unsigned short int scale, + const unsigned short int power2, + unsigned short int *output); static int dsp_protocol_update_state(dsp_protocol_t * dsp_protocol); static inline int dsp_protocol_get_sem(dsp_protocol_t * dsp_protocol); static inline int dsp_protocol_lock_dev(dsp_protocol_t * dsp_protocol); @@ -90,8 +92,8 @@ static inline int dsp_protocol_unlock_dev(dsp_protocol_t * dsp_protocol); */ int dsp_protocol_create(dsp_protocol_t ** dsp_protocol) { + pthread_mutex_t mutex = PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP; int ret = 0; - pthread_mutexattr_t mattr; DENTER(); *dsp_protocol = (dsp_protocol_t *) calloc(1, sizeof(dsp_protocol_t)); if ((*dsp_protocol) == NULL) { @@ -107,9 +109,7 @@ int dsp_protocol_create(dsp_protocol_t ** dsp_protocol) (*dsp_protocol)->bridge_buffer_size = 0; (*dsp_protocol)->mmap_buffer_size = 0; (*dsp_protocol)->mmap_buffer = NULL; - pthread_mutexattr_init(&mattr); - pthread_mutexattr_settype(PTHREAD_MUTEX_ERRORCHECK_NP); - pthread_mutex_init(&((*dsp_protocol)->mutex), &mattr); + (*dsp_protocol)->mutex = mutex; (*dsp_protocol)->sem_set_id = -1; #ifdef USE_RESOURCE_MANAGER (*dsp_protocol)->dbus_connection = dbus_bus_get(DBUS_BUS_SYSTEM, NULL); @@ -719,7 +719,7 @@ int dsp_protocol_set_volume(dsp_protocol_t * dsp_protocol, int dsp_protocol_get_volume(dsp_protocol_t * dsp_protocol, unsigned char *left, unsigned char *right) { - short int tmp; + unsigned short int tmp; int ret; audio_status_info_t audio_status_info; DENTER(); @@ -1050,8 +1050,9 @@ static int dsp_protocol_send_command(dsp_protocol_t * dsp_protocol, * Converts a 0 - 100 value to a Q15 format value. * */ -static void dsp_protocol_linear2Q15(const short int input, - short int *scale, short int *power2) +static void dsp_protocol_linear2Q15(const unsigned short int input, + unsigned short int *scale, + unsigned short int *power2) { unsigned long int val = MAGIC_NUMBER * input; DENTER(); @@ -1079,8 +1080,8 @@ static void dsp_protocol_linear2Q15(const short int input, * Converts a Q15 format value to a 0 - 100 value. * */ -static void dsp_protocol_Q152linear(const short int scale, - const short int power2, short int *output) +static void dsp_protocol_Q152linear(const unsigned short int scale, + const unsigned short int power2, unsigned short int *output) { float result = scale * 1.0 / 0x8000 * pow(2.0, 1.0 * power2) * 100.0; DENTER(); diff --git a/maemo/dsp-protocol.h b/maemo/dsp-protocol.h index be5d554..d3f2711 100644 --- a/maemo/dsp-protocol.h +++ b/maemo/dsp-protocol.h @@ -24,7 +24,7 @@ #ifndef _DSP_PROTOCOL_H #define _DSP_PROTOCOL_H -#define _GNU_SOURCE +#define __USE_GNU #include #include #include -- cgit