Skip to content

Commit dac2db6

Browse files
committed
update to libsndfile 1.2.2, avoid accessing openal after it has been de-initialized
1 parent e252f66 commit dac2db6

File tree

15 files changed

+154
-85
lines changed

15 files changed

+154
-85
lines changed

bin/amd64/libsndfile-1.dll

-1.67 MB
Binary file not shown.

bin/amd64/sndfile.dll

2.48 MB
Binary file not shown.

bin/x86/libsndfile-1.dll

-1.6 MB
Binary file not shown.

bin/x86/sndfile.dll

2.14 MB
Binary file not shown.

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ list(REMOVE_ITEM server_sources ${tessfont_cpp_path})
136136
# platform specific code
137137
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
138138
list(APPEND client_deps x11)
139-
set(link_libs rt openal sndfile-1)
139+
set(link_libs rt openal sndfile)
140140
if(${WANT_STEAM})
141141
add_library(steam_lib SHARED IMPORTED)
142142
if(${CMAKE_HOST_SYSTEM_PROCESSOR} MATCHES "i[3-6]86")
@@ -156,7 +156,7 @@ if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
156156
link_libraries(${link_libs})
157157
set(BIN_SUFFIX "_linux")
158158
elseif(MINGW)
159-
set(link_libs ws2_32 winmm OpenAL32 sndfile-1)
159+
set(link_libs ws2_32 winmm OpenAL32 sndfile)
160160
link_libraries(${link_libs})
161161
set(BIN_SUFFIX "_windows")
162162
else()

src/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ ifeq (1,$(BUILD_WINDOWS))
202202
CLIENT_INCLUDES = $(INCLUDES) -isystem include
203203

204204
CLIENT_LIBS = $(STD_LIBS) $(SUP_LIBS) \
205-
-lSDL2 -lSDL2_image -lOpenAL32 -lsndfile-1 -lzlib1 -lopengl32 -lenet -lws2_32 -lwinmm
205+
-lSDL2 -lSDL2_image -lOpenAL32 -lsndfile -lzlib1 -lopengl32 -lenet -lws2_32 -lwinmm
206206

207207
ifneq (,$(findstring msvc,$(PLATFORM)))
208208
CLIENT_LIBS += -ldbghelp -luser32 -lshell32

src/engine/main.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,13 +169,14 @@ void cleanup()
169169
SDL_SetRelativeMouseMode(SDL_FALSE);
170170
if(screen) SDL_SetWindowGrab(screen, SDL_FALSE);
171171
cleargamma();
172+
172173
freeocta(worldroot);
173174
UI::cleanup();
174175
fx::cleanup();
175176
cleanupwind();
176177
extern void clear_command(); clear_command();
177178
extern void clear_binds(); clear_binds();
178-
extern void clear_models(); clear_models();
179+
extern void clear_models(); clear_models();
179180

180181
stopsound();
181182
SDL_Quit();

src/engine/sound.cpp

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1597,7 +1597,7 @@ void soundsample::clear()
15971597

15981598
bool soundsample::valid()
15991599
{
1600-
if(!alIsBuffer(buffer)) return false;
1600+
if(nosound || !alIsBuffer(buffer)) return false;
16011601
return true;
16021602
}
16031603

@@ -1725,22 +1725,20 @@ void soundsource::cleanup()
17251725
cshook = NULL;
17261726
}
17271727

1728-
if(!valid())
1728+
if(valid())
17291729
{
1730-
source = AL_INVALID;
1731-
return;
1732-
}
1730+
if(al_ext_efx)
1731+
{
1732+
if(alIsFilter(dirfilter)) alDeleteFilters(1, &dirfilter);
1733+
dirfilter = AL_INVALID;
1734+
if(alIsFilter(efxfilter)) alDeleteFilters(1, &efxfilter);
1735+
efxfilter = AL_INVALID;
1736+
}
17331737

1734-
if(al_ext_efx)
1735-
{
1736-
if(alIsFilter(dirfilter)) alDeleteFilters(1, &dirfilter);
1737-
dirfilter = AL_INVALID;
1738-
if(alIsFilter(efxfilter)) alDeleteFilters(1, &efxfilter);
1739-
efxfilter = AL_INVALID;
1738+
alSourceStop(source);
1739+
alDeleteSources(1, &source);
17401740
}
17411741

1742-
alSourceStop(source);
1743-
alDeleteSources(1, &source);
17441742
source = AL_INVALID;
17451743
}
17461744

@@ -1900,7 +1898,7 @@ ALenum soundsource::update()
19001898

19011899
bool soundsource::valid()
19021900
{
1903-
if(!alIsSource(source)) return false;
1901+
if(nosound || !alIsSource(source)) return false;
19041902
return true;
19051903
}
19061904

@@ -2041,15 +2039,19 @@ ALenum musicstream::fill(ALint bufid)
20412039

20422040
void musicstream::cleanup()
20432041
{
2044-
if(!valid()) return;
2045-
alSourceStop(source);
2046-
alDeleteSources(1, &source);
2047-
alDeleteBuffers(MUSICBUFS, buffer);
2042+
if(valid())
2043+
{
2044+
alSourceStop(source);
2045+
alDeleteSources(1, &source);
2046+
alDeleteBuffers(MUSICBUFS, buffer);
2047+
}
2048+
20482049
if(name) delete[] name;
20492050
if(artist) delete[] artist;
20502051
if(title) delete[] title;
20512052
if(album) delete[] album;
20522053
if(data) delete data;
2054+
20532055
source = AL_INVALID;
20542056
}
20552057

@@ -2152,7 +2154,7 @@ ALenum musicstream::update()
21522154

21532155
bool musicstream::valid()
21542156
{
2155-
if(!alIsSource(source)) return false;
2157+
if(nosound || !alIsSource(source)) return false;
21562158
loopi(MUSICBUFS) if(!alIsBuffer(buffer[i])) return false;
21572159
return true;
21582160
}

src/include/sndfile.h

Lines changed: 51 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
** sndfile.h -- system-wide definitions
2121
**
2222
** API documentation is in the doc/ directory of the source code tarball
23-
** and at http://www.mega-nerd.com/libsndfile/api.html.
23+
** and at http://libsndfile.github.io/libsndfile/api.html.
2424
*/
2525

2626
#ifndef SNDFILE_H
@@ -71,6 +71,7 @@ enum
7171
SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
7272
SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
7373
SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
74+
SF_FORMAT_MPEG = 0x230000, /* MPEG-1/2 audio stream */
7475

7576
/* Subtypes from here on. */
7677

@@ -92,6 +93,10 @@ enum
9293
SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */
9394
SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */
9495

96+
SF_FORMAT_NMS_ADPCM_16 = 0x0022, /* 16kbs NMS G721-variant encoding. */
97+
SF_FORMAT_NMS_ADPCM_24 = 0x0023, /* 24kbs NMS G721-variant encoding. */
98+
SF_FORMAT_NMS_ADPCM_32 = 0x0024, /* 32kbs NMS G721-variant encoding. */
99+
95100
SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */
96101
SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */
97102
SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */
@@ -105,12 +110,17 @@ enum
105110
SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
106111

107112
SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
113+
SF_FORMAT_OPUS = 0x0064, /* Xiph/Skype Opus encoding. */
108114

109115
SF_FORMAT_ALAC_16 = 0x0070, /* Apple Lossless Audio Codec (16 bit). */
110116
SF_FORMAT_ALAC_20 = 0x0071, /* Apple Lossless Audio Codec (20 bit). */
111117
SF_FORMAT_ALAC_24 = 0x0072, /* Apple Lossless Audio Codec (24 bit). */
112118
SF_FORMAT_ALAC_32 = 0x0073, /* Apple Lossless Audio Codec (32 bit). */
113119

120+
SF_FORMAT_MPEG_LAYER_I = 0x0080, /* MPEG-1 Audio Layer I */
121+
SF_FORMAT_MPEG_LAYER_II = 0x0081, /* MPEG-1 Audio Layer II */
122+
SF_FORMAT_MPEG_LAYER_III = 0x0082, /* MPEG-2 Audio Layer III */
123+
114124
/* Endian-ness options. */
115125

116126
SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
@@ -160,7 +170,6 @@ enum
160170
SFC_GET_MAX_ALL_CHANNELS = 0x1045,
161171

162172
SFC_SET_ADD_PEAK_CHUNK = 0x1050,
163-
SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051,
164173

165174
SFC_UPDATE_HEADER_NOW = 0x1060,
166175
SFC_SET_UPDATE_HEADER_AUTO = 0x1061,
@@ -169,6 +178,7 @@ enum
169178

170179
SFC_SET_RAW_START_OFFSET = 0x1090,
171180

181+
/* Commands reserved for dithering, which is not implemented. */
172182
SFC_SET_DITHER_ON_WRITE = 0x10A0,
173183
SFC_SET_DITHER_ON_READ = 0x10A1,
174184

@@ -211,19 +221,33 @@ enum
211221
SFC_SET_VBR_ENCODING_QUALITY = 0x1300,
212222
SFC_SET_COMPRESSION_LEVEL = 0x1301,
213223

224+
/* Ogg format commands */
225+
SFC_SET_OGG_PAGE_LATENCY_MS = 0x1302,
226+
SFC_SET_OGG_PAGE_LATENCY = 0x1303,
227+
SFC_GET_OGG_STREAM_SERIALNO = 0x1306,
228+
229+
SFC_GET_BITRATE_MODE = 0x1304,
230+
SFC_SET_BITRATE_MODE = 0x1305,
231+
214232
/* Cart Chunk support */
215233
SFC_SET_CART_INFO = 0x1400,
216234
SFC_GET_CART_INFO = 0x1401,
217235

236+
/* Opus files original samplerate metadata */
237+
SFC_SET_ORIGINAL_SAMPLERATE = 0x1500,
238+
SFC_GET_ORIGINAL_SAMPLERATE = 0x1501,
239+
218240
/* Following commands for testing only. */
219241
SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,
220242

221243
/*
222-
** SFC_SET_ADD_* values are deprecated and will disappear at some
244+
** These SFC_SET_ADD_* values are deprecated and will disappear at some
223245
** time in the future. They are guaranteed to be here up to and
224246
** including version 1.0.8 to avoid breakage of existing software.
225247
** They currently do nothing and will continue to do nothing.
226248
*/
249+
SFC_SET_ADD_HEADER_PAD_CHUNK = 0x1051,
250+
227251
SFC_SET_ADD_DITHER_ON_WRITE = 0x1070,
228252
SFC_SET_ADD_DITHER_ON_READ = 0x1071
229253
} ;
@@ -321,10 +345,18 @@ enum
321345
SF_CHANNEL_MAP_MAX
322346
} ;
323347

348+
/* Bitrate mode values (for use with SFC_GET/SET_BITRATE_MODE)
349+
*/
350+
enum
351+
{ SF_BITRATE_MODE_CONSTANT = 0,
352+
SF_BITRATE_MODE_AVERAGE,
353+
SF_BITRATE_MODE_VARIABLE
354+
} ;
355+
324356

325357
/* A SNDFILE* pointer can be passed around much like stdio.h's FILE* pointer. */
326358

327-
typedef struct SNDFILE_tag SNDFILE ;
359+
typedef struct sf_private_tag SNDFILE ;
328360

329361
/* The following typedef is system specific and is defined when libsndfile is
330362
** compiled. sf_count_t will be a 64 bit value when the underlying OS allows
@@ -333,12 +365,9 @@ typedef struct SNDFILE_tag SNDFILE ;
333365
** and the Microsoft compiler.
334366
*/
335367

336-
#if (defined (_MSCVER) || defined (_MSC_VER) && (_MSC_VER < 1310))
337-
typedef __int64 sf_count_t ;
338-
#define SF_COUNT_MAX 0x7fffffffffffffffi64
339-
#else
340-
typedef __int64 sf_count_t ;
341-
#define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
368+
typedef int64_t sf_count_t ;
369+
#ifndef SF_COUNT_MAX
370+
#define SF_COUNT_MAX INT64_MAX
342371
#endif
343372

344373

@@ -377,8 +406,7 @@ typedef struct
377406

378407
/*
379408
** Enums and typedefs for adding dither on read and write.
380-
** See the html documentation for sf_command(), SFC_SET_DITHER_ON_WRITE
381-
** and SFC_SET_DITHER_ON_READ.
409+
** Reserved for future implementation.
382410
*/
383411

384412
enum
@@ -492,7 +520,12 @@ typedef struct
492520
uint32_t time_reference_high ; \
493521
short version ; \
494522
char umid [64] ; \
495-
char reserved [190] ; \
523+
int16_t loudness_value ; \
524+
int16_t loudness_range ; \
525+
int16_t max_true_peak_level ; \
526+
int16_t max_momentary_loudness ; \
527+
int16_t max_shortterm_loudness ; \
528+
char reserved [180] ; \
496529
uint32_t coding_history_size ; \
497530
char coding_history [coding_hist_size] ; \
498531
}
@@ -610,7 +643,9 @@ int sf_perror (SNDFILE *sndfile) ;
610643
int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ;
611644

612645

613-
/* Return TRUE if fields of the SF_INFO struct are a valid combination of values. */
646+
/* Allow the caller to retrieve information from or change aspects of the
647+
** library behaviour.
648+
*/
614649

615650
int sf_command (SNDFILE *sndfile, int command, void *data, int datasize) ;
616651

@@ -739,16 +774,10 @@ void sf_write_sync (SNDFILE *sndfile) ;
739774
/* The function sf_wchar_open() is Windows Only!
740775
** Open a file passing in a Windows Unicode filename. Otherwise, this is
741776
** the same as sf_open().
742-
**
743-
** In order for this to work, you need to do the following:
744-
**
745-
** #include <windows.h>
746-
** #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
747-
** #including <sndfile.h>
748777
*/
749778

750-
#if (defined (ENABLE_SNDFILE_WINDOWS_PROTOTYPES) && ENABLE_SNDFILE_WINDOWS_PROTOTYPES)
751-
SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
779+
#ifdef _WIN32
780+
SNDFILE* sf_wchar_open (const wchar_t *wpath, int mode, SF_INFO *sfinfo) ;
752781
#endif
753782

754783

@@ -854,4 +883,3 @@ sf_get_chunk_data (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
854883
#endif /* __cplusplus */
855884

856885
#endif /* SNDFILE_H */
857-

0 commit comments

Comments
 (0)