mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 20:21:24 +00:00
additions:
Original commit message from CVS: additions: - bugfixes - 24bit format tests - a new state change test
This commit is contained in:
parent
02872d827d
commit
28530ecdbe
8 changed files with 378 additions and 12 deletions
|
@ -1,11 +1,14 @@
|
|||
testprogs = formats
|
||||
testprogs = formats state
|
||||
|
||||
TESTS = $(testprogs)
|
||||
|
||||
check_PROGRAMS = $(testprogs)
|
||||
|
||||
formats_SOURCES = formats.c sinesrc.c sinesrc.h
|
||||
state_SOURCES = state.c sinesrc.c sinesrc.h
|
||||
|
||||
# we have nothing but apps here, we can do this safely
|
||||
LIBS = $(GST_LIBS)
|
||||
AM_CFLAGS = $(GST_CFLAGS)
|
||||
|
||||
noinst_HEADERS = sinesrc.h
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* formats.c: Tests the different formats on alsasink
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
|
@ -25,7 +27,7 @@ gint endianness = G_LITTLE_ENDIAN;
|
|||
gint depth = 8;
|
||||
gint width = 8;
|
||||
|
||||
#define NUMBER_OF_INT_TESTS 16
|
||||
#define NUMBER_OF_INT_TESTS 28
|
||||
#define NUMBER_OF_FLOAT_TESTS 2
|
||||
#define NUMBER_OF_LAW_TESTS 2
|
||||
|
||||
|
@ -164,7 +166,7 @@ main (gint argc, gchar *argv[])
|
|||
g_print ("\n"
|
||||
"This test will test the various formats ALSA and GStreamer support.\n"
|
||||
"You will hear a short sine tone on your default ALSA soundcard for every\n"
|
||||
"format tested. They should all sound the same.\n"
|
||||
"format tested. They should all sound the same (incl. volume).\n"
|
||||
"\n");
|
||||
create_pipeline ();
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "sinesrc.h"
|
||||
#include <math.h>
|
||||
#include <string.h> /* memcpy */
|
||||
|
||||
#define SAMPLES_PER_WAVE 200
|
||||
|
||||
|
@ -56,6 +57,7 @@ static void sinesrc_init (SineSrc *src);
|
|||
static void sinesrc_class_init (SineSrcClass *klass);
|
||||
|
||||
static GstBuffer * sinesrc_get (GstPad *pad);
|
||||
static GstElementStateReturn sinesrc_change_state (GstElement *element);
|
||||
|
||||
|
||||
GType
|
||||
|
@ -78,6 +80,10 @@ sinesrc_get_type (void)
|
|||
static void
|
||||
sinesrc_class_init (SineSrcClass *klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
element_class->change_state = sinesrc_change_state;
|
||||
|
||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||
}
|
||||
|
||||
|
@ -222,8 +228,47 @@ sinesrc_get (GstPad *pad)
|
|||
POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE)
|
||||
break;
|
||||
case 24:
|
||||
/* mom, can I have gint24 plz? */
|
||||
g_assert_not_reached ();
|
||||
if (src->sign) {
|
||||
gpointer p;
|
||||
gint32 val = (gint32) int_value;
|
||||
switch (src->endianness) {
|
||||
case G_LITTLE_ENDIAN:
|
||||
val = GINT32_TO_LE (val);
|
||||
break;
|
||||
case G_BIG_ENDIAN:
|
||||
val = GINT32_TO_BE (val);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
};
|
||||
p = &val;
|
||||
if (src->endianness == G_BIG_ENDIAN)
|
||||
p++;
|
||||
for (j = 0; j < src->channels; j++) {
|
||||
memcpy (data, p, 3);
|
||||
data += 3;
|
||||
}
|
||||
} else {
|
||||
gpointer p;
|
||||
guint32 val = (guint32) int_value;
|
||||
switch (src->endianness) {
|
||||
case G_LITTLE_ENDIAN:
|
||||
val = GUINT32_TO_LE (val);
|
||||
break;
|
||||
case G_BIG_ENDIAN:
|
||||
val = GUINT32_TO_BE (val);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
};
|
||||
p = &val;
|
||||
if (src->endianness == G_BIG_ENDIAN)
|
||||
p++;
|
||||
for (j = 0; j < src->channels; j++) {
|
||||
memcpy (data, p, 3);
|
||||
data += 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
if (src->sign)
|
||||
|
@ -278,3 +323,31 @@ sinesrc_set_pre_get_func (SineSrc *src, PreGetFunc func)
|
|||
{
|
||||
src->pre_get_func = func;
|
||||
}
|
||||
static GstElementStateReturn
|
||||
sinesrc_change_state (GstElement *element)
|
||||
{
|
||||
SineSrc *sinesrc;
|
||||
|
||||
g_return_val_if_fail (element != NULL, FALSE);
|
||||
sinesrc = SINESRC (element);
|
||||
|
||||
switch (GST_STATE_TRANSITION (element)) {
|
||||
case GST_STATE_NULL_TO_READY:
|
||||
case GST_STATE_READY_TO_PAUSED:
|
||||
case GST_STATE_PAUSED_TO_PLAYING:
|
||||
case GST_STATE_PLAYING_TO_PAUSED:
|
||||
break;
|
||||
case GST_STATE_PAUSED_TO_READY:
|
||||
sinesrc->newcaps = TRUE;
|
||||
break;
|
||||
case GST_STATE_READY_TO_NULL:
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
|
105
tests/old/testsuite/alsa/state.c
Normal file
105
tests/old/testsuite/alsa/state.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* state.c: Tests alsasink for state changes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "sinesrc.h"
|
||||
|
||||
GstElement *pipeline;
|
||||
|
||||
static void
|
||||
set_state (GstElementState state)
|
||||
{
|
||||
GstElementState old_state = gst_element_get_state (pipeline);
|
||||
|
||||
g_print ("Setting state from %s to %s...", gst_element_state_get_name (old_state), gst_element_state_get_name (state));
|
||||
|
||||
if (!gst_element_set_state (pipeline, state)) {
|
||||
g_print (" ERROR\n");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
if (state == GST_STATE_PLAYING) {
|
||||
gint i;
|
||||
g_print (" DONE - iterating a bit...");
|
||||
for (i = 0; i < 400; i++) {
|
||||
if (!gst_bin_iterate (GST_BIN (pipeline))) {
|
||||
g_print (" ERROR in iteration %d\n", i);
|
||||
exit (-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
g_print (" DONE\n");
|
||||
}
|
||||
|
||||
static void
|
||||
create_pipeline (void)
|
||||
{
|
||||
GstElement *src;
|
||||
SineSrc *sinesrc;
|
||||
GstElement *alsasink;
|
||||
|
||||
pipeline = gst_pipeline_new ("pipeline");
|
||||
src = sinesrc_new ();
|
||||
alsasink = gst_element_factory_make ("alsasink", "alsasink");
|
||||
|
||||
gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL);
|
||||
gst_element_link (src, alsasink);
|
||||
|
||||
/* prepare our sinesrc */
|
||||
sinesrc = (SineSrc *) src;
|
||||
sinesrc->newcaps = TRUE;
|
||||
sinesrc->type = SINE_SRC_INT;
|
||||
sinesrc->sign = TRUE;
|
||||
sinesrc->endianness = G_BYTE_ORDER;
|
||||
sinesrc->depth = 16;
|
||||
sinesrc->width = 16;
|
||||
}
|
||||
gint
|
||||
main (gint argc, gchar *argv[])
|
||||
{
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
g_print ("\n"
|
||||
"This test will check if state changes work on the alsasink.\n"
|
||||
"You will hear some short sine tones on your default ALSA soundcard,\n"
|
||||
"but they are not important in this test.\n"
|
||||
"\n");
|
||||
create_pipeline ();
|
||||
|
||||
/* simulate some state changes here */
|
||||
set_state (GST_STATE_READY);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_READY);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_PAUSED);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
set_state (GST_STATE_PAUSED);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
set_state (GST_STATE_READY);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
|
||||
g_print ("The alsa plugin mastered another test.\n");
|
||||
|
||||
gst_object_unref (GST_OBJECT (pipeline));
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,11 +1,14 @@
|
|||
testprogs = formats
|
||||
testprogs = formats state
|
||||
|
||||
TESTS = $(testprogs)
|
||||
|
||||
check_PROGRAMS = $(testprogs)
|
||||
|
||||
formats_SOURCES = formats.c sinesrc.c sinesrc.h
|
||||
state_SOURCES = state.c sinesrc.c sinesrc.h
|
||||
|
||||
# we have nothing but apps here, we can do this safely
|
||||
LIBS = $(GST_LIBS)
|
||||
AM_CFLAGS = $(GST_CFLAGS)
|
||||
|
||||
noinst_HEADERS = sinesrc.h
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* formats.c: Tests the different formats on alsasink
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
|
@ -25,7 +27,7 @@ gint endianness = G_LITTLE_ENDIAN;
|
|||
gint depth = 8;
|
||||
gint width = 8;
|
||||
|
||||
#define NUMBER_OF_INT_TESTS 16
|
||||
#define NUMBER_OF_INT_TESTS 28
|
||||
#define NUMBER_OF_FLOAT_TESTS 2
|
||||
#define NUMBER_OF_LAW_TESTS 2
|
||||
|
||||
|
@ -164,7 +166,7 @@ main (gint argc, gchar *argv[])
|
|||
g_print ("\n"
|
||||
"This test will test the various formats ALSA and GStreamer support.\n"
|
||||
"You will hear a short sine tone on your default ALSA soundcard for every\n"
|
||||
"format tested. They should all sound the same.\n"
|
||||
"format tested. They should all sound the same (incl. volume).\n"
|
||||
"\n");
|
||||
create_pipeline ();
|
||||
|
||||
|
|
|
@ -18,8 +18,9 @@
|
|||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include "sinesrc.h"
|
||||
#include <math.h>
|
||||
#include <string.h> /* memcpy */
|
||||
|
||||
#define SAMPLES_PER_WAVE 200
|
||||
|
||||
|
@ -56,6 +57,7 @@ static void sinesrc_init (SineSrc *src);
|
|||
static void sinesrc_class_init (SineSrcClass *klass);
|
||||
|
||||
static GstBuffer * sinesrc_get (GstPad *pad);
|
||||
static GstElementStateReturn sinesrc_change_state (GstElement *element);
|
||||
|
||||
|
||||
GType
|
||||
|
@ -78,6 +80,10 @@ sinesrc_get_type (void)
|
|||
static void
|
||||
sinesrc_class_init (SineSrcClass *klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
element_class->change_state = sinesrc_change_state;
|
||||
|
||||
parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
|
||||
}
|
||||
|
||||
|
@ -222,8 +228,47 @@ sinesrc_get (GstPad *pad)
|
|||
POPULATE (guint16, GUINT16_TO_BE, GUINT16_TO_LE)
|
||||
break;
|
||||
case 24:
|
||||
/* mom, can I have gint24 plz? */
|
||||
g_assert_not_reached ();
|
||||
if (src->sign) {
|
||||
gpointer p;
|
||||
gint32 val = (gint32) int_value;
|
||||
switch (src->endianness) {
|
||||
case G_LITTLE_ENDIAN:
|
||||
val = GINT32_TO_LE (val);
|
||||
break;
|
||||
case G_BIG_ENDIAN:
|
||||
val = GINT32_TO_BE (val);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
};
|
||||
p = &val;
|
||||
if (src->endianness == G_BIG_ENDIAN)
|
||||
p++;
|
||||
for (j = 0; j < src->channels; j++) {
|
||||
memcpy (data, p, 3);
|
||||
data += 3;
|
||||
}
|
||||
} else {
|
||||
gpointer p;
|
||||
guint32 val = (guint32) int_value;
|
||||
switch (src->endianness) {
|
||||
case G_LITTLE_ENDIAN:
|
||||
val = GUINT32_TO_LE (val);
|
||||
break;
|
||||
case G_BIG_ENDIAN:
|
||||
val = GUINT32_TO_BE (val);
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
};
|
||||
p = &val;
|
||||
if (src->endianness == G_BIG_ENDIAN)
|
||||
p++;
|
||||
for (j = 0; j < src->channels; j++) {
|
||||
memcpy (data, p, 3);
|
||||
data += 3;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 32:
|
||||
if (src->sign)
|
||||
|
@ -278,3 +323,31 @@ sinesrc_set_pre_get_func (SineSrc *src, PreGetFunc func)
|
|||
{
|
||||
src->pre_get_func = func;
|
||||
}
|
||||
static GstElementStateReturn
|
||||
sinesrc_change_state (GstElement *element)
|
||||
{
|
||||
SineSrc *sinesrc;
|
||||
|
||||
g_return_val_if_fail (element != NULL, FALSE);
|
||||
sinesrc = SINESRC (element);
|
||||
|
||||
switch (GST_STATE_TRANSITION (element)) {
|
||||
case GST_STATE_NULL_TO_READY:
|
||||
case GST_STATE_READY_TO_PAUSED:
|
||||
case GST_STATE_PAUSED_TO_PLAYING:
|
||||
case GST_STATE_PLAYING_TO_PAUSED:
|
||||
break;
|
||||
case GST_STATE_PAUSED_TO_READY:
|
||||
sinesrc->newcaps = TRUE;
|
||||
break;
|
||||
case GST_STATE_READY_TO_NULL:
|
||||
break;
|
||||
default:
|
||||
g_assert_not_reached();
|
||||
}
|
||||
|
||||
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
||||
return GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
||||
|
||||
return GST_STATE_SUCCESS;
|
||||
}
|
||||
|
|
105
testsuite/alsa/state.c
Normal file
105
testsuite/alsa/state.c
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* Copyright (C) 2003 Benjamin Otte <in7y118@public.uni-hamburg.de>
|
||||
*
|
||||
* state.c: Tests alsasink for state changes
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public
|
||||
* License along with this library; if not, write to the Free
|
||||
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
#include "sinesrc.h"
|
||||
|
||||
GstElement *pipeline;
|
||||
|
||||
static void
|
||||
set_state (GstElementState state)
|
||||
{
|
||||
GstElementState old_state = gst_element_get_state (pipeline);
|
||||
|
||||
g_print ("Setting state from %s to %s...", gst_element_state_get_name (old_state), gst_element_state_get_name (state));
|
||||
|
||||
if (!gst_element_set_state (pipeline, state)) {
|
||||
g_print (" ERROR\n");
|
||||
exit (-1);
|
||||
}
|
||||
|
||||
if (state == GST_STATE_PLAYING) {
|
||||
gint i;
|
||||
g_print (" DONE - iterating a bit...");
|
||||
for (i = 0; i < 400; i++) {
|
||||
if (!gst_bin_iterate (GST_BIN (pipeline))) {
|
||||
g_print (" ERROR in iteration %d\n", i);
|
||||
exit (-2);
|
||||
}
|
||||
}
|
||||
}
|
||||
g_print (" DONE\n");
|
||||
}
|
||||
|
||||
static void
|
||||
create_pipeline (void)
|
||||
{
|
||||
GstElement *src;
|
||||
SineSrc *sinesrc;
|
||||
GstElement *alsasink;
|
||||
|
||||
pipeline = gst_pipeline_new ("pipeline");
|
||||
src = sinesrc_new ();
|
||||
alsasink = gst_element_factory_make ("alsasink", "alsasink");
|
||||
|
||||
gst_bin_add_many (GST_BIN (pipeline), src, alsasink, NULL);
|
||||
gst_element_link (src, alsasink);
|
||||
|
||||
/* prepare our sinesrc */
|
||||
sinesrc = (SineSrc *) src;
|
||||
sinesrc->newcaps = TRUE;
|
||||
sinesrc->type = SINE_SRC_INT;
|
||||
sinesrc->sign = TRUE;
|
||||
sinesrc->endianness = G_BYTE_ORDER;
|
||||
sinesrc->depth = 16;
|
||||
sinesrc->width = 16;
|
||||
}
|
||||
gint
|
||||
main (gint argc, gchar *argv[])
|
||||
{
|
||||
gst_init (&argc, &argv);
|
||||
|
||||
g_print ("\n"
|
||||
"This test will check if state changes work on the alsasink.\n"
|
||||
"You will hear some short sine tones on your default ALSA soundcard,\n"
|
||||
"but they are not important in this test.\n"
|
||||
"\n");
|
||||
create_pipeline ();
|
||||
|
||||
/* simulate some state changes here */
|
||||
set_state (GST_STATE_READY);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_READY);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_PAUSED);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
set_state (GST_STATE_PAUSED);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
set_state (GST_STATE_READY);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
set_state (GST_STATE_NULL);
|
||||
set_state (GST_STATE_PLAYING);
|
||||
|
||||
g_print ("The alsa plugin mastered another test.\n");
|
||||
|
||||
gst_object_unref (GST_OBJECT (pipeline));
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue