Class: GstAudio::AudioRingBuffer

Inherits:
Gst::Object
  • Object
show all
Defined in:
(unknown)

Overview

The vmethods that subclasses can override to implement the ringbuffer.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Gst::Object

#add_control_binding, check_uniqueness, #control_bindings_disabled=, #control_rate, #control_rate=, default_deep_notify, #default_error, #get_control_binding, #get_g_value_array, #get_value, #get_value_array, #has_active_control_bindings, #has_ancestor, #has_as_ancestor, #has_as_parent, #name, #name=, #parent, #parent=, #path_string, #ref, ref_sink, #remove_control_binding, replace, #set_control_binding_disabled, #suggest_next_sync, #sync_values, #unparent, #unref

Class Method Details

.debug_spec_buff(spec) ⇒ nil

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

Parameters:

  • spec (GstAudio::AudioRingBufferSpec)

    the spec to debug

Returns:

  • (nil)

.debug_spec_caps(spec) ⇒ nil

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

Parameters:

  • spec (GstAudio::AudioRingBufferSpec)

    the spec to debug

Returns:

  • (nil)

.parse_caps(spec, caps) ⇒ Boolean

Parse caps into spec.

Parameters:

  • spec (GstAudio::AudioRingBufferSpec)

    a spec

  • caps (Gst::Caps)

    a Gst::Caps

Returns:

  • (Boolean)

    TRUE if the caps could be parsed.

Instance Method Details

#acquire(spec) ⇒ Boolean

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

Parameters:

  • spec (GstAudio::AudioRingBufferSpec)

    the specs of the buffer

Returns:

  • (Boolean)

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

#activate(active) ⇒ Boolean

Activate buf to start or stop pulling data.

MT safe. FALSE on error.

Parameters:

  • active (Boolean)

    the new mode

Returns:

  • (Boolean)

    TRUE if the device could be activated in the requested mode,

#advance(advance) ⇒ nil

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

MT safe.

Parameters:

  • advance (Integer)

    the number of segments written

Returns:

  • (nil)

#channel_positions=(position) ⇒ nil

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

Parameters:

Returns:

  • (nil)

#clear(segment) ⇒ nil

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

MT safe.

Parameters:

  • segment (Integer)

    the segment to clear

Returns:

  • (nil)

#clear_allnil

Clear all samples from the ringbuffer.

MT safe.

Returns:

  • (nil)

#close_deviceBoolean

Close the audio device associated with the ring buffer. The ring buffer should already have been released via gst_audio_ring_buffer_release(). MT safe.

Returns:

  • (Boolean)

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

#commit(sample, data, in_samples, out_samples, accum) ⇒ Integer

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

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

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

out_samples 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. number of samples written can be less than out_samples when buf was interrupted with a flush or stop.

Parameters:

  • sample (Integer)

    the sample position of the data

  • data (Array<Integer>)

    the data to commit

  • in_samples (Integer)

    the number of samples in the data to commit

  • out_samples (Integer)

    the number of samples to write to the ringbuffer

  • accum (Integer)

    accumulator for rate conversion.

Returns:

  • (Integer)

    The number of samples written to the ringbuffer or -1 on error. The

#convert(src_fmt, src_val, dest_fmt, dest_val) ⇒ Boolean

Convert src_val in src_fmt to the equivalent value in dest_fmt. The result will be put in dest_val.

Parameters:

  • src_fmt (Gst::Format)

    the source format

  • src_val (Integer)

    the source value

  • dest_fmt (Gst::Format)

    the destination format

  • dest_val (Integer)

    a location to store the converted value

Returns:

  • (Boolean)

    TRUE if the conversion succeeded.

#delayInteger

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. MT safe.

Returns:

  • (Integer)

    The number of samples queued in the audio device.

#device_is_openBoolean

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

Returns:

  • (Boolean)

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

#flushing=(flushing) ⇒ nil

Set the ringbuffer to flushing mode or normal mode.

MT safe.

Parameters:

  • flushing (Boolean)

    the new mode

Returns:

  • (nil)

#is_acquiredBoolean

Check if the ringbuffer is acquired and ready to use. MT safe.

Returns:

  • (Boolean)

    TRUE if the ringbuffer is acquired, FALSE on error.

#is_activeBoolean

Check if buf is activated.

MT safe.

Returns:

  • (Boolean)

    TRUE if the device is active.

#is_flushingBoolean

Check if buf is flushing.

MT safe.

Returns:

  • (Boolean)

    TRUE if the device is flushing.

#may_start(allowed) ⇒ nil

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

MT safe.

Parameters:

  • allowed (Boolean)

    the new value

Returns:

  • (nil)

#open_deviceBoolean

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. MT safe.

Returns:

  • (Boolean)

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

#pauseBoolean

Pause processing samples from the ringbuffer. MT safe.

Returns:

  • (Boolean)

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

#prepare_read(segment, readptr, len) ⇒ Boolean

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

Parameters:

  • segment (Integer)

    the segment to read

  • readptr (Array<Integer>)

    the pointer to the memory where samples can be read

  • len (Integer)

    the number of bytes to read

Returns:

  • (Boolean)

    FALSE if the buffer is not started.

#read(sample, data, len, timestamp) ⇒ Integer

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. error.

MT safe.

Parameters:

  • sample (Integer)

    the sample position of the data

  • data (Array<Integer>)

    where the data should be read

  • len (Integer)

    the number of samples in data to read

  • timestamp (Gst::ClockTime)

    where the timestamp is returned

Returns:

  • (Integer)

    The number of samples read from the ringbuffer or -1 on

#releaseBoolean

Free the resources of the ringbuffer. MT safe.

Returns:

  • (Boolean)

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

#sample=(sample) ⇒ nil

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.

Parameters:

  • sample (Integer)

    the sample number to set

Returns:

  • (nil)

#samples_doneInteger

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 gst_audio_ring_buffer_delay()). MT safe.

Returns:

  • (Integer)

    The number of samples processed by the ringbuffer.

#set_callback(cb, user_data) ⇒ nil

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.

Parameters:

  • cb (GstAudio::AudioRingBufferCallback)

    the callback to set

  • user_data (GObject)

    user data passed to the callback

Returns:

  • (nil)

#set_callback_full(cb, user_data, notify) ⇒ nil

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.

Parameters:

  • cb (GstAudio::AudioRingBufferCallback)

    the callback to set

  • user_data (GObject)

    user data passed to the callback

  • notify (GLib::DestroyNotify)

    function to be called when user_data is no longer needed

Returns:

  • (nil)

#set_errorednil

Mark the ringbuffer as errored after it has started.

MT safe.

Returns:

  • (nil)

#set_timestamp(readseg, timestamp) ⇒ nil

Parameters:

  • readseg (Integer)
  • timestamp (Gst::ClockTime)

Returns:

  • (nil)

#startBoolean

Start processing samples from the ringbuffer. MT safe.

Returns:

  • (Boolean)

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

#stopBoolean

Stop processing samples from the ringbuffer. MT safe.

Returns:

  • (Boolean)

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