shithub: choc

Download patch

ref: e7b1f3015bdae2519a5f040b52a37feaa9502e3e
parent: f6deaba729b678fa92d3edddf1b1b1ea944f78fc
author: Jonathan Dowland <jon+github@alcopop.org>
date: Thu Jun 25 14:58:57 EDT 2015

rework AllocateSound to return allocated_sound_t

Necessary so I can use AllocateSound as part of a new routine that
will clone an existing allocated_sound_t.

--- a/src/i_sdlsound.c
+++ b/src/i_sdlsound.c
@@ -196,7 +196,7 @@
 
 // Allocate a block for a new sound effect.
 
-static Mix_Chunk *AllocateSound(sfxinfo_t *sfxinfo, size_t len)
+static allocated_sound_t *AllocateSound(sfxinfo_t *sfxinfo, size_t len)
 {
     allocated_sound_t *snd;
 
@@ -237,7 +237,7 @@
 
     AllocatedSoundLink(snd);
 
-    return &snd->chunk;
+    return snd;
 }
 
 // Lock a sound, to indicate that it may not be freed.
@@ -353,6 +353,7 @@
 //    uint32_t alen;
     int retn;
     int16_t *expanded;
+    allocated_sound_t *snd;
     Mix_Chunk *chunk;
 
     src_data.input_frames = length;
@@ -384,13 +385,14 @@
 
 //    alen = src_data.output_frames_gen * 4;
 
-    chunk = AllocateSound(sfxinfo, src_data.output_frames_gen * 4);
+    snd = AllocateSound(sfxinfo, src_data.output_frames_gen * 4);
 
-    if (chunk == NULL)
+    if (snd == NULL)
     {
         return false;
     }
 
+    chunk = &snd->chunk;
     expanded = (int16_t *) chunk->abuf;
 
     // Convert the result back into 16-bit integers.
@@ -543,6 +545,7 @@
                                    int length)
 {
     SDL_AudioCVT convertor;
+    allocated_sound_t *snd;
     Mix_Chunk *chunk;
     uint32_t expanded_length;
 
@@ -556,12 +559,14 @@
 
     // Allocate a chunk in which to expand the sound
 
-    chunk = AllocateSound(sfxinfo, expanded_length);
+    snd = AllocateSound(sfxinfo, expanded_length);
 
-    if (chunk == NULL)
+    if (snd == NULL)
     {
         return false;
     }
+
+    chunk = &snd->chunk;
 
     // If we can, use the standard / optimized SDL conversion routines.