mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
Tag the .mid file in /tmp with the username and current pid, and remove it when the sound system is shut down.
git-svn-id: https://svn.eduke32.com/eduke32@488 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
abcce7e337
commit
1fff7e88f4
1 changed files with 42 additions and 17 deletions
|
@ -74,6 +74,8 @@ static char errorMessage[80];
|
||||||
static FILE *debug_file = NULL;
|
static FILE *debug_file = NULL;
|
||||||
static int initialized_debugging = 0;
|
static int initialized_debugging = 0;
|
||||||
|
|
||||||
|
static char *midifn = NULL;
|
||||||
|
|
||||||
// This gets called all over the place for information and debugging messages.
|
// This gets called all over the place for information and debugging messages.
|
||||||
// If the user set the DUKESND_DEBUG environment variable, the messages
|
// If the user set the DUKESND_DEBUG environment variable, the messages
|
||||||
// go to the file that is specified in that variable. Otherwise, they
|
// go to the file that is specified in that variable. Otherwise, they
|
||||||
|
@ -104,7 +106,7 @@ static void init_debugging(void)
|
||||||
envr = getenv(DUKESND_DEBUG);
|
envr = getenv(DUKESND_DEBUG);
|
||||||
if (envr != NULL)
|
if (envr != NULL)
|
||||||
{
|
{
|
||||||
if (strcmp(envr, "-") == 0)
|
if (Bstrcmp(envr, "-") == 0)
|
||||||
debug_file = stdout;
|
debug_file = stdout;
|
||||||
else
|
else
|
||||||
debug_file = fopen(envr, "w");
|
debug_file = fopen(envr, "w");
|
||||||
|
@ -130,7 +132,7 @@ static void setWarningMessage(const char *msg)
|
||||||
|
|
||||||
static void setErrorMessage(const char *msg)
|
static void setErrorMessage(const char *msg)
|
||||||
{
|
{
|
||||||
strncpy(errorMessage, msg, sizeof(errorMessage));
|
Bstrncpy(errorMessage, msg, sizeof(errorMessage));
|
||||||
// strncpy() doesn't add the null char if there isn't room...
|
// strncpy() doesn't add the null char if there isn't room...
|
||||||
errorMessage[sizeof(errorMessage) - 1] = '\0';
|
errorMessage[sizeof(errorMessage) - 1] = '\0';
|
||||||
musdebug("Error message set to [%s].", errorMessage);
|
musdebug("Error message set to [%s].", errorMessage);
|
||||||
|
@ -217,6 +219,15 @@ int MUSIC_Shutdown(void)
|
||||||
music_context = 0;
|
music_context = 0;
|
||||||
music_initialized = 0;
|
music_initialized = 0;
|
||||||
music_loopflag = MUSIC_PlayOnce;
|
music_loopflag = MUSIC_PlayOnce;
|
||||||
|
|
||||||
|
if (midifn != NULL)
|
||||||
|
{
|
||||||
|
initprintf("Removing temporary file '%s'\n",midifn);
|
||||||
|
unlink(midifn);
|
||||||
|
Bfree(midifn);
|
||||||
|
midifn = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return(MUSIC_Ok);
|
return(MUSIC_Ok);
|
||||||
} // MUSIC_Shutdown
|
} // MUSIC_Shutdown
|
||||||
|
|
||||||
|
@ -298,6 +309,7 @@ int MUSIC_StopSong(void)
|
||||||
|
|
||||||
music_songdata = NULL;
|
music_songdata = NULL;
|
||||||
music_musicchunk = NULL;
|
music_musicchunk = NULL;
|
||||||
|
|
||||||
return(MUSIC_Ok);
|
return(MUSIC_Ok);
|
||||||
} // MUSIC_StopSong
|
} // MUSIC_StopSong
|
||||||
|
|
||||||
|
@ -367,17 +379,29 @@ void PlayMusic(char *_filename)
|
||||||
kclose(handle);
|
kclose(handle);
|
||||||
if (rc != size)
|
if (rc != size)
|
||||||
{
|
{
|
||||||
free(song);
|
Bfree(song);
|
||||||
return;
|
return;
|
||||||
} // if
|
} // if
|
||||||
|
|
||||||
// save the file somewhere, so SDL_mixer can load it
|
// save the file somewhere, so SDL_mixer can load it
|
||||||
GetUnixPathFromEnvironment(filename, BMAX_PATH, "tmpsong.mid");
|
{
|
||||||
|
char *user = getenv("USERNAME");
|
||||||
|
|
||||||
|
if (user) Bsprintf(tempbuf,"duke3d-%s.mid.%d",user,getpid());
|
||||||
|
else Bsprintf(tempbuf,"duke3d.mid.%d",getpid());
|
||||||
|
|
||||||
|
GetUnixPathFromEnvironment(filename, BMAX_PATH, tempbuf);
|
||||||
|
|
||||||
handle = SafeOpenWrite(filename, filetype_binary);
|
handle = SafeOpenWrite(filename, filetype_binary);
|
||||||
|
|
||||||
|
if (handle == -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
midifn = Bstrdup(filename);
|
||||||
|
|
||||||
SafeWrite(handle, song, size);
|
SafeWrite(handle, song, size);
|
||||||
close(handle);
|
close(handle);
|
||||||
free(song);
|
Bfree(song);
|
||||||
|
|
||||||
//music_songdata = song;
|
//music_songdata = song;
|
||||||
|
|
||||||
|
@ -387,6 +411,7 @@ void PlayMusic(char *_filename)
|
||||||
// !!! FIXME: I set the music to loop. Hope that's okay. --ryan.
|
// !!! FIXME: I set the music to loop. Hope that's okay. --ryan.
|
||||||
Mix_PlayMusic(music_musicchunk, -1);
|
Mix_PlayMusic(music_musicchunk, -1);
|
||||||
} // if
|
} // if
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue