diff mbox

[19/26] audio: GUSsample is int16_t

Message ID 20170425223739.6703-20-quintela@redhat.com
State New
Headers show

Commit Message

Juan Quintela April 25, 2017, 10:37 p.m. UTC
Signed-off-by: Juan Quintela <quintela@redhat.com>
---
 hw/audio/gus.c          |  2 +-
 hw/audio/gusemu.h       | 12 +-----------
 hw/audio/gusemu_hal.c   |  2 +-
 hw/audio/gusemu_mixer.c |  8 ++++----
 4 files changed, 7 insertions(+), 17 deletions(-)

Comments

Philippe Mathieu-Daudé April 26, 2017, 1:47 a.m. UTC | #1
Hi Juan,

Same here, why not squashing as "Use stdint instead of dead GUSEMU32"?

On 04/25/2017 07:37 PM, Juan Quintela wrote:
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  hw/audio/gus.c          |  2 +-
>  hw/audio/gusemu.h       | 12 +-----------
>  hw/audio/gusemu_hal.c   |  2 +-
>  hw/audio/gusemu_mixer.c |  8 ++++----
>  4 files changed, 7 insertions(+), 17 deletions(-)
>
> diff --git a/hw/audio/gus.c b/hw/audio/gus.c
> index 3d08a65..ec103a4 100644
> --- a/hw/audio/gus.c
> +++ b/hw/audio/gus.c
> @@ -53,7 +53,7 @@ typedef struct GUSState {
>      uint32_t freq;
>      uint32_t port;
>      int pos, left, shift, irqs;
> -    GUSsample *mixbuf;
> +    int16_t *mixbuf;
>      uint8_t himem[1024 * 1024 + 32 + 4096];
>      int samples;
>      SWVoiceOut *voice;
> diff --git a/hw/audio/gusemu.h b/hw/audio/gusemu.h
> index 69dadef..ab591ee 100644
> --- a/hw/audio/gusemu.h
> +++ b/hw/audio/gusemu.h
> @@ -25,16 +25,6 @@
>  #ifndef GUSEMU_H
>  #define GUSEMU_H
>
> -/* data types (need to be adjusted if neither a VC6 nor a C99 compatible compiler is used) */
> -
> -#if defined _WIN32 && defined _MSC_VER /* doesn't support other win32 compilers yet, do it yourself... */
> - typedef unsigned int GUSdword;
> - typedef signed short GUSsample;
> -#else
> - typedef uint32_t GUSdword;
> - typedef int16_t GUSsample;
> -#endif
> -
>  typedef struct _GUSEmuState
>  {
>   uint8_t *himemaddr; /* 1024*1024 bytes used for storing uploaded samples (+32 additional bytes for read padding) */
> @@ -86,7 +76,7 @@ void gus_dma_transferdata(GUSEmuState *state, char *dma_addr, unsigned int count
>  /* If the interrupts are asynchronous, it may be needed to use a separate thread mixing into a temporary */
>  /* audio buffer in order to avoid quality loss caused by large numsamples and elapsed_time values. */
>
> -void gus_mixvoices(GUSEmuState *state, unsigned int playback_freq, unsigned int numsamples, GUSsample *bufferpos);
> +void gus_mixvoices(GUSEmuState *state, unsigned int playback_freq, unsigned int numsamples, int16_t *bufferpos);
>  /* recommended range: 10 < numsamples < 100 */
>  /* lower values may result in increased rounding error, higher values often cause audible timing delays */
>
> diff --git a/hw/audio/gusemu_hal.c b/hw/audio/gusemu_hal.c
> index 3dd7239..1150fc4 100644
> --- a/hw/audio/gusemu_hal.c
> +++ b/hw/audio/gusemu_hal.c
> @@ -32,7 +32,7 @@
>
>  #define GUSregb(position) (*            (gusptr+(position)))
>  #define GUSregw(position) (*(uint16_t *) (gusptr+(position)))
> -#define GUSregd(position) (*(GUSdword *)(gusptr+(position)))
> +#define GUSregd(position) (*(uint16_t *)(gusptr+(position)))
>
>  /* size given in bytes */
>  unsigned int gus_read(GUSEmuState * state, int port, int size)
> diff --git a/hw/audio/gusemu_mixer.c b/hw/audio/gusemu_mixer.c
> index 981a9ae..00b9861 100644
> --- a/hw/audio/gusemu_mixer.c
> +++ b/hw/audio/gusemu_mixer.c
> @@ -28,13 +28,13 @@
>
>  #define GUSregb(position)  (*            (gusptr+(position)))
>  #define GUSregw(position)  (*(uint16_t *) (gusptr+(position)))
> -#define GUSregd(position)  (*(GUSdword *)(gusptr+(position)))
> +#define GUSregd(position)  (*(uint16_t *)(gusptr+(position)))
>
>  #define GUSvoice(position) (*(uint16_t *)(voiceptr+(position)))
>
>  /* samples are always 16bit stereo (4 bytes each, first right then left interleaved) */
>  void gus_mixvoices(GUSEmuState * state, unsigned int playback_freq, unsigned int numsamples,
> -                   GUSsample *bufferpos)
> +                   int16_t *bufferpos)
>  {
>      /* note that byte registers are stored in the upper half of each voice register! */
>      uint8_t        *gusptr;
> @@ -171,8 +171,8 @@ void gus_mixvoices(GUSEmuState * state, unsigned int playback_freq, unsigned int
>                  }
>
>                  /* mix samples into buffer */
> -                *(bufferpos + 2 * sample)     += (GUSsample) ((sample1 * PanningPos) >> 4);        /* right */
> -                *(bufferpos + 2 * sample + 1) += (GUSsample) ((sample1 * (15 - PanningPos)) >> 4); /* left */
> +                *(bufferpos + 2 * sample)     += (int16_t) ((sample1 * PanningPos) >> 4);        /* right */
> +                *(bufferpos + 2 * sample + 1) += (int16_t) ((sample1 * (15 - PanningPos)) >> 4); /* left */
>              }
>              /* write back voice and volume */
>              GUSvoice(wVSRCurrVol)   = Volume32 / 32;
>
diff mbox

Patch

diff --git a/hw/audio/gus.c b/hw/audio/gus.c
index 3d08a65..ec103a4 100644
--- a/hw/audio/gus.c
+++ b/hw/audio/gus.c
@@ -53,7 +53,7 @@  typedef struct GUSState {
     uint32_t freq;
     uint32_t port;
     int pos, left, shift, irqs;
-    GUSsample *mixbuf;
+    int16_t *mixbuf;
     uint8_t himem[1024 * 1024 + 32 + 4096];
     int samples;
     SWVoiceOut *voice;
diff --git a/hw/audio/gusemu.h b/hw/audio/gusemu.h
index 69dadef..ab591ee 100644
--- a/hw/audio/gusemu.h
+++ b/hw/audio/gusemu.h
@@ -25,16 +25,6 @@ 
 #ifndef GUSEMU_H
 #define GUSEMU_H
 
-/* data types (need to be adjusted if neither a VC6 nor a C99 compatible compiler is used) */
-
-#if defined _WIN32 && defined _MSC_VER /* doesn't support other win32 compilers yet, do it yourself... */
- typedef unsigned int GUSdword;
- typedef signed short GUSsample;
-#else
- typedef uint32_t GUSdword;
- typedef int16_t GUSsample;
-#endif
-
 typedef struct _GUSEmuState
 {
  uint8_t *himemaddr; /* 1024*1024 bytes used for storing uploaded samples (+32 additional bytes for read padding) */
@@ -86,7 +76,7 @@  void gus_dma_transferdata(GUSEmuState *state, char *dma_addr, unsigned int count
 /* If the interrupts are asynchronous, it may be needed to use a separate thread mixing into a temporary */
 /* audio buffer in order to avoid quality loss caused by large numsamples and elapsed_time values. */
 
-void gus_mixvoices(GUSEmuState *state, unsigned int playback_freq, unsigned int numsamples, GUSsample *bufferpos);
+void gus_mixvoices(GUSEmuState *state, unsigned int playback_freq, unsigned int numsamples, int16_t *bufferpos);
 /* recommended range: 10 < numsamples < 100 */
 /* lower values may result in increased rounding error, higher values often cause audible timing delays */
 
diff --git a/hw/audio/gusemu_hal.c b/hw/audio/gusemu_hal.c
index 3dd7239..1150fc4 100644
--- a/hw/audio/gusemu_hal.c
+++ b/hw/audio/gusemu_hal.c
@@ -32,7 +32,7 @@ 
 
 #define GUSregb(position) (*            (gusptr+(position)))
 #define GUSregw(position) (*(uint16_t *) (gusptr+(position)))
-#define GUSregd(position) (*(GUSdword *)(gusptr+(position)))
+#define GUSregd(position) (*(uint16_t *)(gusptr+(position)))
 
 /* size given in bytes */
 unsigned int gus_read(GUSEmuState * state, int port, int size)
diff --git a/hw/audio/gusemu_mixer.c b/hw/audio/gusemu_mixer.c
index 981a9ae..00b9861 100644
--- a/hw/audio/gusemu_mixer.c
+++ b/hw/audio/gusemu_mixer.c
@@ -28,13 +28,13 @@ 
 
 #define GUSregb(position)  (*            (gusptr+(position)))
 #define GUSregw(position)  (*(uint16_t *) (gusptr+(position)))
-#define GUSregd(position)  (*(GUSdword *)(gusptr+(position)))
+#define GUSregd(position)  (*(uint16_t *)(gusptr+(position)))
 
 #define GUSvoice(position) (*(uint16_t *)(voiceptr+(position)))
 
 /* samples are always 16bit stereo (4 bytes each, first right then left interleaved) */
 void gus_mixvoices(GUSEmuState * state, unsigned int playback_freq, unsigned int numsamples,
-                   GUSsample *bufferpos)
+                   int16_t *bufferpos)
 {
     /* note that byte registers are stored in the upper half of each voice register! */
     uint8_t        *gusptr;
@@ -171,8 +171,8 @@  void gus_mixvoices(GUSEmuState * state, unsigned int playback_freq, unsigned int
                 }
 
                 /* mix samples into buffer */
-                *(bufferpos + 2 * sample)     += (GUSsample) ((sample1 * PanningPos) >> 4);        /* right */
-                *(bufferpos + 2 * sample + 1) += (GUSsample) ((sample1 * (15 - PanningPos)) >> 4); /* left */
+                *(bufferpos + 2 * sample)     += (int16_t) ((sample1 * PanningPos) >> 4);        /* right */
+                *(bufferpos + 2 * sample + 1) += (int16_t) ((sample1 * (15 - PanningPos)) >> 4); /* left */
             }
             /* write back voice and volume */
             GUSvoice(wVSRCurrVol)   = Volume32 / 32;