Commit 01a1e4bc authored by René Stadler's avatar René Stadler Committed by Tim-Philipp Müller
Browse files

gst-libs/gst/tag/gstvorbistag.c: When writing out floating-point numbers to...

gst-libs/gst/tag/gstvorbistag.c: When writing out floating-point numbers to vorbis comment tags, always use the same ...

Original commit message from CVS:
Patch by: René Stadler  <mail at renestadler de>
* gst-libs/gst/tag/gstvorbistag.c: (gst_tag_to_vorbis_comments):
When writing out floating-point numbers to vorbis comment tags, always
use the same character as separator no matter what the current locale is
(fixes #423051).
* tests/check/libs/tag.c: (GST_START_TEST):
Add unit tests for replaygain tags in vorbis comments (closes #423055).
parent ecab77b7
2007-03-26 Tim-Philipp Müller <tim at centricular dot net>
Patch by: René Stadler <mail at renestadler de>
* gst-libs/gst/tag/gstvorbistag.c: (gst_tag_to_vorbis_comments):
When writing out floating-point numbers to vorbis comment tags, always
use the same character as separator no matter what the current locale is
(fixes #423051).
* tests/check/libs/tag.c: (GST_START_TEST):
Add unit tests for replaygain tags in vorbis comments (closes #423055).
2007-03-26 Thomas Vander Stichele <thomas at apestaart dot org>
 
* ext/vorbis/vorbisdec.c (vorbis_dec_push_forward,
......@@ -433,11 +433,12 @@ gst_tag_to_vorbis_comments (const GstTagList * list, const gchar * tag)
}
case G_TYPE_DOUBLE:{
gdouble value;
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
if (!gst_tag_list_get_double_index (list, tag, i, &value))
g_return_val_if_reached (NULL);
/* FIXME: what about locale-specific floating point separators? */
result = g_strdup_printf ("%s=%f", vorbis_tag, value);
g_ascii_formatd (buf, G_ASCII_DTOSTR_BUF_SIZE, "%f", value);
result = g_strconcat (vorbis_tag, "=", buf, NULL);
break;
}
default:{
......
......@@ -165,6 +165,18 @@ GST_END_TEST;
fail_unless_equals_int (___n, num); \
}
#define MATCH_DOUBLE(p1, p2) ((p1 < p2 + 1e-6) && (p2 < p1 + 1e-6))
#define ASSERT_TAG_LIST_HAS_DOUBLE(list,field,d) \
{ \
gdouble ___d; \
\
fail_unless (gst_tag_list_get_tag_size (list,field) > 0); \
fail_unless (gst_tag_list_get_tag_size (list,field) == 1); \
fail_unless (gst_tag_list_get_double_index (list, field, 0, &___d)); \
fail_unless (MATCH_DOUBLE (d, ___d), \
"%f does not match expected %f", ___d, d); \
}
GST_START_TEST (test_muscibrainz_tag_registration)
{
GstTagList *list;
......@@ -298,21 +310,18 @@ GST_START_TEST (test_vorbis_tags)
ASSERT_TAG_LIST_HAS_STRING (list, GST_TAG_EXTENDED_COMMENT,
"RuBuWuHash=1337BA42F91");
#if 0
/* TODO: test these as well */
{
GST_TAG_TRACK_GAIN, "REPLAYGAIN_TRACK_GAIN"}
, {
GST_TAG_TRACK_PEAK, "REPLAYGAIN_TRACK_PEAK"}
, {
GST_TAG_ALBUM_GAIN, "REPLAYGAIN_ALBUM_GAIN"}
, {
GST_TAG_ALBUM_PEAK, "REPLAYGAIN_ALBUM_PEAK"}
, {
GST_TAG_LANGUAGE_CODE, "LANGUAGE"}
,
#endif
/* make sure we can convert back and forth without loss */
gst_vorbis_tag_add (list, "REPLAYGAIN_TRACK_GAIN", "+12.36");
ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_TRACK_GAIN, +12.36);
gst_vorbis_tag_add (list, "REPLAYGAIN_TRACK_PEAK", "0.96349");
ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_TRACK_PEAK, 0.96349);
gst_vorbis_tag_add (list, "REPLAYGAIN_ALBUM_GAIN", "+10.12");
ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_ALBUM_GAIN, +10.12);
gst_vorbis_tag_add (list, "REPLAYGAIN_ALBUM_PEAK", "0.98107");
ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_ALBUM_PEAK, 0.98107);
gst_vorbis_tag_add (list, "REPLAYGAIN_REFERENCE_LOUDNESS", "89.");
ASSERT_TAG_LIST_HAS_DOUBLE (list, GST_TAG_REFERENCE_LEVEL, 89.);
/* make sure we can convert back and forth without loss */
{
GstTagList *new_list, *even_newer_list;
GstBuffer *buf, *buf2;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment