Skip to content

Commit

Permalink
Cast the string constants to char* when tremor is used.
Browse files Browse the repository at this point in the history
Fixes warning: ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

Tremor never writes to the strings so this is safe to do.
  • Loading branch information
Ghabry committed Sep 2, 2024
1 parent 3073f37 commit 425da58
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/decoder_oggvorbis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,21 +92,29 @@ bool OggVorbisDecoder::Open(Filesystem_Stream::InputStream stream) {
vorbis_comment* vc = ov_comment(ovf, -1);
if (vc) {
// RPG VX loop support
const char* str = vorbis_comment_query(vc, "LOOPSTART", 0);
// Workaround conversion of string constant to char warning because
// of tremor using a different signature.
#if defined(HAVE_TREMOR)
using char_type = char*;
#else
using char_type = const char*;
#endif

const char* str = vorbis_comment_query(vc, (char_type)"LOOPSTART", 0);
if (str) {
auto total = ov_pcm_total(ovf, -1) ;
loop.start = std::min<int64_t>(atoi(str), total);
if (loop.start >= 0) {
loop.looping = true;
loop.end = total;
str = vorbis_comment_query(vc, "LOOPLENGTH", 0);
str = vorbis_comment_query(vc, (char_type)"LOOPLENGTH", 0);
if (str) {
int len = atoi(str);
if (len >= 0) {
loop.end = std::min<int64_t>(loop.start + len, total);
}
} else {
str = vorbis_comment_query(vc, "LOOPEND", 0);
str = vorbis_comment_query(vc, (char_type)"LOOPEND", 0);
if (str) {
int end = atoi(str);
if (end >= 0) {
Expand Down

0 comments on commit 425da58

Please sign in to comment.