mirror of
https://github.com/ZDoom/qzdoom.git
synced 2025-02-12 07:05:21 +00:00
- did a bit of reordering on I_RegisterSong.
The way CDDA was treated as an afterthought made handling of stream songs somewhat problematic, because the state could be unclear. CDDA is an easily identifiable format so it should be tested first.
This commit is contained in:
parent
6d7b6fb9fd
commit
ab016be6b9
1 changed files with 56 additions and 48 deletions
|
@ -372,8 +372,28 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
||||||
info = streamer;
|
info = streamer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for CDDA "format"
|
||||||
|
else if (id[0] == (('R') | (('I') << 8) | (('F') << 16) | (('F') << 24)))
|
||||||
|
{
|
||||||
|
uint32_t subid;
|
||||||
|
|
||||||
|
reader->seek(8, SEEK_CUR);
|
||||||
|
if (reader->read(&subid, 4) == 4)
|
||||||
|
{
|
||||||
|
reader->seek(-12, SEEK_CUR);
|
||||||
|
|
||||||
|
if (subid == (('C') | (('D') << 8) | (('D') << 16) | (('A') << 24)))
|
||||||
|
{
|
||||||
|
// This is a CDDA file
|
||||||
|
info = new CDDAFile(reader);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Check for various raw OPL formats
|
// Check for various raw OPL formats
|
||||||
else if (
|
else
|
||||||
|
{
|
||||||
|
if (
|
||||||
(id[0] == MAKE_ID('R', 'A', 'W', 'A') && id[1] == MAKE_ID('D', 'A', 'T', 'A')) || // Rdos Raw OPL
|
(id[0] == MAKE_ID('R', 'A', 'W', 'A') && id[1] == MAKE_ID('D', 'A', 'T', 'A')) || // Rdos Raw OPL
|
||||||
(id[0] == MAKE_ID('D', 'B', 'R', 'A') && id[1] == MAKE_ID('W', 'O', 'P', 'L')) || // DosBox Raw OPL
|
(id[0] == MAKE_ID('D', 'B', 'R', 'A') && id[1] == MAKE_ID('W', 'O', 'P', 'L')) || // DosBox Raw OPL
|
||||||
(id[0] == MAKE_ID('A', 'D', 'L', 'I') && *((uint8_t*)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
(id[0] == MAKE_ID('A', 'D', 'L', 'I') && *((uint8_t*)id + 4) == 'B')) // Martin Fernandez's modified IMF
|
||||||
|
@ -397,7 +417,7 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
||||||
Dumb_SetupConfig(&dumbConfig);
|
Dumb_SetupConfig(&dumbConfig);
|
||||||
streamsource = MOD_OpenSong(reader, &dumbConfig, (int)GSnd->GetOutputRate());
|
streamsource = MOD_OpenSong(reader, &dumbConfig, (int)GSnd->GetOutputRate());
|
||||||
}
|
}
|
||||||
if (info == nullptr && streamsource == nullptr)
|
if (streamsource == nullptr)
|
||||||
{
|
{
|
||||||
streamsource = SndFile_OpenSong(reader); // this only takes over the reader if it succeeds. We need to look out for this.
|
streamsource = SndFile_OpenSong(reader); // this only takes over the reader if it succeeds. We need to look out for this.
|
||||||
if (streamsource != nullptr) reader = nullptr;
|
if (streamsource != nullptr) reader = nullptr;
|
||||||
|
@ -407,25 +427,13 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
||||||
{
|
{
|
||||||
info = OpenStreamSong(streamsource);
|
info = OpenStreamSong(streamsource);
|
||||||
}
|
}
|
||||||
if (info == nullptr && reader != nullptr)
|
}
|
||||||
{
|
|
||||||
// Check for CDDA "format"
|
|
||||||
if (id[0] == (('R') | (('I') << 8) | (('F') << 16) | (('F') << 24)))
|
|
||||||
{
|
|
||||||
uint32_t subid;
|
|
||||||
|
|
||||||
reader->seek(8, SEEK_CUR);
|
if (!info)
|
||||||
if (reader->read(&subid, 4) == 4)
|
|
||||||
{
|
{
|
||||||
reader->seek(-12, SEEK_CUR);
|
// File could not be identified as music.
|
||||||
|
if (reader) reader->close();
|
||||||
if (subid == (('C') | (('D') << 8) | (('D') << 16) | (('A') << 24)))
|
return nullptr;
|
||||||
{
|
|
||||||
// This is a CDDA file
|
|
||||||
info = new CDDAFile(reader);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info && !info->IsValid())
|
if (info && !info->IsValid())
|
||||||
|
@ -440,7 +448,7 @@ MusInfo *I_RegisterSong (MusicIO::FileInterface *reader, MidiDeviceSetting *devi
|
||||||
if (reader) reader->close();
|
if (reader) reader->close();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
if (reader) reader->close();
|
||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue