Reserve the trackFile shared_ptr prior to its test
This commit is contained in:
parent
5bbf876f0c
commit
908ddafb5f
1 changed files with 5 additions and 4 deletions
|
@ -488,13 +488,16 @@ bool CDROM_Interface_Image::GetMediaTrayStatus(bool& mediaPresent, bool& mediaCh
|
|||
|
||||
bool CDROM_Interface_Image::PlayAudioSector(uint64_t start, uint64_t len)
|
||||
{
|
||||
// Find the track that holds the requested sector
|
||||
track_const_iter track(GetTrack(start));
|
||||
std::shared_ptr<TrackFile> trackFile;
|
||||
if (track != tracks.end() && track->file)
|
||||
trackFile = track->file;
|
||||
|
||||
// Guard: sanity check the request beyond what GetTrack already checks
|
||||
if (len == 0
|
||||
|| track == tracks.end()
|
||||
|| !trackFile
|
||||
|| track->attr == 0x40
|
||||
|| !track->file
|
||||
|| !player.channel
|
||||
|| !player.mutex) {
|
||||
StopAudio();
|
||||
|
@ -521,8 +524,6 @@ bool CDROM_Interface_Image::PlayAudioSector(uint64_t start, uint64_t len)
|
|||
+ clamp(relative_start, 0, static_cast<int>(track->length - 1))
|
||||
* track->sectorSize);
|
||||
|
||||
std::shared_ptr<TrackFile> trackFile(track->file);
|
||||
|
||||
// Guard: Bail if our track could not be seeked
|
||||
if (!trackFile->seek(offset)) {
|
||||
LOG_MSG("CDROM: Track %d failed to seek to byte %u, so cancelling playback",
|
||||
|
|
Loading…
Add table
Reference in a new issue