Font issues fixed. Several framefile issues fixed. Trace file now in data directory. Framefile debugging added.

This commit is contained in:
Scott Duensing 2020-01-07 19:11:54 -06:00
parent a8d8fc8556
commit 21596d97ec
10 changed files with 618 additions and 570 deletions

View file

@ -24,6 +24,9 @@
#define COMMON_H
#include <stdint.h>
#define byte unsigned char
#define bool unsigned char

View file

@ -27,17 +27,20 @@
#include "frameFile.h"
extern bool _confShowCalculated;
typedef struct FrameLineS {
int videoHandle;
int lastFramePlayed;
long frame;
int32_t videoHandle;
int64_t lastFramePlayed;
int64_t frame;
char *filename;
} FrameLineT;
typedef struct FrameFileS {
int id;
int count;
int32_t id;
int32_t count;
char *videoPath;
FrameLineT *files;
UT_hash_handle hh;
@ -45,15 +48,15 @@ typedef struct FrameFileS {
static FrameFileT *_frameFileHash = NULL;
static int _nextId = 0;
static int32_t _nextId = 0;
void _transferProperties(int oldHandle, int newHandle);
void _transferProperties(int32_t oldHandle, int32_t newHandle);
void _transferProperties(int oldHandle, int newHandle) {
int l = 0;
int r = 0;
void _transferProperties(int32_t oldHandle, int32_t newHandle) {
int32_t l = 0;
int32_t r = 0;
if ((oldHandle < 0) || (newHandle < 0)) {
// Invalid handle somewhere
@ -72,13 +75,13 @@ void _transferProperties(int oldHandle, int newHandle) {
}
long frameFileGetFrame(int frameFileIndex, int videoHandle) {
int i = 0;
int64_t frameFileGetFrame(int32_t frameFileHandle, int32_t videoHandle) {
int32_t i = 0;
FrameFileT *f = NULL;
// Get our framefile structure
HASH_FIND_INT(_frameFileHash, &frameFileIndex, f);
if (!f) utilDie("No framefile at index %d in frameFileSeek.", frameFileIndex);
HASH_FIND_INT(_frameFileHash, &frameFileHandle, f);
if (!f) utilDie("No framefile at index %d in frameFileSeek.", frameFileHandle);
// Search through loaded video segments
for (i=0; i<f->count; i++) {
@ -93,15 +96,15 @@ long frameFileGetFrame(int frameFileIndex, int videoHandle) {
}
int frameFileInit(void) {
int32_t frameFileInit(void) {
return 0; // Nothing to do
}
int frameFileLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
int result = 0;
int count = 0;
long frame = 0;
int32_t frameFileLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
int32_t result = 0;
int32_t count = 0;
int64_t frame = 0;
size_t bytes = 0;
char *audio = NULL;
char *data = NULL;
@ -190,23 +193,35 @@ int frameFileLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Render
result = _nextId++;
// Show debug output?
if (_confShowCalculated) {
// 00000000011111111112222222222333333333344444444445555555555666666666677777777778
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
utilSay(" Start Length End File");
utilSay("-------- -------- -------- -------------------------------------------------");
for (count=0; count<frameFile->count; count++) {
frame = videoGetFrameCount(frameFile->files[count].videoHandle);
utilSay("%8ld %8ld %8ld %s", frameFile->files[count].frame, frame, frameFile->files[count].frame + frame, frameFile->files[count].filename);
}
}
return result;
}
int frameFileSeek(int frameFileIndex, long seekFrame, int *videoHandle, int *actualFrame) {
int i = 0;
int32_t frameFileSeek(int32_t frameFileHandle, int64_t seekFrame, int32_t *videoHandle, int64_t *actualFrame) {
int32_t i = 0;
FrameFileT *f = NULL;
// Get our framefile structure
HASH_FIND_INT(_frameFileHash, &frameFileIndex, f);
if (!f) utilDie("No framefile at index %d in frameFileSeek.", frameFileIndex);
HASH_FIND_INT(_frameFileHash, &frameFileHandle, f);
if (!f) utilDie("No framefile at index %d in frameFileSeek.", frameFileHandle);
// Search through loaded video segments
for (i=0; i<f->count; i++) {
if ((seekFrame >= f->files[i].frame) && (seekFrame <= (f->files[i].frame + videoGetFrameCount(f->files[i].videoHandle)))) {
// Frame is in this video
*actualFrame = (int)(seekFrame - f->files[i].frame);
*actualFrame = seekFrame - f->files[i].frame;
f->files[i].lastFramePlayed = *actualFrame;
videoSeek(f->files[i].videoHandle, *actualFrame);
// Is this a different video from the previous one?
@ -226,7 +241,7 @@ int frameFileSeek(int frameFileIndex, long seekFrame, int *videoHandle, int *act
}
int frameFileQuit(void) {
int32_t frameFileQuit(void) {
FrameFileT *f = NULL;
FrameFileT *t = NULL;
@ -239,13 +254,13 @@ int frameFileQuit(void) {
}
int frameFileUnload(int frameFileIndex) {
int i = 0;
int32_t frameFileUnload(int32_t frameFileHandle) {
int32_t i = 0;
FrameFileT *f = NULL;
// Get our framefile structure
HASH_FIND_INT(_frameFileHash, &frameFileIndex, f);
if (!f) utilDie("No framefile at index %d in frameFileUnload.", frameFileIndex);
HASH_FIND_INT(_frameFileHash, &frameFileHandle, f);
if (!f) utilDie("No framefile at index %d in frameFileUnload.", frameFileHandle);
// Unload videos
for (i=0; i<f->count; i++) {
@ -265,14 +280,14 @@ int frameFileUnload(int frameFileIndex) {
}
int frameFileUpdate(int frameFileIndex, int *videoHandle) {
int i = 0;
int frame = 0;
int32_t frameFileUpdate(int32_t frameFileHandle, int32_t *videoHandle) {
int32_t i = 0;
int64_t frame = 0;
FrameFileT *f = NULL;
// Get our framefile structure
HASH_FIND_INT(_frameFileHash, &frameFileIndex, f);
if (!f) utilDie("No framefile at index %d in frameFileUpdate.", frameFileIndex);
HASH_FIND_INT(_frameFileHash, &frameFileHandle, f);
if (!f) utilDie("No framefile at index %d in frameFileUpdate.", frameFileHandle);
// Did the current video loop? If so, move to next video.
for (i=0; i<f->count; i++) {

View file

@ -29,13 +29,13 @@
#include "common.h"
long frameFileGetFrame(int frameFileIndex, int videoHandle);
int frameFileInit(void);
int frameFileLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
int frameFileSeek(int frameFileIndex, long seekFrame, int *videoHandle, int *actualFrame);
int frameFileQuit(void);
int frameFileUnload(int frameFileIndex);
int frameFileUpdate(int frameFileIndex, int *videoHandle);
int64_t frameFileGetFrame(int32_t frameFileHandle, int32_t videoHandle);
int32_t frameFileInit(void);
int32_t frameFileLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
int32_t frameFileSeek(int32_t frameFileHandle, int64_t seekFrame, int32_t *videoHandle, int64_t *actualFrame);
int32_t frameFileQuit(void);
int32_t frameFileUnload(int32_t frameFileHandle);
int32_t frameFileUpdate(int32_t frameFileHandle, int32_t *videoHandle);
#endif // FRAMEFILE_H

View file

@ -20,7 +20,7 @@
*/
// -v singe/ActionMax/frame_SonicFury.txt singe/ActionMax/SonicFury.singe
// -c -v singe/ActionMax/frame_SonicFury.txt singe/ActionMax/SonicFury.singe
// -v singe/ActionMax/BlueThunder.mp4 singe/test.singe
@ -44,13 +44,13 @@
typedef struct RatioS {
int aspectNum;
int aspectDom;
int32_t aspectNum;
int32_t aspectDom;
} RatioT;
typedef struct ResolutionS {
int width;
int height;
int32_t width;
int32_t height;
} ResolutionT;
typedef struct ModeS {
@ -64,7 +64,7 @@ void showUsage(char *name, char *message);
__attribute__((noreturn))
void showUsage(char *name, char *message) {
int result = 0;
int32_t result = 0;
// 00000000011111111112222222222333333333344444444445555555555666666666677777777778
// 12345678901234567890123456789012345678901234567890123456789012345678901234567890
@ -90,6 +90,7 @@ void showUsage(char *name, char *message) {
utilSay(" -x, --xresolution=VALUE specify horizontal resolution");
utilSay(" -y, --yresolution=VALUE specify vertical resolution");
utilSay(" -t, --trace trace script execution to screen and file");
utilSay(" -c, --showcalculated show calculated framefile values for debugging");
utilSay(" -h, --help this display");
utilSay("");
if (message) {
@ -106,18 +107,19 @@ void showUsage(char *name, char *message) {
int main(int argc, char *argv[]) {
int x = 0;
int err = 0;
int flags = 0;
int optionIndex = 0;
int bestResIndex = -1;
int bestRatioIndex = -1;
int aspectNum = -1;
int aspectDom = -1;
int32_t x = 0;
int32_t err = 0;
int32_t flags = 0;
int32_t optionIndex = 0;
int32_t bestResIndex = -1;
int32_t bestRatioIndex = -1;
int32_t aspectNum = -1;
int32_t aspectDom = -1;
char *temp = NULL;
char *aspectString = NULL;
float thisRatio = 0;
float bestRatio = 9999;
bool tracing = false;
SDL_Window *window = NULL;
SDL_Renderer *renderer = NULL;
SDL_Surface *icon = NULL;
@ -140,6 +142,7 @@ int main(int argc, char *argv[]) {
{ "yresolution", optional_argument, NULL, 'y' },
{ "help", no_argument, NULL, 'h' },
{ "trace", no_argument, NULL, 't' },
{ "showcalculated", no_argument, NULL, 'c' },
{ NULL, 0, NULL, 0 }
};
static ModeT modes[] = {
@ -178,7 +181,7 @@ int main(int argc, char *argv[]) {
while (true) {
optionIndex = 0;
opterr = 0;
x = getopt_long(argc, argv, "mnsfwha:d:v:l:e:z:x:y:", options, &optionIndex);
x = getopt_long(argc, argv, "cmnsfwha:d:v:l:e:z:x:y:", options, &optionIndex);
// Out of options?
if (x == -1) break;
@ -265,7 +268,12 @@ int main(int argc, char *argv[]) {
// Trace
case 't':
utilTraceStart("trace.txt");
tracing = true;
break;
// Show Calculated Frame File Values
case 'c':
_confShowCalculated = true;
break;
case '?':
@ -312,7 +320,7 @@ int main(int argc, char *argv[]) {
_confVideoFile = NULL;
}
} else {
x = (int)(strlen(_confScriptFile) - strlen(utilGetFileExtension(_confScriptFile))) - 1;
x = (int32_t)(strlen(_confScriptFile) - strlen(utilGetFileExtension(_confScriptFile))) - 1;
if (x < 0) {
x = 0;
}
@ -353,14 +361,29 @@ int main(int argc, char *argv[]) {
}
} else {
// Put it in the game folder.
x = (int)(strlen(_confScriptFile) - strlen(utilGetLastPathComponent(_confScriptFile))) - 1;
x = (int32_t)(strlen(_confScriptFile) - strlen(utilGetLastPathComponent(_confScriptFile))) - 1;
if (x < 0) {
x = 0;
}
_confDataDir = strdup(_confScriptFile);
_confDataDir[x] = 0;
// All this temp nonsense here...
// I had just jammed a zero into _confDataDir at 'x' but then if utilFixPathSeparators
// calls realloc() it pooches things up. Weird.
temp = strdup(_confScriptFile);
temp[x] = 0;
_confDataDir = strdup(temp);
free(temp);
temp = NULL;
}
if (!_confDataDir) showUsage(argv[0], "Unable to locate data directory.");
utilFixPathSeparators(&_confDataDir);
// Do they want tracing?
if (tracing) {
temp = utilCreateString("%strace.txt", _confDataDir);
utilTraceStart(temp);
free(temp);
temp = NULL;
}
// Do the full screen options make sense?
if (_confFullScreen && _confFullScreenWindow) showUsage(argv[0], "Full Screen or Full Screen Windowed. Pick one.");

File diff suppressed because it is too large Load diff

View file

@ -31,7 +31,7 @@
// Don't forget to update singe.rc!
#define SINGE_VERSION 2.00
#define VERSION_STRING "v2.00b5"
#define VERSION_STRING "v2.00b6"
#define COPYRIGHT_END_YEAR "2020"
@ -46,11 +46,12 @@ extern bool _confNoStats;
extern bool _confNoSound;
extern bool _confFullScreen;
extern bool _confFullScreenWindow;
extern int _confVolumeVldp;
extern int _confVolumeNonVldp;
extern int _confScaleFactor;
extern int _confXResolution;
extern int _confYResolution;
extern bool _confShowCalculated;
extern int32_t _confVolumeVldp;
extern int32_t _confVolumeNonVldp;
extern int32_t _confScaleFactor;
extern int32_t _confXResolution;
extern int32_t _confYResolution;
void singe(SDL_Window *window, SDL_Renderer *renderer);

View file

@ -1,7 +1,7 @@
101 ICON "/tmp/icon.ico"
1 VERSIONINFO
FILEVERSION 2,0,0,0
PRODUCTVERSION 2,0,0,0
FILEVERSION 2,0,0,6
PRODUCTVERSION 2,0,0,6
BEGIN
BLOCK "StringFileInfo"
BEGIN
@ -9,12 +9,12 @@ BEGIN
BEGIN
VALUE "CompanyName", "Kangaroo Punch Studios"
VALUE "FileDescription", "Somewhat Interactive Nostalgic Game Emulator"
VALUE "FileVersion", "2.0b5"
VALUE "FileVersion", "2.00b6"
VALUE "InternalName", "Singe"
VALUE "LegalCopyright", "Copyright 2006-2020 Scott C. Duensing"
VALUE "OriginalFilename", "singe.exe"
VALUE "ProductName", "Singe"
VALUE "ProductVersion", "2.0b5"
VALUE "ProductVersion", "2.00b6"
END
END
BLOCK "VarFileInfo"

View file

@ -55,7 +55,7 @@ char *utilCreateString(char *format, ...) {
__attribute__((__format__(__printf__, 1, 0)))
char *utilCreateStringVArgs(char *format, va_list args) {
va_list argsCopy;
int size = 0;
int32_t size = 0;
char *buffer = NULL;
va_copy(argsCopy, args);
@ -98,7 +98,7 @@ bool utilFileExists(char *filename) {
void utilFixPathSeparators(char **path) {
int i = 0;
int32_t i = 0;
char *temp = *path;
// Flip path separators to whatever our OS wants
@ -113,8 +113,8 @@ void utilFixPathSeparators(char **path) {
if (temp[strlen(temp) - 1] != utilGetPathSeparator()) {
// No - append one.
temp = realloc(temp, sizeof(char) * (strlen(temp) + 1));
temp[strlen(temp) - 1] = utilGetPathSeparator();
temp[strlen(temp)] = 0;
temp[strlen(temp)] = utilGetPathSeparator();
temp[strlen(temp) + 1] = 0;
*path = temp;
}
}
@ -122,10 +122,10 @@ void utilFixPathSeparators(char **path) {
char *utilGetFileExtension(char *filename) {
char *start = filename + strlen(filename);
int x;
int32_t x;
// Scan through name and find the last '.'
for (x=0; x<(int)strlen(filename); x++) {
for (x=0; x<(int32_t)strlen(filename); x++) {
if (filename[x] == '.') {
start = &filename[x + 1];
}
@ -141,10 +141,10 @@ char *utilGetFileExtension(char *filename) {
char *utilGetLastPathComponent(char *pathname) {
char *start = pathname;
int x;
int32_t x;
// Scan through name and find the last path separator
for (x=0; x<(int)strlen(pathname); x++) {
for (x=0; x<(int32_t)strlen(pathname); x++) {
if (pathname[x] == utilGetPathSeparator()) {
start = &pathname[x + 1];
}
@ -245,7 +245,7 @@ char *utilReadLine(char *haystack, size_t length, char **offset) {
void utilRedirectConsole(void) {
#ifdef _WIN32
// http://dslweb.nwnexus.com/~ast/dload/guicon.htm
int hConHandle;
int hConHandle; // Not changing this int.
intptr_t lStdHandle;
CONSOLE_SCREEN_BUFFER_INFO coninfo;
FILE *fp;

View file

@ -37,21 +37,21 @@
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wpadded"
typedef struct VideoPlayerS {
int id;
int32_t id;
bool playing;
bool resetTime;
byte *audioBuffer;
byte audioSampleBytes;
byte *audioSilenceRaw;
char errMsg[1024];
int volumeLeft;
int volumeRight;
int audioTrack;
int videoTrack;
int frame;
int audioSampleSize;
int mixSampleSize;
int audioSilenceChannel;
int32_t volumeLeft;
int32_t volumeRight;
int32_t audioTrack;
int32_t videoTrack;
int32_t audioSampleSize;
int32_t mixSampleSize;
int32_t audioSilenceChannel;
int64_t frame;
int64_t audioBufferSize;
int64_t frameDeltaTime;
int64_t lastFrameTime;
@ -78,25 +78,25 @@ typedef struct VideoPlayerS {
FFMS_Index *_createIndex(char *filename, char *indexPath, bool hasVideo, bool hasAudio, VideoPlayerT *v);
void _dequeueVideoAudio(int channel, void *stream, int len, void *udata);
int FFMS_CC _indexCallBack(int64_t Current, int64_t Total, void *ICPrivate);
int _loadVideoAndAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
void _dequeueVideoAudio(int channel, void *stream, int len, void *udata); // Callback. Not changing ints.
int FFMS_CC _indexCallBack(int64_t Current, int64_t Total, void *ICPrivate); // Callback. Not changing int.
int32_t _loadVideoAndAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
static VideoPlayerT *_videoPlayerHash = NULL;
static int _nextId = 0;
static int _mixRate = -1;
static int32_t _nextId = 0;
static int32_t _mixRate = -1;
static Uint8 _mixChannels = 0;
static SDL_AudioFormat _mixFormat = 0;
void _dequeueVideoAudio(int channel, void *stream, int bytes, void *udata) {
void _dequeueVideoAudio(int channel, void *stream, int bytes, void *udata) { // Callback. Not changing ints.
VideoPlayerT *v = (VideoPlayerT *)udata;
int bytesToCopy = bytes;
int available = SDL_AudioStreamAvailable(v->audioStream);
int remainder = 0;
int bytesRead = 0;
int i = 0;
int32_t bytesToCopy = bytes;
int32_t available = SDL_AudioStreamAvailable(v->audioStream);
int32_t remainder = 0;
int32_t bytesRead = 0;
int32_t i = 0;
Sint16 *data = stream;
(void)channel;
@ -117,7 +117,7 @@ void _dequeueVideoAudio(int channel, void *stream, int bytes, void *udata) {
// We do our own volume per channel here in the mixer
if (_mixChannels < 2) {
// Mono output, average volume levels together
Mix_Volume(channel, (int)((float)MIX_MAX_VOLUME * ((float)v->volumeLeft * (float)v->volumeRight / (float)2) * (float)0.01));
Mix_Volume(channel, (int32_t)((float)MIX_MAX_VOLUME * ((float)v->volumeLeft * (float)v->volumeRight / (float)2) * (float)0.01));
} else {
// Stereo output. Assumes MIX_DEFAULT_FORMAT for now.
Mix_Volume(channel, MIX_MAX_VOLUME);
@ -129,16 +129,16 @@ void _dequeueVideoAudio(int channel, void *stream, int bytes, void *udata) {
}
int FFMS_CC _indexCallBack(int64_t current, int64_t total, void *ICPrivate) {
static int lastPercent = 0;
int thisPercent = 0;
int FFMS_CC _indexCallBack(int64_t current, int64_t total, void *ICPrivate) { // Callback. Not changing int.
static int32_t lastPercent = 0;
int32_t thisPercent = 0;
(void)ICPrivate; // Contains current VideoPlayerT
if ((current == 0) && (total == 0)) {
lastPercent = 0; // Reset
} else {
thisPercent = (int)((double)current / (double)total * 100.0);
thisPercent = (int32_t)((double)current / (double)total * 100.0);
if (thisPercent != lastPercent) {
lastPercent = thisPercent;
utilSay("Indexing: %d%%", thisPercent);
@ -149,6 +149,7 @@ int FFMS_CC _indexCallBack(int64_t current, int64_t total, void *ICPrivate) {
return 0;
}
FFMS_Index *_createIndex(char *filename, char *indexPath, bool hasVideo, bool hasAudio, VideoPlayerT *v) {
char indexName[1024];
FFMS_Index *index = NULL;
@ -161,11 +162,6 @@ FFMS_Index *_createIndex(char *filename, char *indexPath, bool hasVideo, bool ha
if (FFMS_IndexBelongsToFile(index, filename, &v->errInfo)) {
FFMS_DestroyIndex(index);
index = NULL;
/*
utilSay("Cached index is invalid.");
} else {
utilSay("Loaded cached index.");
*/
}
}
if (!index) {
@ -185,9 +181,9 @@ FFMS_Index *_createIndex(char *filename, char *indexPath, bool hasVideo, bool ha
}
int _loadVideoAndAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
int pixelFormats[2];
int result = -1;
int32_t _loadVideoAndAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
int32_t pixelFormats[2];
int32_t result = -1;
FFMS_Index *vIndex = NULL;
FFMS_Index *aIndex = NULL;
VideoPlayerT *v = NULL;
@ -333,9 +329,9 @@ int _loadVideoAndAudio(char *vFilename, char *aFilename, char *indexPath, bool s
}
int videoInit(void) {
int32_t videoInit(void) {
int channels = _mixChannels;
int32_t channels = _mixChannels;
// Start FFMS
FFMS_Init(0, 0);
@ -351,68 +347,68 @@ int videoInit(void) {
}
int videoIsPlaying(int playerIndex) {
int32_t videoIsPlaying(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoIsPlaying.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoIsPlaying.", playerHandle);
return v->playing;
}
int videoGetFrame(int playerIndex) {
int64_t videoGetFrame(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoGetFrame.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoGetFrame.", playerHandle);
return v->frame;
}
int videoGetFrameCount(int playerIndex) {
int64_t videoGetFrameCount(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoGetFrameCount.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoGetFrameCount.", playerHandle);
return v->videoProps->NumFrames;
}
int videoGetHeight(int playerIndex) {
int32_t videoGetHeight(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoGetHeight.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoGetHeight.", playerHandle);
return v->propFrame->EncodedHeight;
}
int videoGetWidth(int playerIndex) {
int32_t videoGetWidth(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoGetWidth.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoGetWidth.", playerHandle);
return v->propFrame->EncodedWidth;
}
int videoGetVolume(int playerIndex, int *leftPercent, int *rightPercent) {
int32_t videoGetVolume(int32_t playerHandle, int32_t *leftPercent, int32_t *rightPercent) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoGetVolume.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoGetVolume.", playerHandle);
if (leftPercent != NULL) *leftPercent = v->volumeLeft;
if (rightPercent != NULL) *rightPercent = v->volumeRight;
@ -421,22 +417,22 @@ int videoGetVolume(int playerIndex, int *leftPercent, int *rightPercent) {
}
int videoLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
int32_t videoLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
return _loadVideoAndAudio(filename, NULL, indexPath, stretchVideo, renderer);
}
int videoLoadWithAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
int32_t videoLoadWithAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer) {
return _loadVideoAndAudio(vFilename, aFilename, indexPath, stretchVideo, renderer);
}
int videoPause(int playerIndex) {
int32_t videoPause(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoPause.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoPause.", playerHandle);
v->playing = false;
v->resetTime = true;
@ -445,12 +441,12 @@ int videoPause(int playerIndex) {
}
int videoPlay(int playerIndex) {
int32_t videoPlay(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoPlay.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoPlay.", playerHandle);
v->playing = true;
v->resetTime = true;
@ -459,7 +455,7 @@ int videoPlay(int playerIndex) {
}
int videoQuit(void) {
int32_t videoQuit(void) {
VideoPlayerT *v = NULL;
VideoPlayerT *t = NULL;
@ -475,12 +471,12 @@ int videoQuit(void) {
}
int videoSeek(int playerIndex, int seekFrame) {
int32_t videoSeek(int32_t playerHandle, int64_t seekFrame) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoSeek.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoSeek.", playerHandle);
while (seekFrame >= v->videoProps->NumFrames) {
seekFrame -= v->videoProps->NumFrames;
@ -496,12 +492,12 @@ int videoSeek(int playerIndex, int seekFrame) {
}
int videoSetVolume(int playerIndex, int leftPercent, int rightPercent) {
int32_t videoSetVolume(int32_t playerHandle, int32_t leftPercent, int32_t rightPercent) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoSetVolume.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoSetVolume.", playerHandle);
v->volumeLeft = leftPercent;
v->volumeRight = rightPercent;
@ -510,12 +506,12 @@ int videoSetVolume(int playerIndex, int leftPercent, int rightPercent) {
}
int videoUnload(int playerIndex) {
int32_t videoUnload(int32_t playerHandle) {
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoStop.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoStop.", playerHandle);
Mix_HaltChannel(v->audioSilenceChannel);
Mix_UnregisterEffect(v->audioSilenceChannel, _dequeueVideoAudio);
@ -539,14 +535,14 @@ int videoUnload(int playerIndex) {
}
int videoUpdate(int playerIndex, SDL_Texture **texture) {
int result = -1;
int32_t videoUpdate(int32_t playerHandle, SDL_Texture **texture) {
int32_t result = -1;
int64_t count = 0;
VideoPlayerT *v = NULL;
// Get our player structure
HASH_FIND_INT(_videoPlayerHash, &playerIndex, v);
if (!v) utilDie("No video player at index %d in videoUpdate.", playerIndex);
HASH_FIND_INT(_videoPlayerHash, &playerHandle, v);
if (!v) utilDie("No video player at index %d in videoUpdate.", playerHandle);
// Handle video frames (and time)
if ((SDL_GetTicks() - v->lastTickTime >= v->frameDeltaTime) || v->resetTime) {
@ -596,7 +592,7 @@ int videoUpdate(int playerIndex, SDL_Texture **texture) {
// Get audio from video stream
if (FFMS_GetAudio(v->audioSource, v->audioBuffer, v->audioPosition, count, &v->errInfo)) utilDie("%s", v->errInfo.Buffer);
// Feed it to the mixer stream
if (SDL_AudioStreamPut(v->audioStream, v->audioBuffer, (int)(count * v->audioSampleSize)) < 0) utilDie("%s", SDL_GetError());
if (SDL_AudioStreamPut(v->audioStream, v->audioBuffer, (int32_t)(count * v->audioSampleSize)) < 0) utilDie("%s", SDL_GetError());
v->audioPosition += count;
}
}

View file

@ -29,22 +29,22 @@
#include "common.h"
int videoInit(void);
int videoIsPlaying(int playerIndex);
int videoGetFrame(int playerIndex);
int videoGetFrameCount(int playerIndex);
int videoGetHeight(int playerIndex);
int videoGetWidth(int playerIndex);
int videoGetVolume(int playerIndex, int *leftPercent, int *rightPercent);
int videoLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
int videoLoadWithAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
int videoPause(int playerIndex);
int videoPlay(int playerIndex);
int videoQuit(void);
int videoSeek(int playerIndex, int seekFrame);
int videoSetVolume(int playerIndex, int leftPercent, int rightPercent);
int videoUnload(int playerIndex);
int videoUpdate(int playerIndex, SDL_Texture **texture);
int32_t videoInit(void);
int32_t videoIsPlaying(int32_t playerHandle);
int64_t videoGetFrame(int32_t playerHandle);
int64_t videoGetFrameCount(int32_t playerHandle);
int32_t videoGetHeight(int32_t playerHandle);
int32_t videoGetWidth(int32_t playerHandle);
int32_t videoGetVolume(int32_t playerHandle, int32_t *leftPercent, int32_t *rightPercent);
int32_t videoLoad(char *filename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
int32_t videoLoadWithAudio(char *vFilename, char *aFilename, char *indexPath, bool stretchVideo, SDL_Renderer *renderer);
int32_t videoPause(int32_t playerHandle);
int32_t videoPlay(int32_t playerHandle);
int32_t videoQuit(void);
int32_t videoSeek(int32_t playerHandle, int64_t seekFrame);
int32_t videoSetVolume(int32_t playerHandle, int32_t leftPercent, int32_t rightPercent);
int32_t videoUnload(int32_t playerHandle);
int32_t videoUpdate(int32_t playerHandle, SDL_Texture **texture);
#endif // VIDEOPLAYER_H