CDImage: Support sub-images, use subimages for m3u

This commit is contained in:
Connor McLaughlin
2021-03-27 02:19:23 +10:00
parent 573aa6d9cc
commit 50d712c3fe
23 changed files with 443 additions and 312 deletions

View File

@ -135,6 +135,8 @@ public:
BitField<u8, bool, 5, 1> digital_copy_permitted;
BitField<u8, bool, 6, 1> data;
BitField<u8, bool, 7, 1> four_channel_audio;
Control& operator=(const Control& c) { bits = c.bits; return *this; }
};
struct
@ -202,6 +204,7 @@ public:
static std::unique_ptr<CDImage> OpenEcmImage(const char* filename, Common::Error* error);
static std::unique_ptr<CDImage> OpenMdsImage(const char* filename, Common::Error* error);
static std::unique_ptr<CDImage> OpenPBPImage(const char* filename, Common::Error* error);
static std::unique_ptr<CDImage> OpenM3uImage(const char* filename, Common::Error* error);
static std::unique_ptr<CDImage>
CreateMemoryImage(CDImage* image, ProgressCallback* progress = ProgressCallback::NullProgressCallback);
@ -247,7 +250,10 @@ public:
bool ReadRawSector(void* buffer);
// Reads sub-channel Q for the current LBA.
virtual bool ReadSubChannelQ(SubChannelQ* subq);
bool ReadSubChannelQ(SubChannelQ* subq);
// Reads sub-channel Q for the specified index+LBA.
virtual bool ReadSubChannelQ(SubChannelQ* subq, const Index& index, LBA lba_in_index);
// Returns true if the image has replacement subchannel data.
virtual bool HasNonStandardSubchannel() const;
@ -255,7 +261,27 @@ public:
// Reads a single sector from an index.
virtual bool ReadSectorFromIndex(void* buffer, const Index& index, LBA lba_in_index) = 0;
// Retrieve image metadata.
virtual std::string GetMetadata(const std::string_view& type) const;
// Returns true if this image type has sub-images (e.g. m3u).
virtual bool HasSubImages() const;
// Returns the number of sub-images in this image, if the format supports multiple.
virtual u32 GetSubImageCount() const;
// Returns the current sub-image index, if any.
virtual u32 GetCurrentSubImage() const;
// Changes the current sub-image. If this fails, the image state is unchanged.
virtual bool SwitchSubImage(u32 index, Common::Error* error);
// Retrieve sub-image metadata.
virtual std::string GetSubImageMetadata(u32 index, const std::string_view& type) const;
protected:
void CopyTOC(const CDImage* image);
const Index* GetIndexForDiscPosition(LBA pos);
const Index* GetIndexForTrackPosition(u32 track_number, LBA track_pos);
@ -263,7 +289,7 @@ protected:
bool GenerateSubChannelQ(SubChannelQ* subq, LBA lba);
/// Generates sub-channel Q from the given index and index-offset.
void GenerateSubChannelQ(SubChannelQ* subq, const Index* index, u32 index_offset);
void GenerateSubChannelQ(SubChannelQ* subq, const Index& index, u32 index_offset);
/// Synthesis of lead-out data.
void AddLeadOutIndex();
@ -274,6 +300,7 @@ protected:
std::vector<Track> m_tracks;
std::vector<Index> m_indices;
private:
// Position on disc.
LBA m_position_on_disc = 0;