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
Description
One of the goals of these bindings is to make it not only possible to interface
with the libcdio library, but to do so as comfortably and safely as possible.
In that, the Foreign.Libcdio interface is a bit lacking, due to its mutable
state and requirement of threading IO
through computations. The modules in
this namespace provide an alternative which builds on that base, with a more
native style. As a general rule, a project should only import modules from
the Sound
or the Foreign
namespaces, not both, as while the types can often
be interchanged, several function names have been reused and so may collide.
Synopsis
- data Cdio a
- data CdioError = CdioError CdioErrorType Text
- data CdioErrorType
- data SessionArg
- = Source
- | Cue
- | ScsiTuple
- | MmcSupported
- data AccessMode
- data Version
- makeVersion :: [Int] -> Version
- open :: Maybe FilePath -> Bool -> Cdio a -> IO (Either CdioError a)
- openMode :: AccessMode -> Maybe FilePath -> Bool -> Cdio a -> IO (Either CdioError a)
- runCdio :: Cdio -> Cdio a -> IO (Either CdioError a)
- getArg :: SessionArg -> Cdio (Maybe Text)
- getAccessMode :: Cdio (Maybe AccessMode)
- cdioVersionString :: String
- libcdioVersionNum :: Version
- apiVersion :: Word
Types
Session
A computation within the environment of the data (music or file) stored on a CD. The options for affecting that environment from within are limited by design, as this library is intended for reading discs rather than authoring them.
Instances
Monad Cdio # | |
Functor Cdio # | |
MonadFail Cdio # | Wraps the text in a |
Defined in Sound.Libcdio.Types.Cdio | |
Applicative Cdio # | |
Alternative Cdio # | |
LibcdioLogger Cdio # | |
MonadError CdioError Cdio # | |
Defined in Sound.Libcdio.Types.Cdio |
Associates a well-typed error with human-readable context information.
Constructors
CdioError CdioErrorType Text |
data CdioErrorType #
Potential situations which may cause a computation to fail.
Constructors
DriverError | A requested operation failed for some unknown reason, or the
operating system doesn't support the |
BadParameter | Some value passed to a requested operation was rejected as nonsensical or otherwise breaking the value-level invariants. |
NotPermitted | The ability to perform a requested operation has been restricted (e.g., the user doesn't have permission to access the disc drive). |
SessionClosed | The underlying library closed the |
Unsupported | A requested operation isn't available with driver used by the
|
CdioEmpty |
|
FreeformCdioError Text | Escape hatch from structured typing to allow user-specified (and user-triggered) errors. |
Instances
Eq CdioErrorType # | |
Defined in Sound.Libcdio.Types.Cdio Methods (==) :: CdioErrorType -> CdioErrorType -> Bool # (/=) :: CdioErrorType -> CdioErrorType -> Bool # | |
Read CdioErrorType # | |
Defined in Sound.Libcdio.Types.Cdio Methods readsPrec :: Int -> ReadS CdioErrorType # readList :: ReadS [CdioErrorType] # | |
Show CdioErrorType # | |
Defined in Sound.Libcdio.Types.Cdio Methods showsPrec :: Int -> CdioErrorType -> ShowS # show :: CdioErrorType -> String # showList :: [CdioErrorType] -> ShowS # |
data SessionArg #
Metadata about the session in the form of (often freeform) text, providing
a type-safe index to getArg
. Note that not every driver type supports
every item.
The key "access-mode"
is handled separately by getAccessMode
, to better
reflect its restricted outputs.
Constructors
Source | |
Cue | |
ScsiTuple | |
MmcSupported |
Instances
data AccessMode #
Which instruction set should be used to communicate with the driver, providing a type-safe input for session initialization. Note that not every driver type supports every item.
Constructors
Image | |
Ioctl | The |
Ioctl_ | The |
Aspi | |
Atapi | |
Cam | |
Scsi | |
ReadCd | |
Read10 | |
MmcReadWrite | |
MmcReadWriteExclusive |
Instances
Version
A Version
represents the version of a software entity.
An instance of Eq
is provided, which implements exact equality
modulo reordering of the tags in the versionTags
field.
An instance of Ord
is also provided, which gives lexicographic
ordering on the versionBranch
fields (i.e. 2.1 > 2.0, 1.2.3 > 1.2.2,
etc.). This is expected to be sufficient for many uses, but note that
you may need to use a more specific ordering for your versioning
scheme. For example, some versioning schemes may include pre-releases
which have tags "pre1"
, "pre2"
, and so on, and these would need to
be taken into account when determining ordering. In some cases, date
ordering may be more appropriate, so the application would have to
look for date
tags in the versionTags
field and compare those.
The bottom line is, don't always assume that compare
and other Ord
operations are the right thing for every Version
.
Similarly, concrete representations of versions may differ. One
possible concrete representation is provided (see showVersion
and
parseVersion
), but depending on the application a different concrete
representation may be more appropriate.
Instances
IsList Version | Since: base-4.8.0.0 |
Eq Version | Since: base-2.1 |
Ord Version | Since: base-2.1 |
Read Version | Since: base-2.1 |
Show Version | Since: base-2.1 |
Generic Version | Since: base-4.9.0.0 |
type Rep Version | |
Defined in Data.Version type Rep Version = D1 ('MetaData "Version" "Data.Version" "base" 'False) (C1 ('MetaCons "Version" 'PrefixI 'True) (S1 ('MetaSel ('Just "versionBranch") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Int]) :*: S1 ('MetaSel ('Just "versionTags") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [String]))) | |
type Item Version | |
makeVersion :: [Int] -> Version #
Construct tag-less Version
Since: base-4.8.0.0
Evaluation
Arguments
:: Maybe FilePath | |
-> Bool | Whether the disc should be ejected after the computation. |
-> Cdio a | |
-> IO (Either CdioError a) |
Open a session to read data from the disc drive/image at the given
location. If passed Nothing
instead, uses the path considered "default";
on operating systems with a concept of numbered devices (e.g., Window's D:
drive, FreeBSD's /dev/cd0
) will usually return the first such device
found to be suitable.
Arguments
:: AccessMode | |
-> Maybe FilePath | |
-> Bool | Whether the disc should be ejected after the computation. |
-> Cdio a | |
-> IO (Either CdioError a) |
Open a session to read data from the disc drive/image at the given
location, using a specific instruction set. If passed Nothing
instead,
uses the path considered "default"; on operating systems with a concept of
numbered devices (e.g., Window's D:
drive, FreeBSD's /dev/cd0
) will
usually return the first such device found to be suitable.
runCdio :: Cdio -> Cdio a -> IO (Either CdioError a) #
Use a C-style Foreign.Libcdio.
object as the base to run
a Haskell-style Cdio
Sound.Libcdio.
computation.Cdio
Note that some invariants of the monadic interface may not work as expected when used with the mutable objects.
getArg :: SessionArg -> Cdio (Maybe Text) #
Retrieve the session value associated with the given key. The particular
case of "access-mode"
is instead handled by getAccessMode
.
getAccessMode :: Cdio (Maybe AccessMode) #
Check what instruction set is in use for reading the disc. Other session
values are handled by getArg
.
Library data
The value of the preprocessor macro CDIO_VERSION
, listing both the
SemVar-style version of libcdio and the full architecture of the system
which compiled it (e.g. 2.0.0 x86_64-pc-linux-gnu
).
libcdioVersionNum :: Version #
The value of the preprocessor macro LIBCDIO_VERSION_NUM
, containing a
numeric representation of the version suitable for arithmetic testing.
apiVersion :: Word #
The value of the preprocessor macro CDIO_API_VERSION
, containing a
single, monotonically increasing constant representing changes to the public
interface. However, as it's somewhat unclear what changes warrant bumping
this number, it is typically better to use libcdioVersionNum
instead.