Skip to content

Commit

Permalink
Merge branch 'master' of github.com:WohlSoft/SDL-Mixer-X
Browse files Browse the repository at this point in the history
  • Loading branch information
Wohlstand committed Aug 19, 2019
2 parents 4c790a3 + 3e8007b commit 6308aac
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 12 deletions.
19 changes: 11 additions & 8 deletions examples/MusPlay-Qt/SingleApplication/singleapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/codecs/music_gme.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
13 changes: 9 additions & 4 deletions src/music.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
}

Expand Down

0 comments on commit 6308aac

Please sign in to comment.