Ejemplo n.º 1
0
static GstBuffer *
gst_alsasink_payload (GstBaseAudioSink * sink, GstBuffer * buf)
{
    GstAlsaSink *alsa;

    alsa = GST_ALSA_SINK (sink);

    if (alsa->iec958) {
        GstBuffer *out;
        gint framesize;

        framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
        if (framesize <= 0)
            return NULL;

        out = gst_buffer_new_and_alloc (framesize);

        if (!gst_audio_iec61937_payload (GST_BUFFER_DATA (buf),
                                         GST_BUFFER_SIZE (buf), GST_BUFFER_DATA (out),
                                         GST_BUFFER_SIZE (out), &sink->ringbuffer->spec)) {
            gst_buffer_unref (out);
            return NULL;
        }

        gst_buffer_copy_metadata (out, buf, GST_BUFFER_COPY_ALL);
        return out;
    }

    return gst_buffer_ref (buf);
}
Ejemplo n.º 2
0
static GstBuffer *
gst_directsound_sink_payload (GstBaseAudioSink * sink, GstBuffer * buf)
{
  if (gst_directsound_sink_is_spdif_format ((GstDirectSoundSink *) sink)) {
    gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
    GstBuffer *out;

    if (framesize <= 0)
      return NULL;

    out = gst_buffer_new_and_alloc (framesize);

    if (!gst_audio_iec61937_payload (GST_BUFFER_DATA (buf),
            GST_BUFFER_SIZE (buf), GST_BUFFER_DATA (out),
            GST_BUFFER_SIZE (out), &sink->ringbuffer->spec)) {
      gst_buffer_unref (out);
      return NULL;
    }

    gst_buffer_copy_metadata (out, buf, GST_BUFFER_COPY_ALL);
    /* Fix endianness */
    _swab ((gchar *) GST_BUFFER_DATA (buf), (gchar *) GST_BUFFER_DATA (buf),
        GST_BUFFER_SIZE (buf));
    return out;
  } else {
    return gst_buffer_ref (buf);
  }
}
static GstBuffer *
gst_directsound_sink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
{
  if (gst_directsound_sink_is_spdif_format (&sink->ringbuffer->spec)) {
    gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
    GstBuffer *out;
    GstMapInfo infobuf, infoout;
    gboolean success;

    if (framesize <= 0)
      return NULL;

    out = gst_buffer_new_and_alloc (framesize);

    if (!gst_buffer_map (buf, &infobuf, GST_MAP_READWRITE)) {
      gst_buffer_unref (out);
      return NULL;
    }
    if (!gst_buffer_map (out, &infoout, GST_MAP_READWRITE)) {
      gst_buffer_unmap (buf, &infobuf);
      gst_buffer_unref (out);
      return NULL;
    }
    success = gst_audio_iec61937_payload (infobuf.data, infobuf.size,
        infoout.data, infoout.size, &sink->ringbuffer->spec, G_BYTE_ORDER);
    if (!success) {
      gst_buffer_unmap (out, &infoout);
      gst_buffer_unmap (buf, &infobuf);
      gst_buffer_unref (out);
      return NULL;
    }

    gst_buffer_copy_into (out, buf, GST_BUFFER_COPY_ALL, 0, -1);
    /* Fix endianness */
    _swab ((gchar *) infoout.data, (gchar *) infoout.data, infobuf.size);
    gst_buffer_unmap (out, &infoout);
    gst_buffer_unmap (buf, &infobuf);
    return out;
  } else
    return gst_buffer_ref (buf);
}
Ejemplo n.º 4
0
static GstBuffer *
gst_alsasink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
{
  GstAlsaSink *alsa;

  alsa = GST_ALSA_SINK (sink);

  if (alsa->iec958) {
    GstBuffer *out;
    gint framesize;
    GstMapInfo iinfo, oinfo;

    framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
    if (framesize <= 0)
      return NULL;

    out = gst_buffer_new_and_alloc (framesize);

    gst_buffer_map (buf, &iinfo, GST_MAP_READ);
    gst_buffer_map (out, &oinfo, GST_MAP_WRITE);

    if (!gst_audio_iec61937_payload (iinfo.data, iinfo.size,
            oinfo.data, oinfo.size, &sink->ringbuffer->spec, G_BIG_ENDIAN)) {
      gst_buffer_unmap (buf, &iinfo);
      gst_buffer_unmap (out, &oinfo);
      gst_buffer_unref (out);
      return NULL;
    }

    gst_buffer_unmap (buf, &iinfo);
    gst_buffer_unmap (out, &oinfo);

    gst_buffer_copy_into (out, buf, GST_BUFFER_COPY_METADATA, 0, -1);
    return out;
  }

  return gst_buffer_ref (buf);
}
Ejemplo n.º 5
0
static GstBuffer *
gst_osx_audio_sink_sink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
{
  if (RINGBUFFER_IS_SPDIF (sink->ringbuffer->spec.type)) {
    gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
    GstBuffer *out;
    GstMapInfo inmap, outmap;
    gboolean res;

    if (framesize <= 0)
      return NULL;

    out = gst_buffer_new_and_alloc (framesize);

    gst_buffer_map (buf, &inmap, GST_MAP_READ);
    gst_buffer_map (out, &outmap, GST_MAP_WRITE);

    /* FIXME: the endianness needs to be queried and then set */
    res = gst_audio_iec61937_payload (inmap.data, inmap.size,
        outmap.data, outmap.size, &sink->ringbuffer->spec, G_BIG_ENDIAN);

    gst_buffer_unmap (buf, &inmap);
    gst_buffer_unmap (out, &outmap);

    if (!res) {
      gst_buffer_unref (out);
      return NULL;
    }

    gst_buffer_copy_into (out, buf, GST_BUFFER_COPY_METADATA, 0, -1);
    return out;

  } else {
    return gst_buffer_ref (buf);
  }
}