|  | @@ -1181,7 +1181,7 @@ void cdromPerformEject(image_config_t &img)
 | 
											
												
													
														|  |          debuglog("------ CDROM open tray on ID ", (int)target);
 |  |          debuglog("------ CDROM open tray on ID ", (int)target);
 | 
											
												
													
														|  |          img.ejected = true;
 |  |          img.ejected = true;
 | 
											
												
													
														|  |          img.cdrom_events = 3; // Media removal
 |  |          img.cdrom_events = 3; // Media removal
 | 
											
												
													
														|  | -        cdromSwitchNextImage(img, nullptr); // Switch media for next time
 |  | 
 | 
											
												
													
														|  | 
 |  | +        switchNextImage(img); // Switch media for next time
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      else
 |  |      else
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
										
											
												
													
														|  | @@ -1199,7 +1199,7 @@ void cdromReinsertFirstImage(image_config_t &img)
 | 
											
												
													
														|  |          debuglog("---- Restarting from first CD-ROM image for ID ", (int)target);
 |  |          debuglog("---- Restarting from first CD-ROM image for ID ", (int)target);
 | 
											
												
													
														|  |          img.image_index = -1;
 |  |          img.image_index = -1;
 | 
											
												
													
														|  |          img.current_image[0] = '\0';
 |  |          img.current_image[0] = '\0';
 | 
											
												
													
														|  | -        cdromSwitchNextImage(img, nullptr);
 |  | 
 | 
											
												
													
														|  | 
 |  | +        switchNextImage(img);
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |      else if (img.ejected)
 |  |      else if (img.ejected)
 | 
											
												
													
														|  |      {
 |  |      {
 | 
											
										
											
												
													
														|  | @@ -1208,55 +1208,6 @@ void cdromReinsertFirstImage(image_config_t &img)
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  }
 |  |  }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | -// Check if we have multiple CD-ROM images to cycle when drive is ejected.
 |  | 
 | 
											
												
													
														|  | -bool cdromSwitchNextImage(image_config_t &img, const char* next_filename)
 |  | 
 | 
											
												
													
														|  | -{
 |  | 
 | 
											
												
													
														|  | -    // Check if we have a next image to load, so that drive is closed next time the host asks.
 |  | 
 | 
											
												
													
														|  | -    char filename[MAX_FILE_PATH];
 |  | 
 | 
											
												
													
														|  | -    int target_idx = img.scsiId & S2S_CFG_TARGET_ID_BITS;
 |  | 
 | 
											
												
													
														|  | -    if (next_filename == nullptr)
 |  | 
 | 
											
												
													
														|  | -    {
 |  | 
 | 
											
												
													
														|  | -        scsiDiskGetNextImageName(img, filename, sizeof(filename));
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -    else
 |  | 
 | 
											
												
													
														|  | -    {
 |  | 
 | 
											
												
													
														|  | -        strncpy(filename, next_filename, MAX_FILE_PATH);
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -    if (filename[0] != '\0')
 |  | 
 | 
											
												
													
														|  | -    {
 |  | 
 | 
											
												
													
														|  | -#ifdef ENABLE_AUDIO_OUTPUT
 |  | 
 | 
											
												
													
														|  | -    // if in progress for this device, terminate audio playback immediately (Annex C)
 |  | 
 | 
											
												
													
														|  | -    audio_stop(target_idx);
 |  | 
 | 
											
												
													
														|  | -    // Reset position tracking for the new image
 |  | 
 | 
											
												
													
														|  | -    audio_get_status_code(target_idx); // trash audio status code
 |  | 
 | 
											
												
													
														|  | -#endif
 |  | 
 | 
											
												
													
														|  | -        log("Switching to next CD-ROM image for ", target_idx, ": ", filename);
 |  | 
 | 
											
												
													
														|  | -        img.file.close();
 |  | 
 | 
											
												
													
														|  | -        bool status = scsiDiskOpenHDDImage(target_idx, filename, target_idx, 0,
 |  | 
 | 
											
												
													
														|  | -                                           getBlockSize(filename, target_idx, 2048));
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -        if (status)
 |  | 
 | 
											
												
													
														|  | -        {
 |  | 
 | 
											
												
													
														|  | -            if (next_filename != nullptr)
 |  | 
 | 
											
												
													
														|  | -            {
 |  | 
 | 
											
												
													
														|  | -                // present the drive as ejected until the host queries it again,
 |  | 
 | 
											
												
													
														|  | -                // to make sure host properly detects the media change
 |  | 
 | 
											
												
													
														|  | -                img.ejected = true;
 |  | 
 | 
											
												
													
														|  | -                img.reinsert_after_eject = true;
 |  | 
 | 
											
												
													
														|  | -                img.cdrom_events = 2; // New Media
 |  | 
 | 
											
												
													
														|  | -            }
 |  | 
 | 
											
												
													
														|  | -            return true;
 |  | 
 | 
											
												
													
														|  | -        }
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -    else
 |  | 
 | 
											
												
													
														|  | -    {
 |  | 
 | 
											
												
													
														|  | -        log("Could not switch to CD-ROM image as provide filename was empty.");
 |  | 
 | 
											
												
													
														|  | -    }
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  | -    return false;
 |  | 
 | 
											
												
													
														|  | -}
 |  | 
 | 
											
												
													
														|  | -
 |  | 
 | 
											
												
													
														|  |  static void doGetEventStatusNotification(bool immed)
 |  |  static void doGetEventStatusNotification(bool immed)
 | 
											
												
													
														|  |  {
 |  |  {
 | 
											
												
													
														|  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 |  |      image_config_t &img = *(image_config_t*)scsiDev.target->cfg;
 |