Use specific type in MVEFILE instead of `void *`
Replace `void *stream` with a typedef and `stream_type *stream`, so that the original type information is propagated down.
This commit is contained in:
parent
51219d3607
commit
6ff9c9029d
|
@ -31,7 +31,6 @@ static uint16_t _mve_get_ushort(const unsigned char *data);
|
|||
/*
|
||||
* private functions for mvefile
|
||||
*/
|
||||
static int _mvefile_open(MVEFILE *movie, void *stream);
|
||||
static int _mvefile_read_header(const MVEFILE *movie);
|
||||
static void _mvefile_set_buffer_size(MVEFILE *movie, std::size_t buf_size);
|
||||
static int _mvefile_fetch_next_chunk(MVEFILE *movie);
|
||||
|
@ -39,7 +38,6 @@ static int _mvefile_fetch_next_chunk(MVEFILE *movie);
|
|||
/*
|
||||
* private functions for mvestream
|
||||
*/
|
||||
static int _mvestream_open(MVESTREAM *movie, void *stream);
|
||||
static void _mvestream_reset(MVESTREAM *movie);
|
||||
|
||||
}
|
||||
|
@ -48,17 +46,17 @@ static void _mvestream_reset(MVESTREAM *movie);
|
|||
* public MVEFILE functions
|
||||
************************************************************/
|
||||
|
||||
namespace {
|
||||
|
||||
/*
|
||||
* open an MVE file
|
||||
*/
|
||||
std::unique_ptr<MVEFILE> mvefile_open(void *stream)
|
||||
std::unique_ptr<MVEFILE> mvefile_open(MVEFILE::stream_type *const stream)
|
||||
{
|
||||
/* create the file */
|
||||
auto file = std::make_unique<MVEFILE>();
|
||||
if (! _mvefile_open(file.get(), stream))
|
||||
{
|
||||
if (!stream)
|
||||
return nullptr;
|
||||
}
|
||||
/* create the file */
|
||||
auto file = std::make_unique<MVEFILE>(stream);
|
||||
|
||||
/* initialize the file */
|
||||
_mvefile_set_buffer_size(file.get(), 1024);
|
||||
|
@ -74,7 +72,14 @@ std::unique_ptr<MVEFILE> mvefile_open(void *stream)
|
|||
return file;
|
||||
}
|
||||
|
||||
namespace {
|
||||
/*
|
||||
* open an MVESTREAM object
|
||||
*/
|
||||
static const MVEFILE *_mvestream_open(MVESTREAM *movie, MVEFILE::stream_type *const stream)
|
||||
{
|
||||
movie->movie = mvefile_open(stream);
|
||||
return movie->movie.get();
|
||||
}
|
||||
|
||||
/*
|
||||
* reset a MVE file
|
||||
|
@ -180,7 +185,7 @@ int mvefile_fetch_next_chunk(MVEFILE *movie)
|
|||
/*
|
||||
* open an MVE stream
|
||||
*/
|
||||
MVESTREAM_ptr_t mve_open(void *stream)
|
||||
MVESTREAM_ptr_t mve_open(MVEFILE::stream_type *const stream)
|
||||
{
|
||||
/* allocate */
|
||||
auto movie = std::make_unique<MVESTREAM>();
|
||||
|
@ -259,7 +264,8 @@ int mve_play_next_chunk(MVESTREAM &movie)
|
|||
/*
|
||||
* allocate an MVEFILE
|
||||
*/
|
||||
MVEFILE::MVEFILE()
|
||||
MVEFILE::MVEFILE(MVEFILE::stream_type *const stream) :
|
||||
stream(stream)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -272,18 +278,6 @@ MVEFILE::~MVEFILE()
|
|||
|
||||
namespace {
|
||||
|
||||
/*
|
||||
* open the file stream in thie object
|
||||
*/
|
||||
static int _mvefile_open(MVEFILE *file, void *stream)
|
||||
{
|
||||
file->stream = stream;
|
||||
if (! file->stream)
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* read and verify the header of the recently opened file
|
||||
*/
|
||||
|
@ -385,16 +379,6 @@ MVESTREAM::~MVESTREAM()
|
|||
|
||||
namespace {
|
||||
|
||||
/*
|
||||
* open an MVESTREAM object
|
||||
*/
|
||||
static int _mvestream_open(MVESTREAM *movie, void *stream)
|
||||
{
|
||||
movie->movie = mvefile_open(stream);
|
||||
|
||||
return (movie->movie == NULL) ? 0 : 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* reset an MVESTREAM
|
||||
*/
|
||||
|
|
|
@ -17,24 +17,22 @@
|
|||
#include <vector>
|
||||
#include "dxxsconf.h"
|
||||
#include <array>
|
||||
#include <SDL.h>
|
||||
|
||||
/*
|
||||
* structure for maintaining info on a MVEFILE stream
|
||||
*/
|
||||
struct MVEFILE
|
||||
{
|
||||
MVEFILE();
|
||||
using stream_type = SDL_RWops;
|
||||
MVEFILE() = default;
|
||||
MVEFILE(stream_type *);
|
||||
~MVEFILE();
|
||||
void *stream = nullptr;
|
||||
stream_type *stream = nullptr;
|
||||
std::vector<uint8_t> cur_chunk;
|
||||
std::size_t next_segment = 0;
|
||||
};
|
||||
|
||||
/*
|
||||
* open a .MVE file
|
||||
*/
|
||||
std::unique_ptr<MVEFILE> mvefile_open(void *stream);
|
||||
|
||||
/*
|
||||
* get size of next segment in chunk (-1 if no more segments in chunk)
|
||||
*/
|
||||
|
@ -92,12 +90,12 @@ struct MVESTREAM_deleter_t
|
|||
};
|
||||
|
||||
typedef std::unique_ptr<MVESTREAM, MVESTREAM_deleter_t> MVESTREAM_ptr_t;
|
||||
int MVE_rmPrepMovie(MVESTREAM_ptr_t &, void *stream, int x, int y, int track);
|
||||
int MVE_rmPrepMovie(MVESTREAM_ptr_t &, MVEFILE::stream_type *stream, int x, int y, int track);
|
||||
|
||||
/*
|
||||
* open an MVE stream
|
||||
*/
|
||||
MVESTREAM_ptr_t mve_open(void *stream);
|
||||
MVESTREAM_ptr_t mve_open(MVEFILE::stream_type *stream);
|
||||
|
||||
/*
|
||||
* reset an MVE stream
|
||||
|
@ -119,4 +117,6 @@ void mve_set_handler_context(MVESTREAM *movie, void *context);
|
|||
*/
|
||||
int mve_play_next_chunk(MVESTREAM &movie);
|
||||
|
||||
unsigned int MovieFileRead(MVEFILE::stream_type *handle, void *buf, unsigned int count);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -663,7 +663,7 @@ static int end_chunk_handler(unsigned char, unsigned char, const unsigned char *
|
|||
return 1;
|
||||
}
|
||||
|
||||
int MVE_rmPrepMovie(MVESTREAM_ptr_t &pMovie, void *src, int x, int y, int)
|
||||
int MVE_rmPrepMovie(MVESTREAM_ptr_t &pMovie, MVEFILE::stream_type *const src, int x, int y, int)
|
||||
{
|
||||
if (pMovie) {
|
||||
mve_reset(pMovie.get());
|
||||
|
|
|
@ -7,10 +7,8 @@
|
|||
#ifndef _LIBMVE_H
|
||||
#define _LIBMVE_H
|
||||
|
||||
#define MVE_ERR_EOF 1
|
||||
|
||||
#ifdef __cplusplus
|
||||
#include <memory>
|
||||
#include <SDL.h>
|
||||
|
||||
enum class MVE_StepStatus
|
||||
{
|
||||
|
@ -36,12 +34,9 @@ void MVE_getVideoSpec(MVE_videoSpec *vSpec);
|
|||
|
||||
void MVE_sndInit(int x);
|
||||
|
||||
unsigned int MovieFileRead(void *handle, void *buf, unsigned int count);
|
||||
void MovieShowFrame(const uint8_t *buf, int dstx, int dsty, int bufw, int bufh, int sw, int sh);
|
||||
void *MovieMemoryAllocate(std::size_t size);
|
||||
void MovieMemoryFree(void *p);
|
||||
void MovieSetPalette(const unsigned char *p, unsigned start, unsigned count);
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _LIBMVE_H */
|
||||
|
|
|
@ -128,9 +128,9 @@ void MovieMemoryFree(void *p)
|
|||
d_free(p);
|
||||
}
|
||||
|
||||
unsigned int MovieFileRead(void *handle, void *buf, unsigned int count)
|
||||
unsigned int MovieFileRead(SDL_RWops *const handle, void *buf, unsigned int count)
|
||||
{
|
||||
const unsigned numread = SDL_RWread(reinterpret_cast<SDL_RWops *>(handle), buf, 1, count);
|
||||
const unsigned numread = SDL_RWread(handle, buf, 1, count);
|
||||
return (numread == count);
|
||||
}
|
||||
|
||||
|
@ -408,7 +408,6 @@ movie_play_status RunMovie(const char *const filename, const char *const subtitl
|
|||
event_process();
|
||||
wind = nullptr;
|
||||
|
||||
filehndl.reset(); // Close Movie File
|
||||
if (reshow)
|
||||
show_menus();
|
||||
|
||||
|
|
Loading…
Reference in New Issue