Copyright | (c) 2019-2021 Sam May |
---|---|
License | GPL-3.0-or-later |
Maintainer | ag@eitilt.life |
Stability | stable |
Portability | non-portable (requires libcdio) |
Safe Haskell | None |
Language | Haskell2010 |
Sound.Libcdio.Device
Description
Any software dealing with CDs has to deal with the fact that they are, ultimately, a physical medium and thus reading from them requires interfacing with system hardware. This module provides the means to do just that. Note that, unlike the C and Foreign.Libcdio interfaces, however, this doesn't provide any means to open a read session; that functionality is instead exported directly from Sound.Libcdio.
Synopsis
- data HardwareInfo = HardwareInfo {}
- emptyHardwareInfo :: HardwareInfo
- data DriverId
- data DriverReturnCode
- type DriveCaps = (DriveReadCaps, DriveWriteCaps, DriveMiscCaps)
- data DriveCapabilityRead
- type DriveReadCaps = BitArray DriveCapabilityRead
- data DriveCapabilityWrite
- type DriveWriteCaps = BitArray DriveCapabilityWrite
- capsWriteCd :: DriveWriteCaps
- capsWriteDvd :: DriveWriteCaps
- capsWrite :: DriveWriteCaps
- data DriveCapabilityMisc
- type DriveMiscCaps = BitArray DriveCapabilityMisc
- driver :: Cdio DriverId
- drivers :: [DriverId]
- osDriver :: DriverId
- isImageDriver :: DriverId -> Bool
- isDevice :: FilePath -> IO Bool
- setBlocksize :: Int -> Cdio DriverReturnCode
- setSpeed :: Int -> Cdio DriverReturnCode
- isMediaChanged :: Cdio (Either DriverReturnCode Bool)
- devices :: DriverId -> IO [FilePath]
- defaultDevice :: IO (Maybe FilePath)
- defaultDeviceDriver :: DriverId -> IO (Maybe FilePath, DriverId)
- capabilities :: Cdio DriveCaps
- deviceCapabilities :: FilePath -> IO DriveCaps
- isCue :: FilePath -> IO Bool
- isToc :: FilePath -> IO Bool
- isNrg :: FilePath -> IO Bool
- hardware :: Cdio HardwareInfo
- haveAtapi :: Cdio (Maybe Bool)
- ejectDevice :: Maybe FilePath -> IO DriverReturnCode
- closeDeviceTray :: Maybe FilePath -> IO DriverReturnCode
- closeDeviceTray' :: Maybe FilePath -> DriverId -> IO DriverReturnCode
Types
data HardwareInfo #
Information defining the make and model of a (typically physical) device.
Constructors
HardwareInfo | |
Instances
Eq HardwareInfo # | |
Defined in Foreign.Libcdio.Device | |
Read HardwareInfo # | |
Defined in Foreign.Libcdio.Device Methods readsPrec :: Int -> ReadS HardwareInfo # readList :: ReadS [HardwareInfo] # | |
Show HardwareInfo # | |
Defined in Foreign.Libcdio.Device Methods showsPrec :: Int -> HardwareInfo -> ShowS # show :: HardwareInfo -> String # showList :: [HardwareInfo] -> ShowS # | |
Storable HardwareInfo # | |
Defined in Foreign.Libcdio.Device Methods sizeOf :: HardwareInfo -> Int # alignment :: HardwareInfo -> Int # peekElemOff :: Ptr HardwareInfo -> Int -> IO HardwareInfo # pokeElemOff :: Ptr HardwareInfo -> Int -> HardwareInfo -> IO () # peekByteOff :: Ptr b -> Int -> IO HardwareInfo # pokeByteOff :: Ptr b -> Int -> HardwareInfo -> IO () # peek :: Ptr HardwareInfo -> IO HardwareInfo # poke :: Ptr HardwareInfo -> HardwareInfo -> IO () # |
emptyHardwareInfo :: HardwareInfo #
A HardwareInfo
object with values suitable as defaults.
Devices or file types supported by the library.
Constructors
DriverUnknown | |
DriverAix | |
DriverFreeBsd | |
DriverNetBsd | |
DriverLinux | |
DriverSolaris | |
DriverOsX | |
DriverWin32 | |
DriverCdrDao | |
DriverBinCue | |
DriverNrg | |
DriverDevice | |
DriverBsdi | |
DriverOs2 |
Instances
Bounded DriverId # | |
Enum DriverId # | |
Defined in Foreign.Libcdio.Types.Enums | |
Eq DriverId # | |
Ord DriverId # | |
Defined in Foreign.Libcdio.Types.Enums | |
Read DriverId # | |
Show DriverId # | |
data DriverReturnCode #
Descriptions of various error states which may be returned by driver functions.
Constructors
MmcSenseData | |
NoDriver | |
BadPointer | |
BadParameter | |
NotPermitted | |
Uninitialized | |
Unsupported | |
DriverError | |
Success |
Instances
Capabilities
type DriveCaps = (DriveReadCaps, DriveWriteCaps, DriveMiscCaps) #
The three types are usually passed around together, so we can simplify the type signatures using them.
data DriveCapabilityRead #
Constructors
Instances
type DriveReadCaps = BitArray DriveCapabilityRead #
The collection of features for reading discs a device provides.
data DriveCapabilityWrite #
Constructors
WriteCdRecordable | |
WriteCdReWritable | |
WriteDvdRecordable | |
WriteDvdPlusRecordable | |
WriteDvdRam | |
WriteDvdReWritable | |
WriteDvdPlusReWritable | |
WriteMtRainier | |
WriteBurnProof |
Instances
type DriveWriteCaps = BitArray DriveCapabilityWrite #
The collection of features for writing discs a device provides.
capsWriteCd :: DriveWriteCaps #
Capabilites indicating a device has some sort of CD-writing ability.
capsWriteDvd :: DriveWriteCaps #
Capabilites indicating a device has some sort of DVD-writing ability.
Capabilites indicating a device has some sort of disc-writing ability.
data DriveCapabilityMisc #
Miscellaneous properties a device can have, typically describing hardware
features, which are collected in DriveMiscCaps
.
Constructors
MiscCloseTray | |
MiscEject | |
MiscLock | |
MiscSelectSpeed | |
MiscSelectDisc | |
MiscMultiSession | |
MiscMediaChanged | |
MiscReset | |
MiscFile |
Instances
type DriveMiscCaps = BitArray DriveCapabilityMisc #
The collection of hardware features a device was built with.
Drivers
The particular driver for the current operating system, or DriverUnknown
if no device driver exists.
isImageDriver :: DriverId -> Bool #
Whether a particular driver deals with image files saved to disc, or a CD drive itself.
Session
setBlocksize :: Int -> Cdio DriverReturnCode #
Specify how much data should be read from a disc at once. Note that this only affects the transport; any reading functions operate on independant byte counts or other sizes derived from such.
setSpeed :: Int -> Cdio DriverReturnCode #
Specify the speed at which the disc is read. Lower values result in slower IO, but better accuracy.
Devices
devices :: DriverId -> IO [FilePath] #
List (static) available devices on the system which can be accessed with a
particular driver; some file devices (e.g. with DriverBinCue
) might be
returned, but an exhaustive list should not be expected in that case.
If passed DriverDevice
, the returned value will list any type of hardware
device, but no image files. Likewise, if passed DriverUnknown
, all
hardware devices will be returned along with any already-known images.
defaultDevice :: IO (Maybe FilePath) #
Find the default disc device for the system, if one exists.
The C library allows getting the default device from a Cdio
object, but
since that seems to only be initialized from either the default device
itself or with an explicit path, doing so seems rather redundant.
Arguments
:: DriverId | |
-> IO (Maybe FilePath, DriverId) | The name of the device, along with the associated driver if
passed |
Find the default disc device for a given driver, if one exists.
capabilities :: Cdio DriveCaps #
Which features are provided by the current device. See
deviceCapabilities
when a session has not yet been opened.
deviceCapabilities :: FilePath -> IO DriveCaps #
Which features are provided by a particular device. See capabilities
for accessing these within a Cdio
session.
Images
Hardware
hardware :: Cdio HardwareInfo #
Get a description of the device in use.
haveAtapi :: Cdio (Maybe Bool) #
Whether ATAPI commands are understood by the current device.
Returns Nothing
if the capability can't be determined.
ejectDevice :: Maybe FilePath -> IO DriverReturnCode #
Open a particular device's tray or otherwise free any disc it holds for removal, replacement, or insertion.
closeDeviceTray :: Maybe FilePath -> IO DriverReturnCode #
If a device supports discs on an extending, motorized tray (i.e. a standard CD drive), close it.
closeDeviceTray' :: Maybe FilePath -> DriverId -> IO DriverReturnCode #
As closeDeviceTray'
, but specify the driver to use in case of ambiguity.