gi-gstaudio-1.0.23: GStreamerAudio bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.GstAudio.Objects.AudioRingBuffer

Description

This object is the base class for audio ringbuffers used by the base audio source and sink classes.

The ringbuffer abstracts a circular buffer of data. One reader and one writer can operate on the data from different threads in a lockfree manner. The base class is sufficiently flexible to be used as an abstraction for DMA based ringbuffers as well as a pure software implementations.

Synopsis

Exported types

newtype AudioRingBuffer Source #

Memory-managed wrapper type.

Constructors

AudioRingBuffer (ManagedPtr AudioRingBuffer) 

Instances

Instances details
Eq AudioRingBuffer Source # 
Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

GObject AudioRingBuffer Source # 
Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

ManagedPtrNewtype AudioRingBuffer Source # 
Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

TypedObject AudioRingBuffer Source # 
Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

Methods

glibType :: IO GType

HasParentTypes AudioRingBuffer Source # 
Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

IsGValue (Maybe AudioRingBuffer) Source #

Convert AudioRingBuffer to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe AudioRingBuffer -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe AudioRingBuffer)

type ParentTypes AudioRingBuffer Source # 
Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

type ParentTypes AudioRingBuffer = '[Object, Object]

class (GObject o, IsDescendantOf AudioRingBuffer o) => IsAudioRingBuffer o Source #

Type class for types which can be safely cast to AudioRingBuffer, for instance with toAudioRingBuffer.

Instances

Instances details
(GObject o, IsDescendantOf AudioRingBuffer o) => IsAudioRingBuffer o Source # 
Instance details

Defined in GI.GstAudio.Objects.AudioRingBuffer

toAudioRingBuffer :: (MonadIO m, IsAudioRingBuffer o) => o -> m AudioRingBuffer Source #

Cast to AudioRingBuffer, for types for which this is known to be safe. For general casts, use castTo.

Methods

acquire

audioRingBufferAcquire Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to acquire

-> AudioRingBufferSpec

spec: the specs of the buffer

-> m Bool

Returns: TRUE if the device could be acquired, FALSE on error.

MT safe.

Allocate the resources for the ringbuffer. This function fills in the data pointer of the ring buffer with a valid Buffer to which samples can be written.

activate

audioRingBufferActivate Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to activate

-> Bool

active: the new mode

-> m Bool

Returns: TRUE if the device could be activated in the requested mode, FALSE on error.

Activate buf to start or stop pulling data.

MT safe.

advance

audioRingBufferAdvance Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to advance

-> Word32

advance: the number of segments written

-> m () 

Subclasses should call this function to notify the fact that advance segments are now processed by the device.

MT safe.

clear

audioRingBufferClear Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to clear

-> Int32

segment: the segment to clear

-> m () 

Clear the given segment of the buffer with silence samples. This function is used by subclasses.

MT safe.

clearAll

audioRingBufferClearAll Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to clear

-> m () 

Clear all samples from the ringbuffer.

MT safe.

closeDevice

audioRingBufferCloseDevice Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> m Bool

Returns: TRUE if the device could be closed, FALSE on error.

MT safe.

Close the audio device associated with the ring buffer. The ring buffer should already have been released via audioRingBufferRelease.

commit

audioRingBufferCommit Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to commit

-> Word64

sample: the sample position of the data

-> ByteString

data: the data to commit

-> Int32

outSamples: the number of samples to write to the ringbuffer

-> Int32

accum: accumulator for rate conversion.

-> m (Word32, Int32)

Returns: The number of samples written to the ringbuffer or -1 on error. The number of samples written can be less than outSamples when buf was interrupted with a flush or stop.

Commit inSamples samples pointed to by data to the ringbuffer buf.

inSamples and outSamples define the rate conversion to perform on the samples in data. For negative rates, outSamples must be negative and inSamples positive.

When outSamples is positive, the first sample will be written at position sample in the ringbuffer. When outSamples is negative, the last sample will be written to sample in reverse order.

outSamples does not need to be a multiple of the segment size of the ringbuffer although it is recommended for optimal performance.

accum will hold a temporary accumulator used in rate conversion and should be set to 0 when this function is first called. In case the commit operation is interrupted, one can resume the processing by passing the previously returned accum value back to this function.

MT safe.

convert

audioRingBufferConvert Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> Format

srcFmt: the source format

-> Int64

srcVal: the source value

-> Format

destFmt: the destination format

-> m (Bool, Int64)

Returns: TRUE if the conversion succeeded.

Convert srcVal in srcFmt to the equivalent value in destFmt. The result will be put in destVal.

debugSpecBuff

audioRingBufferDebugSpecBuff Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> AudioRingBufferSpec

spec: the spec to debug

-> m () 

Print debug info about the buffer sized in spec to the debug log.

debugSpecCaps

audioRingBufferDebugSpecCaps Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> AudioRingBufferSpec

spec: the spec to debug

-> m () 

Print debug info about the parsed caps in spec to the debug log.

delay

audioRingBufferDelay Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to query

-> m Word32

Returns: The number of samples queued in the audio device.

MT safe.

Get the number of samples queued in the audio device. This is usually less than the segment size but can be bigger when the implementation uses another internal buffer between the audio device.

For playback ringbuffers this is the amount of samples transferred from the ringbuffer to the device but still not played.

For capture ringbuffers this is the amount of samples in the device that are not yet transferred to the ringbuffer.

deviceIsOpen

audioRingBufferDeviceIsOpen Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> m Bool

Returns: TRUE if the device was open, FALSE if it was closed.

MT safe.

Checks the status of the device associated with the ring buffer.

isAcquired

audioRingBufferIsAcquired Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to check

-> m Bool

Returns: TRUE if the ringbuffer is acquired, FALSE on error.

MT safe.

Check if the ringbuffer is acquired and ready to use.

isActive

audioRingBufferIsActive Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> m Bool

Returns: TRUE if the device is active.

Check if buf is activated.

MT safe.

isFlushing

audioRingBufferIsFlushing Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> m Bool

Returns: TRUE if the device is flushing.

Check if buf is flushing.

MT safe.

mayStart

audioRingBufferMayStart Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> Bool

allowed: the new value

-> m () 

Tell the ringbuffer that it is allowed to start playback when the ringbuffer is filled with samples.

MT safe.

openDevice

audioRingBufferOpenDevice Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> m Bool

Returns: TRUE if the device could be opened, FALSE on error.

MT safe.

Open the audio device associated with the ring buffer. Does not perform any setup on the device. You must open the device before acquiring the ring buffer.

parseCaps

audioRingBufferParseCaps Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> AudioRingBufferSpec

spec: a spec

-> Caps

caps: a Caps

-> m Bool

Returns: TRUE if the caps could be parsed.

Parse caps into spec.

pause

audioRingBufferPause Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to pause

-> m Bool

Returns: TRUE if the device could be paused, FALSE on error.

MT safe.

Pause processing samples from the ringbuffer.

prepareRead

audioRingBufferPrepareRead Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to read from

-> m (Bool, Int32, ByteString)

Returns: FALSE if the buffer is not started.

MT safe.

Returns a pointer to memory where the data from segment segment can be found. This function is mostly used by subclasses.

read

audioRingBufferRead Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to read from

-> Word64

sample: the sample position of the data

-> ByteString

data: where the data should be read

-> m (Word32, Word64)

Returns: The number of samples read from the ringbuffer or -1 on error.

MT safe.

Read len samples from the ringbuffer into the memory pointed to by data. The first sample should be read from position sample in the ringbuffer.

len should not be a multiple of the segment size of the ringbuffer although it is recommended.

timestamp will return the timestamp associated with the data returned.

release

audioRingBufferRelease Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to release

-> m Bool

Returns: TRUE if the device could be released, FALSE on error.

MT safe.

Free the resources of the ringbuffer.

samplesDone

audioRingBufferSamplesDone Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to query

-> m Word64

Returns: The number of samples processed by the ringbuffer.

MT safe.

Get the number of samples that were processed by the ringbuffer since it was last started. This does not include the number of samples not yet processed (see audioRingBufferDelay).

setCallback

audioRingBufferSetCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to set the callback on

-> Maybe AudioRingBufferCallback

cb: the callback to set

-> m () 

Sets the given callback function on the buffer. This function will be called every time a segment has been written to a device.

MT safe.

Since: 1.12

setChannelPositions

audioRingBufferSetChannelPositions Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer

-> [AudioChannelPosition]

position: the device channel positions

-> m () 

Tell the ringbuffer about the device's channel positions. This must be called in when the ringbuffer is acquired.

setFlushing

audioRingBufferSetFlushing Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to flush

-> Bool

flushing: the new mode

-> m () 

Set the ringbuffer to flushing mode or normal mode.

MT safe.

setSample

audioRingBufferSetSample Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to use

-> Word64

sample: the sample number to set

-> m () 

Make sure that the next sample written to the device is accounted for as being the sample sample written to the device. This value will be used in reporting the current sample position of the ringbuffer.

This function will also clear the buffer with silence.

MT safe.

setTimestamp

audioRingBufferSetTimestamp :: (HasCallStack, MonadIO m, IsAudioRingBuffer a) => a -> Int32 -> Word64 -> m () Source #

No description available in the introspection data.

start

audioRingBufferStart Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to start

-> m Bool

Returns: TRUE if the device could be started, FALSE on error.

MT safe.

Start processing samples from the ringbuffer.

stop

audioRingBufferStop Source #

Arguments

:: (HasCallStack, MonadIO m, IsAudioRingBuffer a) 
=> a

buf: the AudioRingBuffer to stop

-> m Bool

Returns: TRUE if the device could be stopped, FALSE on error.

MT safe.

Stop processing samples from the ringbuffer.