Change asserts to ssnes_assert().

This commit is contained in:
Themaister 2011-12-25 12:47:47 +01:00
parent fe7f05e717
commit 672102d377
17 changed files with 46 additions and 64 deletions

View File

@ -287,11 +287,11 @@ void init_audio(void)
size_t max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2;
// Used for recording even if audio isn't enabled.
ssnes_assert((g_extern.audio_data.conv_outsamples = (int16_t*)malloc(max_bufsamples * sizeof(int16_t) * AUDIO_MAX_RATIO)));
ssnes_assert(g_extern.audio_data.conv_outsamples = (int16_t*)malloc(max_bufsamples * sizeof(int16_t) * AUDIO_MAX_RATIO));
g_extern.audio_data.chunk_size = g_extern.audio_data.block_chunk_size;
// Needs to be able to hold full content of a full max_bufsamples in addition to its own.
ssnes_assert((g_extern.audio_data.rewind_buf = (int16_t*)malloc(max_bufsamples * sizeof(int16_t))));
ssnes_assert(g_extern.audio_data.rewind_buf = (int16_t*)malloc(max_bufsamples * sizeof(int16_t)));
g_extern.audio_data.rewind_size = max_bufsamples;
if (!g_settings.audio.enable)
@ -325,11 +325,11 @@ void init_audio(void)
if (!g_extern.audio_data.source)
g_extern.audio_active = false;
ssnes_assert((g_extern.audio_data.data = (float*)malloc(max_bufsamples * sizeof(float))));
ssnes_assert(g_extern.audio_data.data = (float*)malloc(max_bufsamples * sizeof(float)));
g_extern.audio_data.data_ptr = 0;
ssnes_assert(g_settings.audio.out_rate < g_settings.audio.in_rate * AUDIO_MAX_RATIO);
ssnes_assert((g_extern.audio_data.outsamples = (float*)malloc(max_bufsamples * sizeof(float) * AUDIO_MAX_RATIO)));
ssnes_assert(g_extern.audio_data.outsamples = (float*)malloc(max_bufsamples * sizeof(float) * AUDIO_MAX_RATIO));
g_extern.audio_data.src_ratio =
(double)g_settings.audio.out_rate / g_settings.audio.in_rate;

View File

@ -19,7 +19,6 @@
#include "general.h"
#include "strl.h"
#include <string.h>
#include <assert.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -192,7 +191,7 @@ void init_libsnes_sym(void)
{
// Guarantee that we can do "dirty" casting.
// Every OS that this program supports should pass this ...
assert(sizeof(void*) == sizeof(void (*)(void)));
ssnes_assert(sizeof(void*) == sizeof(void (*)(void)));
#ifdef HAVE_DYNAMIC
// Try to verify that -lsnes was not linked in from other modules

View File

@ -17,7 +17,6 @@
#define __BUFFER_H
#include <stdlib.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

View File

@ -22,9 +22,9 @@
#include <string.h>
#include "boolean.h"
#include <stddef.h>
#include <assert.h>
#include <stdlib.h>
#include "msvc/msvc_compat.h"
#include "general.h"
char *optarg;
int optind, opterr, optopt;
@ -134,7 +134,7 @@ static void shuffle_block(char **begin, char **last, char **end)
{
ptrdiff_t len = last - begin;
const char **tmp = (const char**)calloc(len, sizeof(const char*));
assert(tmp);
ssnes_assert(tmp);
memcpy(tmp, begin, sizeof(tmp));
memmove(begin, last, (end - last) * sizeof(char*));
@ -173,7 +173,7 @@ int getopt_long(int argc, char *argv[],
long_index = 0;
}
assert(short_index == 0 || long_index == 0);
ssnes_assert(short_index == 0 || long_index == 0);
if (short_index == 0)
return parse_short(optstring, &argv[optind]);

View File

@ -23,7 +23,6 @@
#include <stdio.h>
#include <string.h>
#include "../general.h"
#include <assert.h>
#include <math.h>
#ifdef HAVE_CONFIG_H
@ -1210,7 +1209,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo
return NULL;
const SDL_VideoInfo *video_info = SDL_GetVideoInfo();
assert(video_info);
ssnes_assert(video_info);
unsigned full_x = video_info->current_w;
unsigned full_y = video_info->current_h;
SSNES_LOG("Detecting desktop resolution %ux%u.\n", full_x, full_y);

View File

@ -19,7 +19,6 @@
#define __GL_COMMON_H
#include "../general.h"
#include <assert.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"

View File

@ -17,7 +17,6 @@
#include "SDL.h"
#include "../driver.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include "../general.h"
@ -259,7 +258,7 @@ static void *sdl_gfx_init(const video_info_t *video, const input_driver_t **inpu
return NULL;
const SDL_VideoInfo *video_info = SDL_GetVideoInfo();
assert(video_info);
ssnes_assert(video_info);
unsigned full_x = video_info->current_w;
unsigned full_y = video_info->current_h;
SSNES_LOG("Detecting desktop resolution %ux%u.\n", full_x, full_y);

View File

@ -18,7 +18,6 @@
#include "sdlwrap.h"
#include "SDL_syswm.h"
#include "../general.h"
#include <assert.h>
#ifdef __APPLE__
#include <OpenGL/OpenGL.h>

View File

@ -35,7 +35,7 @@
// Not legal to cast (void*) to fn-pointer. Need workaround to be compliant.
#define SDL_SYM_WRAP(sym, symbol) { \
assert(sizeof(void*) == sizeof(void (*)(void))); \
ssnes_assert(sizeof(void*) == sizeof(void (*)(void))); \
void *sym__ = SDL_GL_GetProcAddress(symbol); \
memcpy(&(sym), &sym__, sizeof(void*)); \
}

View File

@ -17,7 +17,6 @@
#include "snes_state.h"
#include <stdlib.h>
#include <assert.h>
#include "../strl.h"
#include "../general.h"
#include "../libsnes.hpp"

View File

@ -20,7 +20,6 @@
#include <stdlib.h>
#include "general.h"
#include "dynamic.h"
#include <assert.h>
// CRC32 implementation taken from BSNES source :)

View File

@ -55,12 +55,12 @@
<ExceptionHandling>false</ExceptionHandling>
<FloatingPointModel>Precise</FloatingPointModel>
<CompileAs>CompileAsCpp</CompileAs>
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.3\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.3\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND /D HAVE_FFMPEG %(AdditionalOptions)</AdditionalOptions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>SDL.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>SDL.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;avcodec.lib;avformat.lib;swscale.lib;avutil.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
@ -72,16 +72,17 @@
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.3\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND %(AdditionalOptions)</AdditionalOptions>
<AdditionalOptions>/D HAVE_SDL /D PACKAGE_VERSION=\"0.9.3\" /D _CRT_SECURE_NO_WARNINGS /D HAVE_NETPLAY /D HAVE_THREADS /D HAVE_OPENGL /D HAVE_DYLIB /D HAVE_DYNAMIC /D HAVE_CG /D HAVE_XAUDIO /D HAVE_FBO /D HAVE_CONFIGFILE /D HAVE_DSOUND /D HAVE_FFMPEG %(AdditionalOptions)</AdditionalOptions>
<CompileAs>CompileAsCpp</CompileAs>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>SDL.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalDependencies>SDL.lib;opengl32.lib;ws2_32.lib;dxguid.lib;dinput8.lib;cg.lib;cgGL.lib;winmm.lib;shlwapi.lib;dsound.lib;avcodec.lib;avformat.lib;swscale.lib;avutil.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
@ -114,6 +115,7 @@
<ClCompile Include="..\..\..\movie.c" />
<ClCompile Include="..\..\..\netplay.c" />
<ClCompile Include="..\..\..\posix_string.c" />
<ClCompile Include="..\..\..\record\ffemu.c" />
<ClCompile Include="..\..\..\rewind.c" />
<ClCompile Include="..\..\..\screenshot.c" />
<ClCompile Include="..\..\..\settings.c" />
@ -158,12 +160,14 @@
<ClInclude Include="..\..\..\movie.h" />
<ClInclude Include="..\..\..\netplay.h" />
<ClInclude Include="..\..\..\posix_string.h" />
<ClInclude Include="..\..\..\record\ffemu.h" />
<ClInclude Include="..\..\..\rewind.h" />
<ClInclude Include="..\..\..\screenshot.h" />
<ClInclude Include="..\..\..\sha256.h" />
<ClInclude Include="..\..\..\strl.h" />
<ClInclude Include="..\..\..\thread.h" />
<ClInclude Include="..\..\..\ups.h" />
<ClInclude Include="..\..\msvc_compat.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -42,8 +42,6 @@
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#ifdef _WIN32
// Woohoo, Winsock has headers from the STONE AGE! :D
#define close(x) closesocket(x)
@ -594,16 +592,6 @@ bool netplay_poll(netplay_t *handle)
return true;
}
//fprintf(stderr, "Before poll: Other ptr: %lu, Read ptr: %lu, Self ptr: %lu\n", handle->other_ptr, handle->read_ptr, handle->self_ptr);
/*
if (handle->buffer_size > 1)
{
assert(handle->other_ptr != handle->self_ptr);
assert(handle->read_ptr != handle->self_ptr);
}
assert(handle->other_ptr == handle->read_ptr);
*/
// We might have reached the end of the buffer, where we simply have to block.
int res = poll_input(handle, handle->other_ptr == handle->self_ptr);
if (res == -1)

View File

@ -15,6 +15,8 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "../msvc/msvc_compat.h"
#ifdef __cplusplus
extern "C" {
#endif
@ -32,18 +34,18 @@ extern "C" {
#include <stdint.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include "../boolean.h"
#include "ffemu.h"
#include "fifo_buffer.h"
#include "thread.h"
#include "../fifo_buffer.h"
#include "../thread.h"
#include "../general.h"
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
struct video_info
struct ff_video_info
{
AVCodecContext *codec;
AVCodec *encoder;
@ -64,7 +66,7 @@ struct video_info
struct SwsContext *sws_ctx;
} video;
struct audio_info
struct ff_audio_info
{
AVCodecContext *codec;
AVCodec *encoder;
@ -78,7 +80,7 @@ struct audio_info
size_t outbuf_size;
} audio;
struct muxer_info
struct ff_muxer_info
{
AVFormatContext *ctx;
AVStream *astream;
@ -87,9 +89,9 @@ struct muxer_info
struct ffemu
{
struct video_info video;
struct audio_info audio;
struct muxer_info muxer;
struct ff_video_info video;
struct ff_audio_info audio;
struct ff_muxer_info muxer;
struct ffemu_params params;
@ -105,7 +107,7 @@ struct ffemu
volatile bool can_sleep;
};
static bool init_audio(struct audio_info *audio, struct ffemu_params *param)
static bool init_audio(struct ff_audio_info *audio, struct ffemu_params *param)
{
AVCodec *codec = avcodec_find_encoder(CODEC_ID_FLAC);
if (!codec)
@ -121,7 +123,7 @@ static bool init_audio(struct audio_info *audio, struct ffemu_params *param)
avcodec_get_context_defaults(audio->codec);
#endif
audio->codec->sample_rate = param->samplerate;
audio->codec->sample_rate = (int)roundf(param->samplerate);
audio->codec->time_base = av_d2q(1.0 / param->samplerate, 1000000);
audio->codec->channels = param->channels;
audio->codec->sample_fmt = AV_SAMPLE_FMT_S16;
@ -147,7 +149,7 @@ static bool init_audio(struct audio_info *audio, struct ffemu_params *param)
return true;
}
static bool init_video(struct video_info *video, const struct ffemu_params *param)
static bool init_video(struct ff_video_info *video, const struct ffemu_params *param)
{
#ifdef HAVE_X264RGB
AVCodec *codec = avcodec_find_encoder(CODEC_ID_H264);
@ -303,17 +305,17 @@ static void ffemu_thread(void *data);
static bool init_thread(ffemu_t *handle)
{
assert(handle->lock = slock_new());
assert(handle->cond_lock = slock_new());
assert(handle->cond = scond_new());
assert(handle->audio_fifo = fifo_new(32000 * sizeof(int16_t) * handle->params.channels * MAX_FRAMES / 60));
assert(handle->attr_fifo = fifo_new(sizeof(struct ffemu_video_data) * MAX_FRAMES));
assert(handle->video_fifo = fifo_new(handle->params.fb_width * handle->params.fb_height *
ssnes_assert(handle->lock = slock_new());
ssnes_assert(handle->cond_lock = slock_new());
ssnes_assert(handle->cond = scond_new());
ssnes_assert(handle->audio_fifo = fifo_new(32000 * sizeof(int16_t) * handle->params.channels * MAX_FRAMES / 60));
ssnes_assert(handle->attr_fifo = fifo_new(sizeof(struct ffemu_video_data) * MAX_FRAMES));
ssnes_assert(handle->video_fifo = fifo_new(handle->params.fb_width * handle->params.fb_height *
handle->video.pix_size * MAX_FRAMES));
handle->alive = true;
handle->can_sleep = true;
assert(handle->thread = sthread_create(ffemu_thread, handle));
ssnes_assert(handle->thread = sthread_create(ffemu_thread, handle));
return true;
}
@ -684,11 +686,11 @@ static void ffemu_thread(void *data)
// For some reason, FFmpeg has a tendency to crash if we don't overallocate a bit. :s
void *video_buf = av_malloc(2 * ff->params.fb_width * ff->params.fb_height * ff->video.pix_size);
assert(video_buf);
ssnes_assert(video_buf);
size_t audio_buf_size = 512 * ff->params.channels * sizeof(int16_t);
int16_t *audio_buf = (int16_t*)av_malloc(audio_buf_size);
assert(audio_buf);
ssnes_assert(audio_buf);
while (ff->alive)
{

View File

@ -20,7 +20,6 @@
#include <stdint.h>
#include "boolean.h"
#include <string.h>
#include <assert.h>
#include <limits.h>
#include "general.h"
@ -73,7 +72,7 @@ state_manager_t *state_manager_new(size_t state_size, size_t buffer_size, void *
return NULL;
// We need 4-byte aligned state_size to avoid having to enforce this with unneeded memcpy's!
assert(state_size % 4 == 0);
ssnes_assert(state_size % 4 == 0);
state->top_ptr = 1;
state->state_size = state_size / sizeof(uint32_t); // Works in multiple of 4.

View File

@ -18,7 +18,6 @@
#include "general.h"
#include "conf/config_file.h"
#include "input/keysym.h"
#include <assert.h>
#include "strl.h"
#include "config.def.h"
#include "file.h"
@ -196,8 +195,8 @@ static void set_defaults(void)
g_settings.block_sram_overwrite = block_sram_overwrite;
g_settings.savestate_auto_index = savestate_auto_index;
assert(sizeof(g_settings.input.binds[0]) >= sizeof(snes_keybinds_1));
assert(sizeof(g_settings.input.binds[1]) >= sizeof(snes_keybinds_rest));
ssnes_assert(sizeof(g_settings.input.binds[0]) >= sizeof(snes_keybinds_1));
ssnes_assert(sizeof(g_settings.input.binds[1]) >= sizeof(snes_keybinds_rest));
memcpy(g_settings.input.binds[0], snes_keybinds_1, sizeof(snes_keybinds_1));
for (unsigned i = 1; i < 5; i++)
memcpy(g_settings.input.binds[i], snes_keybinds_rest, sizeof(snes_keybinds_rest));

View File

@ -34,7 +34,6 @@
#include "screenshot.h"
#include "cheats.h"
#include "getopt_ssnes.h"
#include <assert.h>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
@ -1068,8 +1067,7 @@ static void deinit_recording(void)
static void init_msg_queue(void)
{
g_extern.msg_queue = msg_queue_new(8);
assert(g_extern.msg_queue);
ssnes_assert(g_extern.msg_queue = msg_queue_new(8));
}
static void deinit_msg_queue(void)