break;
}
case GST_EVENT_EOS:
- if (wav->state == GST_WAVPARSE_START || !wav->caps) {
+ if (!wav->caps) {
GST_ELEMENT_ERROR (wav, STREAM, WRONG_TYPE, (NULL),
("No valid input found before end of stream"));
} else {
- /* add pad if needed so EOS is seen downstream */
- if (G_UNLIKELY (wav->first)) {
- wav->first = FALSE;
- gst_wavparse_add_src_pad (wav, NULL);
+ switch (wav->state) {
+ case GST_WAVPARSE_START:
+ GST_ELEMENT_ERROR (wav, STREAM, WRONG_TYPE, (NULL),
+ ("No valid input found before end of stream"));
+ break;
+ case GST_WAVPARSE_HEADER:
+ GST_ELEMENT_ERROR (wav, STREAM, DEMUX, (NULL),
+ ("No audio data chunk found before end of stream"));
+ break;
+ case GST_WAVPARSE_DATA:
+ /* add pad if needed so EOS is seen downstream */
+ if (G_UNLIKELY (wav->first)) {
+ wav->first = FALSE;
+ gst_wavparse_add_src_pad (wav, NULL);
+ }
+ /* stream leftover data in current segment */
+ gst_wavparse_flush_data (wav);
+ break;
+ default:
+ g_assert_not_reached ();
}
-
- /* stream leftover data in current segment */
- gst_wavparse_flush_data (wav);
}
-
/* fall-through */
case GST_EVENT_FLUSH_STOP:
{
#include <gst/check/gstcheck.h>
+#define CORRUPT_HEADER_WAV_PATH GST_TEST_FILES_PATH G_DIR_SEPARATOR_S \
+ "corruptheadertestsrc.wav"
#define SIMPLE_WAV_PATH GST_TEST_FILES_PATH G_DIR_SEPARATOR_S "audiotestsrc.wav"
static GstElement *
-create_pipeline (GstPadMode mode)
+create_file_pipeline (const char *path, GstPadMode mode)
{
GstElement *pipeline;
GstElement *src, *q = NULL;
gst_bin_add_many (GST_BIN (pipeline), src, wavparse, fakesink, q, NULL);
- g_object_set (src, "location", SIMPLE_WAV_PATH, NULL);
+ g_object_set (src, "location", path, NULL);
if (mode == GST_PAD_MODE_PUSH)
fail_unless (gst_element_link_many (src, q, wavparse, fakesink, NULL));
GstElement *pipeline;
GstMessage *msg;
- pipeline = create_pipeline (mode);
+ pipeline = create_file_pipeline (SIMPLE_WAV_PATH, mode);
ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
fail_unless_equals_int (ret, GST_STATE_CHANGE_ASYNC);
GST_END_TEST;
static void
+do_test_corrupt_header_file (GstPadMode mode)
+{
+ GstStateChangeReturn ret;
+ GstElement *pipeline;
+ GstMessage *msg;
+
+ pipeline = create_file_pipeline (CORRUPT_HEADER_WAV_PATH, mode);
+
+ ret = gst_element_set_state (pipeline, GST_STATE_PLAYING);
+ fail_unless_equals_int (ret, GST_STATE_CHANGE_ASYNC);
+
+ ret = gst_element_get_state (pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
+ fail_unless_equals_int (ret, GST_STATE_CHANGE_FAILURE);
+
+ msg = gst_bus_timed_pop_filtered (GST_ELEMENT_BUS (pipeline),
+ GST_CLOCK_TIME_NONE, GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
+ fail_unless_equals_int (GST_MESSAGE_TYPE (msg), GST_MESSAGE_ERROR);
+
+ gst_message_unref (msg);
+ gst_element_set_state (pipeline, GST_STATE_NULL);
+ gst_object_unref (pipeline);
+}
+
+GST_START_TEST (test_corrupt_header_file_push)
+{
+ do_test_corrupt_header_file (GST_PAD_MODE_PUSH);
+}
+
+GST_END_TEST;
+
+static void
do_test_empty_file (gboolean can_activate_pull)
{
GstStateChangeReturn ret1, ret2;
GstClockTime seek_position = (20 * GST_MSECOND);
GstClockTime first_ts = GST_CLOCK_TIME_NONE;
- pipeline = create_pipeline (GST_PAD_MODE_PULL);
+ pipeline = create_file_pipeline (SIMPLE_WAV_PATH, GST_PAD_MODE_PULL);
wavparse = gst_bin_get_by_name (GST_BIN (pipeline), "wavparse");
fail_unless (wavparse);
fakesink = gst_bin_get_by_name (GST_BIN (pipeline), "fakesink");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_empty_file_pull);
tcase_add_test (tc_chain, test_empty_file_push);
+ tcase_add_test (tc_chain, test_corrupt_header_file_push);
tcase_add_test (tc_chain, test_simple_file_pull);
tcase_add_test (tc_chain, test_simple_file_push);
tcase_add_test (tc_chain, test_seek);