Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MP3 music #3

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added base/music/.gitkeep
Empty file.
13 changes: 7 additions & 6 deletions code/iphone/BackgroundMusic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,23 @@ void BackgroundTrackMgr2::QueueCallback( void * inUserData, AudioQueueRef inAQ,
OSStatus result = noErr;
BackgroundTrackMgr2 *THIS = (BackgroundTrackMgr2*)inUserData;
UInt32 nPackets = 0;
UInt32 ioNumBytes;
// loop the current buffer if the following:
// 1. file was loaded into the buffer previously
// 2. only one file in the queue
// 3. we have not been told to stop at playlist completion
if ((CurFileInfo->mFileDataInQueue) && (!THIS->mStopAtEnd)) {
nPackets = THIS->mNumPacketsToRead;
} else {
UInt32 numBytes;
while (nPackets == 0) {
// if loadAtOnce, get all packets in the file, otherwise ~.5 seconds of data
nPackets = THIS->mNumPacketsToRead;
result = AudioFileReadPacketData(CurFileInfo->mAFID, false, &numBytes, THIS->mPacketDescs, THIS->mCurrentPacket, &nPackets, inCompleteAQBuffer->mAudioData);
nPackets = THIS->mNumPacketsToRead;
ioNumBytes = kAudioFilePropertyMaximumPacketSize * nPackets;

result = AudioFileReadPacketData(CurFileInfo->mAFID, false, &ioNumBytes, THIS->mPacketDescs, THIS->mCurrentPacket, &nPackets, inCompleteAQBuffer->mAudioData);
AssertNoError("Error reading file data", end);

inCompleteAQBuffer->mAudioDataByteSize = numBytes;

inCompleteAQBuffer->mAudioDataByteSize = ioNumBytes;
if (nPackets == 0) { // no packets were read, this file has ended.
if (CurFileInfo->mLoadAtOnce) {
CurFileInfo->mFileDataInQueue = true;
Expand Down Expand Up @@ -515,7 +516,7 @@ void iphoneStartMusic() {
return;
}
char fullName[1024];
sprintf( fullName, "%s/base/music/d_%s.mp3", SysIphoneGetAppDir(), currentMusicName );
sprintf( fullName, "%s/music/d_%s.mp3", SysIphoneGetAppDir(), currentMusicName );

printf( "Starting music '%s'\n", fullName );

Expand Down
14 changes: 14 additions & 0 deletions code/iphone/DOOM.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@
43CF030A0F56D5C200E4A23D /* iphone_loop.c in Sources */ = {isa = PBXBuildFile; fileRef = 43CF03090F56D5C200E4A23D /* iphone_loop.c */; };
43E8D2E10F4FC61E003F09B2 /* iphone_main.c in Sources */ = {isa = PBXBuildFile; fileRef = 43E8D2DF0F4FC61E003F09B2 /* iphone_main.c */; };
43E8D4E00F51B48B003F09B2 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 43E8D4DF0F51B48B003F09B2 /* OpenAL.framework */; };
5581EB8528999CE200DDB5D0 /* music in Resources */ = {isa = PBXBuildFile; fileRef = 55D250DB2521286A0066E854 /* music */; };
55B06E362531F23200F82EF5 /* music in Resources */ = {isa = PBXBuildFile; fileRef = 55D250DB2521286A0066E854 /* music */; };
55D250DC2521286A0066E854 /* music in Resources */ = {isa = PBXBuildFile; fileRef = 55D250DB2521286A0066E854 /* music */; };
55D250DD2521286A0066E854 /* music in Resources */ = {isa = PBXBuildFile; fileRef = 55D250DB2521286A0066E854 /* music */; };
55D250E6252129FF0066E854 /* music in Resources */ = {isa = PBXBuildFile; fileRef = 55D250DB2521286A0066E854 /* music */; };
55D9F1D125433A57002A145C /* music in Resources */ = {isa = PBXBuildFile; fileRef = 55D250DB2521286A0066E854 /* music */; };
720EBBAE0F82E0BB003F989A /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 720EBBAD0F82E0BB003F989A /* QuartzCore.framework */; };
7229CE4A0F6C89F8004123C5 /* EAGLView.m in Sources */ = {isa = PBXBuildFile; fileRef = 7229CE460F6C89F8004123C5 /* EAGLView.m */; };
7229CE550F6C8CDE004123C5 /* gles_glue.c in Sources */ = {isa = PBXBuildFile; fileRef = 7229CE540F6C8CDE004123C5 /* gles_glue.c */; };
Expand Down Expand Up @@ -2126,6 +2132,7 @@
43CF03090F56D5C200E4A23D /* iphone_loop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iphone_loop.c; sourceTree = "<group>"; };
43E8D2DF0F4FC61E003F09B2 /* iphone_main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = iphone_main.c; sourceTree = "<group>"; };
43E8D4DF0F51B48B003F09B2 /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = /System/Library/Frameworks/OpenAL.framework; sourceTree = "<absolute>"; };
55D250DB2521286A0066E854 /* music */ = {isa = PBXFileReference; lastKnownFileType = folder; name = music; path = ../../base/music; sourceTree = "<group>"; };
720EBBAD0F82E0BB003F989A /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = /System/Library/Frameworks/QuartzCore.framework; sourceTree = "<absolute>"; };
7229CC8E0F6B3363004123C5 /* doomiphone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = doomiphone.h; path = ../doomiphone.h; sourceTree = SOURCE_ROOT; };
7229CE450F6C89F8004123C5 /* EAGLView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EAGLView.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2846,6 +2853,7 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
55D250DB2521286A0066E854 /* music */,
A12302FA205783E70075CBAD /* base.iPack */,
C8D1CFA913E1CDC600F0EAC6 /* Default-Landscape~ipad.png */,
C8D1CFA713E1CDBD00F0EAC6 /* Default-Portrait~ipad.png */,
Expand Down Expand Up @@ -3649,6 +3657,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
55B06E362531F23200F82EF5 /* music in Resources */,
43CF02FF0F56974E00E4A23D /* Default.png in Resources */,
4364BF3F0F5CB25900F29317 /* dist.plist in Resources */,
A1B9E45D21700601003E9731 /* DOOM-iOS.xcassets in Resources */,
Expand Down Expand Up @@ -3750,6 +3759,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
55D9F1D125433A57002A145C /* music in Resources */,
A10638C8216EF7C700BDE196 /* Default.png in Resources */,
A10638C9216EF7C700BDE196 /* r_drawflush.inl in Resources */,
A10638CA216EF7C700BDE196 /* SliderSkull~ipad.png in Resources */,
Expand Down Expand Up @@ -3930,6 +3940,7 @@
A1063A2C216EFCEE00BDE196 /* base.iPack in Resources */,
A1063A2D216EFCEE00BDE196 /* OpenGLView.xib in Resources */,
A1063A2E216EFCEE00BDE196 /* r_drawcolumn.inl in Resources */,
55D250DC2521286A0066E854 /* music in Resources */,
A1063A2F216EFCEE00BDE196 /* SliderSkull.png in Resources */,
A1063A30216EFCEE00BDE196 /* MissionMenuView.xib in Resources */,
A1063A31216EFCEE00BDE196 /* [email protected] in Resources */,
Expand Down Expand Up @@ -3996,6 +4007,7 @@
A1063B29216F012000BDE196 /* MenuBackground.png in Resources */,
A1063B2A216F012000BDE196 /* Nightmare.png in Resources */,
A1063B2B216F012000BDE196 /* ResumeButton.png in Resources */,
55D250DD2521286A0066E854 /* music in Resources */,
A1063C0B216F0B1D00BDE196 /* plutonia.wad in Resources */,
A1063B2C216F012000BDE196 /* SelectedBracket.png in Resources */,
A1063B2D216F012000BDE196 /* idGinzaNar-Md2.otf in Resources */,
Expand Down Expand Up @@ -4032,6 +4044,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
5581EB8528999CE200DDB5D0 /* music in Resources */,
A1870808216EB633006C013F /* Default.png in Resources */,
A1870809216EB633006C013F /* dist.plist in Resources */,
A187080A216EB633006C013F /* DOOM_57.png in Resources */,
Expand Down Expand Up @@ -4134,6 +4147,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
55D250E6252129FF0066E854 /* music in Resources */,
A1B98E65207F026900827A46 /* Default.png in Resources */,
A1B98F90207F07E300827A46 /* r_drawflush.inl in Resources */,
A1B98E33207F025600827A46 /* SliderSkull~ipad.png in Resources */,
Expand Down
10 changes: 9 additions & 1 deletion code/iphone/prboomInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,15 @@ void I_FindFile(const char* wfname, const char* ext, char * returnFileName )
// Found the file.
return;
}


sprintf( returnFileName, "%s/music/d_%s", SysIphoneGetAppDir(), wfname );
if (!access(returnFileName,F_OK)) {
lprintf(LO_INFO, " found %s\n", returnFileName);

// Found the file.
return;
}

// did not find the file.
returnFileName[0] = '\0';
lprintf(LO_INFO, " NOT found %s\n", wfname );
Expand Down
16 changes: 8 additions & 8 deletions code/prboom/m_misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -736,35 +736,35 @@ def_bool,ss_none}, // enables translucency
def_str,ss_none,NULL,NULL},
{"mus_e2m4", {0,&S_music_files[mus_e2m4]}, {0,"e2m4.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e2m5", {0,&S_music_files[mus_e2m5]}, {0,"e1m7.mp3"},UL,UL,
{"mus_e2m5", {0,&S_music_files[mus_e2m5]}, {0,"e2m5.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e2m6", {0,&S_music_files[mus_e2m6]}, {0,"e2m6.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e2m7", {0,&S_music_files[mus_e2m7]}, {0,"e2m7.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e2m8", {0,&S_music_files[mus_e2m8]}, {0,"e2m8.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e2m9", {0,&S_music_files[mus_e2m9]}, {0,"e3m1.mp3"},UL,UL,
{"mus_e2m9", {0,&S_music_files[mus_e2m9]}, {0,"e2m9.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m1", {0,&S_music_files[mus_e3m1]}, {0,"e3m1.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m2", {0,&S_music_files[mus_e3m2]}, {0,"e3m2.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m3", {0,&S_music_files[mus_e3m3]}, {0,"e3m3.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m4", {0,&S_music_files[mus_e3m4]}, {0,"e1m8.mp3"},UL,UL,
{"mus_e3m4", {0,&S_music_files[mus_e3m4]}, {0,"e3m4.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m5", {0,&S_music_files[mus_e3m5]}, {0,"e1m7.mp3"},UL,UL,
{"mus_e3m5", {0,&S_music_files[mus_e3m5]}, {0,"e3m5.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m6", {0,&S_music_files[mus_e3m6]}, {0,"e1m6.mp3"},UL,UL,
{"mus_e3m6", {0,&S_music_files[mus_e3m6]}, {0,"e3m6.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m7", {0,&S_music_files[mus_e3m7]}, {0,"e2m7.mp3"},UL,UL,
{"mus_e3m7", {0,&S_music_files[mus_e3m7]}, {0,"e3m7.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m8", {0,&S_music_files[mus_e3m8]}, {0,"e3m8.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_e3m9", {0,&S_music_files[mus_e3m9]}, {0,"e1m9.mp3"},UL,UL,
{"mus_e3m9", {0,&S_music_files[mus_e3m9]}, {0,"e3m9.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_inter", {0,&S_music_files[mus_inter]}, {0,"e2m3.mp3"},UL,UL,
{"mus_inter", {0,&S_music_files[mus_inter]}, {0,"inter.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
{"mus_intro", {0,&S_music_files[mus_intro]}, {0,"intro.mp3"},UL,UL,
def_str,ss_none,NULL,NULL},
Expand Down
8 changes: 7 additions & 1 deletion code/prboom/s_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,13 @@ void S_ChangeMusic(int musicnum, int looping)
I_FindFile(S_music_files[musicnum], "", music_filename);
if ( music_filename[0] != '\0' )
{
music_file_failed = I_RegisterMusic(music_filename, music);
#ifdef IPHONE
extern void iphonePlayMusic( const char *name );
iphonePlayMusic( music->name );
music_file_failed = 0;
#else
music_file_failed = I_RegisterMusic(music_filename, music);
#endif
//free(music_filename);
}

Expand Down