From 1a6516710db697f09a1a50d33da26d34a9a916aa Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 18 Aug 2019 01:03:33 +0300 Subject: [PATCH 1/3] Minor fix of GME --- src/codecs/music_gme.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/codecs/music_gme.c b/src/codecs/music_gme.c index 0c387e24..9906a35c 100644 --- a/src/codecs/music_gme.c +++ b/src/codecs/music_gme.c @@ -138,6 +138,8 @@ GME_Music *GME_LoadSongRW(SDL_RWops *src, int trackNum) /* Set infinite playback */ gme_set_fade(music->game_emu, -1); + /* For old versions, for newer the next call is supported: */ + /* gme_set_autoload_playback_limit(music->game_emu, 0); */ music->volume = MIX_MAX_VOLUME; music->tempo = 1.0; From 1b6f7335f8d2c94d26e25c4079054a65da0a6ef3 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 18 Aug 2019 16:39:32 +0300 Subject: [PATCH 2/3] Better detection of IMF file (Sometimes it detects unnecessary files as IMF, for example, WMAs: #29) --- src/music.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/music.c b/src/music.c index b7dc74a5..0ce96bf3 100644 --- a/src/music.c +++ b/src/music.c @@ -665,8 +665,8 @@ static Mix_MusicType xmi_compatible_midi_player() #ifdef MUSIC_MID_ADLMIDI static int detect_imf(SDL_RWops *in, Sint64 start) { - Uint16 chunksize, buff, i = 42; - Uint32 sum1 = 0, sum2 = 0; + Uint16 chunksize, buff; + Uint32 sum1 = 0, sum2 = 0, passed_length = 0; Uint16 word; if(!in) @@ -684,22 +684,27 @@ static int detect_imf(SDL_RWops *in, Sint64 start) return 0; } - while (i > 0) { + while (passed_length < chunksize) { if (SDL_RWread(in, &word, 1, 2) != 2) { SDL_RWseek(in, start, RW_SEEK_SET); break; } + passed_length += 2; buff = SDL_SwapLE16(word); sum1 += buff; if (SDL_RWread(in, &word, 1, 2) != 2) { SDL_RWseek(in, start, RW_SEEK_SET); break; } + passed_length += 2; buff = SDL_SwapLE16(word); sum2 += buff; - i--; } SDL_RWseek(in, start, RW_SEEK_SET); + + if (passed_length != chunksize) + return 0; + return (sum1 > sum2); } From 3e8007b0557ffa6f10c75a21e9a16f9c5f919ad6 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 18 Aug 2019 21:19:56 +0300 Subject: [PATCH 3/3] MusPlay: Single-application fix --- .../SingleApplication/singleapplication.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/examples/MusPlay-Qt/SingleApplication/singleapplication.cpp b/examples/MusPlay-Qt/SingleApplication/singleapplication.cpp index 1be086af..8154242e 100644 --- a/examples/MusPlay-Qt/SingleApplication/singleapplication.cpp +++ b/examples/MusPlay-Qt/SingleApplication/singleapplication.cpp @@ -35,19 +35,22 @@ SingleApplication::SingleApplication(QStringList &args) : _shouldContinue = false; // By default this is not the main process socket = new QUdpSocket(); - server = NULL; + server = nullptr; QString isServerRuns; bool isRunning=false; m_sema.acquire();//Avoid races - if(m_shmem.attach()) //Detect shared memory copy - { - isRunning = true; - } - else + + if(!m_shmem.create(1))//Detect shared memory copy { - m_shmem.create(1); - isRunning = false; + m_shmem.attach(); + m_shmem.detach(); + if(!m_shmem.create(1)) + { + isRunning = true; + if(!m_shmem.attach()) + qWarning() << "Can't re-attach existing shared memory!"; + } } //Force run second copy of application