shithub: mp3dec

Download patch

ref: dd063794986a1e6a23b6dc4dcdf95014e6c3df06
parent: 7295650ab38760846505897bd85b150022b9c570
parent: 5baf5cde14286b3ffeb7497bd6b11026051633aa
author: Lion <lieff@users.noreply.github.com>
date: Wed Nov 14 09:51:23 EST 2018

Merge pull request #46 from bog-dan-ro/fix_cpp

Fix compile with g++ 8

--- a/minimp3_ex.h
+++ b/minimp3_ex.h
@@ -103,7 +103,7 @@
         return;
     samples *= frame_info.channels;
     size_t allocated = (buf_size/frame_info.frame_bytes)*samples*sizeof(mp3d_sample_t) + MINIMP3_MAX_SAMPLES_PER_FRAME*sizeof(mp3d_sample_t);
-    info->buffer = malloc(allocated);
+    info->buffer = (mp3d_sample_t*)malloc(allocated);
     if (!info->buffer)
         return;
     info->samples = samples;
@@ -121,7 +121,7 @@
         if ((allocated - info->samples*sizeof(mp3d_sample_t)) < MINIMP3_MAX_SAMPLES_PER_FRAME*sizeof(mp3d_sample_t))
         {
             allocated *= 2;
-            info->buffer = realloc(info->buffer, allocated);
+            info->buffer = (mp3d_sample_t*)realloc(info->buffer, allocated);
         }
         samples = mp3dec_decode_frame(dec, buf, buf_size, info->buffer + info->samples, &frame_info);
         frame_bytes = frame_info.frame_bytes;
@@ -146,7 +146,7 @@
     } while (frame_bytes);
     /* reallocate to normal buffer size */
     if (allocated != info->samples*sizeof(mp3d_sample_t))
-        info->buffer = realloc(info->buffer, info->samples*sizeof(mp3d_sample_t));
+        info->buffer = (mp3d_sample_t*)realloc(info->buffer, info->samples*sizeof(mp3d_sample_t));
     info->avg_bitrate_kbps = avg_bitrate_kbps/frames;
 }
 
@@ -246,7 +246,7 @@
 
     map_info->size = st.st_size;
 retry_mmap:
-    map_info->buffer = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, file, 0);
+    map_info->buffer = (const uint8_t *)mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE | MAP_POPULATE, file, 0);
     if (MAP_FAILED == map_info->buffer && (errno == EAGAIN || errno == EINTR))
         goto retry_mmap;
     close(file);