| Copyright | Will Thompson and Iñaki García Etxebarria |
|---|---|
| License | LGPL-2.1 |
| Maintainer | Iñaki García Etxebarria |
| Safe Haskell | Safe-Inferred |
| Language | Haskell2010 |
GI.GstAudio.Structs.AudioBuffer
Description
A structure containing the result of an audio buffer map operation,
which is executed with audioBufferMap. For non-interleaved (planar)
buffers, the beginning of each channel in the buffer has its own pointer in
the planes array. For interleaved buffers, the planes array only contains
one item, which is the pointer to the beginning of the buffer, and nPlanes
equals 1.
The different channels in planes are always in the GStreamer channel order.
Since: 1.16
Synopsis
- newtype AudioBuffer = AudioBuffer (ManagedPtr AudioBuffer)
- newZeroAudioBuffer :: MonadIO m => m AudioBuffer
- audioBufferClip :: (HasCallStack, MonadIO m) => Buffer -> Segment -> Int32 -> Int32 -> m (Maybe Buffer)
- audioBufferMap :: (HasCallStack, MonadIO m) => AudioInfo -> Buffer -> [MapFlags] -> m (Bool, AudioBuffer)
- audioBufferReorderChannels :: (HasCallStack, MonadIO m) => Buffer -> AudioFormat -> [AudioChannelPosition] -> [AudioChannelPosition] -> m Bool
- audioBufferTruncate :: (HasCallStack, MonadIO m) => Buffer -> Int32 -> CSize -> CSize -> m Buffer
- audioBufferUnmap :: (HasCallStack, MonadIO m) => AudioBuffer -> m ()
- clearAudioBufferBuffer :: MonadIO m => AudioBuffer -> m ()
- getAudioBufferBuffer :: MonadIO m => AudioBuffer -> m (Maybe Buffer)
- setAudioBufferBuffer :: MonadIO m => AudioBuffer -> Ptr Buffer -> m ()
- getAudioBufferInfo :: MonadIO m => AudioBuffer -> m AudioInfo
- getAudioBufferNPlanes :: MonadIO m => AudioBuffer -> m Int32
- setAudioBufferNPlanes :: MonadIO m => AudioBuffer -> Int32 -> m ()
- getAudioBufferNSamples :: MonadIO m => AudioBuffer -> m CSize
- setAudioBufferNSamples :: MonadIO m => AudioBuffer -> CSize -> m ()
- clearAudioBufferPlanes :: MonadIO m => AudioBuffer -> m ()
- getAudioBufferPlanes :: MonadIO m => AudioBuffer -> m (Ptr ())
- setAudioBufferPlanes :: MonadIO m => AudioBuffer -> Ptr () -> m ()
Exported types
newtype AudioBuffer Source #
Memory-managed wrapper type.
Constructors
| AudioBuffer (ManagedPtr AudioBuffer) |
Instances
| Eq AudioBuffer Source # | |
Defined in GI.GstAudio.Structs.AudioBuffer | |
| BoxedPtr AudioBuffer Source # | |
Defined in GI.GstAudio.Structs.AudioBuffer | |
| CallocPtr AudioBuffer Source # | |
Defined in GI.GstAudio.Structs.AudioBuffer Methods boxedPtrCalloc :: IO (Ptr AudioBuffer) | |
| ManagedPtrNewtype AudioBuffer Source # | |
Defined in GI.GstAudio.Structs.AudioBuffer Methods toManagedPtr :: AudioBuffer -> ManagedPtr AudioBuffer | |
| tag ~ 'AttrSet => Constructible AudioBuffer tag Source # | |
Defined in GI.GstAudio.Structs.AudioBuffer Methods new :: MonadIO m => (ManagedPtr AudioBuffer -> AudioBuffer) -> [AttrOp AudioBuffer tag] -> m AudioBuffer | |
newZeroAudioBuffer :: MonadIO m => m AudioBuffer Source #
Construct a AudioBuffer struct initialized to zero.
Methods
Click to display all available methods, including inherited ones
clip
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> Segment |
|
| -> Int32 |
|
| -> Int32 |
|
| -> m (Maybe Buffer) | Returns: If the buffer has no timestamp, it is assumed to be inside the segment and is not clipped |
Clip the buffer to the given GstSegment.
After calling this function the caller does not own a reference to
buffer anymore.
map
Arguments
| :: (HasCallStack, MonadIO m) | |
| => AudioInfo |
|
| -> Buffer |
|
| -> [MapFlags] |
|
| -> m (Bool, AudioBuffer) | Returns: |
Maps an audio gstbuffer so that it can be read or written and stores the
result of the map operation in buffer.
This is especially useful when the gstbuffer is in non-interleaved (planar)
layout, in which case this function will use the information in the
gstbuffer's attached AudioMeta in order to map each channel in a
separate "plane" in AudioBuffer. If a AudioMeta is not attached
on the gstbuffer, then it must be in interleaved layout.
If a AudioMeta is attached, then the AudioInfo on the meta is checked
against info. Normally, they should be equal, but in case they are not,
a g_critical will be printed and the AudioInfo from the meta will be
used.
In non-interleaved buffers, it is possible to have each channel on a separate
Memory. In this case, each memory will be mapped separately to avoid
copying their contents in a larger memory area. Do note though that it is
not supported to have a single channel spanning over two or more different
Memory objects. Although the map operation will likely succeed in this
case, it will be highly sub-optimal and it is recommended to merge all the
memories in the buffer before calling this function.
Note: The actual Buffer is not ref'ed, but it is required to stay valid
as long as it's mapped.
Since: 1.16
reorderChannels
audioBufferReorderChannels Source #
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> AudioFormat |
|
| -> [AudioChannelPosition] |
|
| -> [AudioChannelPosition] |
|
| -> m Bool | Returns: |
Reorders buffer from the channel positions from to the channel
positions to. from and to must contain the same number of
positions and the same positions, only in a different order.
buffer must be writable.
truncate
Arguments
| :: (HasCallStack, MonadIO m) | |
| => Buffer |
|
| -> Int32 |
|
| -> CSize |
|
| -> CSize |
|
| -> m Buffer | Returns: the truncated buffer |
Truncate the buffer to finally have samples number of samples, removing
the necessary amount of samples from the end and trim number of samples
from the beginning.
This function does not know the audio rate, therefore the caller is responsible for re-setting the correct timestamp and duration to the buffer. However, timestamp will be preserved if trim == 0, and duration will also be preserved if there is no trimming to be done. Offset and offset end will be preserved / updated.
After calling this function the caller does not own a reference to
buffer anymore.
Since: 1.16
unmap
Arguments
| :: (HasCallStack, MonadIO m) | |
| => AudioBuffer |
|
| -> m () |
Unmaps an audio buffer that was previously mapped with
audioBufferMap.
Since: 1.16
Properties
buffer
the mapped buffer
clearAudioBufferBuffer :: MonadIO m => AudioBuffer -> m () Source #
Set the value of the “buffer” field to Nothing.
When overloading is enabled, this is equivalent to
clear #buffer
getAudioBufferBuffer :: MonadIO m => AudioBuffer -> m (Maybe Buffer) Source #
Get the value of the “buffer” field.
When overloading is enabled, this is equivalent to
get audioBuffer #buffer
setAudioBufferBuffer :: MonadIO m => AudioBuffer -> Ptr Buffer -> m () Source #
Set the value of the “buffer” field.
When overloading is enabled, this is equivalent to
setaudioBuffer [ #buffer:=value ]
info
a AudioInfo describing the audio properties of this buffer
getAudioBufferInfo :: MonadIO m => AudioBuffer -> m AudioInfo Source #
Get the value of the “info” field.
When overloading is enabled, this is equivalent to
get audioBuffer #info
nPlanes
the number of planes available
getAudioBufferNPlanes :: MonadIO m => AudioBuffer -> m Int32 Source #
Get the value of the “n_planes” field.
When overloading is enabled, this is equivalent to
get audioBuffer #nPlanes
setAudioBufferNPlanes :: MonadIO m => AudioBuffer -> Int32 -> m () Source #
Set the value of the “n_planes” field.
When overloading is enabled, this is equivalent to
setaudioBuffer [ #nPlanes:=value ]
nSamples
the size of the buffer in samples
getAudioBufferNSamples :: MonadIO m => AudioBuffer -> m CSize Source #
Get the value of the “n_samples” field.
When overloading is enabled, this is equivalent to
get audioBuffer #nSamples
setAudioBufferNSamples :: MonadIO m => AudioBuffer -> CSize -> m () Source #
Set the value of the “n_samples” field.
When overloading is enabled, this is equivalent to
setaudioBuffer [ #nSamples:=value ]
planes
an array of nPlanes pointers pointing to the start of each
plane in the mapped buffer
clearAudioBufferPlanes :: MonadIO m => AudioBuffer -> m () Source #
Set the value of the “planes” field to Nothing.
When overloading is enabled, this is equivalent to
clear #planes
getAudioBufferPlanes :: MonadIO m => AudioBuffer -> m (Ptr ()) Source #
Get the value of the “planes” field.
When overloading is enabled, this is equivalent to
get audioBuffer #planes
setAudioBufferPlanes :: MonadIO m => AudioBuffer -> Ptr () -> m () Source #
Set the value of the “planes” field.
When overloading is enabled, this is equivalent to
setaudioBuffer [ #planes:=value ]