Replace SDL types by C99 standard types

Scrcpy is a C11 project. Use the C99 standard types instead of the
SDL-specific types:

    SDL_bool -> bool
    SintXX   -> intXX_t
    UintXX   -> uintXX_t
This commit is contained in:
Romain Vimont
2019-03-02 23:52:22 +01:00
parent 8655ba7197
commit dfed1b250e
40 changed files with 456 additions and 438 deletions

View File

@@ -26,7 +26,7 @@ find_muxer(const char *name) {
return oformat;
}
SDL_bool
bool
recorder_init(struct recorder *recorder,
const char *filename,
enum recorder_format format,
@@ -34,14 +34,14 @@ recorder_init(struct recorder *recorder,
recorder->filename = SDL_strdup(filename);
if (!recorder->filename) {
LOGE("Cannot strdup filename");
return SDL_FALSE;
return false;
}
recorder->format = format;
recorder->declared_frame_size = declared_frame_size;
recorder->header_written = SDL_FALSE;
recorder->header_written = false;
return SDL_TRUE;
return true;
}
void
@@ -58,20 +58,20 @@ recorder_get_format_name(enum recorder_format format) {
}
}
SDL_bool
bool
recorder_open(struct recorder *recorder, AVCodec *input_codec) {
const char *format_name = recorder_get_format_name(recorder->format);
SDL_assert(format_name);
const AVOutputFormat *format = find_muxer(format_name);
if (!format) {
LOGE("Could not find muxer");
return SDL_FALSE;
return false;
}
recorder->ctx = avformat_alloc_context();
if (!recorder->ctx) {
LOGE("Could not allocate output context");
return SDL_FALSE;
return false;
}
// contrary to the deprecated API (av_oformat_next()), av_muxer_iterate()
@@ -83,7 +83,7 @@ recorder_open(struct recorder *recorder, AVCodec *input_codec) {
AVStream *ostream = avformat_new_stream(recorder->ctx, input_codec);
if (!ostream) {
avformat_free_context(recorder->ctx);
return SDL_FALSE;
return false;
}
#ifdef SCRCPY_LAVF_HAS_NEW_CODEC_PARAMS_API
@@ -106,12 +106,12 @@ recorder_open(struct recorder *recorder, AVCodec *input_codec) {
LOGE("Failed to open output file: %s", recorder->filename);
// ostream will be cleaned up during context cleaning
avformat_free_context(recorder->ctx);
return SDL_FALSE;
return false;
}
LOGI("Recording started to %s file: %s", format_name, recorder->filename);
return SDL_TRUE;
return true;
}
void
@@ -127,14 +127,14 @@ recorder_close(struct recorder *recorder) {
LOGI("Recording complete to %s file: %s", format_name, recorder->filename);
}
static SDL_bool
static bool
recorder_write_header(struct recorder *recorder, AVPacket *packet) {
AVStream *ostream = recorder->ctx->streams[0];
uint8_t *extradata = av_malloc(packet->size * sizeof(uint8_t));
if (!extradata) {
LOGC("Cannot allocate extradata");
return SDL_FALSE;
return false;
}
// copy the first packet to the extra data
@@ -154,10 +154,10 @@ recorder_write_header(struct recorder *recorder, AVPacket *packet) {
SDL_free(extradata);
avio_closep(&recorder->ctx->pb);
avformat_free_context(recorder->ctx);
return SDL_FALSE;
return false;
}
return SDL_TRUE;
return true;
}
static void
@@ -166,14 +166,14 @@ recorder_rescale_packet(struct recorder *recorder, AVPacket *packet) {
av_packet_rescale_ts(packet, SCRCPY_TIME_BASE, ostream->time_base);
}
SDL_bool
bool
recorder_write(struct recorder *recorder, AVPacket *packet) {
if (!recorder->header_written) {
SDL_bool ok = recorder_write_header(recorder, packet);
bool ok = recorder_write_header(recorder, packet);
if (!ok) {
return SDL_FALSE;
return false;
}
recorder->header_written = SDL_TRUE;
recorder->header_written = true;
}
recorder_rescale_packet(recorder, packet);