Ejemplo n.º 1
0
static gboolean
gst_nas_sink_unprepare (GstAudioSink * asink)
{
    GstNasSink *sink = GST_NAS_SINK (asink);

    if (sink->flow != AuNone) {
        AuBool clocked;
        int num_elements;
        AuStatus status;
        AuElement *oldelems;

        GST_DEBUG_OBJECT (sink, "flushing buffer");
        NAS_flush (sink);

        oldelems =
            AuGetElements (sink->audio, sink->flow, &clocked, &num_elements,
                           &status);
        if (num_elements > 0) {
            GST_DEBUG_OBJECT (sink, "GetElements status: %i", status);
            if (oldelems)
                AuFreeElements (sink->audio, num_elements, oldelems);
        }

        AuStopFlow (sink->audio, sink->flow, NULL);
        AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
        sink->flow = AuNone;
    }
    sink->need_data = 0;

    return TRUE;
}
Ejemplo n.º 2
0
static gboolean
gst_nas_sink_prepare (GstAudioSink * asink, GstRingBufferSpec * spec)
{
  GstNasSink *sink = GST_NAS_SINK (asink);

  /*spec->bytes_per_sample = sink->rate * NAS_SOUND_PORT_DURATION; */
  /*spec->bytes_per_sample = (spec->width / 8) * spec->channels; */
  memset (spec->silence_sample, 0, spec->bytes_per_sample);
  GST_DEBUG_OBJECT (sink, "Sample %d", spec->bytes_per_sample);

  if (sink->audio == NULL)
    return TRUE;

  if (sink->flow != AuNone) {
    GST_DEBUG_OBJECT (sink, "flushing buffer");
    NAS_flush (sink);
    AuStopFlow (sink->audio, sink->flow, NULL);
    AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
    sink->flow = AuNone;
  }

  return NAS_createFlow (sink, spec);
}
Ejemplo n.º 3
0
static gboolean
gst_nas_sink_close (GstAudioSink * asink)
{
  GstNasSink *sink = GST_NAS_SINK (asink);

  if (sink->audio == NULL)
    return TRUE;

  if (sink->flow != AuNone) {
    NAS_flush (sink);

    AuStopFlow (sink->audio, sink->flow, NULL);
    AuReleaseScratchFlow (sink->audio, sink->flow, NULL);
    sink->flow = AuNone;
  }

  sink->need_data = 0;

  AuCloseServer (sink->audio);
  sink->audio = NULL;

  GST_DEBUG_OBJECT (sink, "closed audio device");
  return TRUE;
}
Ejemplo n.º 4
0
static AuBool
NAS_EventHandler (AuServer * aud, AuEvent * ev, AuEventHandlerRec * handler)
{
    GstNasSink *sink = (GstNasSink *) handler->data;
    AuElementNotifyEvent *notify;

    switch (ev->type) {

    case AuEventTypeElementNotify:

        notify = (AuElementNotifyEvent *) ev;

        switch (notify->kind) {

        case AuElementNotifyKindLowWater:
            NAS_sendData (sink, notify->num_bytes);
            break;

        case AuElementNotifyKindState:

            switch (notify->cur_state) {

            case AuStateStop:

                if (sink->flow != AuNone) {
                    if (notify->reason == AuReasonEOF)
                        AuStopFlow (handler->aud, sink->flow, NULL);
                    AuReleaseScratchFlow (handler->aud, sink->flow, NULL);
                    sink->flow = AuNone;
                }
                AuUnregisterEventHandler (handler->aud, handler);
                break;

            case AuStatePause:

                switch (notify->reason) {
                case AuReasonUnderrun:
                case AuReasonOverrun:
                case AuReasonEOF:
                case AuReasonWatermark:

                    NAS_sendData (sink, notify->num_bytes);

                    break;

                case AuReasonHardware:

                    if (AuSoundRestartHardwarePauses)
                        AuStartFlow (handler->aud, sink->flow, NULL);
                    else
                        AuStopFlow (handler->aud, sink->flow, NULL);

                    break;
                }
                break;
            }
            break;
        }
        break;
    }

    return AuTrue;
}