directsoundsink: use helper function to check for spdif formats

This commit is contained in:
Andoni Morales Alastruey 2012-05-25 10:14:57 +00:00 committed by Sebastian Dröge
parent a9dff8adb9
commit ed8ad7bffe

View file

@ -102,6 +102,8 @@ static void gst_directsound_sink_set_mute (GstDirectSoundSink * sink,
gboolean mute); gboolean mute);
static gboolean gst_directsound_sink_get_mute (GstDirectSoundSink * sink); static gboolean gst_directsound_sink_get_mute (GstDirectSoundSink * sink);
static gboolean gst_directsound_sink_is_spdif_format (GstDirectSoundSink * dsoundsink);
static GstStaticPadTemplate directsoundsink_sink_factory = static GstStaticPadTemplate directsoundsink_sink_factory =
GST_STATIC_PAD_TEMPLATE ("sink", GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK, GST_PAD_SINK,
@ -324,8 +326,7 @@ gst_directsound_sink_acceptcaps (GstBaseSink * sink, GstQuery * query)
goto done; goto done;
/* Make sure input is framed (one frame per buffer) and can be payloaded */ /* Make sure input is framed (one frame per buffer) and can be payloaded */
switch (rbuf->spec.type) { if (gst_directsound_sink_is_spdif_format (dsink))
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3:
{ {
gboolean framed = FALSE, parsed = FALSE; gboolean framed = FALSE, parsed = FALSE;
st = gst_caps_get_structure (caps, 0); st = gst_caps_get_structure (caps, 0);
@ -335,9 +336,6 @@ gst_directsound_sink_acceptcaps (GstBaseSink * sink, GstQuery * query)
if ((!framed && !parsed) || gst_audio_iec61937_frame_size (&spec) <= 0) if ((!framed && !parsed) || gst_audio_iec61937_frame_size (&spec) <= 0)
goto done; goto done;
} }
default:{
}
}
ret = TRUE; ret = TRUE;
done: done:
@ -389,7 +387,7 @@ gst_directsound_sink_open (GstAudioSink * asink)
return TRUE; return TRUE;
} }
static boolean static gboolean
gst_directsound_sink_is_spdif_format (GstDirectSoundSink * dsoundsink) gst_directsound_sink_is_spdif_format (GstDirectSoundSink * dsoundsink)
{ {
GstAudioRingBufferFormatType type; GstAudioRingBufferFormatType type;
@ -754,8 +752,7 @@ gst_directsound_probe_supported_formats (GstDirectSoundSink * dsoundsink,
static GstBuffer * static GstBuffer *
gst_directsound_sink_payload (GstAudioBaseSink * sink, GstBuffer * buf) gst_directsound_sink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
{ {
switch (sink->ringbuffer->spec.type) { if (gst_directsound_sink_is_spdif_format ((GstDirectSoundSink *) sink))
case GST_AUDIO_RING_BUFFER_FORMAT_TYPE_AC3:
{ {
gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec); gint framesize = gst_audio_iec61937_frame_size (&sink->ringbuffer->spec);
GstBuffer *out; GstBuffer *out;
@ -794,10 +791,8 @@ gst_directsound_sink_payload (GstAudioBaseSink * sink, GstBuffer * buf)
gst_buffer_unmap (buf, &infobuf); gst_buffer_unmap (buf, &infobuf);
return out; return out;
} }
else
default:
return gst_buffer_ref (buf); return gst_buffer_ref (buf);
}
} }
static void static void