summaryrefslogtreecommitdiff
path: root/src/internal
diff options
context:
space:
mode:
authorTuomas Virtanen <katajakasa@gmail.com>2020-05-02 02:23:18 +0300
committerTuomas Virtanen <katajakasa@gmail.com>2020-05-02 02:23:18 +0300
commit5ac1bdda13ce9557e18f924addd3bb54a8da5a15 (patch)
tree974be5b597c6f42c13cd547ad0a0c926cdcfe1a1 /src/internal
parent243140385848145c53b5b2c209f715be864bcecb (diff)
Add consts and clean unnecessary state
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/audio/kitaudio.c4
-rw-r--r--src/internal/kitdecoder.c42
-rw-r--r--src/internal/subtitle/kitsubtitle.c8
-rw-r--r--src/internal/subtitle/renderers/kitsubass.c2
-rw-r--r--src/internal/utils/kithelpers.c4
-rw-r--r--src/internal/video/kitvideo.c2
6 files changed, 31 insertions, 31 deletions
diff --git a/src/internal/audio/kitaudio.c b/src/internal/audio/kitaudio.c
index b2f41fc..04dd4f1 100644
--- a/src/internal/audio/kitaudio.c
+++ b/src/internal/audio/kitaudio.c
@@ -278,7 +278,7 @@ Kit_Decoder* Kit_CreateAudioDecoder(const Kit_Source *src, int stream_index) {
return NULL;
}
- Kit_LibraryState *state = Kit_GetLibraryState();
+ const Kit_LibraryState *state = Kit_GetLibraryState();
// First the generic decoder component ...
Kit_Decoder *dec = Kit_CreateDecoder(
@@ -347,7 +347,7 @@ exit_0:
}
double Kit_GetAudioDecoderPTS(Kit_Decoder *dec) {
- Kit_AudioPacket *packet = Kit_PeekDecoderOutput(dec);
+ const Kit_AudioPacket *packet = Kit_PeekDecoderOutput(dec);
if(packet == NULL) {
return -1.0;
}
diff --git a/src/internal/kitdecoder.c b/src/internal/kitdecoder.c
index 9b925c7..530473e 100644
--- a/src/internal/kitdecoder.c
+++ b/src/internal/kitdecoder.c
@@ -170,6 +170,13 @@ int Kit_RunDecoder(Kit_Decoder *dec) {
return 0;
}
+void Kit_ClearDecoderBuffers(Kit_Decoder *dec) {
+ if(dec == NULL) return;
+ Kit_ClearDecoderInput(dec);
+ Kit_ClearDecoderOutput(dec);
+ avcodec_flush_buffers(dec->codec_ctx);
+}
+
// ---- Information API ----
int Kit_GetDecoderCodecInfo(const Kit_Decoder *dec, Kit_Codec *codec) {
@@ -214,38 +221,38 @@ void Kit_ChangeDecoderClockSync(Kit_Decoder *dec, double sync) {
// ---- Input buffer handling ----
-int Kit_WriteDecoderInput(Kit_Decoder *dec, AVPacket *packet) {
+int Kit_WriteDecoderInput(const Kit_Decoder *dec, AVPacket *packet) {
assert(dec != NULL);
return Kit_WriteBuffer(dec->buffer[KIT_DEC_BUF_IN], packet);
}
-bool Kit_CanWriteDecoderInput(Kit_Decoder *dec) {
+bool Kit_CanWriteDecoderInput(const Kit_Decoder *dec) {
assert(dec != NULL);
return !Kit_IsBufferFull(dec->buffer[KIT_DEC_BUF_IN]);
}
-AVPacket* Kit_ReadDecoderInput(Kit_Decoder *dec) {
+AVPacket* Kit_ReadDecoderInput(const Kit_Decoder *dec) {
assert(dec != NULL);
return Kit_ReadBuffer(dec->buffer[KIT_DEC_BUF_IN]);
}
-AVPacket* Kit_PeekDecoderInput(Kit_Decoder *dec) {
+AVPacket* Kit_PeekDecoderInput(const Kit_Decoder *dec) {
assert(dec != NULL);
return Kit_PeekBuffer(dec->buffer[KIT_DEC_BUF_IN]);
}
-void Kit_AdvanceDecoderInput(Kit_Decoder *dec) {
+void Kit_AdvanceDecoderInput(const Kit_Decoder *dec) {
assert(dec != NULL);
Kit_AdvanceBuffer(dec->buffer[KIT_DEC_BUF_IN]);
}
-void Kit_ClearDecoderInput(Kit_Decoder *dec) {
+void Kit_ClearDecoderInput(const Kit_Decoder *dec) {
Kit_ClearBuffer(dec->buffer[KIT_DEC_BUF_IN]);
}
// ---- Output buffer handling ----
-int Kit_WriteDecoderOutput(Kit_Decoder *dec, void *packet) {
+int Kit_WriteDecoderOutput(const Kit_Decoder *dec, void *packet) {
assert(dec != NULL);
int ret = 1;
if(SDL_LockMutex(dec->output_lock) == 0) {
@@ -255,14 +262,14 @@ int Kit_WriteDecoderOutput(Kit_Decoder *dec, void *packet) {
return ret;
}
-void Kit_ClearDecoderOutput(Kit_Decoder *dec) {
+void Kit_ClearDecoderOutput(const Kit_Decoder *dec) {
if(SDL_LockMutex(dec->output_lock) == 0) {
Kit_ClearBuffer(dec->buffer[KIT_DEC_BUF_OUT]);
SDL_UnlockMutex(dec->output_lock);
}
}
-void* Kit_PeekDecoderOutput(Kit_Decoder *dec) {
+void* Kit_PeekDecoderOutput(const Kit_Decoder *dec) {
assert(dec != NULL);
void *ret = NULL;
if(SDL_LockMutex(dec->output_lock) == 0) {
@@ -272,7 +279,7 @@ void* Kit_PeekDecoderOutput(Kit_Decoder *dec) {
return ret;
}
-void* Kit_ReadDecoderOutput(Kit_Decoder *dec) {
+void* Kit_ReadDecoderOutput(const Kit_Decoder *dec) {
assert(dec != NULL);
void *ret = NULL;
if(SDL_LockMutex(dec->output_lock) == 0) {
@@ -282,7 +289,7 @@ void* Kit_ReadDecoderOutput(Kit_Decoder *dec) {
return ret;
}
-bool Kit_CanWriteDecoderOutput(Kit_Decoder *dec) {
+bool Kit_CanWriteDecoderOutput(const Kit_Decoder *dec) {
assert(dec != NULL);
bool ret = false;
if(SDL_LockMutex(dec->output_lock) == 0) {
@@ -292,7 +299,7 @@ bool Kit_CanWriteDecoderOutput(Kit_Decoder *dec) {
return ret;
}
-void Kit_ForEachDecoderOutput(Kit_Decoder *dec, Kit_ForEachItemCallback cb, void *userdata) {
+void Kit_ForEachDecoderOutput(const Kit_Decoder *dec, Kit_ForEachItemCallback cb, void *userdata) {
assert(dec != NULL);
if(SDL_LockMutex(dec->output_lock) == 0) {
Kit_ForEachItemInBuffer(dec->buffer[KIT_DEC_BUF_OUT], cb, userdata);
@@ -300,7 +307,7 @@ void Kit_ForEachDecoderOutput(Kit_Decoder *dec, Kit_ForEachItemCallback cb, void
}
}
-void Kit_AdvanceDecoderOutput(Kit_Decoder *dec) {
+void Kit_AdvanceDecoderOutput(const Kit_Decoder *dec) {
assert(dec != NULL);
if(SDL_LockMutex(dec->output_lock) == 0) {
Kit_AdvanceBuffer(dec->buffer[KIT_DEC_BUF_OUT]);
@@ -308,7 +315,7 @@ void Kit_AdvanceDecoderOutput(Kit_Decoder *dec) {
}
}
-unsigned int Kit_GetDecoderOutputLength(Kit_Decoder *dec) {
+unsigned int Kit_GetDecoderOutputLength(const Kit_Decoder *dec) {
assert(dec != NULL);
unsigned int len = 0;
if(SDL_LockMutex(dec->output_lock) == 0) {
@@ -318,13 +325,6 @@ unsigned int Kit_GetDecoderOutputLength(Kit_Decoder *dec) {
return len;
}
-void Kit_ClearDecoderBuffers(Kit_Decoder *dec) {
- if(dec == NULL) return;
- Kit_ClearDecoderInput(dec);
- Kit_ClearDecoderOutput(dec);
- avcodec_flush_buffers(dec->codec_ctx);
-}
-
int Kit_LockDecoderOutput(Kit_Decoder *dec) {
return SDL_LockMutex(dec->output_lock);
}
diff --git a/src/internal/subtitle/kitsubtitle.c b/src/internal/subtitle/kitsubtitle.c
index 024179e..e222794 100644
--- a/src/internal/subtitle/kitsubtitle.c
+++ b/src/internal/subtitle/kitsubtitle.c
@@ -95,7 +95,7 @@ Kit_Decoder* Kit_CreateSubtitleDecoder(const Kit_Source *src, int stream_index,
return NULL;
}
- Kit_LibraryState *state = Kit_GetLibraryState();
+ const Kit_LibraryState *state = Kit_GetLibraryState();
// First the generic decoder component
Kit_Decoder *dec = Kit_CreateDecoder(
@@ -173,7 +173,7 @@ exit_0:
void Kit_SetSubtitleDecoderSize(Kit_Decoder *dec, int screen_w, int screen_h) {
assert(dec != NULL);
- Kit_SubtitleDecoder *subtitle_dec = dec->userdata;
+ const Kit_SubtitleDecoder *subtitle_dec = dec->userdata;
Kit_SetSubtitleRendererSize(subtitle_dec->renderer, screen_w, screen_h);
}
@@ -181,11 +181,11 @@ void Kit_GetSubtitleDecoderTexture(Kit_Decoder *dec, SDL_Texture *texture, doubl
assert(dec != NULL);
assert(texture != NULL);
- Kit_SubtitleDecoder *subtitle_dec = dec->userdata;
+ const Kit_SubtitleDecoder *subtitle_dec = dec->userdata;
Kit_GetSubtitleRendererData(subtitle_dec->renderer, subtitle_dec->atlas, texture, sync_ts);
}
int Kit_GetSubtitleDecoderInfo(Kit_Decoder *dec, SDL_Texture *texture, SDL_Rect *sources, SDL_Rect *targets, int limit) {
- Kit_SubtitleDecoder *subtitle_dec = dec->userdata;
+ const Kit_SubtitleDecoder *subtitle_dec = dec->userdata;
return Kit_GetAtlasItems(subtitle_dec->atlas, sources, targets, limit);
}
diff --git a/src/internal/subtitle/renderers/kitsubass.c b/src/internal/subtitle/renderers/kitsubass.c
index 7dfb31b..b2c37c8 100644
--- a/src/internal/subtitle/renderers/kitsubass.c
+++ b/src/internal/subtitle/renderers/kitsubass.c
@@ -137,7 +137,7 @@ Kit_SubtitleRenderer* Kit_CreateASSSubtitleRenderer(Kit_Decoder *dec, int video_
assert(screen_h >= 0);
// Make sure that libass library has been initialized + get handle
- Kit_LibraryState *state = Kit_GetLibraryState();
+ const Kit_LibraryState *state = Kit_GetLibraryState();
if(state->libass_handle == NULL) {
Kit_SetError("Libass library has not been initialized");
return NULL;
diff --git a/src/internal/utils/kithelpers.c b/src/internal/utils/kithelpers.c
index c68f1c7..0108f1b 100644
--- a/src/internal/utils/kithelpers.c
+++ b/src/internal/utils/kithelpers.c
@@ -17,8 +17,8 @@ double _GetSystemTime() {
return (double)av_gettime() / 1000000.0;
}
-bool attachment_is_font(AVStream *stream) {
- AVDictionaryEntry *tag = av_dict_get(stream->metadata, "mimetype", NULL, AV_DICT_MATCH_CASE);
+bool attachment_is_font(const AVStream *stream) {
+ const AVDictionaryEntry *tag = av_dict_get(stream->metadata, "mimetype", NULL, AV_DICT_MATCH_CASE);
if(tag) {
for(int n = 0; font_mime[n]; n++) {
if(av_strcasecmp(font_mime[n], tag->value) == 0) {
diff --git a/src/internal/video/kitvideo.c b/src/internal/video/kitvideo.c
index 1f2bed9..a29d58d 100644
--- a/src/internal/video/kitvideo.c
+++ b/src/internal/video/kitvideo.c
@@ -232,7 +232,7 @@ Kit_Decoder* Kit_CreateVideoDecoder(const Kit_Source *src, int stream_index) {
return NULL;
}
- Kit_LibraryState *state = Kit_GetLibraryState();
+ const Kit_LibraryState *state = Kit_GetLibraryState();
// First the generic decoder component ...
Kit_Decoder *dec = Kit_CreateDecoder(