Code Monkey home page Code Monkey logo

dr_libs's Introduction

David Reid

Open source C and C++ developer focusing on small, easy to use libraries with no dependencies and simple build systems.

discord mastodon

dr_libs's People

Contributors

bendrien avatar bmcdonnell-ionx avatar bobsayshilol avatar ccawley2011 avatar chausner avatar clownacy avatar deltabeard avatar dreamer avatar g4vi avatar hookedbehemoth avatar krossx avatar ktmf01 avatar liuyang1 avatar mackron avatar maraakate avatar musicinmybrain avatar rdb avatar samwindell avatar scribam avatar sezero avatar slouken avatar vieux avatar wohlstand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dr_libs's Issues

heap-buffer-overflow in drflac__decode_samples__verbatim

Hello.

I found a heap-buffer-overflow bug in dr_libs.

Please confirm.

Thanks.

OS: CentOS 7 64bit
Version: commit f4b2f62
PoC Download: OV_drflac__decode_samples__verbatim.zip

Steps to reproduce:
1.Download the .POC files.
2.Execute the following command
: ./dr_flac

Source

#define DR_FLAC_IMPLEMENTATION
#include "dr_flac.h"

int main()
{
    drflac* pFlac = drflac_open_file("$FILE");
    if (pFlac == NULL) {
        return -1;
    }

    int32_t* pSampleData = (int32_t*)malloc((size_t)pFlac->totalSampleCount * sizeof(int32_t));
    drflac_read_s32(pFlac, pFlac->totalSampleCount, pSampleData);

    // At this point pSampleData contains every decoded sample as signed 32-bit PCM.

    drflac_close(pFlac);
    return 0;
}

Log

=================================================================
==12175==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6220000016a0 at pc 0x00000051a719 bp 0x7ffe69e01b70 sp 0x7ffe69e01b68
WRITE of size 4 at 0x6220000016a0 thread T0
    #0 0x51a718 in drflac__decode_samples__verbatim /home/karas/dr_libs/./dr_flac.h:2551:28
    #1 0x51a718 in drflac__decode_subframe /home/karas/dr_libs/./dr_flac.h:2868
    #2 0x51a718 in drflac__decode_frame /home/karas/dr_libs/./dr_flac.h:2987
    #3 0x51aa31 in drflac__read_and_decode_next_frame /home/karas/dr_libs/./dr_flac.h:3060:32
    #4 0x51aa31 in drflac_read_s32 /home/karas/dr_libs/./dr_flac.h:5026
    #5 0x52b05a in main /home/karas/dr_libs/dr_flac.c:13:11
    #6 0x7f93b1c313f0 in __libc_start_main /build/glibc-mXZSwJ/glibc-2.24/csu/../csu/libc-start.c:291
    #7 0x4199b9 in _start (/home/karas/dr_libs/dr_flac_asan+0x4199b9)

0x6220000016a0 is located 0 bytes to the right of 5536-byte region [0x622000000100,0x6220000016a0)
allocated by thread T0 here:
    #0 0x4d7b38 in __interceptor_malloc (/home/karas/dr_libs/dr_flac_asan+0x4d7b38)
    #1 0x51fabd in drflac_open_with_metadata_private /home/karas/dr_libs/./dr_flac.h:4586:30
    #2 0x52b00e in drflac_open /home/karas/dr_libs/./dr_flac.h:4865:12
    #3 0x52b00e in drflac_open_file /home/karas/dr_libs/./dr_flac.h:4735
    #4 0x52b00e in main /home/karas/dr_libs/dr_flac.c:7

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/karas/dr_libs/./dr_flac.h:2551:28 in drflac__decode_samples__verbatim
Shadow bytes around the buggy address:
  0x0c447fff8280: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c447fff8290: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c447fff82a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c447fff82b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c447fff82c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c447fff82d0: 00 00 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa
  0x0c447fff82e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c447fff82f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c447fff8300: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c447fff8310: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c447fff8320: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==12175==ABORTING

=================================================================
[Acknowledgement]
This work was supported by ICT R&D program of MSIP/IITP. [R7518-16-1001, Innovation hub for high Performance Computing]

dr_wav loads half track on 2 channel file

When a wave file has two channels, dr_wav loads only haldf the file. The problem appears to be in dr_wav.h in the function drwav_get_bytes_per_pcm_frame in the following part:

drwav_uint32 bitsPerFrame = pWav->bitsPerSample / pWav->fmt.channels;

The no. of bits per sample should not be divided by the number of channels (IMHO). When I remove the division it does load correctly.

dr_flac.h build failure with -fPIC

This is on CentOS 6.10 / i686 with gcc-4.4.7 as came with the OS:

$ gcc -xc -O3 -DDR_FLAC_IMPLEMENTATION -DNDEBUG -std=gnu99 -fPIC -o dr_flac.c.o -c dr_flac.h
dr_flac.h:799:1: warning: "_BSD_SOURCE" redefined
In file included from /usr/include/stdint.h:26,
                 from dr_flac.h:133:
/usr/include/features.h:182:1: warning: this is the location of the previous definition
dr_flac.h: In function ‘drflac__swap_endian_uint16’:
dr_flac.h:921: warning: implicit declaration of function ‘__builtin_bswap16’
dr_flac.h: In function ‘drflac_open_with_metadata_private’:
dr_flac.h:785: error: can't find a register in class ‘BREG’ while reloading ‘asm’
dr_flac.h:785: error: can't find a register in class ‘BREG’ while reloading ‘asm’
dr_flac.h:785: error: ‘asm’ operand has impossible constraints
dr_flac.h:785: error: ‘asm’ operand has impossible constraints

The cpuid asm failure seems to be because ebx is the PIC register:
The failure doesn't happen without -fPIC.

The __builtin_bswap16 warning is there because, unlike __builtin_bswap32,
__builtin_bswap16 is added in gcc-4.8, not gcc-4.3.

gcc-4.9.4 fails in a similar way:

$ gcc49 -xc -O3 -DDR_FLAC_IMPLEMENTATION -DNDEBUG -std=gnu99 -fPIC -o dr_flac.c.o -c dr_flac.h
dr_flac.h:799:0: warning: "_BSD_SOURCE" redefined
 #define _BSD_SOURCE
 ^
In file included from /usr/include/stdint.h:26:0,
                 from /opt/gcc490/lib/gcc/i686-pc-linux-gnu/4.9.4/include/stdint.h:9,
                 from dr_flac.h:133:
/usr/include/features.h:182:0: note: this is the location of the previous definition
 # define _BSD_SOURCE 1
 ^
dr_flac.h: In function 'drflac_open_with_metadata_private':
dr_flac.h:785:17: error: inconsistent operand constraints in an 'asm'
                 __asm__ __volatile__ (
                 ^
dr_flac.h:785:17: error: inconsistent operand constraints in an 'asm'
                 __asm__ __volatile__ (
                 ^

dr_wav - only assert things that you (intend to) ensure internally

I've reached a conclusion on an issue we discussed previously: in drwav_uninit(), I think this should be a runtime failure, not an assert.

        /* Validation for sequential mode. */
        if (pWav->isSequentialWrite) {
            drwav_assert(pWav->dataChunkDataSize == pWav->dataChunkDataSizeTargetWrite);
        }

You're imposing an assert on the client, which they may not check for.

If the application wants to abort the write, how are they supposed to cleanup?

More broadly, I think the rule of thumb should be as stated in this issue title. IDK if there are other instances, potentially outside of dr_wav.

https://www.beningo.com/tips-and-tricks-when-to-assert-or-not-assert/

Opus decoder.

Was just wondering if its possible that a one-file Opus decoder can be made.

dr_gui: Remove superfluous redraws.

There needs to be some kind of accumulator where a call to drgui_dirty() does not immediately request a redraw, but instead only does it if some kind of reference counter or whatnot is at 0.

Possible API:
drgui__begin_dirty() - Increments a reference counter.
drgui__end_dirty() - Decrements a reference counter. If it hits zero, request an actual redraw via the backend.

When an element is automatically marked as dirty from an event handler, the event handler should be placed between the begin/end pair.

[dr_wav] Connection to openal

Have you ever used openal?
Because i have a problem, using openal-soft
A mono .wav sound is loaded correctly and is correctly 3d spatialized
A stereo (double channel) .wav sound is played only from one speaker (the one on the right in my case).
It looks like is played from both speakers when using headphones but is very very low on the left one.
Edit: after trying several headphones i can confirm it only play on the right channel
I don't understand if i'm missing something while loading the .wav using dr_wav to openal buffer or if i did something wrong using openal

PS: Stereo sounds should not be spatialized by openal and should be played as 2d sounds by openal, so from both speakers, the sound/listener position is not a problem here

question about threading

Hi mackron,

I noted you mention dr_flac is not thread safe, so that is my question: if I 'open_memory' a FLAC file twice (i.e., get two different handles for the same file/memory) and I call 'read_frames' in two different threads, one for each handler, will there be a race condition or this situation is safe?

Thanks.
Best regards,
Roberto.

dr_flac: 16-bit output?

Hello,

I'm currently using the dr_flac library to play flac files on the 3DS. The 3DS can only play 16-bit PCM streams, so I tried to make a number of changes to the library to return the samples in 16-bit but it was buggy and I didn't really know what I was doing.

I was wondering if you could recommend any changes that I could make to your library to return samples in 16-bit rather than 32-bit?

Thank you in advance.

stack-buffer-overflow in drwav_f64_to_s32

Hello.

I found a stack-buffer-overflow bug in dr_libs.

Please confirm.

Thanks.

OS: CentOS 7 64bit
Version: commit f4b2f62
PoC Download: OV_drwav_f64_to_s32.zip

Steps to reproduce:
1.Download the .POC files.
2.Execute the following command
: ./dr_wav

Source

#define DR_WAV_IMPLEMENTATION
#include "dr_wav.h"

int main()
{
    drwav* pWav = drwav_open_file("$FILE");
    if (pWav == NULL) {
        return -1;
    }

    int32_t* pSampleData = (int32_t*)malloc((size_t)pWav->totalSampleCount * sizeof(int32_t));
    drwav_read_s32(pWav, pWav->totalSampleCount, pSampleData);


    drwav_close(pWav);
    return 0;
}

Log

=================================================================
==18637==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fff7a90c100 at pc 0x00000052cc11 bp 0x7fff7a90b0d0 sp 0x7fff7a90b0c8
READ of size 16 at 0x7fff7a90c100 thread T0
    #0 0x52cc10 in drwav_f64_to_s32 /home/karas/dr_libs/./dr_wav.h:3089:48
    #1 0x52cc10 in drwav__ieee_to_s32 /home/karas/dr_libs/./dr_wav.h:2859
    #2 0x52cc10 in drwav_read_s32__ieee /home/karas/dr_libs/./dr_wav.h:2944
    #3 0x52e87d in drwav_read_s32 /home/karas/dr_libs/./dr_wav.h:3015:16
    #4 0x5345f8 in main /home/karas/dr_libs/1.c:11:11
    #5 0x7fd499ade3f0 in __libc_start_main /build/glibc-mXZSwJ/glibc-2.24/csu/../csu/libc-start.c:291
    #6 0x4199b9 in _start (/home/karas/dr_libs/dr_wav+0x4199b9)

Address 0x7fff7a90c100 is located in stack of thread T0 at offset 4128 in frame
    #0 0x52bd0f in drwav_read_s32__ieee /home/karas/dr_libs/./dr_wav.h:2935

  This frame has 1 object(s):
    [32, 4128) 'sampleData' (line 2937) <== Memory access at offset 4128 overflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism or swapcontext
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow /home/karas/dr_libs/./dr_wav.h:3089:48 in drwav_f64_to_s32
Shadow bytes around the buggy address:
  0x10006f5197d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006f5197e0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006f5197f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006f519800: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006f519810: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x10006f519820:[f3]f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3 f3
  0x10006f519830: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006f519840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x10006f519850: f1 f1 f1 f1 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
  0x10006f519860: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
  0x10006f519870: f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8 f8
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==18637==ABORTING
==28425== Invalid read of size 8
==28425==    at 0x110022: drwav_f64_to_s32 (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x10F5FE: drwav__ieee_to_s32 (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x10FA24: drwav_read_s32(int,...)(...)(...) (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x10FD4E: drwav_read_s32 (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x110D22: main (in /home/karas/dr_libs/dr_wav)
==28425==  Address 0xfff001000 is not stack'd, malloc'd or (recently) free'd
==28425== 
==28425== 
==28425== Process terminating with default action of signal 11 (SIGSEGV)
==28425==  Access not within mapped region at address 0xFFF001000
==28425==    at 0x110022: drwav_f64_to_s32 (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x10F5FE: drwav__ieee_to_s32 (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x10FA24: drwav_read_s32(int,...)(...)(...) (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x10FD4E: drwav_read_s32 (in /home/karas/dr_libs/dr_wav)
==28425==    by 0x110D22: main (in /home/karas/dr_libs/dr_wav)
==28425==  If you believe this happened as a result of a stack
==28425==  overflow in your program's main thread (unlikely but
==28425==  possible), you can try to increase the size of the
==28425==  main thread stack using the --main-stacksize= flag.
==28425==  The main thread stack size used in this run was 8388608.
==28425== 

=================================================================
[Acknowledgement]
This work was supported by ICT R&D program of MSIP/IITP. [R7518-16-1001, Innovation hub for high Performance Computing]

Push API for dr_wav/dr_flac?

Hi there - I noticed dr_mp3 has a push-style API, as does stb_vorbis.

I didn't know if there were any plans to implement one - or is there a way to do it with the decoders as-is?

I've got an application where I just read audio data as it comes in, via pipe, and decode whatever I have available. Right now it just accepts raw PCM samples, I was hoping to add the ability to decode other codecs in a similar way.

Thank you in advance, these are such great libraries!

dr_flac bitstream, unalignedByteCount not cleared

Hej!

I'm currently writing a single-file unrar library (GPLv2+-licensed, though, because I'm also basing it on GPLv2+ and LGPLv2.1+ unrar code), and I'm reusing your bitstream code. Thanks for writing it, btw, it's really nice and clean!

I've noticed that drflac__reload_cache(), in the slow path, doesn't clear unalignedByteCount after loading unalignedCache into the L1 cache. Is there a reason for that, or is that a mistake?

Specifically, I think there should be a
bs->unalignedByteCount = 0;
before the return here: https://github.com/mackron/dr_libs/blob/master/dr_flac.h#L961

Otherwise, when reading past the end of the client buffer, the last n bits will be repeated over and over, instead of the _read* functions returning DR_FALSE. Or am I just missing something?

Cheers,
Sven

dr_flac SSE2 type error when building under Github's CI chain, amd64, Ubuntu 18.04.1, gcc 7.4.0

See Line 861 here - https://github.com/dreamer/dosbox-staging/commit/a4563e66636a85254f05891441cd350511fb61a7/checks

This appears to be using the SSE2 functions.

dr_flac.h: In function ‘drflac_read_pcm_frames_s16__decode_left_side__sse2’:
dr_flac.h:8243:60: warning: implicit declaration of function ‘drflac__mm_packs_interleaved_epi32’ [-Wimplicit-function-declaration]
         _mm_storeu_si128((__m128i*)(pOutputSamples + i*8), drflac__mm_packs_interleaved_epi32(left, right));
                                                            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8243:60: error: incompatible type for argument 2 of ‘_mm_storeu_si128’
In file included from dr_flac.h:1052:0,
                 from flac.c:47:
/usr/lib/gcc/x86_64-linux-gnu/7/include/emmintrin.h:719:1: note: expected ‘__m128i {aka __vector(2) long long int}’ but argument is of type ‘int’
 _mm_storeu_si128 (__m128i_u *__P, __m128i __B)
 ^~~~~~~~~~~~~~~~

(and following lines).

I unfortunately can't reproduce this on my own Linux system (Ubuntu 19.04) using gcc-7.4.0; it builds clean. My Skylake system might be using newer instructions and not taking the SSE2 code-path in dr_flac.

We can add commands to github's CI commands to help diagnose this, like dumping /proc/cpuinfo, uname -a, etc.. ); just let me know.

dr_flac (dev/flac) gcc 8.3 warnings using "-Wall -Wpedantic", as of 14-Sep-2019

Not sure if these are fixable or not; I realize I might be causing this excessive verbosity due to using the pedantic flag (if so, please disregard!).

gcc -DHAVE_CONFIG_H -I. -I../../..   -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT -Iinternal/ogg/include -Iinternal/opus/include -I/usr/local/include/SDL -D_GNU_SOURCE=1 -D_REENTRANT  -O3 -march=native -frename-registers -flto=8 -pipe -fno-unsafe-math-optimizations -Wpedantic -Wall -MT libdecoders_a-flac.o -MD -MP -MF .deps/libdecoders_a-flac.Tpo -c -o libdecoders_a-flac.o `test -f 'flac.c' || echo './'`flac.c
In file included from flac.c:46:
dr_flac.h:9401:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:9369:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:9331:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:9304:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:9207:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:9094:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:9061:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:9020:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8974:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8941:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8900:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8854:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_f32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, float* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8739:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8710:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8664:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8636:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8550:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8419:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8386:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8344:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8287:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8251:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8209:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8152:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s16__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int16* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8034:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:8008:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7972:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_independent_stereo__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7944:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7862:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7751:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_mid_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7718:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7681:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7637:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_right_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7604:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7567:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__sse2(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:7523:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac_read_pcm_frames_s32__decode_left_side__scalar(drflac* pFlac, drflac_uint64 frameCount, drflac_int32 unusedBitsPerSample, const drflac_int32* pInputSamples0, const drflac_int32* pInputSamples1, drflac_int32* pOutputSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:6253:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_body_size(drflac_ogg_page_header* pHeader)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:6248:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac_ogg__get_page_header_size(drflac_ogg_page_header* pHeader)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:6243:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac_ogg__is_capture_pattern(drflac_uint8 pattern[4])
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:6232:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
                                    ^~~~~~~~~~~~~~~~~~~
dr_flac.h:6204:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac_crc32_byte(drflac_uint32 crc32, drflac_uint8 data)
                                    ^~~~~~~~~~~~~~~~~
dr_flac.h:5561:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__read_and_decode_block_header(drflac_read_proc onRead, void* pUserData, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:5553:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac__decode_block_header(drflac_uint32 blockHeader, drflac_uint8* isLastBlock, drflac_uint8* blockType, drflac_uint32* blockSize)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:5001:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_result drflac__seek_to_next_flac_frame(drflac* pFlac)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:4836:35: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint8 drflac__get_channel_count_from_channel_assignment(drflac_int8 channelAssignment)
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:3692:30: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE __m128i drflac__mm_srai_epi64(__m128i x, int count)
                              ^~~~~~~~~~~~~~~~~~~~~
dr_flac.h:3687:30: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE __m128i drflac__mm_hadd_epi64(__m128i x)
                              ^~~~~~~~~~~~~~~~~~~~~
dr_flac.h:3680:30: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE __m128i drflac__mm_hadd_epi32(__m128i x)
                              ^~~~~~~~~~~~~~~~~~~~~
dr_flac.h:3675:30: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE __m128i drflac__mm_not_si128(__m128i a)
                              ^~~~~~~~~~~~~~~~~~~~
dr_flac.h:3658:30: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE __m128i drflac__mm_packs_interleaved_epi32(__m128i a, __m128i b)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:3395:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__seek_rice_parts(drflac_bs* bs, drflac_uint8 riceParam)
                                    ^~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:3268:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x4(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:3147:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x1(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2793:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac__calculate_prediction_64_x4(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, const drflac_uint32 riceParamParts[4], drflac_int32* pDecodedSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2612:35: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_64(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2419:27: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE void drflac__calculate_prediction_32_x4(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, const drflac_uint32 riceParamParts[4], drflac_int32* pDecodedSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2371:35: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_int32 drflac__calculate_prediction_32(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, drflac_int32* pDecodedSamples)
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2235:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__seek_past_next_set_bit(drflac_bs* bs, unsigned int* pOffsetOut)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2218:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac__clz(drflac_cache_t x)
                                    ^~~~~~~~~~~
dr_flac.h:2172:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac__clz_lzcnt(drflac_cache_t x)
                                    ^~~~~~~~~~~~~~~~~
dr_flac.h:2162:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__is_lzcnt_supported()
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2128:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac__clz_software(drflac_cache_t x)
                                    ^~~~~~~~~~~~~~~~~~~~
dr_flac.h:1832:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__read_uint32(drflac_bs* bs, unsigned int bitCount, drflac_uint32* pResultOut)
                                    ^~~~~~~~~~~~~~~~~~~
dr_flac.h:1713:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__reload_l1_cache_from_l2(drflac_bs* bs)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:1636:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
                                    ^~~~~~~~~~~~
In file included from flac.c:46:
dr_flac.h:1597:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16__64bit(drflac_uint16 crc, drflac_uint64 data, drflac_uint32 count)
                                    ^~~~~~~~~~~~~~~~~~~
dr_flac.h:1548:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
                                    ^~~~~~~~~~~~~~~~~~~
dr_flac.h:1529:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
                                    ^~~~~~~~~~~~~~~~~~
dr_flac.h:1524:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16_byte(drflac_uint16 crc, drflac_uint8 data)
                                    ^~~~~~~~~~~~~~~~~
In file included from flac.c:46:
dr_flac.h:1477:35: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint8 drflac_crc8(drflac_uint8 crc, drflac_uint32 data, drflac_uint32 count)
                                   ^~~~~~~~~~~
dr_flac.h:1472:35: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
                                   ^~~~~~~~~~~~~~~~
dr_flac.h:1404:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac__unsynchsafe_32(drflac_uint32 n)
                                    ^~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:1394:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac__le2host_32(drflac_uint32 n)
                                    ^~~~~~~~~~~~~~~~~~
dr_flac.h:1384:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint64 drflac__be2host_64(drflac_uint64 n)
                                    ^~~~~~~~~~~~~~~~~~
dr_flac.h:1375:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac__be2host_32(drflac_uint32 n)
                                    ^~~~~~~~~~~~~~~~~~
dr_flac.h:1366:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint16 drflac__be2host_16(drflac_uint16 n)
                                    ^~~~~~~~~~~~~~~~~~
dr_flac.h:1343:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint64 drflac__swap_endian_uint64(drflac_uint64 n)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:1325:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint32 drflac__swap_endian_uint32(drflac_uint32 n)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:1309:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_uint16 drflac__swap_endian_uint16(drflac_uint16 n)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:1297:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac__is_little_endian()
                                    ^~~~~~~~~~~~~~~~~~~~~~~~
In file included from flac.c:46:
dr_flac.h:1134:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac_has_sse41()
                                    ^~~~~~~~~~~~~~~~
dr_flac.h:1109:36: warning: always_inline function might not be inlinable [-Wattributes]
 static DRFLAC_INLINE drflac_bool32 drflac_has_sse2()
                                    ^~~~~~~~~~~~~~~
In file included from flac.c:46:
dr_flac.h:6232:36: warning: ‘drflac_crc32_buffer’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE drflac_uint32 drflac_crc32_buffer(drflac_uint32 crc32, drflac_uint8* pData, drflac_uint32 dataSize)
                                    ^~~~~~~~~~~~~~~~~~~
dr_flac.h:3268:36: warning: ‘drflac__read_rice_parts_x4’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE drflac_bool32 drflac__read_rice_parts_x4(drflac_bs* bs, drflac_uint8 riceParam, drflac_uint32* pZeroCounterOut, drflac_uint32* pRiceParamPartOut)
                                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2793:27: warning: ‘drflac__calculate_prediction_64_x4’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE void drflac__calculate_prediction_64_x4(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, const drflac_uint32 riceParamParts[4], drflac_int32* pDecodedSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:2419:27: warning: ‘drflac__calculate_prediction_32_x4’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE void drflac__calculate_prediction_32_x4(drflac_uint32 order, drflac_int32 shift, const drflac_int32* coefficients, const drflac_uint32 riceParamParts[4], drflac_int32* pDecodedSamples)
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
dr_flac.h:1636:36: warning: ‘drflac_crc16’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 count)
                                    ^~~~~~~~~~~~
In file included from flac.c:46:
dr_flac.h:1548:36: warning: ‘drflac_crc16__32bit’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16__32bit(drflac_uint16 crc, drflac_uint32 data, drflac_uint32 count)
                                    ^~~~~~~~~~~~~~~~~~~
dr_flac.h:1529:36: warning: ‘drflac_crc16_bytes’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE drflac_uint16 drflac_crc16_bytes(drflac_uint16 crc, drflac_cache_t data, drflac_uint32 byteCount)
                                    ^~~~~~~~~~~~~~~~~~
In file included from flac.c:46:
dr_flac.h:1472:35: warning: ‘drflac_crc8_byte’ defined but not used [-Wunused-function]
 static DRFLAC_INLINE drflac_uint8 drflac_crc8_byte(drflac_uint8 crc, drflac_uint8 data)
                                   ^~~~~~~~~~~~~~~~

Floating point exception in drwav_init

Hello.

I found a Floating point exception bug in dr_libs.

Please confirm.

Thanks.

OS: CentOS 7 64bit
Version: commit f4b2f62
PoC Download: FPE_drwav_init.zip

Steps to reproduce:
1.Download the .POC files.
2.Execute the following command
: ./dr_wav

Source

#define DR_WAV_IMPLEMENTATION
#include "dr_wav.h"

int main()
{
    drwav* pWav = drwav_open_file("$FILE");
    if (pWav == NULL) {
        return -1;
    }

    int32_t* pSampleData = (int32_t*)malloc((size_t)pWav->totalSampleCount * sizeof(int32_t));
    drwav_read_s32(pWav, pWav->totalSampleCount, pSampleData);


    drwav_close(pWav);
    return 0;
}

Log

=================================================================
==27224==ERROR: AddressSanitizer: FPE on unknown address 0x00000050efe0 (pc 0x00000050efe0 bp 0x7fff47b52ed0 sp 0x7fff47b52c40 T0)
    #0 0x50efdf in drwav_init /home/karas/dr_libs/./dr_wav.h:1484:43
    #1 0x5345b4 in drwav_open /home/karas/dr_libs/./dr_wav.h:1701:10
    #2 0x5345b4 in drwav_open_file /home/karas/dr_libs/./dr_wav.h:1065
    #3 0x5345b4 in main /home/karas/dr_libs/1.c:6
    #4 0x7f9686fae3f0 in __libc_start_main /build/glibc-mXZSwJ/glibc-2.24/csu/../csu/libc-start.c:291
    #5 0x4199b9 in _start (/home/karas/dr_libs/foo+0x4199b9)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: FPE /home/karas/dr_libs/./dr_wav.h:1484:43 in drwav_init
==27224==ABORTING

=================================================================
[Acknowledgement]
This work was supported by ICT R&D program of MSIP/IITP. [R7518-16-1001, Innovation hub for high Performance Computing]

dr_wav: need help decoding on big-endian architecture

Hi Dave,
Looking for some tips on how to get usable signed 16-bit output on a big-endian machine from dr_wav. Right now I get what sounds like static, garbage, or possibly byte-swapped data.

I'm using an up-to-date Ubuntu-ppc Linux distro, building with gcc 5.4.x, on a big-endian PowerMac G4 with a PowerPC-7400 CPU. Of note is that dr_mp3 and dr_flac both work flawless on this machine using their respective drmp3_read_pcm_frames_s16(...) and drflac_read_pcm_frames_s16(...) functions.

The WAV file was created on an x86_64 machine and is a typical CD-rip: 44.1 kHz, 2 channels, and 16-bit samples. Decoding it with dr_wav on an x86_64 machine works great using drwav_read_pcm_frames_s16(...) and treating the data as least-significant-byte first.

On the PowerMac, I've tried drwav_read_pcm_frames_s16 and drwav_read_raw, and I've tried treating those resulting 2-byte samples as litte, big, and system-endian: all of them play as harsh static.

I'm wondering if the two-byte values need to be byte-swapped? Is that something dr_wav can do as part of the multi-byte 32 and 16 bit read functions when operating under big-endian? Or do you suspect something else?

dr_wav: API inconsistent - samples vs. frames

Per dr_wav.h,

Version 0.9.0 deprecated the per-sample reading and seeking APIs and replaced them with versions that work on the resolution of a PCM frame instead.
...
drwav_write() -> drwav_write_pcm_frames()
...

However, several apparently not deprecated functions take a totalSampleCount parameter, not framesToWrite. So far, I see that includes drwav_init_write__internal(), and all of the functions that call it and pass through totalSampleCount. (Generally the *_sequential ones.)

It also includes the new/proposed drwav_target_write_size_bytes() in #56.

NULL pointer dereference in drpcx__decode_8bit

Hello.

I found a NULL pointer dereference bug in dr_libs.(pcx)

Please confirm.

Thanks.

OS: CentOS 7 64bit
Version: commit 5a6e384
PoC Download: null_drpcx__decode_8bit.zip

Steps to reproduce:
1.Download the .POC files.
2.Execute the following command
: ./dr_pcx

=================================================================
==1390==ERROR: AddressSanitizer: SEGV on unknown address 0x7f56bdd27e00 (pc 0x0000004eaf24 bp 0x7fff6586c630 sp 0x7fff6586c120 T0)
    #0 0x4eaf23 in drpcx__decode_8bit /home/karas/dr_libs/./dr_pcx.h:541:25
    #1 0x4dbb5f in drpcx_load /home/karas/dr_libs/./dr_pcx.h:663:22
    #2 0x4ec9c9 in drpcx_load_file /home/karas/dr_libs/./dr_pcx.h:138:28
    #3 0x4ec9c9 in main /home/karas/dr_libs/pcx.c:12
    #4 0x7f56bd4d782f in __libc_start_main /build/glibc-Cl5G7W/glibc-2.23/csu/../csu/libc-start.c:291
    #5 0x434fd8 in _start (/home/karas/dr_libs/asan_pcx+0x434fd8)

AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /home/karas/dr_libs/./dr_pcx.h:541 drpcx__decode_8bit
==1390==ABORTING

drmp3_init_memory always returns NULL

Noticed a possible bug.

Whenever I try to use drmp3_init_memory, I always get the return value of the function as false.

I am using:

 drmp3 dr_mp3;
 bool res =drmp3_init_memory(&dr_mp3,(const unsigned char*)sound->types.mp3.data,sound->types.mp3.size,NULL);

It seems the pMP3->memory struct is zeroed out somewhere which means it seems to not read from the memory buffer at all on the read callback, which means it always fails decoding the first MPEG frame.

heap-buffer-overflow in drflac__decode_samples_with_residual__rice__simple

Hello.

I found a heap-buffer-overflow bug in dr_libs.

Please confirm.

Thanks.

OS: CentOS 7 64bit
Version: commit f4b2f62
PoC Download: drflac__decode_samples_with_residual__rice__simple.zip

Steps to reproduce:
1.Download the .POC files.
2.Execute the following command
: ./dr_flac

Source

#define DR_FLAC_IMPLEMENTATION
#include "dr_flac.h"

int main()
{
    drflac* pFlac = drflac_open_file("$FILE");
    if (pFlac == NULL) {
        return -1;
    }

    int32_t* pSampleData = (int32_t*)malloc((size_t)pFlac->totalSampleCount * sizeof(int32_t));
    drflac_read_s32(pFlac, pFlac->totalSampleCount, pSampleData);

    // At this point pSampleData contains every decoded sample as signed 32-bit PCM.

    drflac_close(pFlac);
    return 0;
}

Log

=================================================================
==4729==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x6270000036a0 at pc 0x000000534496 bp 0x7ffce2c0a2a0 sp 0x7ffce2c0a298
WRITE of size 4 at 0x6270000036a0 thread T0
    #0 0x534495 in drflac__decode_samples_with_residual__rice__simple /home/karas/dr_libs/./dr_flac.h
    #1 0x534495 in drflac__decode_samples_with_residual__rice /home/karas/dr_libs/./dr_flac.h:2334
    #2 0x534495 in drflac__decode_samples_with_residual /home/karas/dr_libs/./dr_flac.h:2427
    #3 0x51932b in drflac__decode_samples__fixed /home/karas/dr_libs/./dr_flac.h:2578:10
    #4 0x51932b in drflac__decode_subframe /home/karas/dr_libs/./dr_flac.h:2873
    #5 0x51932b in drflac__decode_frame /home/karas/dr_libs/./dr_flac.h:2987
    #6 0x51aa31 in drflac__read_and_decode_next_frame /home/karas/dr_libs/./dr_flac.h:3060:32
    #7 0x51aa31 in drflac_read_s32 /home/karas/dr_libs/./dr_flac.h:5026
    #8 0x52b05a in main /home/karas/dr_libs/dr_flac.c:13:11
    #9 0x7f0b7e4463f0 in __libc_start_main /build/glibc-mXZSwJ/glibc-2.24/csu/../csu/libc-start.c:291
    #10 0x4199b9 in _start (/home/karas/dr_libs/dr_flac_asan+0x4199b9)

0x6270000036a0 is located 0 bytes to the right of 13728-byte region [0x627000000100,0x6270000036a0)
allocated by thread T0 here:
    #0 0x4d7b38 in __interceptor_malloc (/home/karas/dr_libs/dr_flac_asan+0x4d7b38)
    #1 0x51fabd in drflac_open_with_metadata_private /home/karas/dr_libs/./dr_flac.h:4586:30
    #2 0x52b00e in drflac_open /home/karas/dr_libs/./dr_flac.h:4865:12
    #3 0x52b00e in drflac_open_file /home/karas/dr_libs/./dr_flac.h:4735
    #4 0x52b00e in main /home/karas/dr_libs/dr_flac.c:7

SUMMARY: AddressSanitizer: heap-buffer-overflow /home/karas/dr_libs/./dr_flac.h in drflac__decode_samples_with_residual__rice__simple
Shadow bytes around the buggy address:
  0x0c4e7fff8680: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4e7fff8690: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4e7fff86a0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4e7fff86b0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c4e7fff86c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c4e7fff86d0: 00 00 00 00[fa]fa fa fa fa fa fa fa fa fa fa fa
  0x0c4e7fff86e0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4e7fff86f0: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4e7fff8700: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4e7fff8710: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
  0x0c4e7fff8720: fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==4729==ABORTING

=================================================================
[Acknowledgement]
This work was supported by ICT R&D program of MSIP/IITP. [R7518-16-1001, Innovation hub for high Performance Computing]

dr_mp3.h the 2168 line

static const drmp3_f4 g_scale = { 32768.0f, 32768.0f, 32768.0f, 32768.0f };
My Android Studio report that: Excess elements in scalar initializer
How can I deal with it?

dr_flac: avoid malloc/free

Hi there.
I'm appreciate your work you've done with dr_flac. It works like a charm (that's the reason I used it in the example for sts_mixer).

But here's my proposal: please modify drflac_open_* that it takes a pointer to a user allocated drflac structure and initializes it during the opening process. Your internal buffers are also included in this structure. This would save us from an additional (unneeded) malloc. Especially if you need drflac only for a one-shot decoding, it would be easier to store it on the stack.

Small typo in comment

I know it's just in the comment/usage documentation but if you simply copy/paste it does not compile:

https://github.com/mackron/dr_libs/blob/master/dr_wav.h#L43

// does not compile
//     float* pSampleData = drwav_open_and_read_file_s32("my_song.wav", &channels, &sampleRate, &totalSampleCount);

// should be =>
//     float* pSampleData = drwav_open_and_read_file_f32("my_song.wav", &channels, &sampleRate, &totalSampleCount);

Incorrect sample rate on mp3

Hi

I'm using the flac and wav files successfully (many thanks they are great!!!) and am just trying to use mp3 for the first time (latest version).

I'm running on a STM32H7 with FatFS as the file system so I use onread and onseek.

    if(drmp3_init(&mymp3, (drmp3_read_proc)onRead, (drmp3_seek_proc)onSeek, NULL, &mymp3data)==DRMP3_FALSE)error("Mp3 init");

returns success but when I read mymp3.sampleRate I get a strange number "713056260". This is the same with different mp3 files.
mymp3.channels correctly returns the value "2".

repeated calls to
drmp3_read_pcm_frames_f32(&mymp3, WAV_BUFFER_SIZE/8, (float*)sbuff1);

checking for a zero return do read through the file but either very slowly or they stall.

Any help or ideas appreciated.

My test mp3 file has a bit rate of 176Kbps

What is the expected range of the floating point PCM values?

dr_wav: handful of minor warnings and one unused var from clang's static analysis

Almost a mirror copy of the flac report:

Clang's Static Analyzer

2019-10-02T07:33:49.6342133Z analyze-build: INFO: ./dr_wav.h:1870:5: warning: Value stored to 'chunkSize' is never read
2019-10-02T07:33:49.6343791Z analyze-build: INFO:     chunkSize = 0;

GCC 9.1's inline warnings:

2019-10-02T07:28:17.5572516Z dr_wav.h:3034:33: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5573403Z  static DRWAV_INLINE drwav_int16 drwav__mulaw_to_s16(drwav_uint8 sampleIn)
2019-10-02T07:28:17.5573985Z                                  ^~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5574826Z dr_wav.h:3029:33: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5575292Z  static DRWAV_INLINE drwav_int16 drwav__alaw_to_s16(drwav_uint8 sampleIn)
2019-10-02T07:28:17.5575665Z                                  ^~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5576317Z dr_wav.h:971:34: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5576751Z  static DRWAV_INLINE drwav_bool32 drwav__is_compressed_format_tag(drwav_uint16 formatTag)
2019-10-02T07:28:17.5577115Z                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5577781Z dr_wav.h:962:26: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5578235Z  static DRWAV_INLINE void drwav__bytes_to_guid(const unsigned char* data, drwav_uint8* guid)
2019-10-02T07:28:17.5578588Z                           ^~~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5579326Z dr_wav.h:955:34: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5580194Z  static DRWAV_INLINE drwav_uint64 drwav__bytes_to_u64(const unsigned char* data)
2019-10-02T07:28:17.5580559Z                                   ^~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5581224Z dr_wav.h:950:34: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5581658Z  static DRWAV_INLINE unsigned int drwav__bytes_to_u32(const unsigned char* data)
2019-10-02T07:28:17.5581993Z                                   ^~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5582592Z dr_wav.h:945:27: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5583457Z  static DRWAV_INLINE short drwav__bytes_to_s16(const unsigned char* data)
2019-10-02T07:28:17.5583936Z                            ^~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5584619Z dr_wav.h:940:36: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5585295Z  static DRWAV_INLINE unsigned short drwav__bytes_to_u16(const unsigned char* data)
2019-10-02T07:28:17.5585742Z                                     ^~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5586422Z dr_wav.h:934:25: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5586879Z  static DRWAV_INLINE int drwav__is_little_endian()
2019-10-02T07:28:17.5587218Z                          ^~~~~~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5587844Z dr_wav.h:923:34: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5588292Z  static DRWAV_INLINE drwav_bool32 drwav__fourcc_equal(const unsigned char* a, const char* b)
2019-10-02T07:28:17.5588759Z                                   ^~~~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5589908Z dr_wav.h:911:34: warning: always_inline function might not be inlinable [-Wattributes]
2019-10-02T07:28:17.5590402Z  static DRWAV_INLINE drwav_bool32 drwav__guid_equal(const drwav_uint8 a[16], const drwav_uint8 b[16])
2019-10-02T07:28:17.5590754Z                                   ^~~~~~~~~~~~~~~~~
2019-10-02T07:28:17.5714175Z dr_wav.h:934:25: warning: ‘drwav__is_little_endian’ defined but not used [-Wunused-function]
2019-10-02T07:28:17.5714950Z  static DRWAV_INLINE int drwav__is_little_endian()
2019-10-02T07:28:17.5715651Z                          ^~~~~~~~~~~~~~~~~~~~~~~

use standard datatypes?

Low priority.

Are the dr*_*int* and dr*_bool* types necessary? Why not just use stdint.h, and stdbool.h, and if some user is using a compiler that doesn't have those, they can just make their own?

https://stackoverflow.com/questions/25461/interfacing-with-stdbool-h-c

OTOH, if you wanted to use the c-prefix headers (e.g. cstdint) in C++, the safest way to do that would be e.g.

#ifdef __cplusplus
    #include <cstdint>
    #include <cstddef>

    typedef std::int8_t      drwav_int8;
    // ... etc
#else
    #include <stdint.h>
    #include <stdbool.h>
    #include <stddef.h>

    typedef int8_t           drwav_int8;
    // ... etc
#endif

You'd still use bool with no additional typedef for both.

https://stackoverflow.com/questions/13642827/cstdint-vs-stdint-h/13643019#13643019

Strange sounding wav decoding?

I'm really not sure where the problem is with some wave files I'm testing, check this one for instance:

https://mega.nz/#!FEEFDYIL!pTcZgyRD_0Y0XR3YypsxG6fqo-zt5ZLwnCEw8Dwbfks

You can play this file over VLC as the ground truth, as there it sound perfectly (or, for my use case - exactly the same as BASS plays it).

I ported the audio system from an open source game re-implementation from BASS to SoLoud (that uses dr_wav internally) and a lot of waves sounded weirdly.
To validate it wasn't anything I did wrong, I extracted this wav and played through different players, including the mini_al play sample.
This showed me that dr_wav may have a relation to the issue, as both mini_al and soloud plays it wrongly. I tested all soloud backends (it does not use mini_al) and all mini_al backends on windows and every backend sounded the same too.

Thanks

pcx build error.

Hello,

If you build the sample pcx code you provided, an error will occur.

Thanks.

CODE

#define DR_PCX_IMPLEMENTATION
#include "dr_pcx.h"

int main()
{
    int width;
    int height;
    int components;
    uint8_t* pImageData = drpcx_load_file("my_image.pcx", false, &width, &height, &components);
    if (pImageData == NULL) {
        return -1;
    }

    // At this point pImageData contains the raw decoded image data as tightly
    // packed RGB or RGBA, depending on on the value of "components".

    drpcx_free(pImageData);
    return 0;
}

ERROR

karas@karas:~/dr_libs$ gcc -o pcx pcx.c
In file included from 44.c:2:0:
dr_pcx.h:78:17: error: expected declaration specifiers or ‘...’ before ‘*’ token
 typedef size_t (* drpcx_read_proc)(void* userData, void* bufferOut, size_t bytesToRead);
                 ^
dr_pcx.h:82:22: error: unknown type name ‘drpcx_read_proc’
 dr_uint8* drpcx_load(drpcx_read_proc onRead, void* pUserData, dr_bool32 flipped, int* x, int* y, int* internalComponents, int desiredCo
                      ^
In file included from 44.c:2:0:
dr_pcx.h:94:47: error: unknown type name ‘size_t’
 dr_uint8* drpcx_load_memory(const void* data, size_t dataSize, dr_bool32 flipped, int* x, int* y, int* internalComponents, int desiredC
                                               ^
In file included from 44.c:2:0:
dr_pcx.h: In function ‘drpcx_load_file’:
dr_pcx.h:136:28: warning: implicit declaration of function ‘drpcx_load’ [-Wimplicit-function-declaration]
     dr_uint8* pImageData = drpcx_load(drpcx__on_read_stdio, pFile, flipped, x, y, internalComponents, desiredComponents);
                            ^
dr_pcx.h:136:28: warning: initialization makes pointer from integer without a cast [-Wint-conversion]
dr_pcx.h: In function ‘drpcx_load_memory’:
dr_pcx.h:177:12: warning: return makes pointer from integer without a cast [-Wint-conversion]
     return drpcx_load(drpcx__on_read_memory, &memory, flipped, x, y, internalComponents, desiredComponents);
            ^
dr_pcx.h: At top level:
dr_pcx.h:205:5: error: unknown type name ‘drpcx_read_proc’
     drpcx_read_proc onRead;
     ^
dr_pcx.h: In function ‘drpcx__read_byte’:
dr_pcx.h:220:5: error: called object is not a function or function pointer
     pPCX->onRead(pPCX->pUserData, &byte, 1);
     ^
dr_pcx.h: In function ‘drpcx__decode_8bit’:
dr_pcx.h:554:21: error: called object is not a function or function pointer
                 if (pPCX->onRead(pPCX->pUserData, palette256, sizeof(palette256)) != sizeof(palette256)) {
                     ^
dr_pcx.h: At top level:
dr_pcx.h:605:22: error: unknown type name ‘drpcx_read_proc’
 dr_uint8* drpcx_load(drpcx_read_proc onRead, void* pUserData, dr_bool32 flipped, int* x, int* y, int* internalComponents, int desiredCo
                      ^
44.c: In function ‘main’:
44.c:9:59: error: ‘false’ undeclared (first use in this function)
     uint8_t* pImageData = drpcx_load_file("my_image.pcx", false, &width, &height, &components);
                                                           ^
44.c:9:59: note: each undeclared identifier is reported only once for each function it appears in
44.c:9:27: error: too few arguments to function ‘drpcx_load_file’
     uint8_t* pImageData = drpcx_load_file("my_image.pcx", false, &width, &height, &components);
                           ^
In file included from 44.c:2:0:
dr_pcx.h:122:11: note: declared here
 dr_uint8* drpcx_load_file(const char* filename, dr_bool32 flipped, int* x, int* y, int* internalComponents, int desiredComponents)
           ^

dr_wav - malloc-less implementation option

What do you think about maybe adding a #define option to build dr_wav without the functions that use dynamic memory allocation (DRWAV_MALLOC, DRWAV_REALLOC, DRWAV_FREE)? It's preferable to be able to control (or sometimes prevent) dynamic memory allocation, especially in embedded environments.

My cursory review suggest that those macros are only used for the memory and open/close functions, and the CONVERSION_API. So without those, you can still init (optionally to a file), read or write, and uninit.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.