Remove ineffective consts and indicate unused variables
This commit is contained in:
parent
d23f31fbe3
commit
01a61a33f8
7 changed files with 30 additions and 22 deletions
|
@ -91,6 +91,7 @@ static void FLAC_quit(void)
|
|||
|
||||
static int FLAC_open(Sound_Sample *sample, const char *ext)
|
||||
{
|
||||
(void) ext; // deliberately unused, but present for API compliance
|
||||
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
||||
drflac *dr = drflac_open(flac_read, flac_seek, sample, NULL);
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
static size_t mp3_read(void* const pUserData, void* const pBufferOut, const size_t bytesToRead)
|
||||
{
|
||||
Uint8* ptr = static_cast<Uint8*>(pBufferOut);
|
||||
Sound_Sample* const sample = static_cast<Sound_Sample* const>(pUserData);
|
||||
Sound_Sample* const sample = static_cast<Sound_Sample*>(pUserData);
|
||||
const Sound_SampleInternal* const internal = static_cast<const Sound_SampleInternal*>(sample->opaque);
|
||||
SDL_RWops* rwops = internal->rw;
|
||||
size_t retval = 0;
|
||||
|
@ -88,7 +88,7 @@ static void MP3_quit(void)
|
|||
|
||||
static void MP3_close(Sound_Sample* const sample)
|
||||
{
|
||||
Sound_SampleInternal* const internal = static_cast<Sound_SampleInternal* const>(sample->opaque);
|
||||
Sound_SampleInternal* const internal = static_cast<Sound_SampleInternal*>(sample->opaque);
|
||||
mp3_t* p_mp3 = static_cast<mp3_t*>(internal->decoder_private);
|
||||
if (p_mp3 != nullptr) {
|
||||
if (p_mp3->p_dr != nullptr) {
|
||||
|
@ -103,7 +103,7 @@ static void MP3_close(Sound_Sample* const sample)
|
|||
|
||||
static Uint32 MP3_read(Sound_Sample* const sample, void* buffer, Uint32 desired_frames)
|
||||
{
|
||||
Sound_SampleInternal* const internal = static_cast<Sound_SampleInternal* const>(sample->opaque);
|
||||
Sound_SampleInternal* const internal = static_cast<Sound_SampleInternal*>(sample->opaque);
|
||||
mp3_t* p_mp3 = static_cast<mp3_t*>(internal->decoder_private);
|
||||
|
||||
// LOG_MSG("read-while: num_frames: %u", num_frames);
|
||||
|
@ -114,6 +114,7 @@ static Uint32 MP3_read(Sound_Sample* const sample, void* buffer, Uint32 desired_
|
|||
|
||||
static Sint32 MP3_open(Sound_Sample* const sample, const char* const ext)
|
||||
{
|
||||
(void) ext; // deliberately unused
|
||||
Sound_SampleInternal* const internal = static_cast<Sound_SampleInternal*>(sample->opaque);
|
||||
Sint32 result(0); // assume failure until proven otherwise
|
||||
mp3_t* p_mp3 = (mp3_t*) SDL_calloc(1, sizeof (mp3_t));
|
||||
|
@ -148,7 +149,7 @@ static Sint32 MP3_open(Sound_Sample* const sample, const char* const ext)
|
|||
MP3_close(sample);
|
||||
}
|
||||
|
||||
return static_cast<Sint32>(result);
|
||||
return result;
|
||||
} /* MP3_open */
|
||||
|
||||
static Sint32 MP3_rewind(Sound_Sample* const sample)
|
||||
|
@ -160,7 +161,7 @@ static Sint32 MP3_rewind(Sound_Sample* const sample)
|
|||
|
||||
static Sint32 MP3_seek(Sound_Sample* const sample, const Uint32 ms)
|
||||
{
|
||||
Sound_SampleInternal* const internal = static_cast<Sound_SampleInternal* const>(sample->opaque);
|
||||
Sound_SampleInternal* const internal = static_cast<Sound_SampleInternal*>(sample->opaque);
|
||||
mp3_t* p_mp3 = static_cast<mp3_t*>(internal->decoder_private);
|
||||
const float frames_per_ms = sample->actual.rate / 1000.0f;
|
||||
const drmp3_uint64 frame_offset = static_cast<drmp3_uint64>(frames_per_ms) * ms;
|
||||
|
|
|
@ -102,7 +102,7 @@ using std::ofstream;
|
|||
#define FRAMES_PER_SEEK_POINT 7
|
||||
|
||||
// Returns the size of a file in bytes (if valid), otherwise 0
|
||||
const size_t get_file_size(const char* filename) {
|
||||
size_t get_file_size(const char* filename) {
|
||||
struct stat stat_buf;
|
||||
int rc = stat(filename, &stat_buf);
|
||||
return rc == 0 ? stat_buf.st_size : -1;
|
||||
|
@ -119,15 +119,14 @@ const size_t get_file_size(const char* filename) {
|
|||
// 1. ID3 tag filler content, which might be boiler plate or all empty
|
||||
// 2. Trailing silence or similar zero-PCM content
|
||||
//
|
||||
const Uint64 calculate_stream_hash(struct SDL_RWops* const context) {
|
||||
|
||||
Uint64 calculate_stream_hash(struct SDL_RWops* const context) {
|
||||
// Save the current stream position, so we can restore it at the end of the function.
|
||||
const Sint64 original_pos = SDL_RWtell(context);
|
||||
|
||||
// Seek to the end of the file so we can calculate the stream size.
|
||||
SDL_RWseek(context, 0, RW_SEEK_END);
|
||||
|
||||
const Sint32 stream_size = (Sint32) SDL_RWtell(context);
|
||||
const Sint32 stream_size = SDL_RWtell(context);
|
||||
if (stream_size <= 0) {
|
||||
// LOG_MSG("MP3: get_stream_size returned %d, but should be positive", stream_size);
|
||||
return 0;
|
||||
|
@ -175,12 +174,12 @@ const Uint64 calculate_stream_hash(struct SDL_RWops* const context) {
|
|||
// This function generates a new seek-table for a given mp3 stream and writes
|
||||
// the data to the fast-seek file.
|
||||
//
|
||||
const Uint64 generate_new_seek_points(const char* filename,
|
||||
const Uint64& stream_hash,
|
||||
drmp3* const p_dr,
|
||||
map<Uint64, vector<drmp3_seek_point_serial> >& seek_points_table,
|
||||
map<Uint64, drmp3_uint64>& pcm_frame_count_table,
|
||||
vector<drmp3_seek_point_serial>& seek_points_vector) {
|
||||
Uint64 generate_new_seek_points(const char* filename,
|
||||
const Uint64& stream_hash,
|
||||
drmp3* const p_dr,
|
||||
map<Uint64, vector<drmp3_seek_point_serial> >& seek_points_table,
|
||||
map<Uint64, drmp3_uint64>& pcm_frame_count_table,
|
||||
vector<drmp3_seek_point_serial>& seek_points_vector) {
|
||||
|
||||
// Initialize our frame counters with zeros.
|
||||
drmp3_uint64 mp3_frame_count(0);
|
||||
|
@ -244,11 +243,11 @@ const Uint64 generate_new_seek_points(const char* filename,
|
|||
// This function attempts to fetch a seek-table for a given mp3 stream from the fast-seek file.
|
||||
// If anything is amiss then this function fails.
|
||||
//
|
||||
const Uint64 load_existing_seek_points(const char* filename,
|
||||
const Uint64& stream_hash,
|
||||
map<Uint64, vector<drmp3_seek_point_serial> >& seek_points_table,
|
||||
map<Uint64, drmp3_uint64>& pcm_frame_count_table,
|
||||
vector<drmp3_seek_point_serial>& seek_points) {
|
||||
Uint64 load_existing_seek_points(const char* filename,
|
||||
const Uint64& stream_hash,
|
||||
map<Uint64, vector<drmp3_seek_point_serial> >& seek_points_table,
|
||||
map<Uint64, drmp3_uint64>& pcm_frame_count_table,
|
||||
vector<drmp3_seek_point_serial>& seek_points) {
|
||||
|
||||
// The below sentinals sanity check and read the incoming
|
||||
// file one-by-one until all the data can be trusted.
|
||||
|
@ -301,7 +300,7 @@ const Uint64 load_existing_seek_points(const char* filename,
|
|||
// attempting to read it from the fast-seek file and (if it can't be read for any reason), it
|
||||
// calculates new data. It makes use of the above two functions.
|
||||
//
|
||||
const Uint64 populate_seek_points(struct SDL_RWops* const context, mp3_t* p_mp3, const char* seektable_filename) {
|
||||
Uint64 populate_seek_points(struct SDL_RWops* const context, mp3_t* p_mp3, const char* seektable_filename) {
|
||||
|
||||
// Calculate the stream's xxHash value.
|
||||
Uint64 stream_hash = calculate_stream_hash(context);
|
||||
|
|
|
@ -54,4 +54,4 @@ struct mp3_t {
|
|||
std::vector<drmp3_seek_point_serial> seek_points_vector;
|
||||
};
|
||||
|
||||
const Uint64 populate_seek_points(struct SDL_RWops* const context, mp3_t* p_mp3, const char* seektable_filename);
|
||||
Uint64 populate_seek_points(struct SDL_RWops* const context, mp3_t* p_mp3, const char* seektable_filename);
|
||||
|
|
|
@ -140,6 +140,7 @@ static Sint32 RWops_opus_seek(void* stream, const opus_int64 offset, const Sint3
|
|||
*/
|
||||
static Sint32 RWops_opus_close(void* stream)
|
||||
{
|
||||
(void) stream; // deliberately unused, but present for API compliance
|
||||
/* SDL closes this for us */
|
||||
// return SDL_RWclose((SDL_RWops*)stream);
|
||||
return 0;
|
||||
|
@ -188,6 +189,9 @@ static __inline__ void output_opus_info(const OggOpusFile* of, const OpusHead* o
|
|||
SNDDBG(("Opus: user comment: '%s'\n", ot->user_comments[i]));
|
||||
}
|
||||
}
|
||||
#else
|
||||
(void) of; // unused if DEBUG_CHATTER not defined
|
||||
(void) oh; // unused if DEBUG_CHATTER not defined
|
||||
#endif
|
||||
} /* output_opus_comments */
|
||||
|
||||
|
@ -199,6 +203,7 @@ static __inline__ void output_opus_info(const OggOpusFile* of, const OpusHead* o
|
|||
*/
|
||||
static Sint32 opus_open(Sound_Sample* sample, const char* ext)
|
||||
{
|
||||
(void) ext; // deliberately unused, but present for API compliance
|
||||
Sint32 rcode;
|
||||
Sound_SampleInternal* internal = (Sound_SampleInternal*)sample->opaque;
|
||||
OggOpusFile* of = op_open_callbacks(internal->rw, &RWops_opus_callbacks, NULL, 0, &rcode);
|
||||
|
|
|
@ -115,6 +115,7 @@ static void VORBIS_quit(void)
|
|||
|
||||
static int VORBIS_open(Sound_Sample *sample, const char *ext)
|
||||
{
|
||||
(void) ext; // deliberately unused, but present for API compliance
|
||||
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
||||
SDL_RWops *rw = internal->rw;
|
||||
int err = 0;
|
||||
|
|
|
@ -89,6 +89,7 @@ static void WAV_close(Sound_Sample *sample)
|
|||
|
||||
static int WAV_open(Sound_Sample *sample, const char *ext)
|
||||
{
|
||||
(void) ext; // deliberately unused, but present for API compliance
|
||||
Sound_SampleInternal *internal = (Sound_SampleInternal *) sample->opaque;
|
||||
drwav* dr = SDL_malloc(sizeof(drwav));
|
||||
drwav_result result = drwav_init_ex(dr, wav_read, wav_seek, NULL, sample, NULL, 0, NULL);
|
||||
|
|
Loading…
Add table
Reference in a new issue